From ae7bb069ff1ca681150cc31ac0cf8770006bce15 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Mon, 8 Aug 2016 16:59:29 +1000 Subject: [PATCH 01/44] - Change the IPSLA feature to allow different metrics to be collected per type. - UDP Jitter metrics collected. - Added opstatus code and DB field - Discovery sets opstatus - Added Status selector to SLA page - Merged master and moved SQL --- html/includes/graphs/device/sla.inc.php | 40 ++---- .../graphs/device/sla_jitter-icpif.inc.php | 28 ++++ .../graphs/device/sla_jitter-latency.inc.php | 34 +++++ .../graphs/device/sla_jitter-loss.inc.php | 34 +++++ .../graphs/device/sla_jitter-lost.inc.php | 40 ++++++ .../graphs/device/sla_jitter-mos.inc.php | 28 ++++ .../includes/graphs/device/sla_jitter.inc.php | 34 +++++ .../includes/graphs/sla-jitter-jitter.inc.php | 34 +++++ html/pages/device/sla.inc.php | 34 +++++ html/pages/device/sla/jitter.inc.php | 95 +++++++++++++ html/pages/device/sla/rtt.inc.php | 15 ++ html/pages/device/slas.inc.php | 70 +++++++-- includes/discovery/cisco-sla.inc.php | 1 + includes/polling/cisco-sla.inc.php | 134 ++++++++++-------- sql-schema/127.sql | 1 + 15 files changed, 526 insertions(+), 96 deletions(-) create mode 100644 html/includes/graphs/device/sla_jitter-icpif.inc.php create mode 100644 html/includes/graphs/device/sla_jitter-latency.inc.php create mode 100644 html/includes/graphs/device/sla_jitter-loss.inc.php create mode 100644 html/includes/graphs/device/sla_jitter-lost.inc.php create mode 100644 html/includes/graphs/device/sla_jitter-mos.inc.php create mode 100644 html/includes/graphs/device/sla_jitter.inc.php create mode 100644 html/includes/graphs/sla-jitter-jitter.inc.php create mode 100644 html/pages/device/sla.inc.php create mode 100644 html/pages/device/sla/jitter.inc.php create mode 100644 html/pages/device/sla/rtt.inc.php create mode 100644 sql-schema/127.sql diff --git a/html/includes/graphs/device/sla.inc.php b/html/includes/graphs/device/sla.inc.php index 607d612c1a..1deb4d9674 100644 --- a/html/includes/graphs/device/sla.inc.php +++ b/html/includes/graphs/device/sla.inc.php @@ -2,35 +2,19 @@ require 'includes/graphs/common.inc.php'; -// FIXME - THIS IS BROKEN -$sla = dbFetchRow('SELECT * FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); -$device = device_by_id_cache($sla['device_id']); - -// if ($_GET['width'] >= "450") { $descr_len = "48"; } else { $descr_len = "21"; } -$descr_len = (intval(($_GET['width'] / 8)) * 0.8); - -$unit_long = 'milliseconds'; -$unit = 'ms'; +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); $rrd_options .= ' -l 0 -E '; -$rrd_options .= " COMMENT:'".str_pad($unit_long, $descr_len)." Cur Min Max\\n'"; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'.rrd'); -$name = ''; -if ($sla['tag']) { - $name .= $sla['tag']; +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:'Round Trip Time Cur Min Max\\n'"; + $rrd_options .= " DEF:rtt=$rrd_filename:rtt:AVERAGE "; + $rrd_options .= ' VDEF:avg=rtt,AVERAGE '; + $rrd_options .= " LINE1:avg#CCCCFF:'Average':dashes"; + $rrd_options .= ' GPRINT:rtt:AVERAGE:%4.1lfms\\\l '; + $rrd_options .= " LINE1:rtt#CC0000:'RTT'"; + $rrd_options .= ' GPRINT:rtt:LAST:%4.1lfms '; + $rrd_options .= ' GPRINT:rtt:MIN:%4.1lfms '; + $rrd_options .= ' GPRINT:rtt:MAX:%4.1lfms\\\l '; } - -if ($sla['owner']) { - $name .= ' (Owner: '.$sla['owner'].')'; -} - -$rrd_file = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('sla-'.$sla['sla_nr'].'.rrd'); - -$rrd_options .= " DEF:rtt=$rrd_file:rtt:AVERAGE "; -$rrd_options .= ' VDEF:avg=rtt,AVERAGE '; -$rrd_options .= " LINE1:avg#CCCCFF:'".str_pad('Average', ($descr_len - 3))."':dashes"; -$rrd_options .= ' GPRINT:rtt:AVERAGE:%4.1lf'.$unit.'\\\l '; -$rrd_options .= " LINE1:rtt#CC0000:'".rrdtool_escape($descr, ($descr_len - 3))."'"; -$rrd_options .= ' GPRINT:rtt:LAST:%4.1lf'.$unit.' '; -$rrd_options .= ' GPRINT:rtt:MIN:%4.1lf'.$unit.' '; -$rrd_options .= ' GPRINT:rtt:MAX:%4.1lf'.$unit.'\\\l '; diff --git a/html/includes/graphs/device/sla_jitter-icpif.inc.php b/html/includes/graphs/device/sla_jitter-icpif.inc.php new file mode 100644 index 0000000000..2c385cea4c --- /dev/null +++ b/html/includes/graphs/device/sla_jitter-icpif.inc.php @@ -0,0 +1,28 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:ICPIF=" . $rrd_filename . ":ICPIF:AVERAGE "; + $rrd_options .= " LINE1.25:ICPIF#0000ee:'ICPIF ' "; + $rrd_options .= " GPRINT:ICPIF:LAST:%3.0lf "; + $rrd_options .= " GPRINT:ICPIF:MIN:%3.0lf "; + $rrd_options .= " GPRINT:ICPIF:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/device/sla_jitter-latency.inc.php b/html/includes/graphs/device/sla_jitter-latency.inc.php new file mode 100644 index 0000000000..9b1a9c5e34 --- /dev/null +++ b/html/includes/graphs/device/sla_jitter-latency.inc.php @@ -0,0 +1,34 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:SD=" . $rrd_filename . ":OWAvgSD:AVERAGE "; + $rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' "; + $rrd_options .= " GPRINT:SD:LAST:%3.0lf "; + $rrd_options .= " GPRINT:SD:MIN:%3.0lf "; + $rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:DS=" . $rrd_filename . ":OWAvgDS:AVERAGE "; + $rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' "; + $rrd_options .= " GPRINT:DS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:DS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/device/sla_jitter-loss.inc.php b/html/includes/graphs/device/sla_jitter-loss.inc.php new file mode 100644 index 0000000000..5b4cfa24e9 --- /dev/null +++ b/html/includes/graphs/device/sla_jitter-loss.inc.php @@ -0,0 +1,34 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:SD=" . $rrd_filename . ":PacketLossSD:AVERAGE "; + $rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' "; + $rrd_options .= " GPRINT:SD:LAST:%3.0lf "; + $rrd_options .= " GPRINT:SD:MIN:%3.0lf "; + $rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:DS=" . $rrd_filename . ":PacketLossDS:AVERAGE "; + $rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' "; + $rrd_options .= " GPRINT:DS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:DS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/device/sla_jitter-lost.inc.php b/html/includes/graphs/device/sla_jitter-lost.inc.php new file mode 100644 index 0000000000..eed454c32c --- /dev/null +++ b/html/includes/graphs/device/sla_jitter-lost.inc.php @@ -0,0 +1,40 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:POS=" . $rrd_filename . ":PacketOutOfSequence:AVERAGE "; + $rrd_options .= " LINE1.25:POS#0000ee:'Out of Sequence ' "; + $rrd_options .= " GPRINT:POS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:POS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:POS:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:MIA=" . $rrd_filename . ":PacketMIA:AVERAGE "; + $rrd_options .= " LINE1.25:MIA#008C00:'Missing in Action ' "; + $rrd_options .= " GPRINT:MIA:LAST:%3.0lf "; + $rrd_options .= " GPRINT:MIA:MIN:%3.0lf "; + $rrd_options .= " GPRINT:MIA:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:PLA=" . $rrd_filename . ":PacketLateArrival:AVERAGE "; + $rrd_options .= " LINE1.25:PLA#CC0000:'Late Arrival ' "; + $rrd_options .= " GPRINT:PLA:LAST:%3.0lf "; + $rrd_options .= " GPRINT:PLA:MIN:%3.0lf "; + $rrd_options .= " GPRINT:PLA:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/device/sla_jitter-mos.inc.php b/html/includes/graphs/device/sla_jitter-mos.inc.php new file mode 100644 index 0000000000..407794faa5 --- /dev/null +++ b/html/includes/graphs/device/sla_jitter-mos.inc.php @@ -0,0 +1,28 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:MOS=" . $rrd_filename . ":MOS:AVERAGE "; + $rrd_options .= " LINE1.25:MOS#0000ee:'Mean Opinion Score ' "; + $rrd_options .= " GPRINT:MOS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:MOS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:MOS:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/device/sla_jitter.inc.php b/html/includes/graphs/device/sla_jitter.inc.php new file mode 100644 index 0000000000..7175609992 --- /dev/null +++ b/html/includes/graphs/device/sla_jitter.inc.php @@ -0,0 +1,34 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:SD=" . $rrd_filename . ":AvgSDJ:AVERAGE "; + $rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' "; + $rrd_options .= " GPRINT:SD:LAST:%3.0lf "; + $rrd_options .= " GPRINT:SD:MIN:%3.0lf "; + $rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:DS=" . $rrd_filename . ":AvgDSJ:AVERAGE "; + $rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' "; + $rrd_options .= " GPRINT:DS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:DS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l "; +} diff --git a/html/includes/graphs/sla-jitter-jitter.inc.php b/html/includes/graphs/sla-jitter-jitter.inc.php new file mode 100644 index 0000000000..7175609992 --- /dev/null +++ b/html/includes/graphs/sla-jitter-jitter.inc.php @@ -0,0 +1,34 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +require 'includes/graphs/common.inc.php'; +$rrd_options .= ' -l 0 -E '; +$rrd_filename = $config['rrd_dir']."/".$device['hostname']."/".safename('sla-'.$sla['sla_nr'].'-jitter.rrd'); + +if (file_exists($rrd_filename)) { + $rrd_options .= " COMMENT:' Cur Min Max\\n'"; + + $rrd_options .= " DEF:SD=" . $rrd_filename . ":AvgSDJ:AVERAGE "; + $rrd_options .= " LINE1.25:SD#0000ee:'Src to Dst ' "; + $rrd_options .= " GPRINT:SD:LAST:%3.0lf "; + $rrd_options .= " GPRINT:SD:MIN:%3.0lf "; + $rrd_options .= " GPRINT:SD:MAX:%3.0lf\\\l "; + + $rrd_options .= " DEF:DS=" . $rrd_filename . ":AvgDSJ:AVERAGE "; + $rrd_options .= " LINE1.25:DS#008C00:'Dst to Src ' "; + $rrd_options .= " GPRINT:DS:LAST:%3.0lf "; + $rrd_options .= " GPRINT:DS:MIN:%3.0lf "; + $rrd_options .= " GPRINT:DS:MAX:%3.0lf\\\l "; +} diff --git a/html/pages/device/sla.inc.php b/html/pages/device/sla.inc.php new file mode 100644 index 0000000000..646ac8ee67 --- /dev/null +++ b/html/pages/device/sla.inc.php @@ -0,0 +1,34 @@ + + * + * 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. + */ + +$sla = dbFetchRow('SELECT `sla_nr`,`rtt_type` FROM `slas` WHERE `sla_id` = ?', array($vars['id'])); + +?> +
+ +
+ +
+ +
+ +

Average Latency One Way

+ +
+ +
+ +
+

Average Jitter

+
+
+ +
+ +
+

Packet Loss

+
+
+ +
+ +
+

Lost Packets (Out Of Sequence, Tail Drop, Late Arrival)

+
+
+ +
+ +
+

Mean Opinion Score

+
+
+ +
+ +
+

Impairment / Calculated Planning Impairment Factor

+
+
+ +
diff --git a/html/pages/device/sla/rtt.inc.php b/html/pages/device/sla/rtt.inc.php new file mode 100644 index 0000000000..892a2e26f0 --- /dev/null +++ b/html/pages/device/sla/rtt.inc.php @@ -0,0 +1,15 @@ +
+

Round Trip Time

+
+
+ +
diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index cdab9660fe..56a0cd9d89 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -2,8 +2,6 @@ print_optionbar_start(); -echo "SLA » "; - $slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 ORDER BY `sla_nr`', array($device['device_id'])); // Collect types @@ -18,16 +16,23 @@ foreach ($slas as $sla) { if (isset($config['sla_type_labels'][$sla_type])) { $text = $config['sla_type_labels'][$sla_type]; } - } - else { + } else { $text = ucfirst($sla_type); } $sla_types[$sla_type] = $text; } - asort($sla_types); +$status_options = array( + 'all' => 'All', + 'up' => 'Up', + 'down' => 'Down', +); + +echo "SLA » "; + +// SLA Types, on the left. $sep = ''; foreach ($sla_types as $sla_type => $text) { if (!$vars['view']) { @@ -46,7 +51,27 @@ foreach ($sla_types as $sla_type => $text) { $sep = ' | '; } +unset($sep); +// The status option - on the right +echo '
'; +echo "Status » "; +$sep = ''; +foreach ($status_options as $option => $text) { + if (empty($vars['opstatus'])) { + $vars['opstatus'] = $option; + } + echo $sep; + if ($vars['opstatus'] == $option) { + echo ""; + } + + echo generate_link($text, $vars, array('opstatus' => $option)); + if ($vars['opstatus'] == $option) { + echo ''; + } + $sep = ' | '; +} unset($sep); print_optionbar_end(); @@ -56,6 +81,12 @@ foreach ($slas as $sla) { continue; } + $opstatus = ($sla['opstatus'] === '0') ? 'up' : 'down'; + d_echo("
Opstatus :: var: ".$vars['opstatus'].", db: ".$sla['opstatus'].", name: ".$opstatus."
"); + if ($vars['opstatus'] != 'all' && $vars['opstatus'] != $opstatus) { + continue; + } + $name = 'SLA #'.$sla['sla_nr'].' - '.$sla_types[$sla['rtt_type']]; if ($sla['tag']) { $name .= ': '.$sla['tag']; @@ -65,11 +96,30 @@ foreach ($slas as $sla) { $name .= ' (Owner: '.$sla['owner'].')'; } - $graph_array['type'] = 'device_sla'; - $graph_array['id'] = $sla['sla_id']; - echo '
+ // Jitter has more graphs. Display a sub-page + if ($sla['rtt_type'] == 'jitter') { + $name = ' $sla['sla_id'])).'">'.$name.''; + } else { + $name = htmlentities($name); + } + + // If we have an error highlight the row. + if ($sla['opstatus'] == 2) { + $danger = "panel-danger"; + } else { + $danger = ''; + } + + $graph_array = array(); + $graph_array['device'] = $device['device_id']; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['type'] = 'device_sla'; + $graph_array['id'] = $sla['sla_id']; + echo '
-

'.htmlentities($name).'

+

'.$name.'

'; echo "
"; @@ -79,4 +129,4 @@ foreach ($slas as $sla) { echo '
'; } -$pagetitle[] = 'SLAs'; +$pagetitle[] = 'SLAs'; \ No newline at end of file diff --git a/includes/discovery/cisco-sla.inc.php b/includes/discovery/cisco-sla.inc.php index a5352ffd8a..9f9359c3c7 100644 --- a/includes/discovery/cisco-sla.inc.php +++ b/includes/discovery/cisco-sla.inc.php @@ -43,6 +43,7 @@ if ($config['enable_sla'] && $device['os_group'] == 'cisco') { 'tag' => $sla_config['rttMonCtrlAdminTag'], 'rtt_type' => $sla_config['rttMonCtrlAdminRttType'], 'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0, + 'opstatus' => ($sla_config['rttMonLatestRttOperSense'] == 'ok') ? 0 : 2, 'deleted' => 0, ); diff --git a/includes/polling/cisco-sla.inc.php b/includes/polling/cisco-sla.inc.php index bf3ce730f3..c7b7b46e85 100644 --- a/includes/polling/cisco-sla.inc.php +++ b/includes/polling/cisco-sla.inc.php @@ -1,70 +1,88 @@ 0)) { + // We have SLA's, lets go!!! -$sla_table = array(); -foreach (explode("\n", $slavals) as $sla) { - $key_val = explode(' ', $sla, 2); - if (count($key_val) != 2) { - $key_val[] = ''; - } + // Go get some data from the device. + $rttMonLatestRttOperTable = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.2.10.1', 1); + $rttMonLatestOper = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.5', 1); - $key = $key_val[0]; - $value = $key_val[1]; + $uptime = snmp_get($device, 'sysUpTime.0', '-Otv'); + $time_offset = (time() - intval($uptime) / 100); - $prop_id = explode('.', $key); - if ((count($prop_id) != 2) || !ctype_digit($prop_id[1])) { - continue; - } + foreach ($slas as $sla) { + // Lets process each SLA + $unixtime = intval(($rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.5'][$sla['sla_nr']] / 100 + $time_offset)); + $time = strftime('%Y-%m-%d %H:%M:%S', $unixtime); + $update = array(); - $property = str_replace('rttMonLatestRttOper', '', $prop_id[0]); - $id = intval($prop_id[1]); + // Use Nagios Status codes. + $opstatus = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.2'][$sla['sla_nr']]; + if ($opstatus == 1) { + $opstatus = 0; // 0=Good + } else { + $opstatus = 2; // 2=Critical + } - $sla_table[$id][$property] = trim($value); -} + // Populating the update array means we need to update the DB. + if ($opstatus != $sla['opstatus']) { + $update['opstatus'] = $opstatus; + } -// Update timestamps -foreach ($sla_table as &$sla) { - $sla['UnixTime'] = intval(($sla['Time'] / 100 + $time_offset)); - $sla['TimeStr'] = strftime('%Y-%m-%d %H:%M:%S', $sla['UnixTime']); -} + $rtt = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.1'][$sla['sla_nr']]; + echo 'SLA '.$sla['sla_nr'].': '.$sla['rtt_type'].' '.$sla['owner'].' '.$sla['tag'].'... '.$rtt.'ms at '.$time.'\n'; -unset($sla); - -foreach (dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 AND `status` = 1', array($device['device_id'])) as $sla) { - echo 'SLA '.$sla['sla_nr'].': '.$sla['rtt_type'].' '.$sla['owner'].' '.$sla['tag'].'... '; - - $slarrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('sla-'.$sla['sla_nr'].'.rrd'); - - if (!is_file($slarrd)) { - rrdtool_create( - $slarrd, - '--step 300 - DS:rtt:GAUGE:600:0:300000 '.$config['rrd_rra'] + $metrics = array( + 'rtt' => $rtt, ); + + // The base RRD + $filename = 'sla-'.$sla['sla_nr'].'.rrd'; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:rtt:GAUGE:600:0:300000" . $config['rrd_rra']); + } + rrdtool_update($rrd_filename, $metrics); + + // Let's gather some per-type metrics. + switch ($sla['rtt_type']) { + case 'jitter': + $jitter = array( + 'PacketLossSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.26'][$sla['sla_nr']], + 'PacketLossDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.27'][$sla['sla_nr']], + 'PacketOutOfSequence' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.28'][$sla['sla_nr']], + 'PacketMIA' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.29'][$sla['sla_nr']], + 'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.30'][$sla['sla_nr']], + 'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla['sla_nr']]/100, + 'ICPIF' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.43'][$sla['sla_nr']], + 'OWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.49'][$sla['sla_nr']], + 'OWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.50'][$sla['sla_nr']], + 'AvgSDJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.47'][$sla['sla_nr']], + 'AvgDSJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.48'][$sla['sla_nr']], + ); + $filename = 'sla-'.$sla['sla_nr'].'-jitter.rrd'; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:PacketLossSD:GAUGE:600:0:U DS:PacketLossDS:GAUGE:600:0:U DS:PacketOutOfSequence:GAUGE:600:0:U DS:PacketMIA:GAUGE:600:0:U DS:PacketLateArrival:GAUGE:600:0:U DS:MOS:GAUGE:600:0:U DS:ICPIF:GAUGE:600:0:U DS:OWAvgSD:GAUGE:600:0:U DS:OWAvgDS:GAUGE:600:0:U DS:AvgSDJ:GAUGE:600:0:U DS:AvgDSJ:GAUGE:600:0:U" . $config['rrd_rra']); + } + rrdtool_update($rrd_filename, $jitter); + $metrics = array_merge($metrics,$jitter); + break; + } + + d_echo("The following metrics were collected for #".$sla['sla_nr'].":\n"); + d_echo($metrics); + + // Update influx + $tags = array('sla_nr' => $sla['sla_nr']); + influx_update($device,'sla',$tags,$metrics); + + // Update the DB if necessary + if (count($update) > 0) { + $updated = dbUpdate($update, 'slas', '`sla_id` = ?', array($sla['sla_id'])); + } } - - if (isset($sla_table[$sla['sla_nr']])) { - $slaval = $sla_table[$sla['sla_nr']]; - echo $slaval['CompletionTime'].'ms at '.$slaval['TimeStr']; - $val = $slaval['CompletionTime']; - } - else { - echo 'NaN'; - $val = 'U'; - } - - $fields = array( - 'rtt' => $val, - ); - - rrdtool_update($slarrd, $fields); - - $tags = array('sla_nr' => $sla['sla_nr']); - influx_update($device,'sla',$tags,$fields); - - echo "\n"; -}//end foreach +} diff --git a/sql-schema/127.sql b/sql-schema/127.sql new file mode 100644 index 0000000000..902091df86 --- /dev/null +++ b/sql-schema/127.sql @@ -0,0 +1 @@ +ALTER TABLE `slas` ADD `opstatus` TINYINT(1) NOT NULL DEFAULT '0' AFTER `status`; From b9747b2002cea433a16d4311a26f9d6fda58143d Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 9 Aug 2016 07:14:25 +1000 Subject: [PATCH 02/44] CISCO-NTP-MIB A new Discovery/Poller module to collect NTP statistics from devices which support the CISCO-NTP-MIB Discovered peers are stored using components and statistics are displayed using 'applications' A critical alarm is raised when a stratum of 16 is reported. --- .../graphs/device/cisco-ntp_delay.inc.php | 53 ++++++ .../device/cisco-ntp_dispersion.inc.php | 53 ++++++ .../graphs/device/cisco-ntp_offset.inc.php | 53 ++++++ .../graphs/device/cisco-ntp_stratum.inc.php | 53 ++++++ html/pages/apps/cisco-ntp.inc.php | 167 ++++++++++++++++++ html/pages/device/apps/cisco-ntp.inc.php | 129 ++++++++++++++ includes/defaults.inc.php | 2 + includes/discovery/cisco-ntp.inc.php | 135 ++++++++++++++ includes/polling/cisco-ntp.inc.php | 82 +++++++++ 9 files changed, 727 insertions(+) create mode 100644 html/includes/graphs/device/cisco-ntp_delay.inc.php create mode 100644 html/includes/graphs/device/cisco-ntp_dispersion.inc.php create mode 100644 html/includes/graphs/device/cisco-ntp_offset.inc.php create mode 100644 html/includes/graphs/device/cisco-ntp_stratum.inc.php create mode 100644 html/pages/apps/cisco-ntp.inc.php create mode 100644 html/pages/device/apps/cisco-ntp.inc.php create mode 100644 includes/discovery/cisco-ntp.inc.php create mode 100644 includes/polling/cisco-ntp.inc.php diff --git a/html/includes/graphs/device/cisco-ntp_delay.inc.php b/html/includes/graphs/device/cisco-ntp_delay.inc.php new file mode 100644 index 0000000000..7da30204a0 --- /dev/null +++ b/html/includes/graphs/device/cisco-ntp_delay.inc.php @@ -0,0 +1,53 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['type'] = array('=','Cisco-NTP'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Delay Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + + if (file_exists($rrd_filename)) { + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":delay:AVERAGE "; + $rrd_additions .= " LINE1.25:DS" . $count . "#" . $color . ":'" . str_pad(substr($array['peer'].' (s)',0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%7.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%7.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%7.0lf\\\l "; + $count++; + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/device/cisco-ntp_dispersion.inc.php b/html/includes/graphs/device/cisco-ntp_dispersion.inc.php new file mode 100644 index 0000000000..412e9989f9 --- /dev/null +++ b/html/includes/graphs/device/cisco-ntp_dispersion.inc.php @@ -0,0 +1,53 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['type'] = array('=','Cisco-NTP'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Dispersion Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + + if (file_exists($rrd_filename)) { + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":dispersion:AVERAGE "; + $rrd_additions .= " LINE1.25:DS" . $count . "#" . $color . ":'" . str_pad(substr($array['peer'].' (s)',0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%7.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%7.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%7.0lf\\\l "; + $count++; + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/device/cisco-ntp_offset.inc.php b/html/includes/graphs/device/cisco-ntp_offset.inc.php new file mode 100644 index 0000000000..4e9281018e --- /dev/null +++ b/html/includes/graphs/device/cisco-ntp_offset.inc.php @@ -0,0 +1,53 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['type'] = array('=','Cisco-NTP'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Offset Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + + if (file_exists($rrd_filename)) { + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":offset:AVERAGE "; + $rrd_additions .= " LINE1.25:DS" . $count . "#" . $color . ":'" . str_pad(substr($array['peer'].' (s)',0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%4.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%4.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%4.0lf\\\l "; + $count++; + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/device/cisco-ntp_stratum.inc.php b/html/includes/graphs/device/cisco-ntp_stratum.inc.php new file mode 100644 index 0000000000..0ed0945d33 --- /dev/null +++ b/html/includes/graphs/device/cisco-ntp_stratum.inc.php @@ -0,0 +1,53 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['type'] = array('=','Cisco-NTP'); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Stratum Now Min Max\\n'"; +$rrd_additions = ""; + +$count = 0; +foreach ($components as $id => $array) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + + if (file_exists($rrd_filename)) { + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; + } else { + $color = $config['graph_colours']['oranges'][$count-7]; + } + + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":stratum:AVERAGE "; + $rrd_additions .= " LINE1.25:DS" . $count . "#" . $color . ":'" . str_pad(substr($array['peer'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:DS" . $count . ":LAST:%2.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MIN:%2.0lf "; + $rrd_additions .= " GPRINT:DS" . $count . ":MAX:%2.0lf\\\l "; + $count++; + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} else { + $rrd_options .= $rrd_additions; +} diff --git a/html/pages/apps/cisco-ntp.inc.php b/html/pages/apps/cisco-ntp.inc.php new file mode 100644 index 0000000000..2567eaa533 --- /dev/null +++ b/html/pages/apps/cisco-ntp.inc.php @@ -0,0 +1,167 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['ignore'] = array('=',0); +$options['type'] = 'Cisco-NTP'; +$components = $component->getComponents(null,$options); + +print_optionbar_start(); + +$view_options = array( + 'all' => 'All', + 'error' => 'Error', +); +if (!$vars['view']) { + $vars['view'] = 'all'; +} + +$graph_options = array( + 'none' => 'No Graphs', + 'stratum' => 'Stratum', + 'offset' => 'Offset', + 'delay' => 'Delay', + 'dispersion' => 'Dispersion', +); +if (!$vars['graph']) { + $vars['graph'] = 'none'; +} + +echo 'NTP Peers » '; + +// The menu option - on the left +$sep = ''; +foreach ($view_options as $option => $text) { + if (empty($vars['view'])) { + $vars['view'] = $option; + } + echo $sep; + if ($vars['view'] == $option) { + echo ""; + } + echo generate_link($text, $vars, array('view' => $option)); + if ($vars['view'] == $option) { + echo ''; + } + $sep = ' | '; +} + +// The status option - on the right +echo '
'; +$sep = ''; +foreach ($graph_options as $option => $text) { + if (empty($vars['graph'])) { + $vars['graph'] = $option; + } + echo $sep; + if ($vars['graph'] == $option) { + echo ""; + } + + echo generate_link($text, $vars, array('graph' => $option)); + if ($vars['graph'] == $option) { + echo ''; + } + $sep = ' | '; +} +unset($sep); +echo '
'; +print_optionbar_end(); + +?> + + + + + + + + + + $comp) { + $device = device_by_id_cache($devid); + + // Loop through each component + foreach ($comp as $compid => $array) { + $display = true; + if ($vars['view'] == 'error') { + // Only display peers with errors + if ($array['status'] != 2) { + $display = false; + } + } + if ($array['status'] == 2) { + $status = 'class="danger"'; + } else { + $status = ''; + } + + if ($display === true) { + $link = generate_device_link($device,null,array('tab' => 'apps', 'app' => 'cisco-ntp')); + $count++; +?> + > + + + + + +'; + echo ''; + echo ''; + } + + } // End if display + } // End foreach component + } // End foreach device + + // If there are no results, let the user know. + if ($count == 0) { +?> + + + + +
DevicePeerStratumError
'; + require 'includes/print-graphrow.inc.php'; + echo '
No Matching NTP Peers
diff --git a/html/pages/device/apps/cisco-ntp.inc.php b/html/pages/device/apps/cisco-ntp.inc.php new file mode 100644 index 0000000000..211496ab6f --- /dev/null +++ b/html/pages/device/apps/cisco-ntp.inc.php @@ -0,0 +1,129 @@ + + * + * 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. + */ + +require_once "../includes/component.php"; +$component = new component(); +$options = array(); +$options['filter']['ignore'] = array('=',0); +$options['type'] = 'Cisco-NTP'; +$components = $component->getComponents($device['device_id'],$options); +$components = $components[$device['device_id']]; + +global $config; +?> + + + + + + + + + + + > + + + + + + +
PeerStratumPeer ReferenceStatus
+ +
+
+

