From 308d686294e3e256b35e671d5da94e4a9ae5fc6f Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Mon, 22 Jun 2015 21:12:57 +0200 Subject: [PATCH 01/72] Added plugin hook to create a custom container under device->overview. Container apears over "Overall traffic" on the left phane --- html/pages/device/overview.inc.php | 2 ++ html/plugins/Test/Test.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index f414dd4e5..1d7ee6867 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -26,6 +26,8 @@ echo('
'); include("includes/dev-overview-data.inc.php"); +Plugins::call('device_overview_container',array($device)); + include("overview/ports.inc.php"); echo('
diff --git a/html/plugins/Test/Test.php b/html/plugins/Test/Test.php index dd1134438..06d20d28c 100644 --- a/html/plugins/Test/Test.php +++ b/html/plugins/Test/Test.php @@ -4,6 +4,14 @@ class Test { public function menu() { echo('
  • '.get_class().'
  • '); } + + public function device_overview_container($device) { + echo('
    Test Plugin
    i"ve just added a plugin :)
    '); + echo('
    ');
    +    var_dump($device);
    +    echo('
    '); + echo('
    '); + } } ?> From 07e996094c805f87e04e88eb97d83663f645b192 Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Mon, 22 Jun 2015 21:53:35 +0200 Subject: [PATCH 02/72] Removed var_dump and updated text in Example plugin --- html/plugins/Test/Test.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/html/plugins/Test/Test.php b/html/plugins/Test/Test.php index 06d20d28c..f6817bd31 100644 --- a/html/plugins/Test/Test.php +++ b/html/plugins/Test/Test.php @@ -6,10 +6,8 @@ class Test { } public function device_overview_container($device) { - echo('
    Test Plugin
    i"ve just added a plugin :)
    '); - echo('
    ');
    -    var_dump($device);
    -    echo('
    '); + echo('
    '.get_class().' Plugin
    '); + echo(' Example plugin i "Device - Overview" tab
    '); echo('
    '); } } From 170030c7865913c51b65067e544302d711598031 Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Mon, 22 Jun 2015 21:55:54 +0200 Subject: [PATCH 03/72] Fixed typo... --- html/plugins/Test/Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/plugins/Test/Test.php b/html/plugins/Test/Test.php index f6817bd31..a2bd41744 100644 --- a/html/plugins/Test/Test.php +++ b/html/plugins/Test/Test.php @@ -7,7 +7,7 @@ class Test { public function device_overview_container($device) { echo('
    '.get_class().' Plugin
    '); - echo(' Example plugin i "Device - Overview" tab
    '); + echo(' Example plugin in "Device - Overview" tab
    '); echo('
    '); } } From eee2ae5be1e52d27cccada91a1c55b92f5f9ae56 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 21:55:31 +0100 Subject: [PATCH 04/72] Added support for logging packet loss and min/max/avg response times on fping --- daily.php | 8 ++ daily.sh | 1 + doc/Extensions/Alerting.md | 16 +++ doc/Support/Configuration.md | 1 + html/pages/device.inc.php | 7 ++ html/pages/device/performance.inc.php | 158 ++++++++++++++++++++++++++ includes/defaults.inc.php | 2 + includes/functions.php | 78 ++++++++++--- includes/polling/functions.inc.php | 9 ++ sql-schema/056.sql | 3 + 10 files changed, 268 insertions(+), 15 deletions(-) create mode 100644 html/pages/device/performance.inc.php create mode 100644 sql-schema/056.sql diff --git a/daily.php b/daily.php index 03176a47d..abb525a0b 100644 --- a/daily.php +++ b/daily.php @@ -58,5 +58,13 @@ if ($options['f'] === 'perf_times') { if ($options['f'] === 'callback') { require_once "callback.php"; } +if ($options['f'] === 'device_perf') { + if (is_numeric($config['device_perf_purge'])) { + if (dbDelete('device_perf', "timestamp < UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL ? DAY))", array($config['device_perf_purge'])) ) { + echo 'Device performance times cleared for entries over ' . $config['device_perf_purge'] . " days\n"; + } + } +} + ?> diff --git a/daily.sh b/daily.sh index 4168d7344..91183d6d1 100755 --- a/daily.sh +++ b/daily.sh @@ -12,3 +12,4 @@ php daily.php -f eventlog php daily.php -f authlog php daily.php -f perf_times php daily.php -f callback +php daily.php -f device_perf diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 9390e53af..d90bf4ff0 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -502,3 +502,19 @@ Entity: `%macros.sensor` Description: Only select sensors that aren't ignored. Source: `(%sensors.sensor_alert = 1)` + +## Packet Loss (Boolean) + +Entity: `(%macros.packet_loss_5m)` + +Description: Packet loss % value for the device within the last 5 minutes. + +Example: `%macros.packet_loss_5m` > 50 + +Entity: `(%macros.packet_loss_15m)` + +Description: Packet loss % value for the device within the last 15 minutes. + +Example: `%macros.packet_loss_15m` > 50 + + diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index ae3ee9e19..43d11cffd 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -404,6 +404,7 @@ $config['syslog_purge'] = 30; $config['eventlog_purge'] = 30; $config['authlog_purge'] = 30; $config['perf_times_purge'] = 30; +$config['device_perf_purge'] = 30; ``` This option will ensure data within LibreNMS over 1 month old is automatically purged. You can alter these individually, values are in days. diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index c72daf9bf..ff6a42775 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -382,6 +382,13 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) '); } + echo('
  • + + Performance + +
  • '); + + echo ('
  • https
  • ssh
  • telnet
  • '); diff --git a/html/pages/device/performance.inc.php b/html/pages/device/performance.inc.php new file mode 100644 index 000000000..1c642daf4 --- /dev/null +++ b/html/pages/device/performance.inc.php @@ -0,0 +1,158 @@ + +* 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. + +* Copyright (c) 2014 Neil Lathwood +* +* 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. + +*/ + + +if(!isset($vars['section'])) { $vars['section'] = "performance"; } + +if (is_admin() === true || is_read() === true) { + $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf` WHERE `device_id` = ?"; + $param = array($device['device_id']); +} else { + $query = "SELECT DATE_FORMAT(timestamp, '".$config['alert_graph_date_format']."') Date, xmt,rcv,loss,min,max,avg FROM `device_perf`,`devices_perms` WHERE `device_id` = ? AND alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id']; + $param = array($device['device_id']); +} + +?> + + +
    + + diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a150c2daa..24b43b99f 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -43,6 +43,7 @@ $config['rrdtool'] = "/usr/bin/rrdtool"; $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; +$config['fping_options']['count'] = 3; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; @@ -581,6 +582,7 @@ $config['syslog_purge'] = 30; # Number in days $config['eventlog_purge'] = 30; # Number in days of how long to keep eventlog entries for. $config['authlog_purge'] = 30; # Number in days of how long to keep authlog entries for. $config['perf_times_purge'] = 30; # Number in days of how long to keep performace pooling stats entries for. +$config['device_perf_purge'] = 30; // Number in days of how long to keep device performance data for. # Date format for PHP date()s $config['dateformat']['long'] = "r"; # RFC2822 style diff --git a/includes/functions.php b/includes/functions.php index 725850897..f158067ca 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -495,25 +495,21 @@ function isPingable($hostname,$device_id = FALSE) if(is_numeric($config['fping_options']['timeout']) || $config['fping_options']['timeout'] > 1) { $fping_params .= ' -t ' . $config['fping_options']['timeout']; } - $status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); + if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { + $fping_params .= ' -c ' . $config['fping_options']['count']; + } + //$status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); $response = array(); - if (strstr($status, "alive")) - { - $response['result'] = TRUE; - } else { - $status = shell_exec($config['fping6'] . "$fping_params -e $hostname 2>/dev/null"); - if (strstr($status, "alive")) - { - $response['result'] = TRUE; - } else { + $status = fping($hostname,$fping_params); + if ($status['loss'] < 0 || $status['loss'] == 100) { $response['result'] = FALSE; - } + } else { + $response['result'] = TRUE; } - if(is_numeric($device_id) && !empty($device_id)) - { - preg_match('/(\d+\.*\d*) (ms)/', $status, $time); - $response['last_ping_timetaken'] = $time[1]; + if (is_numeric($status['avg'])) { + $response['last_ping_timetaken'] = $status['avg']; } + $response['db'] = $status; return($response); } @@ -1269,3 +1265,55 @@ function ip_exists($ip) { } return true; } + +function fping($host,$params) { + + global $config; + +// $handle = popen($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', 'r'); +// sleep(0.2); +// $read = fread($handle, 8192); +// pclose($handle); + +$descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") +); + +$process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + +if (is_resource($process)) { + + fwrite($pipes[0], $in); + /* fwrite writes to stdin, 'cat' will immediately write the data from stdin + * to stdout and blocks, when the stdout buffer is full. Then it will not + * continue reading from stdin and php will block here. + */ + + fclose($pipes[0]); + + while (!feof($pipes[1])) { + $read .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + + $return_value = proc_close($process); +} + + system("echo 'YEAH $read END\n' >> /tmp/testing"); + system("echo '". $config['fping'] ." -e -q $params $host' >> /tmp/testing"); + preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); + preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); + $loss = preg_replace("/%/","",$loss_tmp[0]); + list($xmt,$rcv,$loss) = preg_split("/\//", $loss); + list($min,$max,$avg) = preg_split("/\//", $latency[0]); + if ($loss < 0) { + $xmt = 1; + $rcv = 1; + $loss = 100; + } + $response = array('xmt'=>$xmt,'rcv'=>$rcv,'loss'=>$loss,'min'=>$min,'max'=>$max,'avg'=>$avg); + return $response; +} + diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index c705eccb8..03ec28b0a 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -132,6 +132,15 @@ function poll_device($device, $options) if (!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } $ping_response = isPingable($device['hostname'],$device['device_id']); + + $device_perf = $ping_response['db']; + $device_perf['device_id'] = $device['device_id']; + $device_perf['timestamp'] = array('NOW()'); + if (is_array($device_perf)) { + dbInsert($device_perf, 'device_perf'); + } + + $device['pingable'] = $ping_response['result']; $ping_time = $ping_response['last_ping_timetaken']; $response = array(); diff --git a/sql-schema/056.sql b/sql-schema/056.sql new file mode 100644 index 000000000..f8617ab98 --- /dev/null +++ b/sql-schema/056.sql @@ -0,0 +1,3 @@ +CREATE TABLE IF NOT EXISTS `device_perf` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `xmt` float NOT NULL, `rcv` float NOT NULL, `loss` float NOT NULL, `min` float NOT NULL, `max` float NOT NULL, `avg` float NOT NULL, KEY `id` (`id`,`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; +insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_15m','(%macros.past_15m && %device_perf.loss)','(%macros.past_15m && %device_perf.loss)','Packet loss over the last 15 minutes','alerting',0,'macros',0,1,0); +insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_5m','(%macros.past_5m && %device_perf.loss)','(%macros.past_5m && %device_perf.loss)','Packet loss over the last 5 minutes','alerting',0,'macros',0,1,0); From 820afa6dbb28a48eadc19ac698f30a807a89fa97 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 22:11:02 +0100 Subject: [PATCH 05/72] Added logging of reason device was detected as down (icmp/snmp) --- doc/Extensions/Alerting.md | 2 ++ html/includes/table/devices.inc.php | 2 +- includes/polling/functions.inc.php | 10 ++++++---- sql-schema/056.sql | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index d90bf4ff0..253c90cc0 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -321,6 +321,8 @@ __devices.location__ = The devices location. __devices.status__ = The status of the device, 1 = up, 0 = down. +__devices.status_reason__ = The reason the device was detected as down (icmp or snmp). + __devices.ignore__ = If the device is ignored this will be set to 1. __devices.disabled__ = If the device is disabled this will be set to 1. diff --git a/html/includes/table/devices.inc.php b/html/includes/table/devices.inc.php index e89e0b6db..25cf21bd5 100644 --- a/html/includes/table/devices.inc.php +++ b/html/includes/table/devices.inc.php @@ -94,7 +94,7 @@ foreach (dbFetchRows($sql, $param) as $device) { if ($device['status'] == '0') { $extra = "danger"; - $msg = "down"; + $msg = $device['status_reason']; } else { $extra = "success"; $msg = "up"; diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 03ec28b0a..6af89c3b9 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -144,21 +144,23 @@ function poll_device($device, $options) $device['pingable'] = $ping_response['result']; $ping_time = $ping_response['last_ping_timetaken']; $response = array(); + $status_reason = ''; if ($device['pingable']) { $device['snmpable'] = isSNMPable($device); if ($device['snmpable']) { $status = "1"; + $response['status_reason'] = ''; } else { echo("SNMP Unreachable"); $status = "0"; - $response['status'] = 'snmp'; + $response['status_reason'] = 'snmp'; } } else { echo("Unpingable"); $status = "0"; - $response['status'] = 'icmp'; + $response['status_reason'] = 'icmp'; } if ($device['status'] != $status) @@ -166,11 +168,11 @@ function poll_device($device, $options) $poll_update .= $poll_separator . "`status` = '$status'"; $poll_separator = ", "; - dbUpdate(array('status' => $status), 'devices', 'device_id=?', array($device['device_id'])); + dbUpdate(array('status' => $status,'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id'])); dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => "Device is " .($status == '1' ? 'up' : 'down')), 'alerts'); log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down')); - notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status']); + notify($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " " . $response['status_reason']); } if ($status == "1") diff --git a/sql-schema/056.sql b/sql-schema/056.sql index f8617ab98..a434a7d68 100644 --- a/sql-schema/056.sql +++ b/sql-schema/056.sql @@ -1,3 +1,5 @@ CREATE TABLE IF NOT EXISTS `device_perf` ( `id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `xmt` float NOT NULL, `rcv` float NOT NULL, `loss` float NOT NULL, `min` float NOT NULL, `max` float NOT NULL, `avg` float NOT NULL, KEY `id` (`id`,`device_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_15m','(%macros.past_15m && %device_perf.loss)','(%macros.past_15m && %device_perf.loss)','Packet loss over the last 15 minutes','alerting',0,'macros',0,1,0); insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.macros.rule.packet_loss_5m','(%macros.past_5m && %device_perf.loss)','(%macros.past_5m && %device_perf.loss)','Packet loss over the last 5 minutes','alerting',0,'macros',0,1,0); +ALTER TABLE `devices` ADD `status_reason` VARCHAR( 50 ) NOT NULL AFTER `status` ; +UPDATE `devices` SET `status_reason`='down' WHERE `status`=0; From 6c9810fc3cacfc034d31a4055d1d22495fa9b0f8 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 22:55:32 +0100 Subject: [PATCH 06/72] Fix scrut issues --- includes/functions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index f158067ca..43063fd52 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1285,7 +1285,6 @@ $process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', if (is_resource($process)) { - fwrite($pipes[0], $in); /* fwrite writes to stdin, 'cat' will immediately write the data from stdin * to stdout and blocks, when the stdout buffer is full. Then it will not * continue reading from stdin and php will block here. @@ -1293,16 +1292,15 @@ if (is_resource($process)) { fclose($pipes[0]); + $read = ''; while (!feof($pipes[1])) { $read .= fgets($pipes[1], 1024); } fclose($pipes[1]); - $return_value = proc_close($process); + proc_close($process); } - system("echo 'YEAH $read END\n' >> /tmp/testing"); - system("echo '". $config['fping'] ." -e -q $params $host' >> /tmp/testing"); preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); $loss = preg_replace("/%/","",$loss_tmp[0]); From 30a27d719eefe1c7bc040a517e39b4f543aed8a9 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 23:02:11 +0100 Subject: [PATCH 07/72] Fix scrut issues + tidy more code --- includes/functions.php | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 43063fd52..fb4ba1b73 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1270,36 +1270,25 @@ function fping($host,$params) { global $config; -// $handle = popen($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', 'r'); -// sleep(0.2); -// $read = fread($handle, 8192); -// pclose($handle); + $descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") + ); -$descriptorspec = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") -); + $process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + $read = ''; -$process = proc_open($config['fping'] . ' -e -q ' .$params . ' ' .$host.' 2>&1', $descriptorspec, $pipes); + if (is_resource($process)) { -if (is_resource($process)) { + fclose($pipes[0]); - /* fwrite writes to stdin, 'cat' will immediately write the data from stdin - * to stdout and blocks, when the stdout buffer is full. Then it will not - * continue reading from stdin and php will block here. - */ - - fclose($pipes[0]); - - $read = ''; - while (!feof($pipes[1])) { - $read .= fgets($pipes[1], 1024); - } - fclose($pipes[1]); - - proc_close($process); -} + while (!feof($pipes[1])) { + $read .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + proc_close($process); + } preg_match('/[0-9]+\/[0-9]+\/[0-9]+%/', $read, $loss_tmp); preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); From 0525ca79bc1a872ddff7f97387c2245cd7b2f5de Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 22 Jun 2015 23:23:14 +0100 Subject: [PATCH 08/72] Updated to set millisec delay between packets --- doc/Support/Configuration.md | 2 ++ includes/defaults.inc.php | 1 + includes/functions.php | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 43d11cffd..68cb55251 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -33,6 +33,8 @@ $config['fping'] = "/usr/bin/fping"; $config['fping6'] = "/usr/bin/fping6"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; +$config['fping_options']['count'] = 3; +$config['fping_options']['millisec'] = 5; ``` fping configuration options, this includes setting the timeout and retry options. diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 24b43b99f..0880829de 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -44,6 +44,7 @@ $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; $config['fping_options']['count'] = 3; +$config['fping_options']['millisec'] = 5; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; diff --git a/includes/functions.php b/includes/functions.php index fb4ba1b73..a53d76d99 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -498,7 +498,9 @@ function isPingable($hostname,$device_id = FALSE) if(is_numeric($config['fping_options']['count']) || $config['fping_options']['count'] > 0) { $fping_params .= ' -c ' . $config['fping_options']['count']; } - //$status = shell_exec($config['fping'] . "$fping_params -e $hostname 2>/dev/null"); + if(is_numeric($config['fping_options']['millisec']) || $config['fping_options']['millisec'] > 0) { + $fping_params .= ' -p ' . $config['fping_options']['millisec']; + } $response = array(); $status = fping($hostname,$fping_params); if ($status['loss'] < 0 || $status['loss'] == 100) { From 9e5c6f87bbcff3b3bb21fc947b3253dfe0d40b6a Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 23 Jun 2015 09:01:36 +0100 Subject: [PATCH 09/72] Changed default millisec + removed check for loss < 0 --- includes/defaults.inc.php | 2 +- includes/functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 0880829de..ba46626ee 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -44,7 +44,7 @@ $config['fping'] = "/usr/bin/fping"; $config['fping_options']['retries'] = 3; $config['fping_options']['timeout'] = 500; $config['fping_options']['count'] = 3; -$config['fping_options']['millisec'] = 5; +$config['fping_options']['millisec'] = 20; $config['fping6'] = "/usr/bin/fping6"; $config['snmpwalk'] = "/usr/bin/snmpwalk"; $config['snmpget'] = "/usr/bin/snmpget"; diff --git a/includes/functions.php b/includes/functions.php index a53d76d99..487ed857f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -503,7 +503,7 @@ function isPingable($hostname,$device_id = FALSE) } $response = array(); $status = fping($hostname,$fping_params); - if ($status['loss'] < 0 || $status['loss'] == 100) { + if ($status['loss'] == 100) { $response['result'] = FALSE; } else { $response['result'] = TRUE; From 03a5e768ec3a6929f4a3234edb4398e210f6d9bc Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 23 Jun 2015 09:48:36 +0100 Subject: [PATCH 10/72] min/avg/max were in the wrong order --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index 487ed857f..6ca29e67c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1296,7 +1296,7 @@ function fping($host,$params) { preg_match('/[0-9\.]+\/[0-9\.]+\/[0-9\.]*$/', $read, $latency); $loss = preg_replace("/%/","",$loss_tmp[0]); list($xmt,$rcv,$loss) = preg_split("/\//", $loss); - list($min,$max,$avg) = preg_split("/\//", $latency[0]); + list($min,$avg,$max) = preg_split("/\//", $latency[0]); if ($loss < 0) { $xmt = 1; $rcv = 1; From 21cf6b2019753b0714c1f554468c4005c45bbb0a Mon Sep 17 00:00:00 2001 From: Runar Borge Date: Tue, 23 Jun 2015 13:15:33 +0200 Subject: [PATCH 11/72] Disabled from Test plugin, user have to manually enable the plugin in Test plugin file --- html/plugins/Test/Test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/plugins/Test/Test.php b/html/plugins/Test/Test.php index a2bd41744..3447d4254 100644 --- a/html/plugins/Test/Test.php +++ b/html/plugins/Test/Test.php @@ -5,11 +5,13 @@ class Test { echo('
  • '.get_class().'
  • '); } + /* public function device_overview_container($device) { echo('
    '.get_class().' Plugin
    '); echo(' Example plugin in "Device - Overview" tab
    '); echo('
    '); } + */ } ?> From 32c20b8a680bceca268a8a22b056bd983d1f148f Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 15:38:54 +0100 Subject: [PATCH 12/72] Added removing of IP addresses before ports are deleted --- includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index 725850897..18937bb53 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -248,6 +248,10 @@ function delete_device($id) return "No such host."; } + // Remove IPv4/IPv6 addresses before removing ports as they depend on port_id + dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?",array($id)); + dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?",array($id)); + foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) { $int_if = $int_data['ifDescr']; From baac6478939fba1c0fe11635cd8b8edcf4be686a Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:02:14 +0100 Subject: [PATCH 13/72] Fixed removing port from bills JS error --- html/pages/bill/edit.inc.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/html/pages/bill/edit.inc.php b/html/pages/bill/edit.inc.php index 6434c93e7..67e500018 100644 --- a/html/pages/bill/edit.inc.php +++ b/html/pages/bill/edit.inc.php @@ -138,7 +138,6 @@ for ($x=1;$x<32;$x++) { -

    Billed Ports

    ".$port['hostname'], "\" style=\"color: #000;\"> ".$port['hostname'], $devicebtn); $portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"> ".$port['ifName']."".$portalias, $portbtn); - echo(" \n"); + echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); @@ -189,7 +188,6 @@ if (is_array($ports)) ?>
    -
    From c4572c206a6b65587a400eca3ccbb9273a957ea6 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:32:42 +0100 Subject: [PATCH 14/72] Added debugging output of invalid snmpv3 args --- addhost.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addhost.php b/addhost.php index 2c75d6573..d1e26a399 100755 --- a/addhost.php +++ b/addhost.php @@ -114,6 +114,9 @@ if (!empty($argv[1])) elseif (preg_match ('/^(sha|md5)$/i', $arg)) { $v3['authalgo'] = $arg; + } else { + echo "Invalid argument: " . $arg . "\n" ; + return ; } } @@ -147,6 +150,9 @@ if (!empty($argv[1])) elseif (preg_match ('/^(aes|des)$/i', $arg)) { $v3['cryptoalgo'] = $arg; + } else { + echo "Invalid argument: " . $arg . "\n" ; + return ; } } From 0624b6c1d01f7c19a350cdba7c6ceb7c6fc2a684 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:39:16 +0100 Subject: [PATCH 15/72] Temp fix to remove .index at the start of the poller run --- poller.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/poller.php b/poller.php index 6608b3254..5bb3fbee8 100755 --- a/poller.php +++ b/poller.php @@ -25,6 +25,11 @@ include("includes/alerts.inc.php"); $poller_start = utime(); echo($config['project_name_version']." Poller\n\n"); +if (is_file($config['mib_dir'].'/.index') === true) { + echo ".index exists, removing\n"; + unlink($config['mib_dir'].'/.index'); +} + $options = getopt("h:m:i:n:r::d::a::"); if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } From 44432c85e5dc06b757f23c824ac0de0aa5a64a8e Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 24 Jun 2015 16:53:10 +0100 Subject: [PATCH 16/72] Added load and state to device overview --- html/pages/device/overview.inc.php | 2 ++ html/pages/device/overview/sensors/load.inc.php | 8 ++++++++ html/pages/device/overview/sensors/state.inc.php | 8 ++++++++ 3 files changed, 18 insertions(+) create mode 100644 html/pages/device/overview/sensors/load.inc.php create mode 100644 html/pages/device/overview/sensors/state.inc.php diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index f414dd4e5..9e6bbdb51 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -48,6 +48,8 @@ include("overview/sensors/voltages.inc.php"); include("overview/sensors/current.inc.php"); include("overview/sensors/power.inc.php"); include("overview/sensors/frequencies.inc.php"); +include("overview/sensors/load.inc.php"); +include("overview/sensors/state.inc.php"); include("overview/eventlog.inc.php"); include("overview/services.inc.php"); include("overview/syslog.inc.php"); diff --git a/html/pages/device/overview/sensors/load.inc.php b/html/pages/device/overview/sensors/load.inc.php new file mode 100644 index 000000000..989a305b9 --- /dev/null +++ b/html/pages/device/overview/sensors/load.inc.php @@ -0,0 +1,8 @@ + Date: Wed, 24 Jun 2015 14:23:54 -0700 Subject: [PATCH 17/72] Added support for WebPower Pro II UPS cards. --- includes/defaults.inc.php | 1 + includes/definitions.inc.php | 6 ++++++ includes/discovery/os/webpower.inc.php | 5 +++++ includes/polling/os/webpower.inc.php | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 includes/discovery/os/webpower.inc.php create mode 100644 includes/polling/os/webpower.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index ba46626ee..abeceee2e 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -574,6 +574,7 @@ $config['modules_compat']['rfc1628']['netmanplus'] = 1; $config['modules_compat']['rfc1628']['deltaups'] = 1; $config['modules_compat']['rfc1628']['poweralert'] = 1; $config['modules_compat']['rfc1628']['multimatic'] = 1; +$config['modules_compat']['rfc1628']['webpower'] = 1; # Enable daily updates $config['update'] = 1; diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 1fb938f36..52d24bbc1 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -850,6 +850,12 @@ $config['os'][$os]['type'] = "power"; $config['os'][$os]['over'][0]['graph'] = "device_current"; $config['os'][$os]['over'][0]['text'] = "Current"; +$os = "webpower"; +$config['os'][$os]['text'] = "WebPower"; +$config['os'][$os]['type'] = "power"; +$config['os'][$os]['over'][0]['graph'] = "device_current"; +$config['os'][$os]['over'][0]['text'] = "Current"; + $os = "netbotz"; $config['os'][$os]['text'] = "Netbotz Environment sensor"; $config['os'][$os]['type'] = "environment"; diff --git a/includes/discovery/os/webpower.inc.php b/includes/discovery/os/webpower.inc.php new file mode 100644 index 000000000..1053667f5 --- /dev/null +++ b/includes/discovery/os/webpower.inc.php @@ -0,0 +1,5 @@ + diff --git a/includes/polling/os/webpower.inc.php b/includes/polling/os/webpower.inc.php new file mode 100644 index 000000000..ff368d76a --- /dev/null +++ b/includes/polling/os/webpower.inc.php @@ -0,0 +1,19 @@ + +* 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. +*/ + +$data = str_replace('"', '', snmp_get($device, "1.3.6.1.2.1.33.1.1.4.0", "-Ovq")); +preg_match_all('/^WebPower Pro II Card|v[0-9]+.[0-9]+|(SN [0-9]+)/', $data, $matches); +$hardware = $matches[0][0]; +$version = $matches[0][1]; +$serial = $matches[0][2]; + +?> From 01f12a3f0a0ae01d27067d4ca580eb9b07bba871 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Wed, 24 Jun 2015 14:25:58 -0700 Subject: [PATCH 18/72] Added discovery of load sensors of RFC1628 devices. --- includes/discovery/load/rfc1628.inc.php | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 includes/discovery/load/rfc1628.inc.php diff --git a/includes/discovery/load/rfc1628.inc.php b/includes/discovery/load/rfc1628.inc.php new file mode 100644 index 000000000..4f35e5265 --- /dev/null +++ b/includes/discovery/load/rfc1628.inc.php @@ -0,0 +1,27 @@ + From e769a4ffc626e1eac045189ca2cfddcbf05214e4 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 25 Jun 2015 03:47:20 -0700 Subject: [PATCH 19/72] Handle case where sensor_limit is not set for sensor_charge graphs --- html/includes/graphs/sensor/charge.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/includes/graphs/sensor/charge.inc.php b/html/includes/graphs/sensor/charge.inc.php index 153d435dd..331d4ff1a 100644 --- a/html/includes/graphs/sensor/charge.inc.php +++ b/html/includes/graphs/sensor/charge.inc.php @@ -10,7 +10,10 @@ $rrd_options .= " COMMENT:' Last Max\\n'"; $rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE"; $rrd_options .= " DEF:sensor_max=$rrd_filename:sensor:MAX"; $rrd_options .= " DEF:sensor_min=$rrd_filename:sensor:MIN"; -$rrd_options .= " CDEF:sensorwarm=sensor_max,".$sensor['sensor_limit'].",GT,sensor,UNKN,IF"; +if (isset($sensor['sensor_limit'])) { + $rrd_options .= " CDEF:sensorwarm=sensor_max,".$sensor['sensor_limit'].",GT,sensor,UNKN,IF"; + $rrd_options .= " LINE1:sensorwarm#660000"; +} $rrd_options .= " CDEF:sensorcold=sensor_min,20,LT,sensor,UNKN,IF"; $rrd_options .= " AREA:sensor_max#c5c5c5"; $rrd_options .= " AREA:sensor_min#ffffffff"; @@ -19,7 +22,6 @@ $rrd_options .= " AREA:sensor_min#ffffffff"; # $rrd_options .= " AREA:sensorwarm#FFCCCC"; # $rrd_options .= " AREA:sensorcold#CCCCFF"; $rrd_options .= " LINE1:sensor#cc0000:'" . rrdtool_escape($sensor['sensor_descr'],28)."'"; -$rrd_options .= " LINE1:sensorwarm#660000"; $rrd_options .= " GPRINT:sensor:LAST:%3.0lf%%"; $rrd_options .= " GPRINT:sensor:MAX:%3.0lf%%\\\\l"; From 0a5460202826108078a293fa4a9156264886ad11 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 25 Jun 2015 08:01:05 -0400 Subject: [PATCH 20/72] Do not rewrite server-status Currently users cannot use the check_mk apache plugin to monitor the apache instance that is running librenms. Excluding server-status from the rewrite rules allows users to use mod_status. --- html/.htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/html/.htaccess b/html/.htaccess index 0b7faa983..44bd1687d 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -9,6 +9,7 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php) RewriteRule ^api/v0(.*)$ api_v0.php/$1 [L] +RewriteCond %{REQUEST_URI} !=/server-status RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(js|ico|txt|gif|jpg|png|css|php) From 07c1be5b0043e8a7cf6444d3c2ae43c8b368bff6 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Thu, 25 Jun 2015 14:20:48 +0100 Subject: [PATCH 21/72] Revert "Temp fix to remove .index at the start of the poller run" --- poller.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/poller.php b/poller.php index 5bb3fbee8..6608b3254 100755 --- a/poller.php +++ b/poller.php @@ -25,11 +25,6 @@ include("includes/alerts.inc.php"); $poller_start = utime(); echo($config['project_name_version']." Poller\n\n"); -if (is_file($config['mib_dir'].'/.index') === true) { - echo ".index exists, removing\n"; - unlink($config['mib_dir'].'/.index'); -} - $options = getopt("h:m:i:n:r::d::a::"); if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; } From dd5d1c5e05f3444f8a37b5235c4da0af5b7a49cf Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 25 Jun 2015 13:24:02 -0400 Subject: [PATCH 22/72] Adding --daemon twice breaks collectd graphs When using rrdcached [rrdtool.inc.php](includes/rrdtool.inc.php#L163) already adds the necessary options. Collectd.inc.php adds them again which breaks drawing the graphs. --- html/includes/graphs/device/collectd.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/html/includes/graphs/device/collectd.inc.php b/html/includes/graphs/device/collectd.inc.php index b6e5e6a3a..05ce8b3cb 100644 --- a/html/includes/graphs/device/collectd.inc.php +++ b/html/includes/graphs/device/collectd.inc.php @@ -197,7 +197,6 @@ if (isset($MetaGraphDefs[$type])) { if(isset($rrd_cmd)) { - if ($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; } if ($_GET['from']) { $from = mres($_GET['from']); } if ($_GET['to']) { $to = mres($_GET['to']); } $rrd_cmd .= " -s " . $from . " -e " . $to; From 8b06659c86ec2b49b26be383e363cb15e5b175e3 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 07:45:29 -0400 Subject: [PATCH 23/72] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index bc4f417c9..10bcc61b8 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -34,6 +34,7 @@ Contributors to LibreNMS: - Steve Calvário (Calvario) - Christian Marg (einhirn) - Louis Rossouw (spinza) +- Clint Armstrong (clinta) [1]: http://observium.org/ "Observium web site" From 523cb83e917fdafe5fd5703d9b86df1f018076aa Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 07:50:37 -0400 Subject: [PATCH 24/72] Correct Apache collectd DS --- html/includes/collectd/definitions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index a3a227775..b7a0fcac1 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -47,9 +47,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { $GraphDefs = array(); $GraphDefs['apache_bytes'] = array( - 'DEF:min_raw={file}:count:MIN', - 'DEF:avg_raw={file}:count:AVERAGE', - 'DEF:max_raw={file}:count:MAX', + 'DEF:min_raw={file}:value:MIN', + 'DEF:avg_raw={file}:value:AVERAGE', + 'DEF:max_raw={file}:value:MAX', 'CDEF:min=min_raw,8,*', 'CDEF:avg=avg_raw,8,*', 'CDEF:max=max_raw,8,*', @@ -67,9 +67,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:min:MIN:%5.1lf%s\l', 'GPRINT:avg_sum:LAST: (ca. %5.1lf%sB Total)'); $GraphDefs['apache_requests'] = array( - 'DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + 'DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', 'COMMENT: Cur Avg Min Max\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", @@ -79,9 +79,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:min:MIN:%5.2lf%s', 'GPRINT:max:MAX:%5.2lf%s\l'); $GraphDefs['apache_scoreboard'] = array( - 'DEF:min={file}:count:MIN', - 'DEF:avg={file}:count:AVERAGE', - 'DEF:max={file}:count:MAX', + 'DEF:min={file}:value:MIN', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:max={file}:value:MAX', 'COMMENT: Cur Min Ave Max\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", @@ -2043,7 +2043,7 @@ function meta_graph_apache_scoreboard($host, $plugin, $plugin_instance, $type, $ if ($file == '') continue; - $sources[] = array('name'=>$inst, 'file'=>$file, 'ds'=>'count'); + $sources[] = array('name'=>$inst, 'file'=>$file, 'ds'=>'value'); } return collectd_draw_meta_stack($opts, $sources); From 02780b8e72c1927c6653b450aa22b13c5bb970b1 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 08:02:20 -0400 Subject: [PATCH 25/72] entropy DS name is value. --- html/includes/collectd/definitions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index b7a0fcac1..6e1269c90 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -397,9 +397,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:avg:LAST:%4.1lf\l'); $GraphDefs['entropy'] = array( #'-v', 'Bits', - 'DEF:avg={file}:entropy:AVERAGE', - 'DEF:min={file}:entropy:MIN', - 'DEF:max={file}:entropy:MAX', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', 'COMMENT: Min Avg Max Cur\l', "AREA:max#$HalfBlue", "AREA:min#$Canvas", From dbae0e371ffa16368fbce9447b0a665118e6e6ce Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Fri, 26 Jun 2015 10:26:52 -0400 Subject: [PATCH 26/72] url encode graph names --- html/includes/functions.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 8912bb636..fc7c52a09 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -69,7 +69,7 @@ function generate_url($vars, $new_vars = array()) { if ($value == "0" || $value != "" && strstr($var, "opt") === FALSE && is_numeric($var) === FALSE) { - $url .= $var ."=".$value."/"; + $url .= $var ."=".urlencode($value)."/"; } } @@ -339,7 +339,7 @@ function generate_graph_tag($args) $urlargs = array(); foreach ($args as $key => $arg) { - $urlargs[] = $key."=".$arg; + $urlargs[] = $key."=".urlencode($arg); } return ''; From 6ed37c67a505d6c560a421021501d80ac9dab1c0 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 21:22:59 +0100 Subject: [PATCH 27/72] Added Services extension doc to help people set this up --- doc/Extensions/Services.md | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 doc/Extensions/Services.md diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md new file mode 100644 index 000000000..ca2e14ed3 --- /dev/null +++ b/doc/Extensions/Services.md @@ -0,0 +1,50 @@ +# Setting up Services + +Services within LibreNMS provides the ability to use Nagios plugins to perform additional monitoring outside of SNMP. + +These services are tied into an existing device so you need at least one device that supports SNMP to be able to add it +to LibreNMS - localhot is a good one. + +## Setup + +Firstly, install Nagios plugins however you would like, this could be via yum, apt-get or direct from source. + +Next, you need to enable the services within config.php with the following: + +```php +$config['show_services'] = 1; +``` +This will enable a new service menu within your navbar. + +```php +$config['nagios_plugins'] = "/usr/lib/nagios/plugins"; +``` + +This will point LibreNMS at the location of the nagios plugins - please ensure that any plugins you use are set to executable. + +Finally, you now need to add check-services.php to the current cron file (/etc/cron.d/librenms typically) like: +```bash +*/5 * * * * librenms /opt/librenms/check-services.php >> /dev/null 2>&1 +``` + +Now you can add services via the main Services link in the navbar, or via the Services link within the device page. + +> **Please note that at present the service checks will only return the status and the response from the check +no graphs will be generated. ** + +## Supported checks + +- ftp +- icmp +- spop +- ssh +- ssl_cert +- http +- domain_expire +- mysql +- imap +- dns +- telnet +- smtp +- pop +- simap From 505429db4dc33b3a08e4ec564e69fd0cdf9f8ee7 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 27 Jun 2015 22:11:54 +0100 Subject: [PATCH 28/72] Added some additional info from pfsense units --- includes/polling/os/unix.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/polling/os/unix.inc.php b/includes/polling/os/unix.inc.php index 5feb16544..4f0f3eacb 100644 --- a/includes/polling/os/unix.inc.php +++ b/includes/polling/os/unix.inc.php @@ -107,6 +107,10 @@ elseif ($device['os'] == "dsm") $hardware = $value; } } +} elseif ($device['os'] == "pfsense") { + $output = preg_split("/ /", $poll_device['sysDescr']); + $version = $output[2]; + $hardware = $output[6]; } ?> From 5c6e4995ab46930cfaf95ddf7d4fb811696ebf02 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 28 Jun 2015 16:25:20 +0100 Subject: [PATCH 29/72] Updated regex for device groups --- html/forms/parse-device-group.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/forms/parse-device-group.inc.php b/html/forms/parse-device-group.inc.php index 7009459f2..9ecd4e52e 100644 --- a/html/forms/parse-device-group.inc.php +++ b/html/forms/parse-device-group.inc.php @@ -20,7 +20,7 @@ $group_id = $_POST['group_id']; if(is_numeric($group_id) && $group_id > 0) { $group = dbFetchRow("SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1",array($group_id)); - $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $count = count($group_split) - 1; $group_split[$count] = $group_split[$count].' &&'; $output = array('name'=>$group['name'],'desc'=>$group['desc'],'pattern'=>$group_split); From 90563c5b1deda6c6312af771b595ef605ed077ee Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 28 Jun 2015 18:54:55 +0100 Subject: [PATCH 30/72] Added HOST-RESOURCES-MIB:: to allow detection of Synology devices --- includes/discovery/os/linux.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/os/linux.inc.php b/includes/discovery/os/linux.inc.php index c09e957ff..7e4b2d238 100644 --- a/includes/discovery/os/linux.inc.php +++ b/includes/discovery/os/linux.inc.php @@ -29,7 +29,7 @@ if (!$os) else { // Check for Synology DSM - $hrSystemInitialLoadParameters = trim(snmp_get($device, "hrSystemInitialLoadParameters.0", "-Osqnv")); + $hrSystemInitialLoadParameters = trim(snmp_get($device, "HOST-RESOURCES-MIB::hrSystemInitialLoadParameters.0", "-Osqnv")); if (strpos($hrSystemInitialLoadParameters, "syno_hw_version") !== FALSE) { $os = "dsm"; } else From 4e34aecce5b2339cf543df239b4218ea5a5f5820 Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 28 Jun 2015 19:05:43 +0100 Subject: [PATCH 31/72] AUTHORS addition --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 10bcc61b8..61343a9ad 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -35,6 +35,7 @@ Contributors to LibreNMS: - Christian Marg (einhirn) - Louis Rossouw (spinza) - Clint Armstrong (clinta) +- Tony Ditchfield (arnoldthebat) [1]: http://observium.org/ "Observium web site" From 8e785ebaaaca3ca9eb8c2d346b0a73ed0a255736 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Mon, 29 Jun 2015 10:34:03 -0400 Subject: [PATCH 32/72] Fix issue #1362, added a line to reset , because the calling page is expecting new graphs, not appended ones --- html/includes/print-graphrow.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/includes/print-graphrow.inc.php b/html/includes/print-graphrow.inc.php index 240362632..c55091044 100644 --- a/html/includes/print-graphrow.inc.php +++ b/html/includes/print-graphrow.inc.php @@ -15,6 +15,7 @@ if($_SESSION['widescreen']) $graph_array['to'] = $config['time']['now']; +$graph_data = array(); foreach ($periods as $period) { $graph_array['from'] = $config['time'][$period]; From a7d83be1af6807269dcc1da9c8a45ed4a54c8392 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 30 Jun 2015 10:48:08 +0100 Subject: [PATCH 33/72] Fixed API graphs not loading --- html/includes/graphs/graph.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/html/includes/graphs/graph.inc.php b/html/includes/graphs/graph.inc.php index 5c6bfe1c1..6ba9de57a 100644 --- a/html/includes/graphs/graph.inc.php +++ b/html/includes/graphs/graph.inc.php @@ -38,7 +38,9 @@ $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $type = $graphtype['type']; $subtype = $graphtype['subtype']; -$auth = is_client_authorized($_SERVER['REMOTE_ADDR']); +if ($auth !== true && $auth != 1) { + $auth = is_client_authorized($_SERVER['REMOTE_ADDR']); +} include($config['install_dir'] . "/html/includes/graphs/$type/auth.inc.php"); if ($auth === true && is_file($config['install_dir'] . "/html/includes/graphs/$type/$subtype.inc.php")) { From b92e9f2d8f1ab01b702342de25c951ef899b4109 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Tue, 30 Jun 2015 07:46:09 -0400 Subject: [PATCH 34/72] Update to the freqency DS used in collectd > 5.0 Similar to #1347 and #1349 --- html/includes/collectd/definitions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/includes/collectd/definitions.php b/html/includes/collectd/definitions.php index 6e1269c90..e93e35cfd 100644 --- a/html/includes/collectd/definitions.php +++ b/html/includes/collectd/definitions.php @@ -422,9 +422,9 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:avg:LAST:%4.1lf\l'); $GraphDefs['frequency'] = array( #'-v', 'Hertz', - 'DEF:avg={file}:frequency:AVERAGE', - 'DEF:min={file}:frequency:MIN', - 'DEF:max={file}:frequency:MAX', + 'DEF:avg={file}:value:AVERAGE', + 'DEF:min={file}:value:MIN', + 'DEF:max={file}:value:MAX', "AREA:max#b5b5b5", "AREA:min#$Canvas", "LINE1:avg#$FullBlue:Frequency [Hz]", From 3b5223994508f48758020d91ebbfd332d76482d9 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Tue, 30 Jun 2015 10:12:07 -0400 Subject: [PATCH 35/72] I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 61343a9ad..86db6c60e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -36,6 +36,7 @@ Contributors to LibreNMS: - Louis Rossouw (spinza) - Clint Armstrong (clinta) - Tony Ditchfield (arnoldthebat) +- Travis Hegner (travishegner) [1]: http://observium.org/ "Observium web site" From e9d7d74b726271dbbc8af8b38595da0185e04ed3 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 1 Jul 2015 21:35:37 +0100 Subject: [PATCH 36/72] Fixed issue with name not being set + some validation around this --- html/includes/api_functions.inc.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index d2e9f3061..a3593e684 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -567,6 +567,10 @@ function add_edit_rule() { if(empty($rule)) { $message = 'Missing the alert rule'; } + $name = mres($data['name']); + if (empty($name)) { + $message = 'Missing the alert rule name'; + } $severity = mres($data['severity']); $sevs = array("ok","warning","critical"); if(!in_array($severity, $sevs)) { @@ -590,15 +594,19 @@ function add_edit_rule() { $extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec); $extra_json = json_encode($extra); + if (dbFetchCell("SELECT `name` FROM `alert_rules` WHERE `name`=?",array($name)) == $name) { + $message = 'Name has already been used'; + } + if(empty($message)) { if(is_numeric($rule_id)) { - if( dbUpdate(array('rule' => $rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json), 'alert_rules', 'id=?',array($rule_id)) >= 0) { + if( dbUpdate(array('name' => $name, 'rule' => $rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json), 'alert_rules', 'id=?',array($rule_id)) >= 0) { $status = 'ok'; $code = 200; } else { $message = 'Failed to update existing alert rule'; } - } elseif( dbInsert(array('device_id'=>$device_id,'rule'=>$rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json),'alert_rules') ) { + } elseif( dbInsert(array('name' => $name, 'device_id'=>$device_id,'rule'=>$rule,'severity'=>$severity,'disabled'=>$disabled,'extra'=>$extra_json),'alert_rules') ) { $status = 'ok'; $code = 200; } else { From 8d49395b1098ebf422510784d3d45d8370a0f2b8 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 13:41:54 -0400 Subject: [PATCH 37/72] test static TZ parse --- html/pages/graphs.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 8e438489d..7806e9833 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,10 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace(' ','T')); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ','T')); + var strto = frmdata.dtpickerto.value.replace(' ', 'T')+':00Z0400'; + var tsto = new Date(strto); + var strfrom = frmdata.dtpickerfrom.value.replace(' ', 'T')+':00Z0400'; + var tsfrom = new Date(strfrom); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From f2fe24c6023296ff61fc791d772412008ca561dd Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 13:54:27 -0400 Subject: [PATCH 38/72] use js to convert --- html/pages/graphs.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 7806e9833..9b82a0a11 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,10 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var strto = frmdata.dtpickerto.value.replace(' ', 'T')+':00Z0400'; - var tsto = new Date(strto); - var strfrom = frmdata.dtpickerfrom.value.replace(' ', 'T')+':00Z0400'; - var tsfrom = new Date(strfrom); + var tsto = new Date(frmdata.dtpickerto.value.replace(' ','T')); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ','T')); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); @@ -137,16 +135,18 @@ if (!$auth) echo('
    - +
    - +
    From a2e248cf4bd921b26511e6ecbbdbe2f4234249f8 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:06:02 -0400 Subject: [PATCH 40/72] trying to set the date from js --- html/pages/graphs.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 1baac09a2..9a55e1de2 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -145,10 +145,12 @@ if (!$auth) From abeb015e33cb06e0c75b6fe3d04446ae97995427 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:09:23 -0400 Subject: [PATCH 41/72] debug output --- html/pages/graphs.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 9a55e1de2..c33f90f39 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -145,6 +145,7 @@ if (!$auth) From 0fbcc0d1b6a0dfcb57fe60f3a2931a937e533441 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:54:36 -0400 Subject: [PATCH 51/72] ff failing to parse --- html/pages/graphs.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index e598af269..4bb521592 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value); - var tsfrom = new Date(frmdata.dtpickerfrom.value); + var tsto = new Date(frmdata.dtpickerto.value+":00"); + var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From 0ab00ba0fb89392ede98067d462df7a1a90e4f48 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:55:42 -0400 Subject: [PATCH 52/72] debug output --- html/pages/graphs.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 4bb521592..42b6dd3d2 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -119,6 +119,7 @@ if (!$auth) var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; var tsto = new Date(frmdata.dtpickerto.value+":00"); + alert(frmdata.dtpickerto.value+":00") var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; From 01e4a6650e476b4f33ead8ca95fa7b2546421906 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 14:59:11 -0400 Subject: [PATCH 53/72] putting the T back with Z this time --- html/pages/graphs.inc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 42b6dd3d2..cd4f6181b 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,9 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value+":00"); - alert(frmdata.dtpickerto.value+":00") - var tsfrom = new Date(frmdata.dtpickerfrom.value+":00"); + var tsto = new Date(frmdata.dtpickerto.value.replace(' ', 'T')+":00.000Z"); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ', 'T')+":00.000Z"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From d3aea6757b2098382f200de963f038495aef1090 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:05:05 -0400 Subject: [PATCH 54/72] trying a more universal (perhaps not standard) format --- html/pages/graphs.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index cd4f6181b..b3f6a36b5 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,8 +118,8 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace(' ', 'T')+":00.000Z"); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace(' ', 'T')+":00.000Z"); + var tsto = new Date(frmdata.dtpickerto.value.replace('-', '/')+":00"); + var tsfrom = new Date(frmdata.dtpickerfrom.value.replace('-', '/')+":00"); tsto = tsto.getTime() / 1000; tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); From 6878e380b3a0712769c88dc88dd46d9153bbf3b2 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:10:49 -0400 Subject: [PATCH 55/72] using moment.js since we have it anyway --- html/pages/graphs.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index b3f6a36b5..72fb1bd82 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -118,10 +118,10 @@ if (!$auth) function submitCustomRange(frmdata) { var reto = /to=([0-9])+/g; var refrom = /from=([0-9])+/g; - var tsto = new Date(frmdata.dtpickerto.value.replace('-', '/')+":00"); - var tsfrom = new Date(frmdata.dtpickerfrom.value.replace('-', '/')+":00"); - tsto = tsto.getTime() / 1000; - tsfrom = tsfrom.getTime() / 1000; + var tsto = moment(frmdata.dtpickerto.value).unix(); + var tsfrom = moment(frmdata.dtpickerfrom.value).unix(); + //tsto = tsto.getTime() / 1000; + //tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); frmdata.selfaction.value = frmdata.selfaction.value.replace(refrom, 'from=' + tsfrom); frmdata.action = frmdata.selfaction.value; From 6314aaddd4f85dd9c515b9633238b6911c515109 Mon Sep 17 00:00:00 2001 From: Travis Hegner Date: Thu, 2 Jul 2015 15:12:42 -0400 Subject: [PATCH 56/72] removing commented code --- html/pages/graphs.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/html/pages/graphs.inc.php b/html/pages/graphs.inc.php index 72fb1bd82..0cc268fce 100644 --- a/html/pages/graphs.inc.php +++ b/html/pages/graphs.inc.php @@ -120,8 +120,6 @@ if (!$auth) var refrom = /from=([0-9])+/g; var tsto = moment(frmdata.dtpickerto.value).unix(); var tsfrom = moment(frmdata.dtpickerfrom.value).unix(); - //tsto = tsto.getTime() / 1000; - //tsfrom = tsfrom.getTime() / 1000; frmdata.selfaction.value = frmdata.selfaction.value.replace(reto, 'to=' + tsto); frmdata.selfaction.value = frmdata.selfaction.value.replace(refrom, 'from=' + tsfrom); frmdata.action = frmdata.selfaction.value; From fd0617acca065ae3df8db6d002ad2c3aba35c04b Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Thu, 2 Jul 2015 15:30:57 -0400 Subject: [PATCH 57/72] Do not allow the master to join twice If the poller master doesn't complete in time and ends up with overlapping jobs, neither job will ever complete because both running jobs will think they are the master and wait for the remaining node to exit. --- poller-wrapper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/poller-wrapper.py b/poller-wrapper.py index 02efa825d..d9b542011 100755 --- a/poller-wrapper.py +++ b/poller-wrapper.py @@ -133,6 +133,9 @@ if ('distributed_poller' in config and import uuid memc = memcache.Client([config['distributed_poller_memcached_host'] + ':' + str(config['distributed_poller_memcached_port'])]) + if str(memc.get("poller.master")) == config['distributed_poller_name']: + print "This sytem is already joined as the poller master." + sys.exit(2) if memc_alive(): if memc.get("poller.master") is None: print "Registered as Master" @@ -148,7 +151,7 @@ if ('distributed_poller' in config and print "Could not connect to memcached, disabling distributed poller." distpoll = False IsNode = False - except: + except ImportError: print "ERROR: missing memcache python module:" print "On deb systems: apt-get install python-memcache" print "On other systems: easy_install python-memcached" From 69e9929ddba7443669e9871bbe59c69a3fd2042c Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:14:28 +0100 Subject: [PATCH 58/72] Support Huawei UPS, tested with UPS5000 --- includes/defaults.inc.php | 1 + includes/definitions.inc.php | 9 +++++++++ includes/discovery/os/huaweiups.inc.php | 12 ++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 includes/discovery/os/huaweiups.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index abeceee2e..8586266ee 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -575,6 +575,7 @@ $config['modules_compat']['rfc1628']['deltaups'] = 1; $config['modules_compat']['rfc1628']['poweralert'] = 1; $config['modules_compat']['rfc1628']['multimatic'] = 1; $config['modules_compat']['rfc1628']['webpower'] = 1; +$config['modules_compat']['rfc1628']['huaweiups'] = 1; # Enable daily updates $config['update'] = 1; diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 52d24bbc1..3c551d571 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1162,6 +1162,15 @@ $config['os'][$os]['text'] = "Multimatic UPS"; $config['os'][$os]['type'] = "power"; $config['os'][$os]['icon'] = "multimatic"; +// Huawei UPS +$os = "huaweiups"; +$config['os'][$os]['text'] = "Huawei UPS"; +$config['os'][$os]['group'] = "ups"; +$config['os'][$os]['type'] = "power"; +$config['os'][$os]['icon'] = "huawei"; +$config['os'][$os]['over'][0]['graph'] = "device_current"; +$config['os'][$os]['over'][0]['text'] = "Current"; + foreach ($config['os'] as $this_os => $blah) { if (isset($config['os'][$this_os]['group'])) diff --git a/includes/discovery/os/huaweiups.inc.php b/includes/discovery/os/huaweiups.inc.php new file mode 100644 index 000000000..6b7f4f38d --- /dev/null +++ b/includes/discovery/os/huaweiups.inc.php @@ -0,0 +1,12 @@ + From ffbe06f64bccdf2356f74f9b128a9c270392fb32 Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:15:17 +0100 Subject: [PATCH 59/72] Check netmanplus UPS by OID as well as descr, tested with Netman 204 --- includes/discovery/os/netmanplus.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/discovery/os/netmanplus.inc.php b/includes/discovery/os/netmanplus.inc.php index 42e081971..969c8bdb2 100644 --- a/includes/discovery/os/netmanplus.inc.php +++ b/includes/discovery/os/netmanplus.inc.php @@ -3,6 +3,7 @@ if (!$os) { if (preg_match("/^NetMan.*plus/", $sysDescr)) { $os = "netmanplus"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.5491.6")) { $os = "netmanplus"; } } -?> \ No newline at end of file +?> From 75704eba8738117244d98925a327318f23c8db8a Mon Sep 17 00:00:00 2001 From: sthen Date: Sat, 4 Jul 2015 20:47:46 +0100 Subject: [PATCH 60/72] Use correct divisor for frequencies on Huawei UPS --- includes/discovery/frequencies/rfc1628.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/discovery/frequencies/rfc1628.inc.php b/includes/discovery/frequencies/rfc1628.inc.php index 58f1fd6e4..340d0a38d 100644 --- a/includes/discovery/frequencies/rfc1628.inc.php +++ b/includes/discovery/frequencies/rfc1628.inc.php @@ -15,6 +15,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '3.2.0.'.$i; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); } @@ -24,6 +25,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '4.2.0'; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); @@ -32,6 +34,7 @@ if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modul $current = snmp_get($device, $freq_oid, "-Oqv") / 10; $type = "rfc1628"; $divisor = 10; + if ($device['os'] == "huaweiups") { $divisor = 100; }; $index = '5.1.0'; discover_sensor($valid['sensor'], 'frequency', $device, $freq_oid, $index, $type, $descr, $divisor, '1', NULL, NULL, NULL, NULL, $current); } From 049fd54bebed8b973818002c840d46b97799b1c9 Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sat, 4 Jul 2015 23:22:26 +0200 Subject: [PATCH 61/72] Add support fo PBN CPE device" Fixes #1382 --- includes/discovery/os/pbn.inc.php | 5 ++--- includes/polling/os/pbn.inc.php | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/discovery/os/pbn.inc.php b/includes/discovery/os/pbn.inc.php index d8930fbb9..d2a5a805c 100644 --- a/includes/discovery/os/pbn.inc.php +++ b/includes/discovery/os/pbn.inc.php @@ -1,9 +1,8 @@ diff --git a/includes/polling/os/pbn.inc.php b/includes/polling/os/pbn.inc.php index aae6675f2..d498dddf8 100644 --- a/includes/polling/os/pbn.inc.php +++ b/includes/polling/os/pbn.inc.php @@ -3,6 +3,13 @@ if (preg_match('/^Pacific Broadband Networks .+\n.+ Version ([^,]+), .+\n.+\n.+\nSerial num:([^,]+), .+/', $poll_device['sysDescr'], $regexp_result)) { $version = $regexp_result[1]; $serial = $regexp_result[2]; + +# for PBN CPE 120/121 +} elseif (strstr(snmp_get($device, "SNMPv2-MIB::sysObjectID.0", "-Ovqn"), ".1.3.6.1.4.1.11606.24.1.1.10")) { + $version = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.6.0", "-Ovq"); + $hardware = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.7.0", "-Ovq"); + $features = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.10.0", "-Ovq"); + $serial = snmp_get($device, "1.3.6.1.4.1.11606.24.1.1.4.0", "-Ovq"); } ?> From bf8df0fbe2b4828108fdec5bdcab0d5964d054a6 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 00:35:33 +0200 Subject: [PATCH 62/72] Pass service parameters to check_ssh allowing one to specify alternative port for ssh for example using -p flag. --- includes/services/ssh/check.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/services/ssh/check.inc b/includes/services/ssh/check.inc index 72bf4c2c5..d9cb7b98f 100644 --- a/includes/services/ssh/check.inc +++ b/includes/services/ssh/check.inc @@ -1,6 +1,6 @@ Date: Sun, 5 Jul 2015 00:47:51 +0200 Subject: [PATCH 63/72] When check_mysql is run with -n option it returns MySQL OK. Also accept that as an status=1 indication. --- includes/services/mysql/check.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/services/mysql/check.inc b/includes/services/mysql/check.inc index 93c97199c..d4d98bc85 100644 --- a/includes/services/mysql/check.inc +++ b/includes/services/mysql/check.inc @@ -7,7 +7,7 @@ $check = shell_exec($config['nagios_plugins'] . "/check_mysql -H ".$service['hos list($check, $time) = split("\|", $check); -if(strstr($check, "Uptime:")) { +if(strstr($check, "Uptime:") || strstr($check, "MySQL OK")) { $status = '1'; } else { $status = '0'; From 96f70b1b9bc9234bb1e4e3f686338f1a6fd92e4a Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 15:24:37 +0200 Subject: [PATCH 64/72] Add ntp service monitoring. --- includes/services/ntp/check.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 includes/services/ntp/check.inc diff --git a/includes/services/ntp/check.inc b/includes/services/ntp/check.inc new file mode 100644 index 000000000..8115e55ad --- /dev/null +++ b/includes/services/ntp/check.inc @@ -0,0 +1,13 @@ + From abe773c1c3b9b8746cbfec8fb312127eea28ebfe Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 15:24:58 +0200 Subject: [PATCH 65/72] Update docs to reflect ntp service being added. --- doc/Extensions/Services.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md index ca2e14ed3..ddae31f27 100644 --- a/doc/Extensions/Services.md +++ b/doc/Extensions/Services.md @@ -48,3 +48,4 @@ no graphs will be generated. ** - smtp - pop - simap +- ntp From 33e8723840d9fe80e9f52c037274fb7fbf1f2ab6 Mon Sep 17 00:00:00 2001 From: dontforget Date: Sun, 5 Jul 2015 17:14:50 +0300 Subject: [PATCH 66/72] fix nginx config file location fix nginx config file location --- doc/Installation/Installation-(RHEL-CentOS).md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index a1aafc2b8..42f277f18 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -96,7 +96,7 @@ Modify permissions and configuration for `php-fpm` to use nginx credentials. vi /etc/php-fpm.d/www.conf # At line #12: Change `listen` to `/var/run/php5-fpm.sock` # At line #39-41: Change the `user` and `group` to `nginx` -Add configuration for `nginx` at `/etc/nginx/conf.d/librenms` with the following content: +Add configuration for `nginx` at `/etc/nginx/conf.d/librenms.conf` with the following content: ```nginx server { From c050ff374fef42609de187f6cbebe933005c70d3 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 21:12:59 +0200 Subject: [PATCH 67/72] Add IRCd service. --- doc/Extensions/Services.md | 1 + includes/services/ircd/check.inc | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 includes/services/ircd/check.inc diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md index ddae31f27..7ad7c9d29 100644 --- a/doc/Extensions/Services.md +++ b/doc/Extensions/Services.md @@ -49,3 +49,4 @@ no graphs will be generated. ** - pop - simap - ntp +- ircd diff --git a/includes/services/ircd/check.inc b/includes/services/ircd/check.inc new file mode 100644 index 000000000..cecfcb6d4 --- /dev/null +++ b/includes/services/ircd/check.inc @@ -0,0 +1,13 @@ + From 90f220108474ce87c7ab721b844cdc94dc990c45 Mon Sep 17 00:00:00 2001 From: Louis Rossouw Date: Sun, 5 Jul 2015 21:31:11 +0200 Subject: [PATCH 68/72] Fix up formatting to http://docs.librenms.org/Developing/Code-Guidelines/ --- includes/services/ircd/check.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/services/ircd/check.inc b/includes/services/ircd/check.inc index cecfcb6d4..80b540a5b 100644 --- a/includes/services/ircd/check.inc +++ b/includes/services/ircd/check.inc @@ -4,10 +4,10 @@ $check = shell_exec($config['nagios_plugins'] . "/check_ircd -H ".$service['host list($check, $time) = split("\|", $check); -if(strstr($check, "IRCD ok")) { - $status = '1'; +if (strstr($check, "IRCD ok")) { + $status = '1'; } else { - $status = '0'; + $status = '0'; } ?> From 06c0803b7be283890279952a71f24c765aaa80d3 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 5 Jul 2015 20:58:01 +0100 Subject: [PATCH 69/72] Updated changelog 05/07/2015 --- doc/General/Changelog.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index ff43400c1..31ce4d0de 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -1,3 +1,16 @@ +### July 2015 + +#### Bug fixes + - Fixed API not functioning. (PR1367) + - Fixed API not storing alert rule names (PR1372) + - Fixed datetimepicker use (PR + - Do not allow master to rejoin itself. (PR1377) + - Fixed Nginx config file (PR1389) + +#### Improvements + - Added additional support for Rielo UPS (PR1381) + - Improved service check support (PR1385,PR1386,PR1387,PR1388) + ### June 2015 #### Bug fixes @@ -15,6 +28,14 @@ - Fixed legend ifLabels (PR1296) - Fixed bug causing map to not load when stale link data was present (PR1297) - Fixed javascript issue preventing removal of alert rules (PR1312) + - Fixed removal of IPs before ports are deleted (PR1329) + - Fixed JS issue when removing ports from bills (PR1330) + - Fixed adding --daemon a second time to collectd Graphs (PR1342) + - Fixed CollectD DS names (PR1347,PR1349,PR1368) + - Fixed graphing issues when rrd contains special chars (PR1350) + - Fixed regex for device groups (PR1359) + - Added HOST-RESOURCES-MIB into Synology detection (RP1360) + - Fix health page graphs showing the first graph for all (PR1363) #### Improvements - Updated Syslog docs to include syslog-ng 3.5.1 updates (PR1171) @@ -48,6 +69,18 @@ - Added WebUI support for Pushover (PR1313) - Updated path check for Oxidized config (PR1316) - Added Multimatic UPS to rfc1628 detection (PR1317) + - Added timeout for Unix agent (PR1319) + - Added support for a poller to use more than one poller group (PR1323) + - Added ability to use Plugins on device overview page (PR1325) + - Added latency loss/avg/max/min results to DB and Graph (PR1326) + - Added recording of device down (snmp/icmp) (PR1326) + - Added debugging output for when invalid SNMPv3 options used (PR1331) + - Added load and state output to device overview page (PR1333) + - Added load sensors to RFC1628 Devices (PR1336) + - Added support for WebPower Pro II UPS Cards (PR1338) + - No longer rewrite server-status in .htaccess (PR1339) + - Added docs for setting up Service extensions (PR1354) + - Added additional info from pfsense devices (PR1356) ### May 2015 From 23fdc03ded2f437162b539732ccead8730e71597 Mon Sep 17 00:00:00 2001 From: Tony Ditchfield Date: Sun, 5 Jul 2015 20:58:56 +0100 Subject: [PATCH 70/72] Added load and state icons from silkicons set --- html/images/icons/load.png | Bin 0 -> 541 bytes html/images/icons/state.png | Bin 0 -> 537 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 html/images/icons/load.png create mode 100644 html/images/icons/state.png diff --git a/html/images/icons/load.png b/html/images/icons/load.png new file mode 100644 index 0000000000000000000000000000000000000000..9051fbc609b92b15af9be410e368b7adc20283b8 GIT binary patch literal 541 zcmV+&0^V&qIn(Wzh!))n z^W^$!aM&X3bCX~Vo|JLOLCb!-`g!yN7b-yh!|sbVZ|M~fElQAyiB?lO%sjz z7TJ==TTk%_A{ znxkIa+E~RC#EKF{U0G~y<6)R9(uCp7&f7|JN}RHwEO@{EgbF~D3a1<@ip|9yZb^6$ fo@6A$W#9P^w2GuX0-m@}00000NkvXXu0mjfB69Bi literal 0 HcmV?d00001 diff --git a/html/images/icons/state.png b/html/images/icons/state.png new file mode 100644 index 0000000000000000000000000000000000000000..a9925a06ab02db30c1e7ead9c701c15bc63145cb GIT binary patch literal 537 zcmV+!0_OdRP)Hs{AQG2a)rMyf zFQK~pm1x3+7!nu%-M`k}``c>^00{o_1pjWJUTfl8mg=3qGEl8H@}^@w`VUx0_$uy4 z2FhRqKX}xI*?Tv1DJd8z#F#0c%*~rM30HE1@2o5m~}ZyoWhqv>ql{V z1ZGE0lgcoK^lx+eqc*rAX1Ky;Xx3U%u#zG!m-;eD1Qsn@kf3|F9qz~|95=&g3(7!X zB}JAT>RU;a%vaNOGnJ%e1=K6eAh43c(QN8RQ6~GP%O}Jju$~Ld*%`mO1p Date: Sun, 5 Jul 2015 21:18:11 +0100 Subject: [PATCH 71/72] Missing pr number --- doc/General/Changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index 31ce4d0de..8cdb6a1e5 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -3,7 +3,7 @@ #### Bug fixes - Fixed API not functioning. (PR1367) - Fixed API not storing alert rule names (PR1372) - - Fixed datetimepicker use (PR + - Fixed datetimepicker use (PR1376) - Do not allow master to rejoin itself. (PR1377) - Fixed Nginx config file (PR1389) From a015db74d94a6c3d134531e9f1cc80343bbab772 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 6 Jul 2015 02:21:40 +0100 Subject: [PATCH 72/72] add Will Jones I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 86db6c60e..ce1ce2b57 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -37,6 +37,7 @@ Contributors to LibreNMS: - Clint Armstrong (clinta) - Tony Ditchfield (arnoldthebat) - Travis Hegner (travishegner) +- Will Jones (willjones) [1]: http://observium.org/ "Observium web site"