From 97a21ae519c76c5dab100c7f79fa6eefc1d5cbfe Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 20 Aug 2014 16:22:21 +0100 Subject: [PATCH 1/7] Start on graphing performance metrics --- includes/polling/functions.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 567c6031e..2214372c6 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -196,6 +196,16 @@ function poll_device($device, $options) $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); + $performance_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/performance-poller.rrd"; + if (!is_file($performance_rrd)) + { + rrdtool_create ($performance_rrd, "DS:performance:GAUGE:600:0:U ".$config['rrd_rra']); + } + if(!empty($device_time)) + { + rrdtool_update($performance_rrd, "N:".$device_time); + } + $update_array['last_polled'] = array('NOW()'); $update_array['last_polled_timetaken'] = $device_time; From 6c28f6367e977a350dcb98526f4d11346b88fc73 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 21 Sep 2014 20:47:32 +0100 Subject: [PATCH 2/7] Poller run time graphing --- .../graphs/device/poller_perf.inc.php | 27 +++++++++++++++++++ html/pages/device/graphs.inc.php | 3 +++ includes/definitions.inc.php | 3 +++ includes/polling/functions.inc.php | 8 +++--- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 html/includes/graphs/device/poller_perf.inc.php diff --git a/html/includes/graphs/device/poller_perf.inc.php b/html/includes/graphs/device/poller_perf.inc.php new file mode 100644 index 000000000..0c6076082 --- /dev/null +++ b/html/includes/graphs/device/poller_perf.inc.php @@ -0,0 +1,27 @@ + + * + * 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"; + +include("includes/graphs/common.inc.php"); + +$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.rrd"; + +$rrd_options .= " DEF:poller=".$rrd_filename.":poller:AVERAGE"; +$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; +$rrd_options .= " AREA:poller#EEEEEE:Poller"; +$rrd_options .= " GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf"; +$rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'"; + +?> diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 9e4b785bc..59df21e74 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -23,6 +23,9 @@ foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY g $graph_enable[$section][$graph['graph']] = $graph['graph']; } +// These are standard graphs we should have for all systems +$graph_enable['poller']['poller_perf'] = 'device_poller_perf'; + #foreach ($config['graph_sections'] as $section) foreach ($graph_enable as $section => $nothing) { diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 76fadbcca..556494fae 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1058,6 +1058,9 @@ $config['graph_types']['device']['ucd_interrupts']['descr'] = 'Interrupts'; $config['graph_types']['device']['uptime']['section'] = 'system'; $config['graph_types']['device']['uptime']['order'] = '0'; $config['graph_types']['device']['uptime']['descr'] = 'System Uptime'; +$config['graph_types']['device']['poller_perf']['section'] = 'poller'; +$config['graph_types']['device']['poller_perf']['order'] = '0'; +$config['graph_types']['device']['poller_perf']['descr'] = 'Poller Performance'; $config['graph_types']['device']['vpdn_sessions_l2tp']['section'] = 'vpdn'; $config['graph_types']['device']['vpdn_sessions_l2tp']['order'] = '0'; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 2214372c6..e64b94bd8 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -196,14 +196,14 @@ function poll_device($device, $options) $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); - $performance_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/performance-poller.rrd"; - if (!is_file($performance_rrd)) + $poller_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.rrd"; + if (!is_file($poller_rrd)) { - rrdtool_create ($performance_rrd, "DS:performance:GAUGE:600:0:U ".$config['rrd_rra']); + rrdtool_create ($poller_rrd, "DS:poller:GAUGE:600:0:U ".$config['rrd_rra']); } if(!empty($device_time)) { - rrdtool_update($performance_rrd, "N:".$device_time); + rrdtool_update($poller_rrd, "N:".$device_time); } $update_array['last_polled'] = array('NOW()'); From 6a1ebd9db46e84daa1bbeac2c701d6ce63c430a8 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 21 Sep 2014 21:18:53 +0100 Subject: [PATCH 3/7] Updated graph from area to line --- html/includes/graphs/device/poller_perf.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/graphs/device/poller_perf.inc.php b/html/includes/graphs/device/poller_perf.inc.php index 0c6076082..1ce7689d6 100644 --- a/html/includes/graphs/device/poller_perf.inc.php +++ b/html/includes/graphs/device/poller_perf.inc.php @@ -20,7 +20,7 @@ $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.r $rrd_options .= " DEF:poller=".$rrd_filename.":poller:AVERAGE"; $rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; -$rrd_options .= " AREA:poller#EEEEEE:Poller"; +$rrd_options .= " LINE1.25:poller#36393D:Poller"; $rrd_options .= " GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf"; $rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'"; From 9a178363a008f1dfda0408e92c5189cfc201f8ad Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 29 Sep 2014 23:03:59 +0100 Subject: [PATCH 4/7] Added ping response graphs and some small updates --- html/includes/graphs/device/ping_perf.inc.php | 27 +++++++++++++++++++ html/pages/device/graphs.inc.php | 1 + includes/definitions.inc.php | 5 +++- includes/functions.php | 20 ++++++++++---- includes/polling/functions.inc.php | 19 +++++++++++-- 5 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 html/includes/graphs/device/ping_perf.inc.php diff --git a/html/includes/graphs/device/ping_perf.inc.php b/html/includes/graphs/device/ping_perf.inc.php new file mode 100644 index 000000000..cbbb48d62 --- /dev/null +++ b/html/includes/graphs/device/ping_perf.inc.php @@ -0,0 +1,27 @@ + + * + * 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"; + +include("includes/graphs/common.inc.php"); + +$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ping-perf.rrd"; + +$rrd_options .= " DEF:ping=".$rrd_filename.":ping:AVERAGE"; +$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'"; +$rrd_options .= " LINE1.25:ping#36393D:Ping"; +$rrd_options .= " GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf"; +$rrd_options .= " GPRINT:ping:MAX:%6.2lf 'GPRINT:ping:AVERAGE:%6.2lf\\n'"; + +?> diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 59df21e74..3be4ad7e7 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -25,6 +25,7 @@ foreach (dbFetchRows("SELECT * FROM device_graphs WHERE device_id = ? ORDER BY g // These are standard graphs we should have for all systems $graph_enable['poller']['poller_perf'] = 'device_poller_perf'; +$graph_enable['poller']['ping_perf'] = 'device_ping_perf'; #foreach ($config['graph_sections'] as $section) foreach ($graph_enable as $section => $nothing) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 556494fae..ac2b2c8a2 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1060,7 +1060,10 @@ $config['graph_types']['device']['uptime']['order'] = '0'; $config['graph_types']['device']['uptime']['descr'] = 'System Uptime'; $config['graph_types']['device']['poller_perf']['section'] = 'poller'; $config['graph_types']['device']['poller_perf']['order'] = '0'; -$config['graph_types']['device']['poller_perf']['descr'] = 'Poller Performance'; +$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']['vpdn_sessions_l2tp']['section'] = 'vpdn'; $config['graph_types']['device']['vpdn_sessions_l2tp']['order'] = '0'; diff --git a/includes/functions.php b/includes/functions.php index 872b6b65f..5371621d3 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -459,23 +459,33 @@ function isSNMPable($device) } } -function isPingable($hostname) +function isPingable($hostname,$device_id) { global $config; - $status = shell_exec($config['fping'] . " $hostname 2>/dev/null"); + $status = shell_exec($config['fping'] . " -e $hostname 2>/dev/null"); if (strstr($status, "alive")) { - return TRUE; + if(is_numeric($device_id) && !empty($device_id)) + { + preg_match('/(\d+\.*\d*) (ms)/', $status, $time); + $response['last_ping_timetaken'] = $time[1]; + $response['result'] = TRUE; + } + else + { + $response['result'] = TRUE; + } } else { $status = shell_exec($config['fping6'] . " $hostname 2>/dev/null"); if (strstr($status, "alive")) { - return TRUE; + $response['result'] = TRUE; } else { - return FALSE; + $response['result'] = FALSE; } } + return($response); } function is_odd($number) diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index e64b94bd8..6eb655f47 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -110,7 +110,9 @@ function poll_device($device, $options) $host_rrd = $config['rrd_dir'] . "/" . $device['hostname']; if (!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } - $device['pingable'] = isPingable($device['hostname']); + $ping_response = isPingable($device['hostname'],$device['device_id']); + $device['pingable'] = $ping_response['result']; + $ping_time = $ping_response['last_ping_timetaken']; if ($device['pingable']) { $device['snmpable'] = isSNMPable($device); @@ -196,6 +198,7 @@ function poll_device($device, $options) $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); + // Poller performance rrd $poller_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.rrd"; if (!is_file($poller_rrd)) { @@ -203,11 +206,23 @@ function poll_device($device, $options) } if(!empty($device_time)) { - rrdtool_update($poller_rrd, "N:".$device_time); + rrdtool_update($poller_rrd, "N:$device_time"); + } + // Ping response rrd + $ping_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/ping-perf.rrd"; + if (!is_file($ping_rrd)) + { + rrdtool_create ($ping_rrd, "DS:ping:GAUGE:600:0:65535 ".$config['rrd_rra']); + } + if(!empty($ping_time)) + { + rrdtool_update($ping_rrd, "N:$ping_time"); } $update_array['last_polled'] = array('NOW()'); $update_array['last_polled_timetaken'] = $device_time; + $update_array['last_ping'] = array('NOW()'); + $update_array['last_ping_timetaken'] = $ping_time; #echo("$device_end - $device_start; $device_time $device_run"); echo("Polled in $device_time seconds\n"); From 6afaa17a8069d91683c50e6bcec518d72aa6c115 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 29 Sep 2014 23:10:00 +0100 Subject: [PATCH 5/7] Updated ping rrd response to include fping6 response --- includes/functions.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 5371621d3..c3c64b301 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -466,18 +466,9 @@ function isPingable($hostname,$device_id) $status = shell_exec($config['fping'] . " -e $hostname 2>/dev/null"); if (strstr($status, "alive")) { - if(is_numeric($device_id) && !empty($device_id)) - { - preg_match('/(\d+\.*\d*) (ms)/', $status, $time); - $response['last_ping_timetaken'] = $time[1]; - $response['result'] = TRUE; - } - else - { - $response['result'] = TRUE; - } + $response['result'] = TRUE; } else { - $status = shell_exec($config['fping6'] . " $hostname 2>/dev/null"); + $status = shell_exec($config['fping6'] . " -e $hostname 2>/dev/null"); if (strstr($status, "alive")) { $response['result'] = TRUE; @@ -485,6 +476,11 @@ function isPingable($hostname,$device_id) $response['result'] = FALSE; } } + if(is_numeric($device_id) && !empty($device_id)) + { + preg_match('/(\d+\.*\d*) (ms)/', $status, $time); + $response['last_ping_timetaken'] = $time[1]; + } return($response); } From 8ea7a16e3edf7e13e3cd25d9285ed7c8f09d5b5e Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 30 Sep 2014 01:15:33 +0100 Subject: [PATCH 6/7] Added sql schema update for ping graphs --- sql-schema/035.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sql-schema/035.sql diff --git a/sql-schema/035.sql b/sql-schema/035.sql new file mode 100644 index 000000000..7212038b9 --- /dev/null +++ b/sql-schema/035.sql @@ -0,0 +1,2 @@ +-- Update to add ping response time and last ping datetime +ALTER TABLE `devices` ADD `last_ping` TIMESTAMP NULL AFTER `last_discovered` , ADD `last_ping_timetaken` DOUBLE( 5, 2 ) NULL AFTER `last_ping` ; From 62200aa5ebef749db6c41ed59cda9516f9fa659c Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 30 Sep 2014 01:50:23 +0100 Subject: [PATCH 7/7] Fixed some scrutinizer warnings --- includes/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index c3c64b301..d699e3a75 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -459,11 +459,12 @@ function isSNMPable($device) } } -function isPingable($hostname,$device_id) +function isPingable($hostname,$device_id = FALSE) { global $config; $status = shell_exec($config['fping'] . " -e $hostname 2>/dev/null"); + $response = array(); if (strstr($status, "alive")) { $response['result'] = TRUE;