mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Store performance data for each poller module
This commit is contained in:
38
html/includes/graphs/device/poller_modules_perf.inc.php
Normal file
38
html/includes/graphs/device/poller_modules_perf.inc.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2016 Mike Rostermund <mike@kollegienet.dk>
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$scale_min = '0';
|
||||
$colour_scheme = 'mixed';
|
||||
$attribs = get_dev_attribs($device['device_id']);
|
||||
ksort($config['poller_modules']);
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$colour_iter = 0;
|
||||
$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'";
|
||||
foreach ($config['poller_modules'] as $module => $module_status) {
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/poller-'.$module.'-perf.rrd';
|
||||
if ($attribs['poll_'.$module] || ( $module_status && !isset($attribs['poll_'.$module]))) {
|
||||
if (is_file($rrd_filename)) {
|
||||
if (!$config['graph_colours'][$colour_scheme][$colour_iter]) {
|
||||
$colour_iter = 0;
|
||||
}
|
||||
$colour = $config['graph_colours'][$colour_scheme][$colour_iter];
|
||||
$colour_iter++;
|
||||
|
||||
$rrd_options .= ' DEF:'.$module.'='.$rrd_filename.':'.$module.':AVERAGE';
|
||||
$rrd_options .= ' LINE1.25:'.$module.'#'.$colour.':"'.str_pad($module, 18," ").'"';
|
||||
$rrd_options .= ' GPRINT:'.$module.':LAST:%6.2lf GPRINT:'.$module.':AVERAGE:%7.2lf';
|
||||
$rrd_options .= " GPRINT:".$module.":MAX:%7.2lf 'GPRINT:".$module.":AVERAGE:%7.2lf\\n'";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -876,7 +876,8 @@ function enable_os_graphs($os, &$graph_enable)
|
||||
function enable_graphs($device, &$graph_enable)
|
||||
{
|
||||
// These are standard graphs we should have for all systems
|
||||
$graph_enable['poller']['poller_perf'] = 'device_poller_perf';
|
||||
$graph_enable['poller']['poller_perf'] = 'device_poller_perf';
|
||||
$graph_enable['poller']['poller_modules_perf'] = 'device_poller_modules_perf';
|
||||
if (can_ping_device($device) === true) {
|
||||
$graph_enable['poller']['ping_perf'] = 'device_ping_perf';
|
||||
}
|
||||
|
||||
@@ -1767,6 +1767,9 @@ $config['graph_types']['device']['poller_perf']['descr'] = 'Poller Time';
|
||||
$config['graph_types']['device']['ping_perf']['section'] = 'poller';
|
||||
$config['graph_types']['device']['ping_perf']['order'] = '0';
|
||||
$config['graph_types']['device']['ping_perf']['descr'] = 'Ping Response';
|
||||
$config['graph_types']['device']['poller_modules_perf']['section'] = 'poller';
|
||||
$config['graph_types']['device']['poller_modules_perf']['order'] = '0';
|
||||
$config['graph_types']['device']['poller_modules_perf']['descr'] = 'Poller Modules Performance';
|
||||
|
||||
$config['graph_types']['device']['vpdn_sessions_l2tp']['section'] = 'vpdn';
|
||||
$config['graph_types']['device']['vpdn_sessions_l2tp']['order'] = '0';
|
||||
|
||||
@@ -230,6 +230,14 @@ function poll_device($device, $options) {
|
||||
include 'includes/polling/'.$module.'.inc.php';
|
||||
$module_time = microtime(true) - $module_start;
|
||||
echo "Runtime for polling module '$module': $module_time\n";
|
||||
|
||||
$tags = array(
|
||||
'rrd_def' => 'DS:'.$module.':GAUGE:600:0:U',
|
||||
);
|
||||
$fields = array(
|
||||
$module => $module_time,
|
||||
);
|
||||
data_update($device, 'poller-'.$module.'-perf', $tags, $fields);
|
||||
}
|
||||
else if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] == '0') {
|
||||
echo "Module [ $module ] disabled on host.\n";
|
||||
|
||||
Reference in New Issue
Block a user