NTP Stratum

+
+
+ +
+
+ +
+
+

Offset

+
+
+ +
+
+ +
+
+

Delay

+
+
+ +
+
+ +
+
+

Dispersion

+
+
+ +
+
diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a8121ded47..6bcb53db64 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -715,6 +715,7 @@ $config['poller_modules']['cisco-voice'] = 1; $config['poller_modules']['cisco-cbqos'] = 1; $config['poller_modules']['stp'] = 1; $config['poller_modules']['cisco-otv'] = 1; +$config['poller_modules']['cisco-ntp'] = 1; $config['poller_modules']['services'] = 1; // List of discovery modules. Need to be in this array to be @@ -752,6 +753,7 @@ $config['discovery_modules']['charge'] = 1; $config['discovery_modules']['cisco-cbqos'] = 0; $config['discovery_modules']['stp'] = 1; $config['discovery_modules']['cisco-otv'] = 1; +$config['discovery_modules']['cisco-ntp'] = 1; $config['modules_compat']['rfc1628']['liebert'] = 1; $config['modules_compat']['rfc1628']['netmanplus'] = 1; diff --git a/includes/discovery/cisco-ntp.inc.php b/includes/discovery/cisco-ntp.inc.php new file mode 100644 index 0000000000..64ffca2a1a --- /dev/null +++ b/includes/discovery/cisco-ntp.inc.php @@ -0,0 +1,135 @@ + + * + * 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 ($device['os_group'] == 'cisco') { + + $module = 'Cisco-NTP'; + + require_once 'includes/component.php'; + $component = new component(); + $components = $component->getComponents($device['device_id'],array('type'=>$module)); + + // We only care about our device id. + $components = $components[$device['device_id']]; + + // Begin our master array, all other values will be processed into this array. + $tblComponents = array(); + + // Let's gather some data.. + // For Reference: + // http://www.oidview.com/mibs/9/CISCO-NTP-MIB.html + // http://www.cisco.com/c/en/us/support/docs/availability/high-availability/19643-ntpm.html + $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); + + /* + * False == no object found - this is not an error, no objects exist + * null == timeout or something else that caused an error, there may be objects but we couldn't get it. + */ + if ( is_null($cntpPeersVarEntry) ) { + // We have to error here or we will end up deleting all our components. + echo "Error\n"; + } else { + // No Error, lets process things. + d_echo("Objects Found:\n"); + + // Let's grab the index for each NTP peer + foreach ($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) { + $result = array(); + $result['UID'] = (string)$index; // This is cast as a string so it can be compared with the database value. + $result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index]; + $result['port'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][4][$index]; + $result['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$index]; + $result['peerref'] = hex_to_ip($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][15][$index]); + $result['label'] = $result['peer'].":".$result['port']; + + // Set the status, 16 = Bad + if ($result['stratum'] == 16) { + $result['status'] = 2; + $result['error'] = 'NTP Stratum is Insane'; + } else { + $result['status'] = 0; + $result['error'] = ''; + } + + d_echo("NTP Peer found: "); + d_echo($result); + $tblComponents[] = $result; + } + + /* + * Ok, we have our 2 array's (Components and SNMP) now we need + * to compare and see what needs to be added/updated. + * + * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. + */ + foreach ($tblComponents as $key => $array) { + $component_key = false; + + // Loop over our components to determine if the component exists, or we need to add it. + foreach ($components as $compid => $child) { + if ($child['UID'] === $array['UID']) { + $component_key = $compid; + } + } + + if (!$component_key) { + // The component doesn't exist, we need to ADD it - ADD. + $new_component = $component->createComponent($device['device_id'],$module); + $component_key = key($new_component); + $components[$component_key] = array_merge($new_component[$component_key], $array); + echo "+"; + } else { + // The component does exist, merge the details in - UPDATE. + $components[$component_key] = array_merge($components[$component_key], $array); + echo "."; + } + + } + + /* + * Loop over the Component data to see if we need to DELETE any components. + */ + foreach ($components as $key => $array) { + // Guilty until proven innocent + $found = false; + + foreach ($tblComponents as $k => $v) { + if ($array['UID'] == $v['UID']) { + // Yay, we found it... + $found = true; + } + } + + if ($found === false) { + // The component has not been found. we should delete it. + echo "-"; + $component->deleteComponent($key); + } + } + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + echo "\n"; + + } // End if not error + + $module = strtolower($module); + if (count($components) > 0) { + if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)) == '0') { + dbInsert(array('device_id' => $device['device_id'], 'app_type' => $module), 'applications'); + } + } else { + dbDelete('applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)); + } + +} diff --git a/includes/polling/cisco-ntp.inc.php b/includes/polling/cisco-ntp.inc.php new file mode 100644 index 0000000000..f7c11654a6 --- /dev/null +++ b/includes/polling/cisco-ntp.inc.php @@ -0,0 +1,82 @@ + + * + * 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 ($device['os_group'] == "cisco") { + + $module = 'Cisco-NTP'; + + require_once 'includes/component.php'; + $component = new component(); + $options = array(); + $options['filter']['type'] = array('=',$module); + $options['filter']['disabled'] = array('=',0); + $options['filter']['ignore'] = array('=',0); + $components = $component->getComponents($device['device_id'],$options); + + // We only care about our device id. + $components = $components[$device['device_id']]; + + // Only collect SNMP data if we have enabled components + if (count($components > 0)) { + // Let's gather the stats.. + $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); + + // Loop through the components and extract the data. + foreach ($components as $key => &$array) { + + // Let's make sure the rrd is setup for this class. + $filename = "ntp-".$array['peer'].".rrd"; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:stratum:GAUGE:600:0:U DS:offset:GAUGE:600:0:U DS:delay:GAUGE:600:0:U DS:dispersion:GAUGE:600:0:U" . $config['rrd_rra']); + } + + $array['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$array['UID']]; + // Set the status, 16 = Bad + if ($array['stratum'] == 16) { + $array['status'] = 2; + $array['error'] = 'NTP Stratum is Insane'; + } else { + $array['status'] = 0; + $array['error'] = ''; + } + + // Extract the statistics and update rrd + $rrd['stratum'] = $array['stratum']; + $rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]); + $rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]); + $rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]); + rrdtool_update ($rrd_filename, $rrd); + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Index: ".$array['UID']."\n"); + d_echo(" Peer: ".$array['peer'].":".$array['port']."\n"); + d_echo(" Stratum: 1.3.6.1.4.1.9.9.168.1.2.1.1.9.".$array['UID']." = ".$rrd['stratum']."\n"); + d_echo(" Offset: 1.3.6.1.4.1.9.9.168.1.2.1.1.23.".$array['UID']." = ".$rrd['offset']."\n"); + d_echo(" Delay: 1.3.6.1.4.1.9.9.168.1.2.1.1.24.".$array['UID']." = ".$rrd['delay']."\n"); + d_echo(" Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25.".$array['UID']." = ".$rrd['dispersion']."\n"); + + // Clean-up after yourself! + unset($filename, $rrd_filename, $rrd); + } // End foreach components + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + + } // end if count components + + // Clean-up after yourself! + unset($type, $components, $component, $options, $module); +} From d95cf4ac16b8bf26a5dc5b776a99a640d56d53c7 Mon Sep 17 00:00:00 2001 From: crcro Date: Thu, 11 Aug 2016 17:49:34 +0300 Subject: [PATCH 03/44] added hardware model, software version, fans and ps sensor states, removed header cpu and memory graphs --- includes/definitions.inc.php | 4 - .../discovery/sensors/states/hpblmos.inc.php | 127 ++++++++++++++++++ includes/polling/os/hpblmos.inc.php | 3 + 3 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 includes/discovery/sensors/states/hpblmos.inc.php create mode 100644 includes/polling/os/hpblmos.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 6e1cd4fa5d..89bcb1b805 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1787,10 +1787,6 @@ $config['os'][$os]['type'] = 'appliance'; $config['os'][$os]['icon'] = 'hp'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Traffic'; -$config['os'][$os]['over'][1]['graph'] = 'device_processor'; -$config['os'][$os]['over'][1]['text'] = 'CPU Usage'; -$config['os'][$os]['over'][2]['graph'] = 'device_mempool'; -$config['os'][$os]['over'][2]['text'] = 'Memory Usage'; // HP MSM $os = 'hpmsm'; diff --git a/includes/discovery/sensors/states/hpblmos.inc.php b/includes/discovery/sensors/states/hpblmos.inc.php new file mode 100644 index 0000000000..082c0c6f5a --- /dev/null +++ b/includes/discovery/sensors/states/hpblmos.inc.php @@ -0,0 +1,127 @@ + $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); + create_sensor_to_state_index($device, $state_name, $index); + $index++; + } + } + + $index = 1; + $state_name = 'hpblmos_PowerSupplyState'; + $state_descr = 'Power supply '; + $oids = array( + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.1', + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.2', + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.3', + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.4', + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.5', + '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.6', + ); + + /* CPQRACK-MIB::cpqRackPowerSupplyTable + * 1 - other + * 2 - ok + * 3 - degraded + * 4 - failed + */ + + foreach($oids as $oid) { + $state = snmp_get($device, $oid, '-Oqv'); + $descr = $state_descr . $index; + + if(!empty($state)) + { + $state_index_id = create_state_index($state_name); + + if($state_index_id) + { + $states = array( + array($state_index_id, 'other', 0, 1, 3), + array($state_index_id, 'ok', 1, 2, 0), + array($state_index_id, 'degraded', 1, 3, 1), + array($state_index_id, 'failed', 1, 4, 2), + ); + + foreach($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + + discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); + create_sensor_to_state_index($device, $state_name, $index); + $index++; + } + } +} diff --git a/includes/polling/os/hpblmos.inc.php b/includes/polling/os/hpblmos.inc.php new file mode 100644 index 0000000000..18f34794cc --- /dev/null +++ b/includes/polling/os/hpblmos.inc.php @@ -0,0 +1,3 @@ + Date: Fri, 12 Aug 2016 16:32:40 +1000 Subject: [PATCH 04/44] - files should have a blank line at the end. --- html/pages/device/slas.inc.php | 2 +- includes/polling/cisco-sla.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/device/slas.inc.php b/html/pages/device/slas.inc.php index 56a0cd9d89..7883f417a2 100644 --- a/html/pages/device/slas.inc.php +++ b/html/pages/device/slas.inc.php @@ -129,4 +129,4 @@ foreach ($slas as $sla) { echo '
'; } -$pagetitle[] = 'SLAs'; \ No newline at end of file +$pagetitle[] = 'SLAs'; diff --git a/includes/polling/cisco-sla.inc.php b/includes/polling/cisco-sla.inc.php index 17418b77a1..91588c590d 100644 --- a/includes/polling/cisco-sla.inc.php +++ b/includes/polling/cisco-sla.inc.php @@ -92,4 +92,4 @@ if (count($slas > 0)) { $updated = dbUpdate($update, 'slas', '`sla_id` = ?', array($sla['sla_id'])); } } -} \ No newline at end of file +} From 4c34541285d7109b5a403139d5eda3fa2531e3c5 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Fri, 12 Aug 2016 16:53:20 +1000 Subject: [PATCH 05/44] - Modified to use standardised RRD functions --- .../graphs/device/cisco-ntp_delay.inc.php | 2 +- .../graphs/device/cisco-ntp_dispersion.inc.php | 2 +- .../graphs/device/cisco-ntp_offset.inc.php | 2 +- .../graphs/device/cisco-ntp_stratum.inc.php | 2 +- includes/polling/cisco-ntp.inc.php | 17 ++++++++++------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/html/includes/graphs/device/cisco-ntp_delay.inc.php b/html/includes/graphs/device/cisco-ntp_delay.inc.php index 7da30204a0..09e2335e48 100644 --- a/html/includes/graphs/device/cisco-ntp_delay.inc.php +++ b/html/includes/graphs/device/cisco-ntp_delay.inc.php @@ -27,7 +27,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('ntp', $array['peer'])); if (file_exists($rrd_filename)) { // Grab a color from the array. diff --git a/html/includes/graphs/device/cisco-ntp_dispersion.inc.php b/html/includes/graphs/device/cisco-ntp_dispersion.inc.php index 412e9989f9..84a4e3e88b 100644 --- a/html/includes/graphs/device/cisco-ntp_dispersion.inc.php +++ b/html/includes/graphs/device/cisco-ntp_dispersion.inc.php @@ -27,7 +27,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('ntp', $array['peer'])); if (file_exists($rrd_filename)) { // Grab a color from the array. diff --git a/html/includes/graphs/device/cisco-ntp_offset.inc.php b/html/includes/graphs/device/cisco-ntp_offset.inc.php index 4e9281018e..4fb0cb6a92 100644 --- a/html/includes/graphs/device/cisco-ntp_offset.inc.php +++ b/html/includes/graphs/device/cisco-ntp_offset.inc.php @@ -27,7 +27,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('ntp', $array['peer'])); if (file_exists($rrd_filename)) { // Grab a color from the array. diff --git a/html/includes/graphs/device/cisco-ntp_stratum.inc.php b/html/includes/graphs/device/cisco-ntp_stratum.inc.php index 0ed0945d33..3eb4a94786 100644 --- a/html/includes/graphs/device/cisco-ntp_stratum.inc.php +++ b/html/includes/graphs/device/cisco-ntp_stratum.inc.php @@ -27,7 +27,7 @@ $rrd_additions = ""; $count = 0; foreach ($components as $id => $array) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("ntp-".$array['peer'].".rrd"); + $rrd_filename = rrd_name($device['hostname'], array('ntp', $array['peer'])); if (file_exists($rrd_filename)) { // Grab a color from the array. diff --git a/includes/polling/cisco-ntp.inc.php b/includes/polling/cisco-ntp.inc.php index f7c11654a6..70e2320181 100644 --- a/includes/polling/cisco-ntp.inc.php +++ b/includes/polling/cisco-ntp.inc.php @@ -33,14 +33,16 @@ if ($device['os_group'] == "cisco") { // Loop through the components and extract the data. foreach ($components as $key => &$array) { + $peer = $array['peer']; // Let's make sure the rrd is setup for this class. - $filename = "ntp-".$array['peer'].".rrd"; - $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); - - if (!file_exists ($rrd_filename)) { - rrdtool_create ($rrd_filename, " DS:stratum:GAUGE:600:0:U DS:offset:GAUGE:600:0:U DS:delay:GAUGE:600:0:U DS:dispersion:GAUGE:600:0:U" . $config['rrd_rra']); - } + $rrd_name = array('ntp', $peer); + $rrd_def = array( + 'DS:stratum:GAUGE:600:0:U', + 'DS:offset:GAUGE:600:0:U', + 'DS:delay:GAUGE:600:0:U', + 'DS:dispersion:GAUGE:600:0:U', + ); $array['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$array['UID']]; // Set the status, 16 = Bad @@ -57,7 +59,8 @@ if ($device['os_group'] == "cisco") { $rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]); $rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]); $rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]); - rrdtool_update ($rrd_filename, $rrd); + $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer'); + data_update($device, 'ntp', $tags, $rrd); // Let's print some debugging info. d_echo("\n\nComponent: ".$key."\n"); From 4c060a430a1df5d62dc3aeffbf4da6b5ae95a929 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Fri, 12 Aug 2016 17:21:55 +1000 Subject: [PATCH 06/44] - Made module generic, not cisco specific. --- ...co-ntp_delay.inc.php => ntp_delay.inc.php} | 4 +- ...persion.inc.php => ntp_dispersion.inc.php} | 4 +- ...-ntp_offset.inc.php => ntp_offset.inc.php} | 4 +- ...tp_stratum.inc.php => ntp_stratum.inc.php} | 4 +- .../apps/{cisco-ntp.inc.php => ntp.inc.php} | 12 +- .../apps/{cisco-ntp.inc.php => ntp.inc.php} | 10 +- includes/defaults.inc.php | 4 +- includes/discovery/cisco-ntp.inc.php | 135 ------------------ includes/discovery/ntp.inc.php | 30 ++++ includes/discovery/ntp/cisco.inc.php | 131 +++++++++++++++++ includes/polling/cisco-ntp.inc.php | 85 ----------- includes/polling/ntp.inc.php | 23 +++ includes/polling/ntp/cisco.inc.php | 82 +++++++++++ 13 files changed, 287 insertions(+), 241 deletions(-) rename html/includes/graphs/device/{cisco-ntp_delay.inc.php => ntp_delay.inc.php} (94%) rename html/includes/graphs/device/{cisco-ntp_dispersion.inc.php => ntp_dispersion.inc.php} (94%) rename html/includes/graphs/device/{cisco-ntp_offset.inc.php => ntp_offset.inc.php} (94%) rename html/includes/graphs/device/{cisco-ntp_stratum.inc.php => ntp_stratum.inc.php} (94%) rename html/pages/apps/{cisco-ntp.inc.php => ntp.inc.php} (92%) rename html/pages/device/apps/{cisco-ntp.inc.php => ntp.inc.php} (92%) delete mode 100644 includes/discovery/cisco-ntp.inc.php create mode 100644 includes/discovery/ntp.inc.php create mode 100644 includes/discovery/ntp/cisco.inc.php delete mode 100644 includes/polling/cisco-ntp.inc.php create mode 100644 includes/polling/ntp.inc.php create mode 100644 includes/polling/ntp/cisco.inc.php diff --git a/html/includes/graphs/device/cisco-ntp_delay.inc.php b/html/includes/graphs/device/ntp_delay.inc.php similarity index 94% rename from html/includes/graphs/device/cisco-ntp_delay.inc.php rename to html/includes/graphs/device/ntp_delay.inc.php index 09e2335e48..f16bbc89a8 100644 --- a/html/includes/graphs/device/cisco-ntp_delay.inc.php +++ b/html/includes/graphs/device/ntp_delay.inc.php @@ -1,6 +1,6 @@ * @@ -14,7 +14,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); -$options['filter']['type'] = array('=','Cisco-NTP'); +$options['filter']['type'] = array('=','ntp'); $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. diff --git a/html/includes/graphs/device/cisco-ntp_dispersion.inc.php b/html/includes/graphs/device/ntp_dispersion.inc.php similarity index 94% rename from html/includes/graphs/device/cisco-ntp_dispersion.inc.php rename to html/includes/graphs/device/ntp_dispersion.inc.php index 84a4e3e88b..d88a00fb68 100644 --- a/html/includes/graphs/device/cisco-ntp_dispersion.inc.php +++ b/html/includes/graphs/device/ntp_dispersion.inc.php @@ -1,6 +1,6 @@ * @@ -14,7 +14,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); -$options['filter']['type'] = array('=','Cisco-NTP'); +$options['filter']['type'] = array('=','ntp'); $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. diff --git a/html/includes/graphs/device/cisco-ntp_offset.inc.php b/html/includes/graphs/device/ntp_offset.inc.php similarity index 94% rename from html/includes/graphs/device/cisco-ntp_offset.inc.php rename to html/includes/graphs/device/ntp_offset.inc.php index 4fb0cb6a92..6e79b9f465 100644 --- a/html/includes/graphs/device/cisco-ntp_offset.inc.php +++ b/html/includes/graphs/device/ntp_offset.inc.php @@ -1,6 +1,6 @@ * @@ -14,7 +14,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); -$options['filter']['type'] = array('=','Cisco-NTP'); +$options['filter']['type'] = array('=','ntp'); $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. diff --git a/html/includes/graphs/device/cisco-ntp_stratum.inc.php b/html/includes/graphs/device/ntp_stratum.inc.php similarity index 94% rename from html/includes/graphs/device/cisco-ntp_stratum.inc.php rename to html/includes/graphs/device/ntp_stratum.inc.php index 3eb4a94786..edd2a71d0c 100644 --- a/html/includes/graphs/device/cisco-ntp_stratum.inc.php +++ b/html/includes/graphs/device/ntp_stratum.inc.php @@ -1,6 +1,6 @@ * @@ -14,7 +14,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); -$options['filter']['type'] = array('=','Cisco-NTP'); +$options['filter']['type'] = array('=','ntp'); $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. diff --git a/html/pages/apps/cisco-ntp.inc.php b/html/pages/apps/ntp.inc.php similarity index 92% rename from html/pages/apps/cisco-ntp.inc.php rename to html/pages/apps/ntp.inc.php index 2567eaa533..d91037775f 100644 --- a/html/pages/apps/cisco-ntp.inc.php +++ b/html/pages/apps/ntp.inc.php @@ -15,7 +15,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); $options['filter']['ignore'] = array('=',0); -$options['type'] = 'Cisco-NTP'; +$options['type'] = 'ntp'; $components = $component->getComponents(null,$options); print_optionbar_start(); @@ -112,7 +112,7 @@ print_optionbar_end(); } if ($display === true) { - $link = generate_device_link($device,null,array('tab' => 'apps', 'app' => 'cisco-ntp')); + $link = generate_device_link($device,null,array('tab' => 'apps', 'app' => 'ntp')); $count++; ?> > @@ -130,13 +130,13 @@ print_optionbar_end(); // Which graph type do we want? if ($vars['graph'] == "stratum") { - $graph_array['type'] = 'device_cisco-ntp_stratum'; + $graph_array['type'] = 'device_ntp_stratum'; } elseif ($vars['graph'] == "offset") { - $graph_array['type'] = 'device_cisco-ntp_offset'; + $graph_array['type'] = 'device_ntp_offset'; } elseif ($vars['graph'] == "delay") { - $graph_array['type'] = 'device_cisco-ntp_delay'; + $graph_array['type'] = 'device_ntp_delay'; } elseif ($vars['graph'] == "dispersion") { - $graph_array['type'] = 'device_cisco-ntp_dispersion'; + $graph_array['type'] = 'device_ntp_dispersion'; } else { // No Graph unset($graph_array); diff --git a/html/pages/device/apps/cisco-ntp.inc.php b/html/pages/device/apps/ntp.inc.php similarity index 92% rename from html/pages/device/apps/cisco-ntp.inc.php rename to html/pages/device/apps/ntp.inc.php index 211496ab6f..b7cafed0d0 100644 --- a/html/pages/device/apps/cisco-ntp.inc.php +++ b/html/pages/device/apps/ntp.inc.php @@ -15,7 +15,7 @@ require_once "../includes/component.php"; $component = new component(); $options = array(); $options['filter']['ignore'] = array('=',0); -$options['type'] = 'Cisco-NTP'; +$options['type'] = 'ntp'; $components = $component->getComponents($device['device_id'],$options); $components = $components[$device['device_id']]; @@ -64,7 +64,7 @@ global $config; $graph_array['height'] = '100'; $graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; - $graph_array['type'] = 'device_cisco-ntp_stratum'; + $graph_array['type'] = 'device_ntp_stratum'; require 'includes/print-graphrow.inc.php'; ?> @@ -83,7 +83,7 @@ global $config; $graph_array['height'] = '100'; $graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; - $graph_array['type'] = 'device_cisco-ntp_offset'; + $graph_array['type'] = 'device_ntp_offset'; require 'includes/print-graphrow.inc.php'; ?> @@ -102,7 +102,7 @@ global $config; $graph_array['height'] = '100'; $graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; - $graph_array['type'] = 'device_cisco-ntp_delay'; + $graph_array['type'] = 'device_ntp_delay'; require 'includes/print-graphrow.inc.php'; ?> @@ -121,7 +121,7 @@ global $config; $graph_array['height'] = '100'; $graph_array['width'] = '215'; $graph_array['to'] = $config['time']['now']; - $graph_array['type'] = 'device_cisco-ntp_dispersion'; + $graph_array['type'] = 'device_ntp_dispersion'; require 'includes/print-graphrow.inc.php'; ?> diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 6f7c9bfb16..38208af33a 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -714,7 +714,7 @@ $config['poller_modules']['cisco-voice'] = 1; $config['poller_modules']['cisco-cbqos'] = 1; $config['poller_modules']['stp'] = 1; $config['poller_modules']['cisco-otv'] = 1; -$config['poller_modules']['cisco-ntp'] = 1; +$config['poller_modules']['ntp'] = 1; $config['poller_modules']['services'] = 1; // List of discovery modules. Need to be in this array to be @@ -752,7 +752,7 @@ $config['discovery_modules']['charge'] = 1; $config['discovery_modules']['cisco-cbqos'] = 0; $config['discovery_modules']['stp'] = 1; $config['discovery_modules']['cisco-otv'] = 1; -$config['discovery_modules']['cisco-ntp'] = 1; +$config['discovery_modules']['ntp'] = 1; $config['modules_compat']['rfc1628']['liebert'] = 1; $config['modules_compat']['rfc1628']['netmanplus'] = 1; diff --git a/includes/discovery/cisco-ntp.inc.php b/includes/discovery/cisco-ntp.inc.php deleted file mode 100644 index 64ffca2a1a..0000000000 --- a/includes/discovery/cisco-ntp.inc.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * 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 ($device['os_group'] == 'cisco') { - - $module = 'Cisco-NTP'; - - require_once 'includes/component.php'; - $component = new component(); - $components = $component->getComponents($device['device_id'],array('type'=>$module)); - - // We only care about our device id. - $components = $components[$device['device_id']]; - - // Begin our master array, all other values will be processed into this array. - $tblComponents = array(); - - // Let's gather some data.. - // For Reference: - // http://www.oidview.com/mibs/9/CISCO-NTP-MIB.html - // http://www.cisco.com/c/en/us/support/docs/availability/high-availability/19643-ntpm.html - $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); - - /* - * False == no object found - this is not an error, no objects exist - * null == timeout or something else that caused an error, there may be objects but we couldn't get it. - */ - if ( is_null($cntpPeersVarEntry) ) { - // We have to error here or we will end up deleting all our components. - echo "Error\n"; - } else { - // No Error, lets process things. - d_echo("Objects Found:\n"); - - // Let's grab the index for each NTP peer - foreach ($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) { - $result = array(); - $result['UID'] = (string)$index; // This is cast as a string so it can be compared with the database value. - $result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index]; - $result['port'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][4][$index]; - $result['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$index]; - $result['peerref'] = hex_to_ip($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][15][$index]); - $result['label'] = $result['peer'].":".$result['port']; - - // Set the status, 16 = Bad - if ($result['stratum'] == 16) { - $result['status'] = 2; - $result['error'] = 'NTP Stratum is Insane'; - } else { - $result['status'] = 0; - $result['error'] = ''; - } - - d_echo("NTP Peer found: "); - d_echo($result); - $tblComponents[] = $result; - } - - /* - * Ok, we have our 2 array's (Components and SNMP) now we need - * to compare and see what needs to be added/updated. - * - * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. - */ - foreach ($tblComponents as $key => $array) { - $component_key = false; - - // Loop over our components to determine if the component exists, or we need to add it. - foreach ($components as $compid => $child) { - if ($child['UID'] === $array['UID']) { - $component_key = $compid; - } - } - - if (!$component_key) { - // The component doesn't exist, we need to ADD it - ADD. - $new_component = $component->createComponent($device['device_id'],$module); - $component_key = key($new_component); - $components[$component_key] = array_merge($new_component[$component_key], $array); - echo "+"; - } else { - // The component does exist, merge the details in - UPDATE. - $components[$component_key] = array_merge($components[$component_key], $array); - echo "."; - } - - } - - /* - * Loop over the Component data to see if we need to DELETE any components. - */ - foreach ($components as $key => $array) { - // Guilty until proven innocent - $found = false; - - foreach ($tblComponents as $k => $v) { - if ($array['UID'] == $v['UID']) { - // Yay, we found it... - $found = true; - } - } - - if ($found === false) { - // The component has not been found. we should delete it. - echo "-"; - $component->deleteComponent($key); - } - } - - // Write the Components back to the DB. - $component->setComponentPrefs($device['device_id'],$components); - echo "\n"; - - } // End if not error - - $module = strtolower($module); - if (count($components) > 0) { - if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)) == '0') { - dbInsert(array('device_id' => $device['device_id'], 'app_type' => $module), 'applications'); - } - } else { - dbDelete('applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)); - } - -} diff --git a/includes/discovery/ntp.inc.php b/includes/discovery/ntp.inc.php new file mode 100644 index 0000000000..60638836ca --- /dev/null +++ b/includes/discovery/ntp.inc.php @@ -0,0 +1,30 @@ + + * + * 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. + * + * This module will display NTP details from various device types. + * To display, modules must store data in for following format: + * Array + * ( + * [UID] => 9093 + * [peer] => 10.0.99.66 + * [port] => 123 + * [stratum] => 4 + * [peerref] => 131.242.253.96 + * [label] => 10.0.99.66:123 + * [status] => 0 + * [error] => + * ) + */ + +if ($device['os_group'] == 'cisco') { + require_once 'includes/discovery/ntp/cisco.inc.php'; +} diff --git a/includes/discovery/ntp/cisco.inc.php b/includes/discovery/ntp/cisco.inc.php new file mode 100644 index 0000000000..1e61110035 --- /dev/null +++ b/includes/discovery/ntp/cisco.inc.php @@ -0,0 +1,131 @@ + + * + * 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. + */ + +$module = 'ntp'; + +require_once 'includes/component.php'; +$component = new component(); +$components = $component->getComponents($device['device_id'],array('type'=>$module)); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// Begin our master array, all other values will be processed into this array. +$tblComponents = array(); + +// Let's gather some data.. +// For Reference: +// http://www.oidview.com/mibs/9/CISCO-NTP-MIB.html +// http://www.cisco.com/c/en/us/support/docs/availability/high-availability/19643-ntpm.html +$cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); + +/* + * False == no object found - this is not an error, no objects exist + * null == timeout or something else that caused an error, there may be objects but we couldn't get it. + */ +if ( is_null($cntpPeersVarEntry) ) { + // We have to error here or we will end up deleting all our components. + echo "Error\n"; +} else { + // No Error, lets process things. + d_echo("Objects Found:\n"); + + // Let's grab the index for each NTP peer + foreach ($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][2] as $index => $value) { + $result = array(); + $result['UID'] = (string)$index; // This is cast as a string so it can be compared with the database value. + $result['peer'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][3][$index]; + $result['port'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][4][$index]; + $result['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$index]; + $result['peerref'] = hex_to_ip($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][15][$index]); + $result['label'] = $result['peer'].":".$result['port']; + + // Set the status, 16 = Bad + if ($result['stratum'] == 16) { + $result['status'] = 2; + $result['error'] = 'NTP Stratum is Insane'; + } else { + $result['status'] = 0; + $result['error'] = ''; + } + + d_echo("NTP Peer found: "); + d_echo($result); + $tblComponents[] = $result; + } + + /* + * Ok, we have our 2 array's (Components and SNMP) now we need + * to compare and see what needs to be added/updated. + * + * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. + */ + foreach ($tblComponents as $key => $array) { + $component_key = false; + + // Loop over our components to determine if the component exists, or we need to add it. + foreach ($components as $compid => $child) { + if ($child['UID'] === $array['UID']) { + $component_key = $compid; + } + } + + if (!$component_key) { + // The component doesn't exist, we need to ADD it - ADD. + $new_component = $component->createComponent($device['device_id'],$module); + $component_key = key($new_component); + $components[$component_key] = array_merge($new_component[$component_key], $array); + echo "+"; + } else { + // The component does exist, merge the details in - UPDATE. + $components[$component_key] = array_merge($components[$component_key], $array); + echo "."; + } + + } + + /* + * Loop over the Component data to see if we need to DELETE any components. + */ + foreach ($components as $key => $array) { + // Guilty until proven innocent + $found = false; + + foreach ($tblComponents as $k => $v) { + if ($array['UID'] == $v['UID']) { + // Yay, we found it... + $found = true; + } + } + + if ($found === false) { + // The component has not been found. we should delete it. + echo "-"; + $component->deleteComponent($key); + } + } + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + echo "\n"; + +} // End if not error + +$module = strtolower($module); +if (count($components) > 0) { + if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)) == '0') { + dbInsert(array('device_id' => $device['device_id'], 'app_type' => $module), 'applications'); + } +} else { + dbDelete('applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $module)); +} diff --git a/includes/polling/cisco-ntp.inc.php b/includes/polling/cisco-ntp.inc.php deleted file mode 100644 index 70e2320181..0000000000 --- a/includes/polling/cisco-ntp.inc.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * 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 ($device['os_group'] == "cisco") { - - $module = 'Cisco-NTP'; - - require_once 'includes/component.php'; - $component = new component(); - $options = array(); - $options['filter']['type'] = array('=',$module); - $options['filter']['disabled'] = array('=',0); - $options['filter']['ignore'] = array('=',0); - $components = $component->getComponents($device['device_id'],$options); - - // We only care about our device id. - $components = $components[$device['device_id']]; - - // Only collect SNMP data if we have enabled components - if (count($components > 0)) { - // Let's gather the stats.. - $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); - - // Loop through the components and extract the data. - foreach ($components as $key => &$array) { - $peer = $array['peer']; - - // Let's make sure the rrd is setup for this class. - $rrd_name = array('ntp', $peer); - $rrd_def = array( - 'DS:stratum:GAUGE:600:0:U', - 'DS:offset:GAUGE:600:0:U', - 'DS:delay:GAUGE:600:0:U', - 'DS:dispersion:GAUGE:600:0:U', - ); - - $array['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$array['UID']]; - // Set the status, 16 = Bad - if ($array['stratum'] == 16) { - $array['status'] = 2; - $array['error'] = 'NTP Stratum is Insane'; - } else { - $array['status'] = 0; - $array['error'] = ''; - } - - // Extract the statistics and update rrd - $rrd['stratum'] = $array['stratum']; - $rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]); - $rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]); - $rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]); - $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer'); - data_update($device, 'ntp', $tags, $rrd); - - // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Index: ".$array['UID']."\n"); - d_echo(" Peer: ".$array['peer'].":".$array['port']."\n"); - d_echo(" Stratum: 1.3.6.1.4.1.9.9.168.1.2.1.1.9.".$array['UID']." = ".$rrd['stratum']."\n"); - d_echo(" Offset: 1.3.6.1.4.1.9.9.168.1.2.1.1.23.".$array['UID']." = ".$rrd['offset']."\n"); - d_echo(" Delay: 1.3.6.1.4.1.9.9.168.1.2.1.1.24.".$array['UID']." = ".$rrd['delay']."\n"); - d_echo(" Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25.".$array['UID']." = ".$rrd['dispersion']."\n"); - - // Clean-up after yourself! - unset($filename, $rrd_filename, $rrd); - } // End foreach components - - // Write the Components back to the DB. - $component->setComponentPrefs($device['device_id'],$components); - - } // end if count components - - // Clean-up after yourself! - unset($type, $components, $component, $options, $module); -} diff --git a/includes/polling/ntp.inc.php b/includes/polling/ntp.inc.php new file mode 100644 index 0000000000..9a1a552384 --- /dev/null +++ b/includes/polling/ntp.inc.php @@ -0,0 +1,23 @@ + + * + * 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. + * + * This module will display NTP details from various device types. + * To display, modules must create rrd's named: ntp-%PEER%.rrd with the following DS': + * DS:stratum:GAUGE:600:0:U + * DS:offset:GAUGE:600:0:U + * DS:delay:GAUGE:600:0:U + * DS:dispersion:GAUGE:600:0:U + */ + +if ($device['os_group'] == 'cisco') { + require_once 'includes/polling/ntp/cisco.inc.php'; +} diff --git a/includes/polling/ntp/cisco.inc.php b/includes/polling/ntp/cisco.inc.php new file mode 100644 index 0000000000..4eab7c4f39 --- /dev/null +++ b/includes/polling/ntp/cisco.inc.php @@ -0,0 +1,82 @@ + + * + * 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. + */ + +$module = 'ntp'; + +require_once 'includes/component.php'; +$component = new component(); +$options = array(); +$options['filter']['type'] = array('=',$module); +$options['filter']['disabled'] = array('=',0); +$options['filter']['ignore'] = array('=',0); +$components = $component->getComponents($device['device_id'],$options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// Only collect SNMP data if we have enabled components +if (count($components > 0)) { + // Let's gather the stats.. + $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2); + + // Loop through the components and extract the data. + foreach ($components as $key => &$array) { + $peer = $array['peer']; + + // Let's make sure the rrd is setup for this class. + $rrd_name = array('ntp', $peer); + $rrd_def = array( + 'DS:stratum:GAUGE:600:0:U', + 'DS:offset:GAUGE:600:0:U', + 'DS:delay:GAUGE:600:0:U', + 'DS:dispersion:GAUGE:600:0:U', + ); + + $array['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$array['UID']]; + // Set the status, 16 = Bad + if ($array['stratum'] == 16) { + $array['status'] = 2; + $array['error'] = 'NTP Stratum is Insane'; + } else { + $array['status'] = 0; + $array['error'] = ''; + } + + // Extract the statistics and update rrd + $rrd['stratum'] = $array['stratum']; + $rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]); + $rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]); + $rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]); + $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer'); + data_update($device, 'ntp', $tags, $rrd); + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Index: ".$array['UID']."\n"); + d_echo(" Peer: ".$array['peer'].":".$array['port']."\n"); + d_echo(" Stratum: 1.3.6.1.4.1.9.9.168.1.2.1.1.9.".$array['UID']." = ".$rrd['stratum']."\n"); + d_echo(" Offset: 1.3.6.1.4.1.9.9.168.1.2.1.1.23.".$array['UID']." = ".$rrd['offset']."\n"); + d_echo(" Delay: 1.3.6.1.4.1.9.9.168.1.2.1.1.24.".$array['UID']." = ".$rrd['delay']."\n"); + d_echo(" Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25.".$array['UID']." = ".$rrd['dispersion']."\n"); + + // Clean-up after yourself! + unset($filename, $rrd_filename, $rrd); + } // End foreach components + + // Write the Components back to the DB. + $component->setComponentPrefs($device['device_id'],$components); + +} // end if count components + +// Clean-up after yourself! +unset($type, $components, $component, $options, $module); From 133a8c87686ed65e7d2c1a9afcef500211ce507f Mon Sep 17 00:00:00 2001 From: crcro Date: Fri, 12 Aug 2016 15:02:58 +0300 Subject: [PATCH 07/44] rewrite the discovery module based on presence oid --- .../discovery/sensors/states/hpblmos.inc.php | 172 +++++++----------- 1 file changed, 65 insertions(+), 107 deletions(-) diff --git a/includes/discovery/sensors/states/hpblmos.inc.php b/includes/discovery/sensors/states/hpblmos.inc.php index 082c0c6f5a..1d08e227e8 100644 --- a/includes/discovery/sensors/states/hpblmos.inc.php +++ b/includes/discovery/sensors/states/hpblmos.inc.php @@ -1,127 +1,85 @@ $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] + $state_index_id = create_state_index($fan_state_name); + if($state_index_id) + { + $states = array( + array($state_index_id, 'other', 0, 1, 3), + array($state_index_id, 'ok', 1, 2, 0), + array($state_index_id, 'degraded', 1, 3, 1), + array($state_index_id, 'failed', 1, 4, 2), ); - dbInsert($insert, 'state_translations'); - } - } - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); - create_sensor_to_state_index($device, $state_name, $index); - $index++; + foreach($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } + } + discover_sensor($valid['sensor'], 'state', $device, $fan_state_oid.$fanid, $fanid, $fan_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $fanid); + create_sensor_to_state_index($device, $fan_state_name, $fanid); + } } } - $index = 1; - $state_name = 'hpblmos_PowerSupplyState'; - $state_descr = 'Power supply '; - $oids = array( - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.1', - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.2', - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.3', - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.4', - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.5', - '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.6', - ); - - /* CPQRACK-MIB::cpqRackPowerSupplyTable - * 1 - other - * 2 - ok - * 3 - degraded - * 4 - failed - */ - - foreach($oids as $oid) { - $state = snmp_get($device, $oid, '-Oqv'); - $descr = $state_descr . $index; - - if(!empty($state)) + for($psuid = 1; $psuid < 7; $psuid++) + { + if (snmp_get($device, $psu_exists_oid.$psuid, '-Oqve') != 2) { - $state_index_id = create_state_index($state_name); + $state = snmp_get($device, $psu_state_oid.$psuid, '-Oqv'); + $descr = $psu_state_descr.$psuid; - if($state_index_id) + if (!empty($state)) { - $states = array( - array($state_index_id, 'other', 0, 1, 3), - array($state_index_id, 'ok', 1, 2, 0), - array($state_index_id, 'degraded', 1, 3, 1), - array($state_index_id, 'failed', 1, 4, 2), - ); - - foreach($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] + $state_index_id = create_state_index($psu_state_name); + if($state_index_id) + { + $states = array( + array($state_index_id, 'other', 0, 1, 3), + array($state_index_id, 'ok', 1, 2, 0), + array($state_index_id, 'degraded', 1, 3, 1), + array($state_index_id, 'failed', 1, 4, 2), ); - dbInsert($insert, 'state_translations'); + + foreach($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } } } - - discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $index); - create_sensor_to_state_index($device, $state_name, $index); - $index++; + discover_sensor($valid['sensor'], 'state', $device, $psu_state_oid.$psuid, $psuid, $psu_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $psuid); + create_sensor_to_state_index($device, $psu_state_name, $psuid); } } } From 655363082c7ad89ed7f602cda0c5d59eece25b98 Mon Sep 17 00:00:00 2001 From: crcro Date: Fri, 12 Aug 2016 22:51:29 +0300 Subject: [PATCH 08/44] rewrite of availability-map --- html/ajax_mapview.php | 7 + html/css/light.css | 98 ++++++++ html/includes/common/availability-map.inc.php | 222 ++++++++++++------ html/js/librenms.js | 13 +- html/pages/availability-map.inc.php | 3 +- 5 files changed, 273 insertions(+), 70 deletions(-) create mode 100644 html/ajax_mapview.php diff --git a/html/ajax_mapview.php b/html/ajax_mapview.php new file mode 100644 index 0000000000..bfc2d19e0b --- /dev/null +++ b/html/ajax_mapview.php @@ -0,0 +1,7 @@ + * Copyright (c) 2016 Jens Langhammer + * Copyright (c) 2016 Cercel Valentin * 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 (defined('show_settings')) { $current_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $current_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; - $common_output[] = ' -
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
- '; -} -else { + + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = ''; + $common_output[] = '
'; + $common_output[] = '
'; + $common_output[] = '
'; + +} else { require_once 'includes/object-cache.inc.php'; - $mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; + $mode = isset($_SESSION["mapView"]) ? $_SESSION["mapView"] : 0; + + $widget_mode = isset($widget_settings['mode']) ? $widget_settings['mode'] : 0; $tile_width = isset($widget_settings['tile_width']) ? $widget_settings['tile_width'] : 10; - $up_count = 0; - $warn_count = 0; - $down_count = 0; + $host_up_count = 0; + $host_warn_count = 0; + $host_down_count = 0; + $service_up_count = 0; + $service_down_count = 0; if ($mode == 0 || $mode == 2) { // Only show devices if mode is 0 or 2 (Only Devices or both) - $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime` FROM `devices` AS `D`'; + $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime`, `D`.`os` FROM `devices` AS `D`'; if (is_normal_user() === true) { $sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; $param = array( $_SESSION['user_id'] - ); - } - else { + ); + } else { $sql .= ' WHERE'; } $sql .= " `D`.`ignore` = '0' AND `D`.`disabled` = '0' ORDER BY `hostname`"; @@ -67,49 +69,135 @@ else { foreach (dbFetchRows($sql, $param) as $device) { if ($device['status'] == '1') { if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != '0')) { - $btn_type = 'btn-warning'; - $warn_count++; + $deviceState = 'warning'; + $deviceLabel = 'label-warning'; + $host_warn_count++; + } else { + $deviceState = 'up'; + $deviceLabel = 'label-success'; + $host_up_count++; } - else { - $btn_type = 'btn-success'; - $up_count ++; - } - } - else { - $btn_type = 'btn-danger'; - $down_count++; + } else { + $deviceState = 'down'; + $deviceLabel = 'label-danger'; + $host_down_count++; + } + + if($directpage == "yes") + { + $deviceIcon = getImage($device); + $temp_output[] = ''; + $temp_output[] = '
'; + $temp_output[] = ''; + $temp_output[] = '' . $deviceIcon . '
'; + $temp_output[] = '' . $device["hostname"] . ''; + $temp_output[] = '
'; + } else { + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = ''; } - $temp_output[] = ''; } } if ($mode == 1 || $mode == 2) { - $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; + $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id`, `D`.`os` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; foreach (dbFetchRows($service_query) as $service) { if ($service['service_status'] == '0') { - $btn_type = 'btn-success'; - $up_count ++; - } - else { - $btn_type = 'btn-danger'; - $down_count += 1; + $serviceLabel = "label-success"; + $serviceState = "up"; + $service_up_count++; + } else { + $serviceLabel = "label-danger"; + $serviceState = "down"; + $service_down_count += 1; } - $temp_output[] = ''; + if($directpage == "yes") + { + $deviceIcon = getImage($service); + $temp_output[] = ''; + $temp_output[] = '
'; + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = '' . $deviceIcon . '
'; + $temp_output[] = '' . $service["hostname"] . ''; + $temp_output[] = '
'; + } else { + $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = ''; + } } } - $temp_output[] = '
'; - $temp_header = array( - '
'.$up_count.' '.$warn_count.' '.$down_count.'

' - ); + if($directpage == "yes") + { + $temp_header[] = '
'; + $temp_header[] = 'Availability map for'; + $temp_header[] = '
'; + $temp_header[] = '
'; + + } + + + if ($mode == 0 || $mode == 2) + { + if($directpage == "yes") + { + $temp_header[] = '
'; + $temp_header[] = 'Hosts report:'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_up_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_warn_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $host_down_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + } else { + $temp_header[] = '
Total hosts '.$host_up_count.' '.$host_warn_count.' '.$host_down_count.'
'; + } + + } + + if ($mode == 1 || $mode == 2) + { + if($directpage == "yes") + { + + $temp_header[] = '
'; + $temp_header[] = 'Services report:'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $service_up_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + $temp_header[] = '
' . $service_down_count . '
'; + $temp_header[] = '
'; + $temp_header[] = '
'; + } else { + $temp_header[] = '
Total services '.$service_up_count.' '.$service_down_count.'
'; + } + } + + $temp_header[] = '
'; + $temp_header[] = '
'; + $common_output = array_merge($temp_header, $temp_output); -} +} \ No newline at end of file diff --git a/html/js/librenms.js b/html/js/librenms.js index f103ea29b0..84cc1b6694 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -225,6 +225,17 @@ $(document).on("click", '.collapse-neighbors', function(event) }); +$(document).on("change", '#mode', function() { + $.post('ajax_mapview.php', + { + mapView: $(this).val() + }, + function(data) { + location.reload(); + },'json' + ); +}); + $(document).ready(function() { var lines = 'on'; $("#linenumbers").button().click(function() { @@ -243,4 +254,4 @@ $(document).ready(function() { }); } }); -}); +}); \ No newline at end of file diff --git a/html/pages/availability-map.inc.php b/html/pages/availability-map.inc.php index b5ede4e144..2b86db8361 100644 --- a/html/pages/availability-map.inc.php +++ b/html/pages/availability-map.inc.php @@ -1,6 +1,5 @@ -

Availability Map

-
Date: Sat, 13 Aug 2016 03:20:55 +0300 Subject: [PATCH 09/44] added linux os distro icon, fixed formatting --- html/ajax_mapview.php | 2 +- html/css/light.css | 18 +++++------ html/includes/common/availability-map.inc.php | 31 +++++++------------ html/js/librenms.js | 2 +- 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/html/ajax_mapview.php b/html/ajax_mapview.php index bfc2d19e0b..66c4cd34d4 100644 --- a/html/ajax_mapview.php +++ b/html/ajax_mapview.php @@ -4,4 +4,4 @@ if (isset($_REQUEST['mapView'])) { $_SESSION['mapView'] = $_REQUEST['mapView']; } header('Content-type: text/plain'); -echo $_SESSION['mapView']; \ No newline at end of file +echo $_SESSION['mapView']; diff --git a/html/css/light.css b/html/css/light.css index ab40e3bc13..ac21bcf9c4 100644 --- a/html/css/light.css +++ b/html/css/light.css @@ -87,7 +87,7 @@ 100% { -o-transform: rotate(360deg); transform: rotate(360deg); } } @-ms-keyframes pace-spinner { - 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); } + 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -ms-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes pace-spinner { @@ -95,7 +95,7 @@ 100% { transform: rotate(360deg); transform: rotate(360deg); } } -.device-availability, .service-availability{ +.device-availability, .service-availability { color:#000000; float:left; width:166px; @@ -118,11 +118,11 @@ border:1px solid #FFB733; } -.availability-label{ +.availability-label { float:right;margin:-8px; } -.service-name-label{ +.service-name-label { float:left;margin:-8px; } @@ -157,13 +157,13 @@ .page-availability-title { font-size:26px; - font-weight: bold; + font-weight:bold; line-height:40px; } .page-availability-report-select { font-size:24px; - font-weight: bold; + font-weight:bold; padding-right:10px; } @@ -185,10 +185,10 @@ .widget-availability-host { float:left; - margin-bottom: 10px; + margin-bottom:10px; } .widget-availability-service { float:right; - margin-bottom: 10px; -} \ No newline at end of file + margin-bottom:10px; +} diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index decaad5c48..bf82cdc363 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -54,7 +54,7 @@ if (defined('show_settings')) { if ($mode == 0 || $mode == 2) { // Only show devices if mode is 0 or 2 (Only Devices or both) - $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime`, `D`.`os` FROM `devices` AS `D`'; + $sql = 'SELECT `D`.`hostname`,`D`.`device_id`,`D`.`status`,`D`.`uptime`, `D`.`os`, `D`.`icon` FROM `devices` AS `D`'; if (is_normal_user() === true) { $sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND'; $param = array( @@ -83,8 +83,7 @@ if (defined('show_settings')) { $host_down_count++; } - if($directpage == "yes") - { + if($directpage == "yes") { $deviceIcon = getImage($device); $temp_output[] = ''; @@ -104,7 +103,7 @@ if (defined('show_settings')) { } if ($mode == 1 || $mode == 2) { - $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id`, `D`.`os` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; + $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id`;'; foreach (dbFetchRows($service_query) as $service) { if ($service['service_status'] == '0') { $serviceLabel = "label-success"; @@ -116,8 +115,7 @@ if (defined('show_settings')) { $service_down_count += 1; } - if($directpage == "yes") - { + if($directpage == "yes") { $deviceIcon = getImage($service); $temp_output[] = ''; @@ -136,8 +134,7 @@ if (defined('show_settings')) { } } - if($directpage == "yes") - { + if($directpage == "yes") { $temp_header[] = '
'; $temp_header[] = 'Availability map for'; $temp_header[] = '
'; $temp_header[] = '
'; - } - if ($mode == 0 || $mode == 2) - { - if($directpage == "yes") - { + if ($mode == 0 || $mode == 2) { + if($directpage == "yes") { $temp_header[] = '
'; $temp_header[] = 'Hosts report:'; $temp_header[] = '
'; @@ -172,13 +166,10 @@ if (defined('show_settings')) { } else { $temp_header[] = '
Total hosts '.$host_up_count.' '.$host_warn_count.' '.$host_down_count.'
'; } - } - if ($mode == 1 || $mode == 2) - { - if($directpage == "yes") - { + if ($mode == 1 || $mode == 2) { + if($directpage == "yes") { $temp_header[] = '
'; $temp_header[] = 'Services report:'; @@ -197,7 +188,7 @@ if (defined('show_settings')) { } $temp_header[] = '
'; - $temp_header[] = '
'; + $temp_header[] = '
'; $common_output = array_merge($temp_header, $temp_output); -} \ No newline at end of file +} diff --git a/html/js/librenms.js b/html/js/librenms.js index 84cc1b6694..8bed8ff000 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -254,4 +254,4 @@ $(document).ready(function() { }); } }); -}); \ No newline at end of file +}); From 709e941c777a1a72bf63476683a9277fc7f113c9 Mon Sep 17 00:00:00 2001 From: crcro Date: Sat, 13 Aug 2016 03:25:28 +0300 Subject: [PATCH 10/44] fixes - PSR-2 style --- .../discovery/sensors/states/hpblmos.inc.php | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/includes/discovery/sensors/states/hpblmos.inc.php b/includes/discovery/sensors/states/hpblmos.inc.php index 1d08e227e8..42d6e4401f 100644 --- a/includes/discovery/sensors/states/hpblmos.inc.php +++ b/includes/discovery/sensors/states/hpblmos.inc.php @@ -1,6 +1,5 @@ Date: Sat, 13 Aug 2016 05:12:05 +0300 Subject: [PATCH 11/44] -fixed select position/size -extra style for text on labels for readibility -PSR-2 style -added classes for all styles --- html/css/dark.css | 106 ++++++++++++++++++ html/css/light.css | 26 +++-- html/css/mono.css | 106 ++++++++++++++++++ html/includes/common/availability-map.inc.php | 37 +++--- 4 files changed, 247 insertions(+), 28 deletions(-) diff --git a/html/css/dark.css b/html/css/dark.css index 980bf42e86..d78912bea2 100644 --- a/html/css/dark.css +++ b/html/css/dark.css @@ -98,3 +98,109 @@ 0% { transform: rotate(0deg); transform: rotate(0deg); } 100% { transform: rotate(360deg); transform: rotate(360deg); } } + +.device-availability, .service-availability{ + color:#000000; + float:left; + width:166px; + height:64px; + margin:10px; + padding:8px; + border-radius:5px; + text-align:center; +} + +.device-availability.up, .service-availability.up { + border:1px solid #5CB85C; +} + +.device-availability.down, .service-availability.down { + border:1px solid #D9534F; +} + +.device-availability.warning { + border:1px solid #FFB733; +} + +.availability-label{ + float:right; + margin:-8px; +} + +.service-name-label{ + float:left; + margin:-8px; +} + +.report-up { + color:#5CB85C; +} + +.report-warning { + color:#FFB733; +} + +.report-down { + color:#D9534F; +} + +.page-availability-report-entry { + text-align:center; + width:50px; +} + +.page-availability-title-left { + width:50%; + float:left; + height:60px; +} + +.page-availability-title-right { + width:50%; + float:left; + text-align:right; +} + +.page-availability-title { + font-size:26px; + font-weight: bold; + line-height:40px; +} + +.page-availability-report-select { + border:none; + font-size:24px; + font-weight:bold; + padding-right:10px; + margin-left:10px; +} + +.page-availability-report-host { + float:right; + text-align:right; + padding-left:10px; +} + +.page-availability-report-service { + float:right; + text-align:right; +} + +.widget-availability { + float:left; + margin:2px; +} + +.widget-availability-host { + float:left; + margin-bottom: 10px; +} + +.widget-availability-service { + float:right; + margin-bottom: 10px; +} + +.label-font-border { + text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; +} \ No newline at end of file diff --git a/html/css/light.css b/html/css/light.css index ac21bcf9c4..c54a5accb1 100644 --- a/html/css/light.css +++ b/html/css/light.css @@ -87,7 +87,7 @@ 100% { -o-transform: rotate(360deg); transform: rotate(360deg); } } @-ms-keyframes pace-spinner { - 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); } + 0% { -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -ms-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes pace-spinner { @@ -95,7 +95,7 @@ 100% { transform: rotate(360deg); transform: rotate(360deg); } } -.device-availability, .service-availability { +.device-availability, .service-availability{ color:#000000; float:left; width:166px; @@ -118,12 +118,14 @@ border:1px solid #FFB733; } -.availability-label { - float:right;margin:-8px; +.availability-label{ + float:right; + margin:-8px; } -.service-name-label { - float:left;margin:-8px; +.service-name-label{ + float:left; + margin:-8px; } .report-up { @@ -157,14 +159,16 @@ .page-availability-title { font-size:26px; - font-weight:bold; + font-weight: bold; line-height:40px; } .page-availability-report-select { + border:none; font-size:24px; font-weight:bold; padding-right:10px; + margin-left:10px; } .page-availability-report-host { @@ -185,10 +189,14 @@ .widget-availability-host { float:left; - margin-bottom:10px; + margin-bottom: 10px; } .widget-availability-service { float:right; - margin-bottom:10px; + margin-bottom: 10px; } + +.label-font-border { + text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; +} \ No newline at end of file diff --git a/html/css/mono.css b/html/css/mono.css index e76425cd34..dbeb71e31a 100644 --- a/html/css/mono.css +++ b/html/css/mono.css @@ -98,3 +98,109 @@ 0% { transform: rotate(0deg); transform: rotate(0deg); } 100% { transform: rotate(360deg); transform: rotate(360deg); } } + +.device-availability, .service-availability{ + color:#000000; + float:left; + width:166px; + height:64px; + margin:10px; + padding:8px; + border-radius:5px; + text-align:center; +} + +.device-availability.up, .service-availability.up { + border:1px solid #5CB85C; +} + +.device-availability.down, .service-availability.down { + border:1px solid #D9534F; +} + +.device-availability.warning { + border:1px solid #FFB733; +} + +.availability-label{ + float:right; + margin:-8px; +} + +.service-name-label{ + float:left; + margin:-8px; +} + +.report-up { + color:#5CB85C; +} + +.report-warning { + color:#FFB733; +} + +.report-down { + color:#D9534F; +} + +.page-availability-report-entry { + text-align:center; + width:50px; +} + +.page-availability-title-left { + width:50%; + float:left; + height:60px; +} + +.page-availability-title-right { + width:50%; + float:left; + text-align:right; +} + +.page-availability-title { + font-size:26px; + font-weight: bold; + line-height:40px; +} + +.page-availability-report-select { + border:none; + font-size:24px; + font-weight:bold; + padding-right:10px; + margin-left:10px; +} + +.page-availability-report-host { + float:right; + text-align:right; + padding-left:10px; +} + +.page-availability-report-service { + float:right; + text-align:right; +} + +.widget-availability { + float:left; + margin:2px; +} + +.widget-availability-host { + float:left; + margin-bottom: 10px; +} + +.widget-availability-service { + float:right; + margin-bottom: 10px; +} + +.label-font-border { + text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; +} \ No newline at end of file diff --git a/html/includes/common/availability-map.inc.php b/html/includes/common/availability-map.inc.php index bf82cdc363..e8158c7f16 100644 --- a/html/includes/common/availability-map.inc.php +++ b/html/includes/common/availability-map.inc.php @@ -83,19 +83,19 @@ if (defined('show_settings')) { $host_down_count++; } - if($directpage == "yes") { + if ($directpage == "yes") { $deviceIcon = getImage($device); $temp_output[] = '
'; $temp_output[] = '
'; - $temp_output[] = ''; + $temp_output[] = ''; $temp_output[] = '' . $deviceIcon . '
'; $temp_output[] = '' . $device["hostname"] . ''; $temp_output[] = '
'; } else { $temp_output[] = ''; - $temp_output[] = ''; + $temp_output[] = ''; $temp_output[] = ''; } @@ -115,26 +115,26 @@ if (defined('show_settings')) { $service_down_count += 1; } - if($directpage == "yes") { + if ($directpage == "yes") { $deviceIcon = getImage($service); $temp_output[] = ''; $temp_output[] = '
'; - $temp_output[] = ''; - $temp_output[] = ''; + $temp_output[] = ''; + $temp_output[] = ''; $temp_output[] = '' . $deviceIcon . '
'; $temp_output[] = '' . $service["hostname"] . ''; $temp_output[] = '
'; } else { $temp_output[] = ''; - $temp_output[] = ''; + $temp_output[] = ''; $temp_output[] = ''; } } } - if($directpage == "yes") { + if ($directpage == "yes") { $temp_header[] = '
'; $temp_header[] = 'Availability map for'; $temp_header[] = ''; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = ''; - $common_output[] = '
'; - $common_output[] = ''; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = ''; - $common_output[] = '
'; - $common_output[] = '
'; - $common_output[] = ''; - + $common_output[] = ' +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
'; } else { require_once 'includes/object-cache.inc.php'; $mode = isset($_SESSION["mapView"]) ? $_SESSION["mapView"] : 0; @@ -86,18 +84,19 @@ if (defined('show_settings')) { if ($directpage == "yes") { $deviceIcon = getImage($device); - $temp_output[] = ''; - $temp_output[] = '
'; - $temp_output[] = ''; - $temp_output[] = '' . $deviceIcon . '
'; - $temp_output[] = '' . $device["hostname"] . ''; - $temp_output[] = '
'; + $temp_output[] = ' + +
+ + '.$deviceIcon.'
+ '.$device["hostname"].' +
+
'; } else { - $temp_output[] = ''; - $temp_output[] = ''; - $temp_output[] = ''; + $temp_output[] = ' + + + '; } } @@ -122,77 +121,65 @@ if (defined('show_settings')) { if ($directpage == "yes") { $deviceIcon = getImage($service); - $temp_output[] = ''; - $temp_output[] = '
'; - $temp_output[] = ''; - $temp_output[] = ''; - $temp_output[] = '' . $deviceIcon . '
'; - $temp_output[] = '' . $service["hostname"] . ''; - $temp_output[] = '
'; + $temp_output[] = ' + +
+ + + '.$deviceIcon.'
+ '.$service["hostname"].' +
+
'; } else { - $temp_output[] = ''; - $temp_output[] = ''; - $temp_output[] = ''; + $temp_output[] = ' + + + '; } } } if ($directpage == "yes") { - $temp_header[] = '
'; - $temp_header[] = 'Availability map for'; - $temp_header[] = '
'; - $temp_header[] = '
'; + $temp_header[] = ' +
+ Availability map for + +
+
'; } - if ($mode == 0 || $mode == 2) { if ($directpage == "yes") { - $temp_header[] = '
'; - $temp_header[] = 'Hosts report:'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $host_up_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $host_warn_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $host_down_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; + $headerClass = 'page-availability-report-host'; } else { - $temp_header[] = '
Total hosts '.$host_up_count.' '.$host_warn_count.' '.$host_down_count.'
'; + $headerClass = 'widget-availability-host'; } + $temp_header[] = ' +
+ Total hosts + + + +
'; } if ($mode == 1 || $mode == 2) { if ($directpage == "yes") { - $temp_header[] = '
'; - $temp_header[] = 'Services report:'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $service_up_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $service_warn_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; - $temp_header[] = '
' . $service_down_count . '
'; - $temp_header[] = '
'; - $temp_header[] = '
'; + $headerClass = 'page-availability-report-service'; } else { - $temp_header[] = '
Total services '.$service_up_count.' '.$service_warn_count.' '.$service_down_count.'
'; + $headerClass = 'widget-availability-service'; } + $temp_header[] = ' +
+ Total services + + + +
'; } $temp_header[] = '
'; From bf2c522c899a41c726830d5bc63f95dc8f6e7a72 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 15 Aug 2016 13:16:10 -0500 Subject: [PATCH 18/44] Move third party software to html/lib form html/includes --- .scrutinizer.yml | 2 +- adduser.php | 2 +- html/api_v0.php | 2 +- html/bandwidth-graph.php | 10 +-- html/billing-graph.php | 8 +- html/includes/authenticate.inc.php | 2 +- html/includes/jpgraph/README | 71 ------------------ html/includes/jpgraph/VERSION | 1 - html/{includes => lib}/PasswordHash.php | 0 html/{includes => lib}/Slim/Environment.php | 0 .../{includes => lib}/Slim/Exception/Pass.php | 0 .../{includes => lib}/Slim/Exception/Stop.php | 0 html/{includes => lib}/Slim/Helper/Set.php | 0 html/{includes => lib}/Slim/Http/Cookies.php | 0 html/{includes => lib}/Slim/Http/Headers.php | 0 html/{includes => lib}/Slim/Http/Request.php | 0 html/{includes => lib}/Slim/Http/Response.php | 0 html/{includes => lib}/Slim/Http/Util.php | 0 html/{includes => lib}/Slim/Log.php | 0 html/{includes => lib}/Slim/LogWriter.php | 0 html/{includes => lib}/Slim/Middleware.php | 0 .../Slim/Middleware/ContentTypes.php | 0 .../Slim/Middleware/Flash.php | 0 .../Slim/Middleware/MethodOverride.php | 0 .../Slim/Middleware/PrettyExceptions.php | 0 .../Slim/Middleware/SessionCookie.php | 0 html/{includes => lib}/Slim/Route.php | 0 html/{includes => lib}/Slim/Router.php | 0 html/{includes => lib}/Slim/Slim.php | 0 html/{includes => lib}/Slim/View.php | 0 html/{includes => lib}/geshi/geshi.php | 0 html/{includes => lib}/geshi/geshi/diff.php | 0 html/{includes => lib}/geshi/geshi/ios.php | 0 .../jpgraph}/contour_dev/findpolygon.php | 0 .../jpgraph}/contour_dev/tri-quad.php | 0 .../jpgraph/src => lib/jpgraph}/flag_mapping | 0 .../jpgraph/src => lib/jpgraph}/flags.dat | Bin .../jpgraph}/flags_thumb100x100.dat | Bin .../src => lib/jpgraph}/flags_thumb35x35.dat | Bin .../src => lib/jpgraph}/flags_thumb60x60.dat | Bin .../src => lib/jpgraph}/gd_image.inc.php | 24 ++++++ .../src => lib/jpgraph}/imgdata_balls.inc.php | 24 ++++++ .../jpgraph}/imgdata_bevels.inc.php | 24 ++++++ .../jpgraph}/imgdata_diamonds.inc.php | 24 ++++++ .../jpgraph}/imgdata_pushpins.inc.php | 24 ++++++ .../jpgraph}/imgdata_squares.inc.php | 24 ++++++ .../src => lib/jpgraph}/imgdata_stars.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpg-config.inc.php | 24 ++++++ .../jpgraph/src => lib/jpgraph}/jpgraph.php | 24 ++++++ .../jpgraph}/jpgraph_antispam-digits.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_antispam.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_bar.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_canvas.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_canvtools.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_contour.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_date.php | 24 ++++++ .../jpgraph}/jpgraph_errhandler.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_error.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_flags.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_gantt.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_gb2312.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_gradient.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_iconplot.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_imgtrans.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_led.php | 24 ++++++ .../jpgraph}/jpgraph_legend.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_line.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_log.php | 24 ++++++ .../jpgraph}/jpgraph_meshinterpolate.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_mgraph.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_pie.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_pie3d.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_plotband.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_plotline.php | 24 ++++++ .../jpgraph}/jpgraph_plotmark.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_polar.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_radar.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_regstat.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_rgb.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_scatter.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_stock.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_text.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_ttf.inc.php | 24 ++++++ .../src => lib/jpgraph}/jpgraph_utils.inc.php | 24 ++++++ .../src => lib/jpgraph}/lang/de.inc.php | 0 .../src => lib/jpgraph}/lang/en.inc.php | 0 .../src => lib/jpgraph}/lang/prod.inc.php | 0 html/pages/device/showconfig.inc.php | 2 +- 88 files changed, 1070 insertions(+), 86 deletions(-) delete mode 100644 html/includes/jpgraph/README delete mode 100644 html/includes/jpgraph/VERSION rename html/{includes => lib}/PasswordHash.php (100%) rename html/{includes => lib}/Slim/Environment.php (100%) rename html/{includes => lib}/Slim/Exception/Pass.php (100%) rename html/{includes => lib}/Slim/Exception/Stop.php (100%) rename html/{includes => lib}/Slim/Helper/Set.php (100%) rename html/{includes => lib}/Slim/Http/Cookies.php (100%) rename html/{includes => lib}/Slim/Http/Headers.php (100%) rename html/{includes => lib}/Slim/Http/Request.php (100%) rename html/{includes => lib}/Slim/Http/Response.php (100%) rename html/{includes => lib}/Slim/Http/Util.php (100%) rename html/{includes => lib}/Slim/Log.php (100%) rename html/{includes => lib}/Slim/LogWriter.php (100%) rename html/{includes => lib}/Slim/Middleware.php (100%) rename html/{includes => lib}/Slim/Middleware/ContentTypes.php (100%) rename html/{includes => lib}/Slim/Middleware/Flash.php (100%) rename html/{includes => lib}/Slim/Middleware/MethodOverride.php (100%) rename html/{includes => lib}/Slim/Middleware/PrettyExceptions.php (100%) rename html/{includes => lib}/Slim/Middleware/SessionCookie.php (100%) rename html/{includes => lib}/Slim/Route.php (100%) rename html/{includes => lib}/Slim/Router.php (100%) rename html/{includes => lib}/Slim/Slim.php (100%) rename html/{includes => lib}/Slim/View.php (100%) rename html/{includes => lib}/geshi/geshi.php (100%) rename html/{includes => lib}/geshi/geshi/diff.php (100%) rename html/{includes => lib}/geshi/geshi/ios.php (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/contour_dev/findpolygon.php (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/contour_dev/tri-quad.php (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/flag_mapping (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/flags.dat (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/flags_thumb100x100.dat (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/flags_thumb35x35.dat (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/flags_thumb60x60.dat (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/gd_image.inc.php (98%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_balls.inc.php (98%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_bevels.inc.php (84%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_diamonds.inc.php (91%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_pushpins.inc.php (97%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_squares.inc.php (89%) rename html/{includes/jpgraph/src => lib/jpgraph}/imgdata_stars.inc.php (89%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpg-config.inc.php (87%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph.php (99%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_antispam-digits.php (93%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_antispam.php (98%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_bar.php (98%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_canvas.php (80%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_canvtools.php (95%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_contour.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_date.php (95%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_errhandler.inc.php (93%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_error.php (85%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_flags.php (94%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_gantt.php (99%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_gb2312.php (99%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_gradient.php (95%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_iconplot.php (87%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_imgtrans.php (90%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_led.php (93%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_legend.inc.php (95%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_line.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_log.php (92%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_meshinterpolate.inc.php (81%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_mgraph.php (93%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_pie.php (98%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_pie3d.php (97%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_plotband.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_plotline.php (83%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_plotmark.inc.php (95%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_polar.php (97%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_radar.php (97%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_regstat.php (89%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_rgb.inc.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_scatter.php (90%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_stock.php (88%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_text.inc.php (92%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_ttf.inc.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/jpgraph_utils.inc.php (96%) rename html/{includes/jpgraph/src => lib/jpgraph}/lang/de.inc.php (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/lang/en.inc.php (100%) rename html/{includes/jpgraph/src => lib/jpgraph}/lang/prod.inc.php (100%) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c924a41d1c..e2ae05a96c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -5,4 +5,4 @@ imports: # FIXME: find a way to keep excluded_paths list sorted filter: - excluded_paths: [ html/includes/geshi/*, html/includes/jpgraph/*, html/js/*, includes/phpmailer/*, html/css/*, html/includes/Slim/*, includes/console_colour.php, includes/console_table.php, html/lib/*, lib/* ] + excluded_paths: [ html/js/*, includes/phpmailer/*, html/css/*, includes/console_colour.php, includes/console_table.php, html/lib/*, lib/* ] diff --git a/adduser.php b/adduser.php index f1e591415c..d46119e770 100755 --- a/adduser.php +++ b/adduser.php @@ -19,7 +19,7 @@ require 'includes/defaults.inc.php'; require 'config.php'; require 'includes/definitions.inc.php'; require 'includes/functions.php'; -require 'html/includes/PasswordHash.php'; +require 'html/lib/PasswordHash.php'; if (file_exists('html/includes/authentication/'.$config['auth_mechanism'].'.inc.php')) { include 'html/includes/authentication/'.$config['auth_mechanism'].'.inc.php'; diff --git a/html/api_v0.php b/html/api_v0.php index 676cca8967..0a18250495 100644 --- a/html/api_v0.php +++ b/html/api_v0.php @@ -20,7 +20,7 @@ require_once '../includes/dbFacile.php'; require_once '../includes/rewrites.php'; require_once 'includes/functions.inc.php'; require_once '../includes/rrdtool.inc.php'; -require 'includes/Slim/Slim.php'; +require 'lib/Slim/Slim.php'; \Slim\Slim::registerAutoloader(); $app = new \Slim\Slim(); require_once 'includes/api_functions.inc.php'; diff --git a/html/bandwidth-graph.php b/html/bandwidth-graph.php index d43f2bd85f..82a2a8662e 100644 --- a/html/bandwidth-graph.php +++ b/html/bandwidth-graph.php @@ -43,11 +43,11 @@ if (get_client_ip() != $_SERVER['SERVER_ADDR']) { } } -require_once 'includes/jpgraph/src/jpgraph.php'; -require_once 'includes/jpgraph/src/jpgraph_line.php'; -require_once 'includes/jpgraph/src/jpgraph_bar.php'; -require_once 'includes/jpgraph/src/jpgraph_utils.inc.php'; -require_once 'includes/jpgraph/src/jpgraph_date.php'; +require_once 'lib/jpgraph/jpgraph.php'; +require_once 'lib/jpgraph/jpgraph_line.php'; +require_once 'lib/jpgraph/jpgraph_bar.php'; +require_once 'lib/jpgraph/jpgraph_utils.inc.php'; +require_once 'lib/jpgraph/jpgraph_date.php'; if (is_numeric($_GET['bill_id'])) { if (get_client_ip() != $_SERVER['SERVER_ADDR']) { diff --git a/html/billing-graph.php b/html/billing-graph.php index 7038de620e..fffc93a7a3 100644 --- a/html/billing-graph.php +++ b/html/billing-graph.php @@ -43,10 +43,10 @@ if (get_client_ip() != $_SERVER['SERVER_ADDR']) { } } -require 'includes/jpgraph/src/jpgraph.php'; -require 'includes/jpgraph/src/jpgraph_line.php'; -require 'includes/jpgraph/src/jpgraph_utils.inc.php'; -require 'includes/jpgraph/src/jpgraph_date.php'; +require 'lib/jpgraph/jpgraph.php'; +require 'lib/jpgraph/jpgraph_line.php'; +require 'lib/jpgraph/jpgraph_utils.inc.php'; +require 'lib/jpgraph/jpgraph_date.php'; if (is_numeric($_GET['bill_id'])) { if (get_client_ip() != $_SERVER['SERVER_ADDR']) { diff --git a/html/includes/authenticate.inc.php b/html/includes/authenticate.inc.php index 0f25d24144..49e8798d84 100644 --- a/html/includes/authenticate.inc.php +++ b/html/includes/authenticate.inc.php @@ -2,7 +2,7 @@ @ini_set('session.use_only_cookies', 1); @ini_set('session.cookie_httponly', 1); -require 'includes/PasswordHash.php'; +require 'lib/PasswordHash.php'; session_start(); diff --git a/html/includes/jpgraph/README b/html/includes/jpgraph/README deleted file mode 100644 index 963cc5c8f1..0000000000 --- a/html/includes/jpgraph/README +++ /dev/null @@ -1,71 +0,0 @@ -README FOR JPGRAPH 3.0.x -======================== - -This package contains JpGraph, an Object Oriented PHP5 Graph Plotting library. - -The library is Copyright (C) 2001-2009 Aditus Consulting and -released under dual license QPL 1.0 for open source and educational -use and JpGraph Professional License for commercial use. - -Please see full license details at http://www.aditus.nu/jpgraph/ - -* -------------------------------------------------------------------- -* PHP4 IS NOT SUPPORTED in the 2.x or 3.x series -* -------------------------------------------------------------------- - -Requirements: -------------- -Miminum: -* PHP 5.1.0 or higher -* GD 2.0.28 or higher -Note: Earlier versions might work but is unsupported. - -Recommended: -* PHP >= 5.2.0 -* PHP Built-in GD library - -Installation ------------- -0. Make sure that the PHP version is compatible with the stated requirements - and that the PHP installation has support for the GD library. - Please run phpinfo() to check if GD library - is supported in the installation. - If the GD library doesn't seem to be installed - please consult the PHP manual under section "Image" for - instructions on where to find this library. Please refer to - the manual section "Verifying your PHP installation" - -1. Unzip and copy the files to a directory of your choice where Your - httpd sever can access them. - For a global site installation you should copy the files to - somewhere in the PHP search path. - -2. Check that the default directory paths in jpg-config.inc - for cache directory and TTF directory suits your installation. - Note1: The default directories are different depending on if - the library is running on Windows or UNIX. - Note2: Apache/PHP must have write permission to your cache - directory if you enable the cache feature. By default the cache - is disabled. - -3. Check that all rest of the DEFINE in jpg-config.inc - is setup to your preference. The default should be fine - for most users. - -4. Read the chapters on installation in the manual. - - -Documentation -------------- -The installation includes HTML documentation and reference guide for the -library. The portal page for all the documentation is -/docs/index.html - - -Bug reports and suggestions ---------------------------- -Should be reported using the the issue tracker at - -http://www.aditus.nu/bugtraq - - diff --git a/html/includes/jpgraph/VERSION b/html/includes/jpgraph/VERSION deleted file mode 100644 index 92f61ae6bd..0000000000 --- a/html/includes/jpgraph/VERSION +++ /dev/null @@ -1 +0,0 @@ -Version: v3.0.7, Build: r1928, Exported: Mon, 11 Jan 2010 at 23:34 (UTC+2), w1002.1 diff --git a/html/includes/PasswordHash.php b/html/lib/PasswordHash.php similarity index 100% rename from html/includes/PasswordHash.php rename to html/lib/PasswordHash.php diff --git a/html/includes/Slim/Environment.php b/html/lib/Slim/Environment.php similarity index 100% rename from html/includes/Slim/Environment.php rename to html/lib/Slim/Environment.php diff --git a/html/includes/Slim/Exception/Pass.php b/html/lib/Slim/Exception/Pass.php similarity index 100% rename from html/includes/Slim/Exception/Pass.php rename to html/lib/Slim/Exception/Pass.php diff --git a/html/includes/Slim/Exception/Stop.php b/html/lib/Slim/Exception/Stop.php similarity index 100% rename from html/includes/Slim/Exception/Stop.php rename to html/lib/Slim/Exception/Stop.php diff --git a/html/includes/Slim/Helper/Set.php b/html/lib/Slim/Helper/Set.php similarity index 100% rename from html/includes/Slim/Helper/Set.php rename to html/lib/Slim/Helper/Set.php diff --git a/html/includes/Slim/Http/Cookies.php b/html/lib/Slim/Http/Cookies.php similarity index 100% rename from html/includes/Slim/Http/Cookies.php rename to html/lib/Slim/Http/Cookies.php diff --git a/html/includes/Slim/Http/Headers.php b/html/lib/Slim/Http/Headers.php similarity index 100% rename from html/includes/Slim/Http/Headers.php rename to html/lib/Slim/Http/Headers.php diff --git a/html/includes/Slim/Http/Request.php b/html/lib/Slim/Http/Request.php similarity index 100% rename from html/includes/Slim/Http/Request.php rename to html/lib/Slim/Http/Request.php diff --git a/html/includes/Slim/Http/Response.php b/html/lib/Slim/Http/Response.php similarity index 100% rename from html/includes/Slim/Http/Response.php rename to html/lib/Slim/Http/Response.php diff --git a/html/includes/Slim/Http/Util.php b/html/lib/Slim/Http/Util.php similarity index 100% rename from html/includes/Slim/Http/Util.php rename to html/lib/Slim/Http/Util.php diff --git a/html/includes/Slim/Log.php b/html/lib/Slim/Log.php similarity index 100% rename from html/includes/Slim/Log.php rename to html/lib/Slim/Log.php diff --git a/html/includes/Slim/LogWriter.php b/html/lib/Slim/LogWriter.php similarity index 100% rename from html/includes/Slim/LogWriter.php rename to html/lib/Slim/LogWriter.php diff --git a/html/includes/Slim/Middleware.php b/html/lib/Slim/Middleware.php similarity index 100% rename from html/includes/Slim/Middleware.php rename to html/lib/Slim/Middleware.php diff --git a/html/includes/Slim/Middleware/ContentTypes.php b/html/lib/Slim/Middleware/ContentTypes.php similarity index 100% rename from html/includes/Slim/Middleware/ContentTypes.php rename to html/lib/Slim/Middleware/ContentTypes.php diff --git a/html/includes/Slim/Middleware/Flash.php b/html/lib/Slim/Middleware/Flash.php similarity index 100% rename from html/includes/Slim/Middleware/Flash.php rename to html/lib/Slim/Middleware/Flash.php diff --git a/html/includes/Slim/Middleware/MethodOverride.php b/html/lib/Slim/Middleware/MethodOverride.php similarity index 100% rename from html/includes/Slim/Middleware/MethodOverride.php rename to html/lib/Slim/Middleware/MethodOverride.php diff --git a/html/includes/Slim/Middleware/PrettyExceptions.php b/html/lib/Slim/Middleware/PrettyExceptions.php similarity index 100% rename from html/includes/Slim/Middleware/PrettyExceptions.php rename to html/lib/Slim/Middleware/PrettyExceptions.php diff --git a/html/includes/Slim/Middleware/SessionCookie.php b/html/lib/Slim/Middleware/SessionCookie.php similarity index 100% rename from html/includes/Slim/Middleware/SessionCookie.php rename to html/lib/Slim/Middleware/SessionCookie.php diff --git a/html/includes/Slim/Route.php b/html/lib/Slim/Route.php similarity index 100% rename from html/includes/Slim/Route.php rename to html/lib/Slim/Route.php diff --git a/html/includes/Slim/Router.php b/html/lib/Slim/Router.php similarity index 100% rename from html/includes/Slim/Router.php rename to html/lib/Slim/Router.php diff --git a/html/includes/Slim/Slim.php b/html/lib/Slim/Slim.php similarity index 100% rename from html/includes/Slim/Slim.php rename to html/lib/Slim/Slim.php diff --git a/html/includes/Slim/View.php b/html/lib/Slim/View.php similarity index 100% rename from html/includes/Slim/View.php rename to html/lib/Slim/View.php diff --git a/html/includes/geshi/geshi.php b/html/lib/geshi/geshi.php similarity index 100% rename from html/includes/geshi/geshi.php rename to html/lib/geshi/geshi.php diff --git a/html/includes/geshi/geshi/diff.php b/html/lib/geshi/geshi/diff.php similarity index 100% rename from html/includes/geshi/geshi/diff.php rename to html/lib/geshi/geshi/diff.php diff --git a/html/includes/geshi/geshi/ios.php b/html/lib/geshi/geshi/ios.php similarity index 100% rename from html/includes/geshi/geshi/ios.php rename to html/lib/geshi/geshi/ios.php diff --git a/html/includes/jpgraph/src/contour_dev/findpolygon.php b/html/lib/jpgraph/contour_dev/findpolygon.php similarity index 100% rename from html/includes/jpgraph/src/contour_dev/findpolygon.php rename to html/lib/jpgraph/contour_dev/findpolygon.php diff --git a/html/includes/jpgraph/src/contour_dev/tri-quad.php b/html/lib/jpgraph/contour_dev/tri-quad.php similarity index 100% rename from html/includes/jpgraph/src/contour_dev/tri-quad.php rename to html/lib/jpgraph/contour_dev/tri-quad.php diff --git a/html/includes/jpgraph/src/flag_mapping b/html/lib/jpgraph/flag_mapping similarity index 100% rename from html/includes/jpgraph/src/flag_mapping rename to html/lib/jpgraph/flag_mapping diff --git a/html/includes/jpgraph/src/flags.dat b/html/lib/jpgraph/flags.dat similarity index 100% rename from html/includes/jpgraph/src/flags.dat rename to html/lib/jpgraph/flags.dat diff --git a/html/includes/jpgraph/src/flags_thumb100x100.dat b/html/lib/jpgraph/flags_thumb100x100.dat similarity index 100% rename from html/includes/jpgraph/src/flags_thumb100x100.dat rename to html/lib/jpgraph/flags_thumb100x100.dat diff --git a/html/includes/jpgraph/src/flags_thumb35x35.dat b/html/lib/jpgraph/flags_thumb35x35.dat similarity index 100% rename from html/includes/jpgraph/src/flags_thumb35x35.dat rename to html/lib/jpgraph/flags_thumb35x35.dat diff --git a/html/includes/jpgraph/src/flags_thumb60x60.dat b/html/lib/jpgraph/flags_thumb60x60.dat similarity index 100% rename from html/includes/jpgraph/src/flags_thumb60x60.dat rename to html/lib/jpgraph/flags_thumb60x60.dat diff --git a/html/includes/jpgraph/src/gd_image.inc.php b/html/lib/jpgraph/gd_image.inc.php similarity index 98% rename from html/includes/jpgraph/src/gd_image.inc.php rename to html/lib/jpgraph/gd_image.inc.php index c2ec49e888..913558914b 100644 --- a/html/includes/jpgraph/src/gd_image.inc.php +++ b/html/lib/jpgraph/gd_image.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: GD_IMAGE.INC.PHP // Description: PHP Graph Plotting library. Low level image drawing routines diff --git a/html/includes/jpgraph/src/imgdata_balls.inc.php b/html/lib/jpgraph/imgdata_balls.inc.php similarity index 98% rename from html/includes/jpgraph/src/imgdata_balls.inc.php rename to html/lib/jpgraph/imgdata_balls.inc.php index abc43d091f..651c51a67f 100644 --- a/html/includes/jpgraph/src/imgdata_balls.inc.php +++ b/html/lib/jpgraph/imgdata_balls.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_ROUNDBALLS.INC // Description: Base64 encoded images for small round markers diff --git a/html/includes/jpgraph/src/imgdata_bevels.inc.php b/html/lib/jpgraph/imgdata_bevels.inc.php similarity index 84% rename from html/includes/jpgraph/src/imgdata_bevels.inc.php rename to html/lib/jpgraph/imgdata_bevels.inc.php index 2cd545f74f..2dab45fc55 100644 --- a/html/includes/jpgraph/src/imgdata_bevels.inc.php +++ b/html/lib/jpgraph/imgdata_bevels.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_BEVELS.INC // Description: Base64 encoded images for round bevels diff --git a/html/includes/jpgraph/src/imgdata_diamonds.inc.php b/html/lib/jpgraph/imgdata_diamonds.inc.php similarity index 91% rename from html/includes/jpgraph/src/imgdata_diamonds.inc.php rename to html/lib/jpgraph/imgdata_diamonds.inc.php index 533cd4753c..c911a97031 100644 --- a/html/includes/jpgraph/src/imgdata_diamonds.inc.php +++ b/html/lib/jpgraph/imgdata_diamonds.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_DIAMONDS.INC // Description: Base64 encoded images for diamonds diff --git a/html/includes/jpgraph/src/imgdata_pushpins.inc.php b/html/lib/jpgraph/imgdata_pushpins.inc.php similarity index 97% rename from html/includes/jpgraph/src/imgdata_pushpins.inc.php rename to html/lib/jpgraph/imgdata_pushpins.inc.php index 53e0b159a7..f15d115e25 100644 --- a/html/includes/jpgraph/src/imgdata_pushpins.inc.php +++ b/html/lib/jpgraph/imgdata_pushpins.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_PUSHPINS.INC // Description: Base64 encoded images for pushpins diff --git a/html/includes/jpgraph/src/imgdata_squares.inc.php b/html/lib/jpgraph/imgdata_squares.inc.php similarity index 89% rename from html/includes/jpgraph/src/imgdata_squares.inc.php rename to html/lib/jpgraph/imgdata_squares.inc.php index b17faf0449..e420b0a243 100644 --- a/html/includes/jpgraph/src/imgdata_squares.inc.php +++ b/html/lib/jpgraph/imgdata_squares.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_SQUARES.INC // Description: Base64 encoded images for squares diff --git a/html/includes/jpgraph/src/imgdata_stars.inc.php b/html/lib/jpgraph/imgdata_stars.inc.php similarity index 89% rename from html/includes/jpgraph/src/imgdata_stars.inc.php rename to html/lib/jpgraph/imgdata_stars.inc.php index 3c5f799a85..44d638ef10 100644 --- a/html/includes/jpgraph/src/imgdata_stars.inc.php +++ b/html/lib/jpgraph/imgdata_stars.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: IMGDATA_STARS.INC // Description: Base64 encoded images for stars diff --git a/html/includes/jpgraph/src/jpg-config.inc.php b/html/lib/jpgraph/jpg-config.inc.php similarity index 87% rename from html/includes/jpgraph/src/jpg-config.inc.php rename to html/lib/jpgraph/jpg-config.inc.php index 35081fa05f..f7ce5b7f6b 100644 --- a/html/includes/jpgraph/src/jpg-config.inc.php +++ b/html/lib/jpgraph/jpg-config.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPG-CONFIG.INC // Description: Configuration file for JpGraph library diff --git a/html/includes/jpgraph/src/jpgraph.php b/html/lib/jpgraph/jpgraph.php similarity index 99% rename from html/includes/jpgraph/src/jpgraph.php rename to html/lib/jpgraph/jpgraph.php index a92e58836f..0eba4e3190 100644 --- a/html/includes/jpgraph/src/jpgraph.php +++ b/html/lib/jpgraph/jpgraph.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH.PHP // Description: PHP Graph Plotting library. Base module. diff --git a/html/includes/jpgraph/src/jpgraph_antispam-digits.php b/html/lib/jpgraph/jpgraph_antispam-digits.php similarity index 93% rename from html/includes/jpgraph/src/jpgraph_antispam-digits.php rename to html/lib/jpgraph/jpgraph_antispam-digits.php index f3cff8ae5d..c032353d68 100644 --- a/html/includes/jpgraph/src/jpgraph_antispam-digits.php +++ b/html/lib/jpgraph/jpgraph_antispam-digits.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_ANTISPAM.PHP // Description: Genarate anti-spam challenge diff --git a/html/includes/jpgraph/src/jpgraph_antispam.php b/html/lib/jpgraph/jpgraph_antispam.php similarity index 98% rename from html/includes/jpgraph/src/jpgraph_antispam.php rename to html/lib/jpgraph/jpgraph_antispam.php index e9c995a745..ed2b1737ee 100644 --- a/html/includes/jpgraph/src/jpgraph_antispam.php +++ b/html/lib/jpgraph/jpgraph_antispam.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_ANTISPAM.PHP // Description: Genarate anti-spam challenge diff --git a/html/includes/jpgraph/src/jpgraph_bar.php b/html/lib/jpgraph/jpgraph_bar.php similarity index 98% rename from html/includes/jpgraph/src/jpgraph_bar.php rename to html/lib/jpgraph/jpgraph_bar.php index 10a5ddfd27..92d8eb7868 100644 --- a/html/includes/jpgraph/src/jpgraph_bar.php +++ b/html/lib/jpgraph/jpgraph_bar.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_BAR.PHP // Description: Bar plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_canvas.php b/html/lib/jpgraph/jpgraph_canvas.php similarity index 80% rename from html/includes/jpgraph/src/jpgraph_canvas.php rename to html/lib/jpgraph/jpgraph_canvas.php index 4e9f9645b1..f6e23e47e6 100644 --- a/html/includes/jpgraph/src/jpgraph_canvas.php +++ b/html/lib/jpgraph/jpgraph_canvas.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_CANVAS.PHP // Description: Canvas drawing extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_canvtools.php b/html/lib/jpgraph/jpgraph_canvtools.php similarity index 95% rename from html/includes/jpgraph/src/jpgraph_canvtools.php rename to html/lib/jpgraph/jpgraph_canvtools.php index bb821bfa0e..ff8e010f54 100644 --- a/html/includes/jpgraph/src/jpgraph_canvtools.php +++ b/html/lib/jpgraph/jpgraph_canvtools.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_CANVTOOLS.PHP // Description: Some utilities for text and shape drawing on a canvas diff --git a/html/includes/jpgraph/src/jpgraph_contour.php b/html/lib/jpgraph/jpgraph_contour.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_contour.php rename to html/lib/jpgraph/jpgraph_contour.php index 0b23cdec40..148eda9d8f 100644 --- a/html/includes/jpgraph/src/jpgraph_contour.php +++ b/html/lib/jpgraph/jpgraph_contour.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_CONTOUR.PHP // Description: Contour plot diff --git a/html/includes/jpgraph/src/jpgraph_date.php b/html/lib/jpgraph/jpgraph_date.php similarity index 95% rename from html/includes/jpgraph/src/jpgraph_date.php rename to html/lib/jpgraph/jpgraph_date.php index 6adc9e4bb8..0fe00b4148 100644 --- a/html/includes/jpgraph/src/jpgraph_date.php +++ b/html/lib/jpgraph/jpgraph_date.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_DATE.PHP // Description: Classes to handle Date scaling diff --git a/html/includes/jpgraph/src/jpgraph_errhandler.inc.php b/html/lib/jpgraph/jpgraph_errhandler.inc.php similarity index 93% rename from html/includes/jpgraph/src/jpgraph_errhandler.inc.php rename to html/lib/jpgraph/jpgraph_errhandler.inc.php index 68b5b5d46b..e325e8ffc0 100644 --- a/html/includes/jpgraph/src/jpgraph_errhandler.inc.php +++ b/html/lib/jpgraph/jpgraph_errhandler.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_ERRHANDLER.PHP // Description: Error handler class together with handling of localized diff --git a/html/includes/jpgraph/src/jpgraph_error.php b/html/lib/jpgraph/jpgraph_error.php similarity index 85% rename from html/includes/jpgraph/src/jpgraph_error.php rename to html/lib/jpgraph/jpgraph_error.php index 5e0857fbee..87f9ce8006 100644 --- a/html/includes/jpgraph/src/jpgraph_error.php +++ b/html/lib/jpgraph/jpgraph_error.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_ERROR.PHP // Description: Error plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_flags.php b/html/lib/jpgraph/jpgraph_flags.php similarity index 94% rename from html/includes/jpgraph/src/jpgraph_flags.php rename to html/lib/jpgraph/jpgraph_flags.php index 3bf902ddce..85295b1457 100644 --- a/html/includes/jpgraph/src/jpgraph_flags.php +++ b/html/lib/jpgraph/jpgraph_flags.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_FLAGS.PHP // Description: Class Jpfile. Handles plotmarks diff --git a/html/includes/jpgraph/src/jpgraph_gantt.php b/html/lib/jpgraph/jpgraph_gantt.php similarity index 99% rename from html/includes/jpgraph/src/jpgraph_gantt.php rename to html/lib/jpgraph/jpgraph_gantt.php index b8f0e5fc9f..635c17612b 100644 --- a/html/includes/jpgraph/src/jpgraph_gantt.php +++ b/html/lib/jpgraph/jpgraph_gantt.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_GANTT.PHP // Description: JpGraph Gantt plot extension diff --git a/html/includes/jpgraph/src/jpgraph_gb2312.php b/html/lib/jpgraph/jpgraph_gb2312.php similarity index 99% rename from html/includes/jpgraph/src/jpgraph_gb2312.php rename to html/lib/jpgraph/jpgraph_gb2312.php index bfaa58af02..0f272ac8f0 100644 --- a/html/includes/jpgraph/src/jpgraph_gb2312.php +++ b/html/lib/jpgraph/jpgraph_gb2312.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_GB2312.PHP // Description: Chinese font conversions diff --git a/html/includes/jpgraph/src/jpgraph_gradient.php b/html/lib/jpgraph/jpgraph_gradient.php similarity index 95% rename from html/includes/jpgraph/src/jpgraph_gradient.php rename to html/lib/jpgraph/jpgraph_gradient.php index a990b9ff45..ff299877dd 100644 --- a/html/includes/jpgraph/src/jpgraph_gradient.php +++ b/html/lib/jpgraph/jpgraph_gradient.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_GRADIENT.PHP // Description: Create a color gradient diff --git a/html/includes/jpgraph/src/jpgraph_iconplot.php b/html/lib/jpgraph/jpgraph_iconplot.php similarity index 87% rename from html/includes/jpgraph/src/jpgraph_iconplot.php rename to html/lib/jpgraph/jpgraph_iconplot.php index ca622314c1..f43cf36962 100644 --- a/html/includes/jpgraph/src/jpgraph_iconplot.php +++ b/html/lib/jpgraph/jpgraph_iconplot.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_ICONPLOT.PHP // Description: Extension module to add icons to plots diff --git a/html/includes/jpgraph/src/jpgraph_imgtrans.php b/html/lib/jpgraph/jpgraph_imgtrans.php similarity index 90% rename from html/includes/jpgraph/src/jpgraph_imgtrans.php rename to html/lib/jpgraph/jpgraph_imgtrans.php index 6f0cc07aa3..4d966d5751 100644 --- a/html/includes/jpgraph/src/jpgraph_imgtrans.php +++ b/html/lib/jpgraph/jpgraph_imgtrans.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_IMGTRANS.PHP // Description: Extension for JpGraph to do some simple img transformations diff --git a/html/includes/jpgraph/src/jpgraph_led.php b/html/lib/jpgraph/jpgraph_led.php similarity index 93% rename from html/includes/jpgraph/src/jpgraph_led.php rename to html/lib/jpgraph/jpgraph_led.php index 45cda1ba9e..accc5b69be 100644 --- a/html/includes/jpgraph/src/jpgraph_led.php +++ b/html/lib/jpgraph/jpgraph_led.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_LED.PHP // Description: Module to generate Dotted LED-like digits diff --git a/html/includes/jpgraph/src/jpgraph_legend.inc.php b/html/lib/jpgraph/jpgraph_legend.inc.php similarity index 95% rename from html/includes/jpgraph/src/jpgraph_legend.inc.php rename to html/lib/jpgraph/jpgraph_legend.inc.php index c1099c4728..9705edcc28 100644 --- a/html/includes/jpgraph/src/jpgraph_legend.inc.php +++ b/html/lib/jpgraph/jpgraph_legend.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_LEGEND.INC.PHP // Description: Class to handle the legend box in the graph that gives diff --git a/html/includes/jpgraph/src/jpgraph_line.php b/html/lib/jpgraph/jpgraph_line.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_line.php rename to html/lib/jpgraph/jpgraph_line.php index 3151fb4fc1..ef72f057c2 100644 --- a/html/includes/jpgraph/src/jpgraph_line.php +++ b/html/lib/jpgraph/jpgraph_line.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_LINE.PHP // Description: Line plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_log.php b/html/lib/jpgraph/jpgraph_log.php similarity index 92% rename from html/includes/jpgraph/src/jpgraph_log.php rename to html/lib/jpgraph/jpgraph_log.php index 58628c4e88..82b48d6a6c 100644 --- a/html/includes/jpgraph/src/jpgraph_log.php +++ b/html/lib/jpgraph/jpgraph_log.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_LOG.PHP // Description: Log scale plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_meshinterpolate.inc.php b/html/lib/jpgraph/jpgraph_meshinterpolate.inc.php similarity index 81% rename from html/includes/jpgraph/src/jpgraph_meshinterpolate.inc.php rename to html/lib/jpgraph/jpgraph_meshinterpolate.inc.php index bc9d6f0363..0aea48b38d 100644 --- a/html/includes/jpgraph/src/jpgraph_meshinterpolate.inc.php +++ b/html/lib/jpgraph/jpgraph_meshinterpolate.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_MESHINTERPOLATE.INC.PHP // Description: Utility class to do mesh linear interpolation of a matrix diff --git a/html/includes/jpgraph/src/jpgraph_mgraph.php b/html/lib/jpgraph/jpgraph_mgraph.php similarity index 93% rename from html/includes/jpgraph/src/jpgraph_mgraph.php rename to html/lib/jpgraph/jpgraph_mgraph.php index fbd8f5d89e..ae92210e72 100644 --- a/html/includes/jpgraph/src/jpgraph_mgraph.php +++ b/html/lib/jpgraph/jpgraph_mgraph.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_MGRAPH.PHP // Description: Class to handle multiple graphs in the same image diff --git a/html/includes/jpgraph/src/jpgraph_pie.php b/html/lib/jpgraph/jpgraph_pie.php similarity index 98% rename from html/includes/jpgraph/src/jpgraph_pie.php rename to html/lib/jpgraph/jpgraph_pie.php index a4208b4529..2b5872d635 100644 --- a/html/includes/jpgraph/src/jpgraph_pie.php +++ b/html/lib/jpgraph/jpgraph_pie.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_PIE.PHP // Description: Pie plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_pie3d.php b/html/lib/jpgraph/jpgraph_pie3d.php similarity index 97% rename from html/includes/jpgraph/src/jpgraph_pie3d.php rename to html/lib/jpgraph/jpgraph_pie3d.php index 45cb2b2b99..2c01e25fa4 100644 --- a/html/includes/jpgraph/src/jpgraph_pie3d.php +++ b/html/lib/jpgraph/jpgraph_pie3d.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_PIE3D.PHP // Description: 3D Pie plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_plotband.php b/html/lib/jpgraph/jpgraph_plotband.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_plotband.php rename to html/lib/jpgraph/jpgraph_plotband.php index 1c78d33a4a..3e7ae3ffee 100644 --- a/html/includes/jpgraph/src/jpgraph_plotband.php +++ b/html/lib/jpgraph/jpgraph_plotband.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_PLOTBAND.PHP // Description: PHP4 Graph Plotting library. Extension module. diff --git a/html/includes/jpgraph/src/jpgraph_plotline.php b/html/lib/jpgraph/jpgraph_plotline.php similarity index 83% rename from html/includes/jpgraph/src/jpgraph_plotline.php rename to html/lib/jpgraph/jpgraph_plotline.php index 7c19219e8f..13a203197c 100644 --- a/html/includes/jpgraph/src/jpgraph_plotline.php +++ b/html/lib/jpgraph/jpgraph_plotline.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_PLOTLINE.PHP // Description: PlotLine extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_plotmark.inc.php b/html/lib/jpgraph/jpgraph_plotmark.inc.php similarity index 95% rename from html/includes/jpgraph/src/jpgraph_plotmark.inc.php rename to html/lib/jpgraph/jpgraph_plotmark.inc.php index 78a08cff2e..c602b65cce 100644 --- a/html/includes/jpgraph/src/jpgraph_plotmark.inc.php +++ b/html/lib/jpgraph/jpgraph_plotmark.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_PLOTMARK.PHP // Description: Class file. Handles plotmarks diff --git a/html/includes/jpgraph/src/jpgraph_polar.php b/html/lib/jpgraph/jpgraph_polar.php similarity index 97% rename from html/includes/jpgraph/src/jpgraph_polar.php rename to html/lib/jpgraph/jpgraph_polar.php index af3c88bde9..6d70e6233d 100644 --- a/html/includes/jpgraph/src/jpgraph_polar.php +++ b/html/lib/jpgraph/jpgraph_polar.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_POLAR.PHP // Description: Polar plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_radar.php b/html/lib/jpgraph/jpgraph_radar.php similarity index 97% rename from html/includes/jpgraph/src/jpgraph_radar.php rename to html/lib/jpgraph/jpgraph_radar.php index c71ffafe5c..ac9b6338e1 100644 --- a/html/includes/jpgraph/src/jpgraph_radar.php +++ b/html/lib/jpgraph/jpgraph_radar.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_RADAR.PHP // Description: Radar plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_regstat.php b/html/lib/jpgraph/jpgraph_regstat.php similarity index 89% rename from html/includes/jpgraph/src/jpgraph_regstat.php rename to html/lib/jpgraph/jpgraph_regstat.php index c327c95985..933123947f 100644 --- a/html/includes/jpgraph/src/jpgraph_regstat.php +++ b/html/lib/jpgraph/jpgraph_regstat.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_REGSTAT.PHP // Description: Regression and statistical analysis helper classes diff --git a/html/includes/jpgraph/src/jpgraph_rgb.inc.php b/html/lib/jpgraph/jpgraph_rgb.inc.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_rgb.inc.php rename to html/lib/jpgraph/jpgraph_rgb.inc.php index 2cbc85bb31..974e0a300e 100644 --- a/html/includes/jpgraph/src/jpgraph_rgb.inc.php +++ b/html/lib/jpgraph/jpgraph_rgb.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_RGB.INC.PHP // Description: Class to handle RGb color space specification and diff --git a/html/includes/jpgraph/src/jpgraph_scatter.php b/html/lib/jpgraph/jpgraph_scatter.php similarity index 90% rename from html/includes/jpgraph/src/jpgraph_scatter.php rename to html/lib/jpgraph/jpgraph_scatter.php index 141fdfa202..8f7ea1ec92 100644 --- a/html/includes/jpgraph/src/jpgraph_scatter.php +++ b/html/lib/jpgraph/jpgraph_scatter.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_SCATTER.PHP // Description: Scatter (and impuls) plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_stock.php b/html/lib/jpgraph/jpgraph_stock.php similarity index 88% rename from html/includes/jpgraph/src/jpgraph_stock.php rename to html/lib/jpgraph/jpgraph_stock.php index 45a136805b..1c257b3c35 100644 --- a/html/includes/jpgraph/src/jpgraph_stock.php +++ b/html/lib/jpgraph/jpgraph_stock.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_STOCK.PHP // Description: Stock plot extension for JpGraph diff --git a/html/includes/jpgraph/src/jpgraph_text.inc.php b/html/lib/jpgraph/jpgraph_text.inc.php similarity index 92% rename from html/includes/jpgraph/src/jpgraph_text.inc.php rename to html/lib/jpgraph/jpgraph_text.inc.php index c93846b858..6de7427e4b 100644 --- a/html/includes/jpgraph/src/jpgraph_text.inc.php +++ b/html/lib/jpgraph/jpgraph_text.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: JPGRAPH_TEXT.INC.PHP // Description: Class to handle text as object in the graph. diff --git a/html/includes/jpgraph/src/jpgraph_ttf.inc.php b/html/lib/jpgraph/jpgraph_ttf.inc.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_ttf.inc.php rename to html/lib/jpgraph/jpgraph_ttf.inc.php index 1e0d52409c..49e0b5cb2f 100644 --- a/html/includes/jpgraph/src/jpgraph_ttf.inc.php +++ b/html/lib/jpgraph/jpgraph_ttf.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + //======================================================================= // File: jpgraph_ttf.inc.php // Description: Handling of TTF fonts diff --git a/html/includes/jpgraph/src/jpgraph_utils.inc.php b/html/lib/jpgraph/jpgraph_utils.inc.php similarity index 96% rename from html/includes/jpgraph/src/jpgraph_utils.inc.php rename to html/lib/jpgraph/jpgraph_utils.inc.php index bd9fc911de..ca179c7e70 100644 --- a/html/includes/jpgraph/src/jpgraph_utils.inc.php +++ b/html/lib/jpgraph/jpgraph_utils.inc.php @@ -1,4 +1,28 @@ . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Tony Murray + * @author Tony Murray + */ + /*======================================================================= // File: JPGRAPH_UTILS.INC // Description: Collection of non-essential "nice to have" utilities diff --git a/html/includes/jpgraph/src/lang/de.inc.php b/html/lib/jpgraph/lang/de.inc.php similarity index 100% rename from html/includes/jpgraph/src/lang/de.inc.php rename to html/lib/jpgraph/lang/de.inc.php diff --git a/html/includes/jpgraph/src/lang/en.inc.php b/html/lib/jpgraph/lang/en.inc.php similarity index 100% rename from html/includes/jpgraph/src/lang/en.inc.php rename to html/lib/jpgraph/lang/en.inc.php diff --git a/html/includes/jpgraph/src/lang/prod.inc.php b/html/lib/jpgraph/lang/prod.inc.php similarity index 100% rename from html/includes/jpgraph/src/lang/prod.inc.php rename to html/lib/jpgraph/lang/prod.inc.php diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 7ae4bd5a21..a60022461c 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,6 +1,6 @@ Date: Mon, 15 Aug 2016 12:41:39 -0500 Subject: [PATCH 19/44] Prep Travis.yml for codesniffer changes --- .gitignore | 3 ++- .travis.yml | 34 ++++++++++++++++++++++++---------- composer.json | 5 +++++ 3 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 composer.json diff --git a/.gitignore b/.gitignore index fe34379a88..8025a1d7e0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # Others # ########## *.swp +/composer.lock Thumbs.db config.php html/plugins/* @@ -20,4 +21,4 @@ logs nbproject patches rrd - +/vendor diff --git a/.travis.yml b/.travis.yml index a3ea97cf9e..d1746dfa3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,18 +2,32 @@ language: php matrix: fast_finish: true include: - - php: 5.3 - script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 - - php: 5.4 - script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 - - php: 5.5 - script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 - - php: 5.6 - script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 - php: 7.0 - script: find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + env: PHP_L=1 + - php: 5.3 + env: PHP_L_OLD=1 + - php: 5.4 + env: PHP_L_OLD=1 + - php: 5.5 + env: PHP_L=1 + - php: 5.6 + env: PHP_L=1 PHPCS=0 - php: hhvm - script: find . -path './lib/influxdb-php' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1 + env: PHP_L_OLD=1 + allow_failures: - php: 7.0 - php: hhvm + +cache: + directories: + - vendor + - $HOME/.composer/cache + +before_script: + - composer install --prefer-dist --no-interaction + +script: + - if [[ $PHP_L == 1 ]]; then find . -path './vendor' -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1; fi + - if [[ $PHP_L_OLD == 1 ]]; then find . -regextype posix-extended -regex "\./(lib/influxdb-php|vendor)" -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v '^No syntax errors detected' ; test $? -eq 1; fi + - if [[ $PHP_CS == 1 ]]; then vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 --ignore=html/lib/* .; fi diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000..2dd4acf45c --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "squizlabs/php_codesniffer": "*" + } +} From 709de9a16628c53f5bd1222197980404bf42b5d5 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 15 Aug 2016 14:04:39 -0500 Subject: [PATCH 20/44] Use namespaces for classes CollectdColor, move into it's own file, change functions to camelCase Plugins use LibreNMS\Plugins --- html/includes/collectd/CollectdColor.php | 109 ++++++++++++++++++++ html/includes/collectd/functions.php | 121 ++--------------------- html/includes/plugins.inc.php | 11 ++- html/index.php | 2 + html/plugins/Test/Test.php | 2 + 5 files changed, 132 insertions(+), 113 deletions(-) create mode 100644 html/includes/collectd/CollectdColor.php diff --git a/html/includes/collectd/CollectdColor.php b/html/includes/collectd/CollectdColor.php new file mode 100644 index 0000000000..1ea18d2e0d --- /dev/null +++ b/html/includes/collectd/CollectdColor.php @@ -0,0 +1,109 @@ +r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; + } + + if (isset($value['g'])) { + $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; + } + + if (isset($value['b'])) { + $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; + } + } else { + if (is_string($value)) { + $matches = array(); + if ($value == 'random') { + $this->randomize(); + } else { + if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', + $value, $matches)) { + $this->r = (('0x' . $matches[1]) / 255.0); + $this->g = (('0x' . $matches[2]) / 255.0); + $this->b = (('0x' . $matches[3]) / 255.0); + } + } + } else { + if (is_a($value, 'CollectdColor')) { + $this->r = $value->r; + $this->g = $value->g; + $this->b = $value->b; + } + } + } + }//end if + + }//end __construct() + + + public function randomize() + { + $this->r = (rand(0, 255) / 255.0); + $this->g = (rand(0, 255) / 255.0); + $this->b = 0.0; + $min = 0.0; + $max = 1.0; + + if (($this->r + $this->g) < 1.0) { + $min = (1.0 - ($this->r + $this->g)); + } else { + $max = (2.0 - ($this->r + $this->g)); + } + + $this->b = ($min + ((rand(0, 255) / 255.0) * ($max - $min))); + + }//end randomize() + + + public function fade($bkgnd = null, $alpha = 0.25) + { + if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { + $bg_r = 1.0; + $bg_g = 1.0; + $bg_b = 1.0; + } else { + $bg_r = $bkgnd->r; + $bg_g = $bkgnd->g; + $bg_b = $bkgnd->b; + } + + $this->r = ($alpha * $this->r + ((1.0 - $alpha) * $bg_r)); + $this->g = ($alpha * $this->g + ((1.0 - $alpha) * $bg_g)); + $this->b = ($alpha * $this->b + ((1.0 - $alpha) * $bg_b)); + + }//end fade() + + + public function toArray() + { + return array( + 'r' => $this->r, + 'g' => $this->g, + 'b' => $this->b, + ); + + }//end as_array() + + + public function toString() + { + $r = (int)($this->r * 255); + $g = (int)($this->g * 255); + $b = (int)($this->b * 255); + return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); + + } +} diff --git a/html/includes/collectd/functions.php b/html/includes/collectd/functions.php index e0cad177b4..7c945a4332 100644 --- a/html/includes/collectd/functions.php +++ b/html/includes/collectd/functions.php @@ -1,5 +1,4 @@ * @@ -17,6 +16,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +require 'includes/collectd/CollectdColor.php'; + +use LibreNMS\CollectdColor; + define('REGEXP_HOST', '/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/'); define('REGEXP_PLUGIN', '/^[a-zA-Z0-9_.-]+$/'); @@ -368,112 +371,6 @@ function collectd_flush($identifier) { }//end collectd_flush() - -class CollectdColor { - - private $r = 0; - - private $g = 0; - - private $b = 0; - - - function __construct($value=null) { - if (is_null($value)) { - } - else if (is_array($value)) { - if (isset($value['r'])) { - $this->r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; - } - - if (isset($value['g'])) { - $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; - } - - if (isset($value['b'])) { - $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; - } - } - else if (is_string($value)) { - $matches = array(); - if ($value == 'random') { - $this->randomize(); - } - else if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', $value, $matches)) { - $this->r = (('0x'.$matches[1]) / 255.0); - $this->g = (('0x'.$matches[2]) / 255.0); - $this->b = (('0x'.$matches[3]) / 255.0); - } - } - else if (is_a($value, 'CollectdColor')) { - $this->r = $value->r; - $this->g = $value->g; - $this->b = $value->b; - }//end if - - }//end __construct() - - - function randomize() { - $this->r = (rand(0, 255) / 255.0); - $this->g = (rand(0, 255) / 255.0); - $this->b = 0.0; - $min = 0.0; - $max = 1.0; - - if (($this->r + $this->g) < 1.0) { - $min = (1.0 - ($this->r + $this->g)); - } - else { - $max = (2.0 - ($this->r + $this->g)); - } - - $this->b = ($min + ((rand(0, 255) / 255.0) * ($max - $min))); - - }//end randomize() - - - function fade($bkgnd=null, $alpha=0.25) { - if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { - $bg_r = 1.0; - $bg_g = 1.0; - $bg_b = 1.0; - } - else { - $bg_r = $bkgnd->r; - $bg_g = $bkgnd->g; - $bg_b = $bkgnd->b; - } - - $this->r = ($alpha * $this->r + ((1.0 - $alpha) * $bg_r)); - $this->g = ($alpha * $this->g + ((1.0 - $alpha) * $bg_g)); - $this->b = ($alpha * $this->b + ((1.0 - $alpha) * $bg_b)); - - }//end fade() - - - function as_array() { - return array( - 'r' => $this->r, - 'g' => $this->g, - 'b' => $this->b, - ); - - }//end as_array() - - - function as_string() { - $r = (int) ($this->r * 255); - $g = (int) ($this->g * 255); - $b = (int) ($this->b * 255); - return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); - - }//end as_string() - - -}//end class - - /** * Helper function to strip quotes from RRD output * @str RRD-Info generated string @@ -564,8 +461,8 @@ function rrd_get_color($code, $line=true) { $c_f = new CollectdColor('random'); $c_h = new CollectdColor($c_f); $c_h->fade(); - $config['rrd_colors']['f_'.$code] = $c_f->as_string(); - $config['rrd_colors']['h_'.$code] = $c_h->as_string(); + $config['rrd_colors']['f_'.$code] = $c_f->toString(); + $config['rrd_colors']['h_'.$code] = $c_h->toString(); } return $config['rrd_colors'][$name]; @@ -952,8 +849,8 @@ function collectd_draw_meta_stack(&$opts, &$sources) { $area_color = new CollectdColor($line_color); $area_color->fade(); - $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->as_string(); - $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->as_string().':'.$legend; + $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->toString(); + $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->toString().':'.$legend; if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.''; $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; @@ -1072,7 +969,7 @@ function collectd_draw_meta_line(&$opts, &$sources) { $line_color = new CollectdColor('random'); } - $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->as_string().':'.$legend; + $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->toString().':'.$legend; if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; diff --git a/html/includes/plugins.inc.php b/html/includes/plugins.inc.php index a10762c5cf..e52015b199 100644 --- a/html/includes/plugins.inc.php +++ b/html/includes/plugins.inc.php @@ -1,5 +1,7 @@ Date: Mon, 15 Aug 2016 17:46:10 -0300 Subject: [PATCH 21/44] Added Unbound Support --- .../application/unbound_queries.inc.php | 47 ++++++++++++++ html/pages/device/apps/unbound.inc.php | 26 ++++++++ includes/polling/applications/unbound.inc.php | 62 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 html/includes/graphs/application/unbound_queries.inc.php create mode 100644 html/pages/device/apps/unbound.inc.php create mode 100644 includes/polling/applications/unbound.inc.php diff --git a/html/includes/graphs/application/unbound_queries.inc.php b/html/includes/graphs/application/unbound_queries.inc.php new file mode 100644 index 0000000000..2733923b42 --- /dev/null +++ b/html/includes/graphs/application/unbound_queries.inc.php @@ -0,0 +1,47 @@ + 'Unbound - Queries' + ); +foreach ($graphs as $key => $text){ + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + + echo '
+
+

'.$text.'

+
+
+
'; + include 'includes/print-graphrow.inc.php'; + echo '
'; + echo '
'; + echo '
'; +} \ No newline at end of file diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php new file mode 100644 index 0000000000..05cf626f85 --- /dev/null +++ b/includes/polling/applications/unbound.inc.php @@ -0,0 +1,62 @@ + $unbound['num.query.type.TYPE0'], + 'a' => $unbound['num.query.type.A'], + 'ns' => $unbound['num.query.type.NS'], + 'cname' => $unbound['num.query.type.CNAME'], + 'soa' => $unbound['num.query.type.SOA'], + 'null' => $unbound['num.query.type.NULL'], + 'wks' => $unbound['num.query.type.WKS'], + 'ptr' => $unbound['num.query.type.PTR'], + 'mx' => $unbound['num.query.type.MX'], + 'txt' => $unbound['num.query.type.TXT'], + 'aaaa' => $unbound['num.query.type.AAAA'], + 'srv' => $unbound['num.query.type.SRV'], + 'naptr' => $unbound['num.query.type.NAPTR'], + 'ds' => $unbound['num.query.type.DS'], + 'dnskey' => $unbound['num.query.type.DNSKEY'], + 'spf' => $unbound['num.query.type.SPF'], + 'any' => $unbound['num.query.type.ANY'], + 'other' => $unbound['num.query.type.other'] + ); +$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); +data_update($device, 'app', $tags, $fields); +$status = true; +unset($lines , $unbound, $rrd_name, $rrd_def, $fields, $tags); \ No newline at end of file From 00c5c65d47644698bb72a7ce5ad2402caa51c7b2 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Mon, 15 Aug 2016 18:07:36 -0300 Subject: [PATCH 22/44] Fix array declaration 5.3 compatible --- includes/polling/applications/unbound.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php index 05cf626f85..f372921b7f 100644 --- a/includes/polling/applications/unbound.inc.php +++ b/includes/polling/applications/unbound.inc.php @@ -9,7 +9,7 @@ if (!empty($agent_data['app'][$name])) { } #Format Data $lines = explode("\n",$rawdata); -$unbound = []; +$unbound = array(); foreach ($lines as $line) { list($var,$value) = explode('=',$line); $unbound[$var] = $value; From 8c0735d64e22d380f208670d24f0633b699ba3d9 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Mon, 15 Aug 2016 18:17:41 -0300 Subject: [PATCH 23/44] Fix parameter order --- includes/polling/applications/unbound.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php index f372921b7f..82cfc4d4eb 100644 --- a/includes/polling/applications/unbound.inc.php +++ b/includes/polling/applications/unbound.inc.php @@ -15,7 +15,7 @@ foreach ($lines as $line) { $unbound[$var] = $value; } #Unbound Queries -$rrd_name = array('app', $name."-queries",$app_id); +$rrd_name = array('app', $name,'queries',$app_id); $rrd_def = array( 'DS:type0:DERIVE:600:0:125000000000', 'DS:A:DERIVE:600:0:125000000000', From 2528171e0a79070b1631afddda5685c7b12c0837 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 15 Aug 2016 20:40:57 -0500 Subject: [PATCH 24/44] Clean up rrdtool output Output the command before other print statements Only output raw rrdtool output with the -v switch Line return and plurality --- includes/rrdtool.inc.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 48466b48f3..44130f3eb7 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -151,7 +151,7 @@ function rrdtool_graph($graph_file, $options) */ function rrdtool($command, $filename, $options, $timeout = 0) { - global $config, $debug, $rrd_pipes, $console_color; + global $config, $vdebug, $rrd_pipes, $console_color; // do not ovewrite files when creating if ($command == 'create') { @@ -173,6 +173,8 @@ function rrdtool($command, $filename, $options, $timeout = 0) $cmd = "$command $filename $options"; } + d_echo($console_color->convert('RRD[%g'.$cmd."%n] \n")); + // do not write rrd files, but allow read-only commands if ($config['norrd'] && !in_array($command, array('graph', 'graphv', 'dump', 'fetch', 'first', 'last', 'lastupdate', 'info', 'xport')) @@ -183,7 +185,7 @@ function rrdtool($command, $filename, $options, $timeout = 0) version_compare($config['rrdtool_version'], '1.5', '<') && is_file($filename) ) { // do not ovewrite RRD if already exist and RRDTool ver. < 1.5 - d_echo('[RRD file ' . $filename . ' already exist]'); + d_echo($console_color->convert('RRD[%g' . $filename . " already exists%n]\n")); $output = array(null, null); } else { if ($timeout > 0 && stream_select($r = $rrd_pipes, $w = null, $x = null, 0)) { @@ -198,8 +200,7 @@ function rrdtool($command, $filename, $options, $timeout = 0) $output = array(stream_get_contents($rrd_pipes[1]), stream_get_contents($rrd_pipes[2])); } - if ($debug) { - print $console_color->convert('RRD[%g'.$cmd."%n] \n"); + if ($vdebug) { echo 'RRDtool Output: '; echo $output[0]; echo $output[1]; From b4354b3801c0ee719b7da52e1a573cde9ed25e23 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 16 Aug 2016 05:48:47 +0300 Subject: [PATCH 25/44] rewrite to use snmp_walk against snmp_get for fewer device queries --- .../discovery/sensors/power/hpblmos.inc.php | 24 ++-- .../discovery/sensors/states/hpblmos.inc.php | 129 ++++++++++-------- .../sensors/temperatures/hpblmos.inc.php | 23 ++-- 3 files changed, 105 insertions(+), 71 deletions(-) diff --git a/includes/discovery/sensors/power/hpblmos.inc.php b/includes/discovery/sensors/power/hpblmos.inc.php index dfc26203a7..df8d87df93 100644 --- a/includes/discovery/sensors/power/hpblmos.inc.php +++ b/includes/discovery/sensors/power/hpblmos.inc.php @@ -2,18 +2,26 @@ if ($device['os'] == 'hpblmos') { $sensor_type = 'hpblmos_psu_usage'; - $psu_exists_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16.'; + //$psu_exists_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16.'; + $psu_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16'; $psu_usage_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.10.'; $psu_max_usage_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.9.'; - for ($psuid = 1; $psuid < 7; $psuid++) { - if (snmp_get($device, $psu_exists_oid.$psuid, '-Oqve') != 2) { - $descr = 'PSU '.$psuid.' output'; - $value = snmp_get($device, $psu_usage_oid.$psuid, '-Oqv'); - $max_value = snmp_get($device, $psu_max_usage_oid.$psuid, '-Oqv'); + $psus = trim(snmp_walk($device, $psu_oid, '-Osqn')); - if (is_numeric($value)) { - discover_sensor($valid['sensor'], 'power', $device, $psu_usage_oid.$psuid, $psuid, $sensor_type, $descr, 1, 1, null, null, null, $max_value, $value); + foreach (explode("\n", $psus) as $psu) { + $psu = trim($psu); + if ($psu) { + list($oid, $presence) = explode(' ', $psu, 2); + if ($presence != 2) { + $split_oid = explode('.', $oid); + $current_id = $split_oid[(count($split_oid) - 1)]; + $current_oid = $psu_usage_oid.$current_id; + $psu_max_oid = $psu_max_usage_oid.$current_id; + $descr = 'PSU '.$psuid.' output'; + $value = snmp_get($device, $current_oid, '-Oqv'); + $max_value = snmp_get($device, $psu_max_oid, '-Oqv'); + discover_sensor($valid['sensor'], 'power', $device, $current_oid, $current_id, $sensor_type, $descr, 1, 1, null, null, null, $max_value, $value); } } } diff --git a/includes/discovery/sensors/states/hpblmos.inc.php b/includes/discovery/sensors/states/hpblmos.inc.php index 42d6e4401f..9ff40fe131 100644 --- a/includes/discovery/sensors/states/hpblmos.inc.php +++ b/includes/discovery/sensors/states/hpblmos.inc.php @@ -1,76 +1,95 @@ $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] + foreach (explode("\n", $fans) as $fan) { + $fan = trim($fan); + if ($fan) { + list($oid, $presence) = explode(' ', $fan, 2); + if ($presence != 2) { + $split_oid = explode('.', $oid); + $current_id = $split_oid[(count($split_oid) - 1)]; + $current_oid = $fan_state_oid.$current_id; + $descr = $fan_state_descr.$current_id; + $state = snmp_get($device, $current_oid, '-Oqv'); + if (!empty($state)) { + $state_index_id = create_state_index($fan_state_name); + if ($state_index_id) { + $states = array( + array($state_index_id, 'other', 0, 1, 3), + array($state_index_id, 'ok', 1, 2, 0), + array($state_index_id, 'degraded', 1, 3, 1), + array($state_index_id, 'failed', 1, 4, 2), ); - dbInsert($insert, 'state_translations'); + + foreach ($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } } } - discover_sensor($valid['sensor'], 'state', $device, $fan_state_oid.$fanid, $fanid, $fan_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $fanid); - create_sensor_to_state_index($device, $fan_state_name, $fanid); - } + discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $fan_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $current_id); + create_sensor_to_state_index($device, $fan_state_name, $current_id); + } } + + } - for($psuid = 1; $psuid < 7; $psuid++) { - if (snmp_get($device, $psu_exists_oid.$psuid, '-Oqve') != 2) { - $state = snmp_get($device, $psu_state_oid.$psuid, '-Oqv'); - $descr = $psu_state_descr.$psuid; + $psu_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16'; + $psu_state_name = 'hpblmos_psustate'; + $psu_state_descr = 'PSU '; + $psu_state_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.17.'; - if (!empty($state)) { - $state_index_id = create_state_index($psu_state_name); - if($state_index_id) { - $states = array( - array($state_index_id, 'other', 0, 1, 3), - array($state_index_id, 'ok', 1, 2, 0), - array($state_index_id, 'degraded', 1, 3, 1), - array($state_index_id, 'failed', 1, 4, 2), - ); + $psus = trim(snmp_walk($device, $psu_oid, '-Osqn')); - foreach($states as $value) { - $insert = array( - 'state_index_id' => $value[0], - 'state_descr' => $value[1], - 'state_draw_graph' => $value[2], - 'state_value' => $value[3], - 'state_generic_value' => $value[4] + foreach (explode("\n", $psus) as $psu) { + $psu = trim($psu); + if ($psu) { + list($oid, $presence) = explode(' ', $psu, 2); + if ($presence != 2) { + $split_oid = explode('.', $oid); + $current_id = $split_oid[(count($split_oid) - 1)]; + $current_oid = $psu_state_oid.$current_id; + $descr = $psu_state_descr.$current_id; + $state = snmp_get($device, $current_oid, '-Oqv'); + if (!empty($state)) { + $state_index_id = create_state_index($psu_state_name); + if ($state_index_id) { + $states = array( + array($state_index_id, 'other', 0, 1, 3), + array($state_index_id, 'ok', 1, 2, 0), + array($state_index_id, 'degraded', 1, 3, 1), + array($state_index_id, 'failed', 1, 4, 2), ); - dbInsert($insert, 'state_translations'); + + foreach ($states as $value) { + $insert = array( + 'state_index_id' => $value[0], + 'state_descr' => $value[1], + 'state_draw_graph' => $value[2], + 'state_value' => $value[3], + 'state_generic_value' => $value[4] + ); + dbInsert($insert, 'state_translations'); + } } } + discover_sensor($valid['sensor'], 'state', $device, $current_oid, $current_id, $psu_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $current_id); + create_sensor_to_state_index($device, $psu_state_name, $current_id); } - discover_sensor($valid['sensor'], 'state', $device, $psu_state_oid.$psuid, $psuid, $psu_state_name, $descr, '1', '1', null, null, null, null, $state, 'snmp', $psuid); - create_sensor_to_state_index($device, $psu_state_name, $psuid); } } } diff --git a/includes/discovery/sensors/temperatures/hpblmos.inc.php b/includes/discovery/sensors/temperatures/hpblmos.inc.php index 9e4f1e8258..d0b733321b 100644 --- a/includes/discovery/sensors/temperatures/hpblmos.inc.php +++ b/includes/discovery/sensors/temperatures/hpblmos.inc.php @@ -2,17 +2,24 @@ if ($device['os'] == 'hpblmos') { $sensor_type = 'hpblmos_temps'; - $sensor_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5.'; + $temps_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5'; + //$sensor_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5.'; $sensor_value_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.6.'; - for ($tempid = 1; $tempid < 61; $tempid++) { - $sensor_descr = snmp_get($device, $sensor_oid.$tempid, '-Oqve'); - if ($sensor_descr != "") { - $descr = 'Temperature '.$sensor_descr.''; - $value = snmp_get($device, $sensor_value_oid.$tempid, '-Oqve'); + $temps = trim(snmp_walk($device, $temps_oid, '-Osqn')); - if ($value > 0) { - discover_sensor($valid['sensor'], 'temperature', $device, $sensor_value_oid.$tempid, $tempid, $sensor_type, $descr, 1, 1, null, null, null, null, $value); + foreach (explode("\n", $temps) as $temp) { + $temp = trim($temp); + if ($temp) { + list($oid, $descr) = explode(' ', $temp, 2); + if ($descr != "") { + $split_oid = explode('.', $oid); + $current_id = $split_oid[(count($split_oid) - 1)]; + $current_oid = $sensor_value_oid.$current_id; + $value = snmp_get($device, $current_oid, '-Oqve'); + if ($value > 0) { + discover_sensor($valid['sensor'], 'temperature', $device, $current_oid, $current_id, $sensor_type, $descr, 1, 1, null, null, null, null, $value); + } } } } From 2bf54f106b23663ee0981a18a96560e2d311c349 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 16 Aug 2016 05:50:45 +0300 Subject: [PATCH 26/44] removed useless comments --- includes/discovery/sensors/power/hpblmos.inc.php | 3 +-- includes/discovery/sensors/temperatures/hpblmos.inc.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/discovery/sensors/power/hpblmos.inc.php b/includes/discovery/sensors/power/hpblmos.inc.php index df8d87df93..7067af91ae 100644 --- a/includes/discovery/sensors/power/hpblmos.inc.php +++ b/includes/discovery/sensors/power/hpblmos.inc.php @@ -2,7 +2,6 @@ if ($device['os'] == 'hpblmos') { $sensor_type = 'hpblmos_psu_usage'; - //$psu_exists_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16.'; $psu_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16'; $psu_usage_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.10.'; $psu_max_usage_oid = '.1.3.6.1.4.1.232.22.2.5.1.1.1.9.'; @@ -25,4 +24,4 @@ if ($device['os'] == 'hpblmos') { } } } -} \ No newline at end of file +} diff --git a/includes/discovery/sensors/temperatures/hpblmos.inc.php b/includes/discovery/sensors/temperatures/hpblmos.inc.php index d0b733321b..e5c74fd2b4 100644 --- a/includes/discovery/sensors/temperatures/hpblmos.inc.php +++ b/includes/discovery/sensors/temperatures/hpblmos.inc.php @@ -3,7 +3,6 @@ if ($device['os'] == 'hpblmos') { $sensor_type = 'hpblmos_temps'; $temps_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5'; - //$sensor_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.5.'; $sensor_value_oid = '.1.3.6.1.4.1.232.22.2.3.1.2.1.6.'; $temps = trim(snmp_walk($device, $temps_oid, '-Osqn')); @@ -23,4 +22,4 @@ if ($device['os'] == 'hpblmos') { } } } -} \ No newline at end of file +} From 370fab065a808ea9d9ffb0a13160ac784ed9ac91 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 16 Aug 2016 09:55:00 +0300 Subject: [PATCH 27/44] fix not set --- includes/discovery/sensors/power/hpblmos.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/sensors/power/hpblmos.inc.php b/includes/discovery/sensors/power/hpblmos.inc.php index 7067af91ae..366244171d 100644 --- a/includes/discovery/sensors/power/hpblmos.inc.php +++ b/includes/discovery/sensors/power/hpblmos.inc.php @@ -17,7 +17,7 @@ if ($device['os'] == 'hpblmos') { $current_id = $split_oid[(count($split_oid) - 1)]; $current_oid = $psu_usage_oid.$current_id; $psu_max_oid = $psu_max_usage_oid.$current_id; - $descr = 'PSU '.$psuid.' output'; + $descr = 'PSU '.$current_id.' output'; $value = snmp_get($device, $current_oid, '-Oqv'); $max_value = snmp_get($device, $psu_max_oid, '-Oqv'); discover_sensor($valid['sensor'], 'power', $device, $current_oid, $current_id, $sensor_type, $descr, 1, 1, null, null, null, $max_value, $value); From 08460ba3c960a2fb8e9ce222fcee4aac8d1dc53d Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Tue, 16 Aug 2016 10:48:33 -0300 Subject: [PATCH 28/44] Added unbound unix agent script --- scripts/unbound.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 scripts/unbound.sh diff --git a/scripts/unbound.sh b/scripts/unbound.sh new file mode 100755 index 0000000000..d9b378892e --- /dev/null +++ b/scripts/unbound.sh @@ -0,0 +1,8 @@ +#!/bin/bash +unboundctl=`which unbound-control` +if [ "$?" != "0" ]; then +#Unbound control executable doesn't exist +exit +fi +echo '<<>>' +$unboundctl stats From 1f15bc64863977bef23330dc6db70e32c8d81def Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Tue, 16 Aug 2016 10:48:57 -0300 Subject: [PATCH 29/44] Adeed unbound App setup docs --- doc/Extensions/Applications.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 4c0539d86b..c3c23456cd 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -168,6 +168,24 @@ extend memcached /usr/local/bin/memcached 4. Restart snmpd on your host 5. On the device page in Librenms, edit your host and check `Memcached` under the Applications tab. +### Unbound + +##### Agent +[Install the agent](#agent-setup) on this device if it isn't already and copy the `unbound.sh` script to `/usr/lib/check_mk_agent/local/` + +Unbound configuration: + +```text +# Enable extended statistics. +server: + statistics-interval: 0 + extended-statistics: yes + # set to yes if graphing tool needs it + statistics-cumulative: no +``` + +Restart your unbound after changing the configuration,v erify it is working by running /usr/lib/check_mk_agent/local/unbound.sh + Agent Setup ----------- From 40984943c0d35adc71a7b6bba9262b37a38964e1 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Tue, 16 Aug 2016 10:51:53 -0300 Subject: [PATCH 30/44] Added menu entry --- doc/Extensions/Applications.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index c3c23456cd..84bcd143b4 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -13,6 +13,7 @@ Different applications support a variety of ways collect data: by direct connect 7. [OS Updates](#os-updates) - extend SNMP 8. [DHCP Stats](#dhcp-stats) - extend SNMP 9. [Memcached](#memcached) - extend SNMP +10. [Unbound]($unbound) - Agent * [Agent Setup](#agent-setup) From cee72a4cd6f14f61276893e4fe60a7b6fc807cb8 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Tue, 16 Aug 2016 11:00:37 -0300 Subject: [PATCH 31/44] Fix tipo --- doc/Extensions/Applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 84bcd143b4..0b8551bbbf 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -13,7 +13,7 @@ Different applications support a variety of ways collect data: by direct connect 7. [OS Updates](#os-updates) - extend SNMP 8. [DHCP Stats](#dhcp-stats) - extend SNMP 9. [Memcached](#memcached) - extend SNMP -10. [Unbound]($unbound) - Agent +10. [Unbound](#unbound) - Agent * [Agent Setup](#agent-setup) From 4a152dab7bd3c053c951c2e2d26b2a1da9ff3279 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 16 Aug 2016 19:07:01 -0500 Subject: [PATCH 32/44] Fix rrdtool_check_rrd_exists() by removing the broken remote check. Maybe this can be re-implemented at a later time. --- includes/rrdtool.inc.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 48466b48f3..98c6810f24 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -210,20 +210,14 @@ function rrdtool($command, $filename, $options, $timeout = 0) /** * Checks if the rrd file exists on the server - * This will perform a remote check if using rrdcached and rrdtool >= 1.5 + * This will perform a remote check if using rrdcached and rrdtool >= 1.5 (broken) * * @param $filename * @return bool */ function rrdtool_check_rrd_exists($filename) { - global $config; - if ($config['rrdcached'] && version_compare($config['rrdtool_version'], '1.5', '>=')) { - $chk = rrdtool('last', $filename, '', 30); // wait up to 30 seconds - return strpos(implode($chk), "$filename': No such file or directory") === false; - } else { - return is_file($filename); - } + return is_file($filename); } /** From d16035e86ae499b5c571d02edf24b6fdd49fff99 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Thu, 2 Jun 2016 17:21:01 +1000 Subject: [PATCH 33/44] Added OS support for Cisco VCS (Expressway) Appliances. --- includes/definitions.inc.php | 5 +++++ includes/discovery/os/vcs.inc.php | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 includes/discovery/os/vcs.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index cefa22c034..600f13ba97 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -574,6 +574,11 @@ $config['os'][$os]['over'][4]['graph'] = 'device_ciscowlc_numclients'; $config['os'][$os]['over'][4]['text'] = 'Number of Clients'; $config['os'][$os]['icon'] = 'cisco'; +$os = 'vcs'; +$config['os'][$os]['text'] = 'Video Communication Server'; +$config['os'][$os]['type'] = 'collaboration'; +$config['os'][$os]['icon'] = 'cisco'; + $os = 'acano'; $config['os'][$os]['group'] = 'cisco'; $config['os'][$os]['text'] = 'Acano OS'; diff --git a/includes/discovery/os/vcs.inc.php b/includes/discovery/os/vcs.inc.php new file mode 100644 index 0000000000..9b00d82d49 --- /dev/null +++ b/includes/discovery/os/vcs.inc.php @@ -0,0 +1,7 @@ + Date: Thu, 2 Jun 2016 17:24:47 +1000 Subject: [PATCH 34/44] Added OS detection for Cisco Telepresence conductor devices --- includes/definitions.inc.php | 5 +++++ includes/discovery/os/tpconductor.inc.php | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 includes/discovery/os/tpconductor.inc.php diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index cefa22c034..d69e4b4308 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -619,6 +619,11 @@ $config['os'][$os]['over'][1]['text'] = 'CPU Usage'; $config['os'][$os]['over'][2]['graph'] = 'device_mempool'; $config['os'][$os]['over'][2]['text'] = 'Memory Usage'; +$os = 'tpconductor'; +$config['os'][$os]['text'] = 'TelePresence Conductor'; +$config['os'][$os]['type'] = 'collaboration'; +$config['os'][$os]['icon'] = 'cisco'; + // Brocade NOS $os = 'nos'; $config['os'][$os]['text'] = 'Brocade NOS'; diff --git a/includes/discovery/os/tpconductor.inc.php b/includes/discovery/os/tpconductor.inc.php new file mode 100644 index 0000000000..1113080689 --- /dev/null +++ b/includes/discovery/os/tpconductor.inc.php @@ -0,0 +1,7 @@ + Date: Wed, 17 Aug 2016 11:28:17 +0200 Subject: [PATCH 35/44] Fix some minor Markdown URL issues & some whitespaces. --- doc/Installation/Installation-Nginx-(Debian-Ubuntu).md | 2 +- doc/Installation/Installation-Ubuntu-1604-Apache.md | 8 ++++---- doc/Installation/Installation-Ubuntu-1604-Nginx.md | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/Installation/Installation-Nginx-(Debian-Ubuntu).md b/doc/Installation/Installation-Nginx-(Debian-Ubuntu).md index 957d0a9706..d44288b29e 100644 --- a/doc/Installation/Installation-Nginx-(Debian-Ubuntu).md +++ b/doc/Installation/Installation-Nginx-(Debian-Ubuntu).md @@ -151,7 +151,7 @@ On at least Ubuntu 14.04 (and possibly other distributions and versions as well) Restart nginx: service nginx restart - + Restart php5-fpm: service php5-fpm restart diff --git a/doc/Installation/Installation-Ubuntu-1604-Apache.md b/doc/Installation/Installation-Ubuntu-1604-Apache.md index 7452ccf571..fd3e834290 100644 --- a/doc/Installation/Installation-Ubuntu-1604-Apache.md +++ b/doc/Installation/Installation-Ubuntu-1604-Apache.md @@ -143,10 +143,10 @@ We now suggest that you add localhost as your first device from within the WebUI Now that you've installed LibreNMS, we'd suggest that you have a read of a few other docs to get you going: - - (Performance tuning)[http://docs.librenms.org/Support/Performance] - - (Alerting)[http://docs.librenms.org/Extensions/Alerting/] - - (Device Groups)[http://docs.librenms.org/Extensions/Device-Groups/] - - (Auto discovery)[http://docs.librenms.org/Extensions/Auto-Discovery/] + - [Performance tuning](http://docs.librenms.org/Support/Performance) + - [Alerting](http://docs.librenms.org/Extensions/Alerting/) + - [Device Groups](http://docs.librenms.org/Extensions/Device-Groups/) + - [Auto discovery](http://docs.librenms.org/Extensions/Auto-Discovery/) #### Closing diff --git a/doc/Installation/Installation-Ubuntu-1604-Nginx.md b/doc/Installation/Installation-Ubuntu-1604-Nginx.md index 076dbb3515..93ae98c4c1 100644 --- a/doc/Installation/Installation-Ubuntu-1604-Nginx.md +++ b/doc/Installation/Installation-Ubuntu-1604-Nginx.md @@ -34,7 +34,7 @@ sql-mode="" ### Web Server ### -#### Install / Configure Nginx +#### Install / Configure Nginx `apt-get install php7.0-cli php7.0-mysql php7.0-gd php7.0-snmp php-pear php7.0-curl php7.0-fpm snmp graphviz php7.0-mcrypt php7.0-json nginx-full fping imagemagick whois mtr-tiny nmap python-mysqldb snmpd php-net-ipv4 php-net-ipv6 rrdtool git` @@ -146,10 +146,10 @@ We now suggest that you add localhost as your first device from within the WebUI Now that you've installed LibreNMS, we'd suggest that you have a read of a few other docs to get you going: - - (Performance tuning)[http://docs.librenms.org/Support/Performance] - - (Alerting)[http://docs.librenms.org/Extensions/Alerting/] - - (Device Groups)[http://docs.librenms.org/Extensions/Device-Groups/] - - (Auto discovery)[http://docs.librenms.org/Extensions/Auto-Discovery/] + - [Performance tuning](http://docs.librenms.org/Support/Performance) + - [Alerting](http://docs.librenms.org/Extensions/Alerting/) + - [Device Groups](http://docs.librenms.org/Extensions/Device-Groups/) + - [Auto discovery](http://docs.librenms.org/Extensions/Auto-Discovery/) #### Closing From 726ca2aa173732d73d270ef396e34e4f02a1ce8b Mon Sep 17 00:00:00 2001 From: Daniel van Dorp Date: Wed, 17 Aug 2016 11:42:46 +0200 Subject: [PATCH 36/44] 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 89c10735ae..e1a211348f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -117,6 +117,7 @@ LibreNMS contributors: - Maxence POULAIN (Linutux42) - Florian Beer (florianbeer) - Vladislav Solovei (vladsol) +- Daniel van Dorp (djvdorp) [1]: http://observium.org/ "Observium web site" Observium was written by: From 8e7d40c1213d5386ea4f696b92b7ed0d7d74ae56 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Wed, 17 Aug 2016 09:34:30 -0300 Subject: [PATCH 37/44] Removed comment and set default value to yes acording to poller --- doc/Extensions/Applications.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 0b8551bbbf..fd5f886268 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -181,8 +181,7 @@ Unbound configuration: server: statistics-interval: 0 extended-statistics: yes - # set to yes if graphing tool needs it - statistics-cumulative: no + statistics-cumulative: yes ``` Restart your unbound after changing the configuration,v erify it is working by running /usr/lib/check_mk_agent/local/unbound.sh From 9de3d430565260bf08ba6a9ac556b1490020e9d5 Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Wed, 17 Aug 2016 09:38:38 -0300 Subject: [PATCH 38/44] Fix unused variable --- includes/polling/applications/unbound.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php index 82cfc4d4eb..ebb044ae16 100644 --- a/includes/polling/applications/unbound.inc.php +++ b/includes/polling/applications/unbound.inc.php @@ -58,5 +58,4 @@ $fields = array ( ); $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -$status = true; unset($lines , $unbound, $rrd_name, $rrd_def, $fields, $tags); \ No newline at end of file From 3ec0b94ace38982aadd5fbc0b34a3a89b2b210df Mon Sep 17 00:00:00 2001 From: Alan Gregory Date: Wed, 17 Aug 2016 09:39:33 -0300 Subject: [PATCH 39/44] Moved unbound script to librenms agent repository --- scripts/unbound.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 scripts/unbound.sh diff --git a/scripts/unbound.sh b/scripts/unbound.sh deleted file mode 100755 index d9b378892e..0000000000 --- a/scripts/unbound.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -unboundctl=`which unbound-control` -if [ "$?" != "0" ]; then -#Unbound control executable doesn't exist -exit -fi -echo '<<>>' -$unboundctl stats From 2c3da4c3cb0426b96b3ccff7e7c1547de5f37ab7 Mon Sep 17 00:00:00 2001 From: Andreser Date: Wed, 17 Aug 2016 12:58:50 -0300 Subject: [PATCH 40/44] Update Configuration.md --- doc/Support/Configuration.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index c44fc9e9cc..47aed8f5cb 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -190,6 +190,11 @@ $config['overview_show_sysDescr'] = TRUE; ``` Enable or disable the sysDescr output for a device. +```php +$config['force_ip_to_sysname'] = false; +``` +When using IP addresses as a hostname you can instead represent the devices on the WebUI by its SNMP sysName resulting in an easier to read overview of your network. This would apply on networks where you don't have DNS records for most of your devices. + ```php $config['device_traffic_iftype'][] = '/loopback/'; ``` From f55c7ea53c3fb7f3cdca38eae91b88ce9f64fe9a Mon Sep 17 00:00:00 2001 From: vitalisator Date: Wed, 17 Aug 2016 21:06:10 +0200 Subject: [PATCH 41/44] add the missing array value --- includes/polling/unix-agent.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index d5fdd2104b..6456f205a3 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -59,6 +59,7 @@ if ($device['os_group'] == 'unix') { "mysql", "nginx", "powerdns", + "powerdns-recursor", "proxmox", "rrdcached", "tinydns"); From 67617d0d3d165c5468fc91155d38806ddd37da05 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 17 Aug 2016 20:22:51 +0100 Subject: [PATCH 42/44] Merged css changes into styles.css --- html/css/dark.css | 105 -------------------------------------------- html/css/light.css | 105 -------------------------------------------- html/css/mono.css | 105 -------------------------------------------- html/css/styles.css | 105 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 315 deletions(-) diff --git a/html/css/dark.css b/html/css/dark.css index ceae5fb09d..fd7f698a34 100644 --- a/html/css/dark.css +++ b/html/css/dark.css @@ -99,108 +99,3 @@ 100% { transform: rotate(360deg); transform: rotate(360deg); } } -.device-availability, .service-availability{ - color:#000000; - float:left; - width:166px; - height:64px; - margin:10px; - padding:8px; - border-radius:5px; - text-align:center; -} - -.device-availability.up, .service-availability.up { - border:1px solid #5CB85C; -} - -.device-availability.down, .service-availability.down { - border:1px solid #D9534F; -} - -.device-availability.warn, .service-availability.warn { - border:1px solid #FFB733; -} - -.availability-label { - float:right; - margin:-8px; -} - -.service-name-label { - float:left; - margin:-8px; -} - -.report-up { - color:#5CB85C; -} - -.report-warning { - color:#FFB733; -} - -.report-down { - color:#D9534F; -} - -.page-availability-title-left { - width:50%; - float:left; - height:40px; -} - -.page-availability-title-right { - width:50%; - float:left; - text-align:right; -} - -.page-availability-title { - font-size:18px; - font-weight: bold; -} - -.page-availability-report-select { - font-size:16px; - border:none; - font-weight:bold; - padding-right:10px; - margin-left:10px; -} - - -.page-availability-report-host { - float:right; - text-align:right; - padding-left:10px; -} - -.page-availability-report-service { - float:right; - text-align:right; -} - -.widget-availability { - float:left; - margin:2px; -} - -.widget-availability-host { - float:left; - margin-bottom: 10px; -} - -.widget-availability-service { - float:right; - margin-bottom: 10px; -} - -.label-font-border { - text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; - font-size: 10px; -} - -.label-font-border.label-border { - margin:0px 2px 0px 2px; -} \ No newline at end of file diff --git a/html/css/light.css b/html/css/light.css index c7acc29dd3..c82b3686db 100644 --- a/html/css/light.css +++ b/html/css/light.css @@ -95,108 +95,3 @@ 100% { transform: rotate(360deg); transform: rotate(360deg); } } -.device-availability, .service-availability{ - color:#000000; - float:left; - width:166px; - height:64px; - margin:10px; - padding:8px; - border-radius:5px; - text-align:center; -} - -.device-availability.up, .service-availability.up { - border:1px solid #5CB85C; -} - -.device-availability.down, .service-availability.down { - border:1px solid #D9534F; -} - -.device-availability.warn, .service-availability.warn { - border:1px solid #FFB733; -} - -.availability-label { - float:right; - margin:-8px; -} - -.service-name-label { - float:left; - margin:-8px; -} - -.report-up { - color:#5CB85C; -} - -.report-warning { - color:#FFB733; -} - -.report-down { - color:#D9534F; -} - -.page-availability-title-left { - width:50%; - float:left; - height:40px; -} - -.page-availability-title-right { - width:50%; - float:left; - text-align:right; -} - -.page-availability-title { - font-size:18px; - font-weight: bold; -} - -.page-availability-report-select { - font-size:16px; - border:none; - font-weight:bold; - padding-right:10px; - margin-left:10px; -} - - -.page-availability-report-host { - float:right; - text-align:right; - padding-left:10px; -} - -.page-availability-report-service { - float:right; - text-align:right; -} - -.widget-availability { - float:left; - margin:2px; -} - -.widget-availability-host { - float:left; - margin-bottom: 10px; -} - -.widget-availability-service { - float:right; - margin-bottom: 10px; -} - -.label-font-border { - text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; - font-size: 10px; -} - -.label-font-border.label-border { - margin:0px 2px 0px 2px; -} \ No newline at end of file diff --git a/html/css/mono.css b/html/css/mono.css index 84c80c6a9d..d932a2ca08 100644 --- a/html/css/mono.css +++ b/html/css/mono.css @@ -99,108 +99,3 @@ 100% { transform: rotate(360deg); transform: rotate(360deg); } } -.device-availability, .service-availability{ - color:#000000; - float:left; - width:166px; - height:64px; - margin:10px; - padding:8px; - border-radius:5px; - text-align:center; -} - -.device-availability.up, .service-availability.up { - border:1px solid #5CB85C; -} - -.device-availability.down, .service-availability.down { - border:1px solid #D9534F; -} - -.device-availability.warn, .service-availability.warn { - border:1px solid #FFB733; -} - -.availability-label { - float:right; - margin:-8px; -} - -.service-name-label { - float:left; - margin:-8px; -} - -.report-up { - color:#5CB85C; -} - -.report-warning { - color:#FFB733; -} - -.report-down { - color:#D9534F; -} - -.page-availability-title-left { - width:50%; - float:left; - height:40px; -} - -.page-availability-title-right { - width:50%; - float:left; - text-align:right; -} - -.page-availability-title { - font-size:18px; - font-weight: bold; -} - -.page-availability-report-select { - font-size:16px; - border:none; - font-weight:bold; - padding-right:10px; - margin-left:10px; -} - - -.page-availability-report-host { - float:right; - text-align:right; - padding-left:10px; -} - -.page-availability-report-service { - float:right; - text-align:right; -} - -.widget-availability { - float:left; - margin:2px; -} - -.widget-availability-host { - float:left; - margin-bottom: 10px; -} - -.widget-availability-service { - float:right; - margin-bottom: 10px; -} - -.label-font-border { - text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; - font-size: 10px; -} - -.label-font-border.label-border { - margin:0px 2px 0px 2px; -} \ No newline at end of file diff --git a/html/css/styles.css b/html/css/styles.css index e30ff97963..42ffd5c546 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1871,3 +1871,108 @@ label { width: 100%; height: calc(100% - 35px); } + +.device-availability, .service-availability { + color:#000000; + float:left; + width:166px; + height:64px; + margin:10px; + padding:8px; + border-radius:5px; + text-align:center; +} + +.device-availability.up, .service-availability.up { + border:1px solid #5CB85C; +} + +.device-availability.down, .service-availability.down { + border:1px solid #D9534F; +} + +.device-availability.warn, .service-availability.warn { + border:1px solid #FFB733; +} + +.availability-label { + float:right; + margin:-8px; +} + +.service-name-label { + float:left; + margin:-8px; +} + +.report-up { + color:#5CB85C; +} + +.report-warning { + color:#FFB733; +} + +.report-down { + color:#D9534F; +} + +.page-availability-title-left { + width:50%; + float:left; + height:40px; +} + +.page-availability-title-right { + width:50%; + float:left; + text-align:right; +} + +.page-availability-title { + font-size:18px; + font-weight: bold; +} + +.page-availability-report-select { + font-size:16px; + border:none; + font-weight:bold; + padding-right:10px; + margin-left:10px; +} + +.page-availability-report-host { + float:right; + text-align:right; + padding-left:10px; +} + +.page-availability-report-service { + float:right; + text-align:right; +} + +.widget-availability { + float:left; + margin:2px; +} + +.widget-availability-host { + float:left; + margin-bottom: 10px; +} + +.widget-availability-service { + float:right; + margin-bottom: 10px; +} + +.label-font-border { + text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; + font-size: 10px; +} + +.label-font-border.label-border { + margin:0px 2px 0px 2px; +} From a61c1b2ebf316e0b31d0521fabb28bf1bcc3c628 Mon Sep 17 00:00:00 2001 From: Florian Beer Date: Wed, 17 Aug 2016 21:48:32 +0200 Subject: [PATCH 43/44] Add snmp polling capability for Proxmox --- doc/Extensions/Applications.md | 11 +++++++++++ includes/polling/applications/proxmox.inc.php | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index fd5f886268..910194430c 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -14,6 +14,7 @@ Different applications support a variety of ways collect data: by direct connect 8. [DHCP Stats](#dhcp-stats) - extend SNMP 9. [Memcached](#memcached) - extend SNMP 10. [Unbound](#unbound) - Agent +11. [Proxmox](#proxmos) - extend SNMP * [Agent Setup](#agent-setup) @@ -186,6 +187,16 @@ server: Restart your unbound after changing the configuration,v erify it is working by running /usr/lib/check_mk_agent/local/unbound.sh +### Proxmox +1. Download the script onto the desired host (the host must be added to LibreNMS devices) +`wget https://github.com/librenms/librenms-agent/blob/master/agent-local/proxmox -o /usr/local/bin/proxmox` +2. Make the script executable: `chmod +x /usr/local/proxmox` +3. Edit your snmpd.conf file (usually `/etc/snmp/snmpd.conf`) and add: +`extend proxmox /usr/local/bin/proxmox` +(Note: if your snmpd doesn't run as root, you might have to invoke the script using sudo. `extend proxmox /usr/bin/sudo /usr/local/bin/proxmox`) +4. Restart snmpd on your host +5. On the device page in Librenms, edit your host and check `Proxmox` on the Applications tab. + Agent Setup ----------- diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php index c11bdb1aa4..7f783a3b0c 100644 --- a/includes/polling/applications/proxmox.inc.php +++ b/includes/polling/applications/proxmox.inc.php @@ -40,6 +40,15 @@ $app_id = $app['app_id']; if (isset($config['enable_proxmox']) && $config['enable_proxmox'] && !empty($agent_data['app'][$name])) { $proxmox = $agent_data['app'][$name]; +} elseif (isset($config['enable_proxmox']) && $config['enable_proxmox']) { + $options = '-O qv'; + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.112.114.111.120.109.111.120'; + $proxmox = snmp_get($device, $oid, $options); + $proxmox = preg_replace('/^.+\n/', '', $proxmox); + $proxmox = str_replace("<<>>\n", '', $proxmox); +} + +if ($proxmox) { $pmxlines = explode("\n", $proxmox); $pmxcluster = array_shift($pmxlines); dbUpdate(array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster), From 809969efc91e062bfd6160c7972351f4c630c13b Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Wed, 17 Aug 2016 21:27:56 +0100 Subject: [PATCH 44/44] Revert "Use namespaces for classes" --- html/includes/collectd/CollectdColor.php | 109 -------------------- html/includes/collectd/functions.php | 121 +++++++++++++++++++++-- html/includes/plugins.inc.php | 11 +-- html/index.php | 2 - html/plugins/Test/Test.php | 2 - 5 files changed, 113 insertions(+), 132 deletions(-) delete mode 100644 html/includes/collectd/CollectdColor.php diff --git a/html/includes/collectd/CollectdColor.php b/html/includes/collectd/CollectdColor.php deleted file mode 100644 index 1ea18d2e0d..0000000000 --- a/html/includes/collectd/CollectdColor.php +++ /dev/null @@ -1,109 +0,0 @@ -r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; - } - - if (isset($value['g'])) { - $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; - } - - if (isset($value['b'])) { - $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; - } - } else { - if (is_string($value)) { - $matches = array(); - if ($value == 'random') { - $this->randomize(); - } else { - if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', - $value, $matches)) { - $this->r = (('0x' . $matches[1]) / 255.0); - $this->g = (('0x' . $matches[2]) / 255.0); - $this->b = (('0x' . $matches[3]) / 255.0); - } - } - } else { - if (is_a($value, 'CollectdColor')) { - $this->r = $value->r; - $this->g = $value->g; - $this->b = $value->b; - } - } - } - }//end if - - }//end __construct() - - - public function randomize() - { - $this->r = (rand(0, 255) / 255.0); - $this->g = (rand(0, 255) / 255.0); - $this->b = 0.0; - $min = 0.0; - $max = 1.0; - - if (($this->r + $this->g) < 1.0) { - $min = (1.0 - ($this->r + $this->g)); - } else { - $max = (2.0 - ($this->r + $this->g)); - } - - $this->b = ($min + ((rand(0, 255) / 255.0) * ($max - $min))); - - }//end randomize() - - - public function fade($bkgnd = null, $alpha = 0.25) - { - if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { - $bg_r = 1.0; - $bg_g = 1.0; - $bg_b = 1.0; - } else { - $bg_r = $bkgnd->r; - $bg_g = $bkgnd->g; - $bg_b = $bkgnd->b; - } - - $this->r = ($alpha * $this->r + ((1.0 - $alpha) * $bg_r)); - $this->g = ($alpha * $this->g + ((1.0 - $alpha) * $bg_g)); - $this->b = ($alpha * $this->b + ((1.0 - $alpha) * $bg_b)); - - }//end fade() - - - public function toArray() - { - return array( - 'r' => $this->r, - 'g' => $this->g, - 'b' => $this->b, - ); - - }//end as_array() - - - public function toString() - { - $r = (int)($this->r * 255); - $g = (int)($this->g * 255); - $b = (int)($this->b * 255); - return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); - - } -} diff --git a/html/includes/collectd/functions.php b/html/includes/collectd/functions.php index 7c945a4332..e0cad177b4 100644 --- a/html/includes/collectd/functions.php +++ b/html/includes/collectd/functions.php @@ -1,4 +1,5 @@ * @@ -16,10 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -require 'includes/collectd/CollectdColor.php'; - -use LibreNMS\CollectdColor; - define('REGEXP_HOST', '/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/'); define('REGEXP_PLUGIN', '/^[a-zA-Z0-9_.-]+$/'); @@ -371,6 +368,112 @@ function collectd_flush($identifier) { }//end collectd_flush() + +class CollectdColor { + + private $r = 0; + + private $g = 0; + + private $b = 0; + + + function __construct($value=null) { + if (is_null($value)) { + } + else if (is_array($value)) { + if (isset($value['r'])) { + $this->r = $value['r'] > 0 ? ($value['r'] > 1 ? 1 : $value['r']) : 0; + } + + if (isset($value['g'])) { + $this->g = $value['g'] > 0 ? ($value['g'] > 1 ? 1 : $value['g']) : 0; + } + + if (isset($value['b'])) { + $this->b = $value['b'] > 0 ? ($value['b'] > 1 ? 1 : $value['b']) : 0; + } + } + else if (is_string($value)) { + $matches = array(); + if ($value == 'random') { + $this->randomize(); + } + else if (preg_match('/([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])([0-9A-Fa-f][0-9A-Fa-f])/', $value, $matches)) { + $this->r = (('0x'.$matches[1]) / 255.0); + $this->g = (('0x'.$matches[2]) / 255.0); + $this->b = (('0x'.$matches[3]) / 255.0); + } + } + else if (is_a($value, 'CollectdColor')) { + $this->r = $value->r; + $this->g = $value->g; + $this->b = $value->b; + }//end if + + }//end __construct() + + + function randomize() { + $this->r = (rand(0, 255) / 255.0); + $this->g = (rand(0, 255) / 255.0); + $this->b = 0.0; + $min = 0.0; + $max = 1.0; + + if (($this->r + $this->g) < 1.0) { + $min = (1.0 - ($this->r + $this->g)); + } + else { + $max = (2.0 - ($this->r + $this->g)); + } + + $this->b = ($min + ((rand(0, 255) / 255.0) * ($max - $min))); + + }//end randomize() + + + function fade($bkgnd=null, $alpha=0.25) { + if (is_null($bkgnd) || !is_a($bkgnd, 'CollectdColor')) { + $bg_r = 1.0; + $bg_g = 1.0; + $bg_b = 1.0; + } + else { + $bg_r = $bkgnd->r; + $bg_g = $bkgnd->g; + $bg_b = $bkgnd->b; + } + + $this->r = ($alpha * $this->r + ((1.0 - $alpha) * $bg_r)); + $this->g = ($alpha * $this->g + ((1.0 - $alpha) * $bg_g)); + $this->b = ($alpha * $this->b + ((1.0 - $alpha) * $bg_b)); + + }//end fade() + + + function as_array() { + return array( + 'r' => $this->r, + 'g' => $this->g, + 'b' => $this->b, + ); + + }//end as_array() + + + function as_string() { + $r = (int) ($this->r * 255); + $g = (int) ($this->g * 255); + $b = (int) ($this->b * 255); + return sprintf('%02x%02x%02x', $r > 255 ? 255 : $r, $g > 255 ? 255 : $g, $b > 255 ? 255 : $b); + + }//end as_string() + + +}//end class + + /** * Helper function to strip quotes from RRD output * @str RRD-Info generated string @@ -461,8 +564,8 @@ function rrd_get_color($code, $line=true) { $c_f = new CollectdColor('random'); $c_h = new CollectdColor($c_f); $c_h->fade(); - $config['rrd_colors']['f_'.$code] = $c_f->toString(); - $config['rrd_colors']['h_'.$code] = $c_h->toString(); + $config['rrd_colors']['f_'.$code] = $c_f->as_string(); + $config['rrd_colors']['h_'.$code] = $c_h->as_string(); } return $config['rrd_colors'][$name]; @@ -849,8 +952,8 @@ function collectd_draw_meta_stack(&$opts, &$sources) { $area_color = new CollectdColor($line_color); $area_color->fade(); - $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->toString(); - $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->toString().':'.$legend; + $cmd[] = 'AREA:'.$inst_name.'_stk#'.$area_color->as_string(); + $cmd[] = 'LINE1:'.$inst_name.'_stk#'.$line_color->as_string().':'.$legend; if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { $cmd[] = 'GPRINT:'.$inst_name.'_avg:LAST:'.$number_format.''; $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; @@ -969,7 +1072,7 @@ function collectd_draw_meta_line(&$opts, &$sources) { $line_color = new CollectdColor('random'); } - $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->toString().':'.$legend; + $cmd[] = 'LINE1:'.$inst_name.'_avg#'.$line_color->as_string().':'.$legend; if (!(isset($opts['tinylegend']) && $opts['tinylegend'])) { $cmd[] = 'GPRINT:'.$inst_name.'_min:MIN:'.$number_format.''; $cmd[] = 'GPRINT:'.$inst_name.'_avg:AVERAGE:'.$number_format.''; diff --git a/html/includes/plugins.inc.php b/html/includes/plugins.inc.php index e52015b199..a10762c5cf 100644 --- a/html/includes/plugins.inc.php +++ b/html/includes/plugins.inc.php @@ -1,7 +1,5 @@