From 708e0534bbbdd62ca107b952a96b9a349c49d4c0 Mon Sep 17 00:00:00 2001 From: HenocKA Date: Wed, 16 Mar 2016 17:16:56 +0100 Subject: [PATCH 01/41] adding sql --- sql-schema/110.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sql-schema/110.sql diff --git a/sql-schema/110.sql b/sql-schema/110.sql new file mode 100644 index 0000000000..d097dec110 --- /dev/null +++ b/sql-schema/110.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); \ No newline at end of file From 4245f06892187ad7a79b577f593f41485ea78ab3 Mon Sep 17 00:00:00 2001 From: HenocKA Date: Wed, 16 Mar 2016 17:17:16 +0100 Subject: [PATCH 02/41] adding route for vrf lite --- includes/defaults.inc.php | 3 + includes/discovery/route.inc.php | 173 +++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 includes/discovery/route.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 2f01dc6bca..b515f3d489 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -440,6 +440,8 @@ $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; // Enable VRF lite cisco +$config['enable_route'] = 1; +// Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support $config['enable_sla'] = 0; @@ -727,6 +729,7 @@ $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['cisco-vrf-lite'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; +$config['discovery_modules']['route'] = 1; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; diff --git a/includes/discovery/route.inc.php b/includes/discovery/route.inc.php new file mode 100644 index 0000000000..8495da4982 --- /dev/null +++ b/includes/discovery/route.inc.php @@ -0,0 +1,173 @@ + and Mathieu Millet + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + +//This file is a litle diferent, because the route depend of the vrf, not of the context, +//like the others, so if i use the context, you will have the same information n time the context how have the same VRF +global $debug; + +if ($config['enable_route']) { + $ids = array(); + + // For the moment only will be cisco and the version 3 + if ($device['os_group'] == "cisco") { + + echo ("ROUTE : "); + //RFC1213-MIB + $mib = "RFC1213-MIB"; + //IpRouteEntry + $vrfs_lite_cisco = array(); + + if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco']) != 0)) { + + //i will only get one context of vrf, read the begin of this file + foreach ($device['vrf_lite_cisco'] as $vrf_lite) { + if (!key_exists($vrf_lite['vrf_name'], $vrfs_lite_cisco)) { + $vrfs_lite_cisco[$vrf_lite['vrf_name']] = $vrf_lite; + } + } + } + else { + $vrfs_lite_cisco = array(array('context_name' => null)); + } + + $tableRoute = array(); + + foreach ($vrfs_lite_cisco as $vrf_lite) { + $device['context_name'] = $vrf_lite['context_name']; + + ////////////////ipRouteDest////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.1'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteDest) { + list($ip, $value) = explode(" ", $ipRouteDest); + $tableRoute[$ip]['ipRouteDest'] = $value; + } + + /////////////////ipRouteIfIndex////////////// + $oid = '.1.3.6.1.2.1.4.21.1.2'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteIfIndex) { + list($ip, $value) = explode(" ", $ipRouteIfIndex); + $tableRoute[$ip]['ipRouteIfIndex'] = $value; + } + + ///////////////ipRouteMetric1/////////////// + $oid = '.1.3.6.1.2.1.4.21.1.3'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteMetric) { + list($ip, $value) = explode(" ", $ipRouteMetric); + $tableRoute[$ip]['ipRouteMetric'] = $value; + } + + ////////////ipRouteNextHop////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.7'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + foreach (explode("\n", $resultHelp) as $ipRouteNextHop) { + list($ip, $value) = explode(" ", $ipRouteNextHop); + $tableRoute[$ip]['ipRouteNextHop'] = $value; + } + + ////////////ipRouteType///////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.8'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteType) { + list($ip, $value) = explode(" ", $ipRouteType); + $tableRoute[$ip]['ipRouteType'] = $value; + } + + ///////////ipRouteProto////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.9'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + + foreach (explode("\n", $resultHelp) as $ipRouteProto) { + list($ip, $value) = explode(" ", $ipRouteProto); + $tableRoute[$ip]['ipRouteProto'] = $value; + } + + /* + ///////////ipRouteAge////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.10'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteAge) { + list($ip,$value)=explode(" ",$ipRouteAge); + $tableRoute[$ip]['ipRouteAge']=$value; + } */ + + ///////////ipRouteMask////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.11'; + $resultHelp = snmp_walk($device, $oid, "-Osqn -Ln", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteMask) { + list($ip, $value) = explode(" ", $ipRouteMask); + $tableRoute[$ip]['ipRouteMask'] = $value; + } + + if ($debug) { + echo 'Table routage'; + var_dump($tableRoute); + } + + foreach ($tableRoute as $ipRoute) { + if (empty($ipRoute['ipRouteDest']) || $ipRoute['ipRouteDest'] == '') { + continue; + } + + $oldRouteRow = dbFetchRow('select * from route where device_id = ? AND ipRouteDest = ? AND context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + if (!empty($oldRouteRow)) { + unset($oldRouteRow['discoveredAt']); + $changeRoute = array(); + foreach ($ipRoute as $key => $value) { + if ($oldRouteRow[$key] != $value) { + $changeRoute[$key] = $value; + } + } + if (!empty($changeRoute)) { + dbUpdate($changeRoute, 'route', 'device_id = ? and ipRouteDest = ? and context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + } + } else { + + $toInsert = array_merge($ipRoute, array('device_id' => $device['device_id'], 'context_name' => $device['context_name'], 'discoveredAt' => time())); + dbInsert($toInsert, 'route'); + } + } + // unset($tableRoute); + } + + unset($vrfs_lite_cisco); + } +} From b9332fad892fa6f94242f7d5f3b677f67948c90e Mon Sep 17 00:00:00 2001 From: thecityofguanyu Date: Fri, 1 Apr 2016 16:29:58 -0500 Subject: [PATCH 03/41] modified: includes/discovery/mempools/ironware-dyn.inc.php modified: includes/polling/mempools/ironware-dyn.inc.php --- .../discovery/mempools/ironware-dyn.inc.php | 46 ++++++++++++++++--- .../polling/mempools/ironware-dyn.inc.php | 39 ++++++++++++++-- 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/includes/discovery/mempools/ironware-dyn.inc.php b/includes/discovery/mempools/ironware-dyn.inc.php index 97934dc724..8f8966ef04 100644 --- a/includes/discovery/mempools/ironware-dyn.inc.php +++ b/includes/discovery/mempools/ironware-dyn.inc.php @@ -1,11 +1,45 @@ $entry) { + + d_echo($index.' '.$entry['snAgentBrdMainBrdDescription'].' -> '.$entry['snAgentBrdMemoryUtil100thPercent']."\n"); + + $usage_oid = '.1.3.6.1.4.1.1991.1.1.2.2.1.1.28.'.$index; + $descr = $entry['snAgentBrdMainBrdDescription']; + $usage = ($entry['snAgentBrdMemoryUtil100thPercent'] / 100); + if (!strstr($descr, 'No') && !strstr($usage, 'No') && $descr != '') { + discover_mempool($valid_mempool, $device, $index, 'ironware-dyn', $descr, '1', null, null); + } //end_if + } //end_foreach + } //end_if + } //end_else +} //end_if + + - if (is_numeric($percent)) { - discover_mempool($valid_mempool, $device, 0, 'ironware-dyn', 'Dynamic Memory', '1', null, null); - } -} diff --git a/includes/polling/mempools/ironware-dyn.inc.php b/includes/polling/mempools/ironware-dyn.inc.php index ed315eff8f..c3dea7b688 100644 --- a/includes/polling/mempools/ironware-dyn.inc.php +++ b/includes/polling/mempools/ironware-dyn.inc.php @@ -1,7 +1,36 @@ Date: Tue, 12 Apr 2016 14:44:11 +0200 Subject: [PATCH 04/41] Update defaults.inc.php --- includes/defaults.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index b515f3d489..4b792016b3 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -440,7 +440,7 @@ $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; // Enable VRF lite cisco -$config['enable_route'] = 1; +$config['enable_route'] = 0; // Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support From 362bcd43539e09bd575a2d249f8256ba245b1e2f Mon Sep 17 00:00:00 2001 From: wiad Date: Tue, 12 Apr 2016 19:16:15 +0200 Subject: [PATCH 05/41] add config option for typeahead limit --- html/includes/common/generic-graph.inc.php | 5 +++++ html/includes/print-menubar.php | 3 +++ includes/defaults.inc.php | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index 038154e5c0..c7425d5a06 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -204,6 +204,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_device.ttAdapter(), + limit: '.$config['typeahead_limit'].', async: false, templates: { header: "
 Devices
", @@ -240,6 +241,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_port.ttAdapter(), + limit: '.$config['typeahead_limit'].', async: false, templates: { header: "
 Ports
", @@ -275,6 +277,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_application.ttAdapter(), + limit: '.$config['typeahead_limit'].', async: false, templates: { header: "
 Applications
", @@ -312,6 +315,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_munin.ttAdapter(), + limit: '.$config['typeahead_limit'].', async: false, templates: { header: "
 Munin
", @@ -346,6 +350,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_bill.ttAdapter(), + limit: '.$config['typeahead_limit'].', async: false, templates: { header: "
 Bill
", diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index afc91e645f..3bccd65900 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -717,6 +717,7 @@ $('#gsearch').typeahead({ }, { source: devices.ttAdapter(), + limit: '', async: true, display: 'name', valueKey: 'name', @@ -727,6 +728,7 @@ $('#gsearch').typeahead({ }, { source: ports.ttAdapter(), + limit: '', async: true, display: 'name', valueKey: 'name', @@ -737,6 +739,7 @@ $('#gsearch').typeahead({ }, { source: bgp.ttAdapter(), + limit: '', async: true, display: 'name', valueKey: 'name', diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 3dac116ada..8d763310db 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -870,4 +870,7 @@ $config['ignore_unmapable_port'] = False; // InfluxDB default configuration $config['influxdb']['timeout'] = 0; -$config['influxdb']['verifySSL'] = false; \ No newline at end of file +$config['influxdb']['verifySSL'] = false; + +// Typeahead default configuration +$config['typeahead_limit'] = 5; From 52ad0b24abdc804f12aafcec3fc57985679df7de Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Wed, 13 Apr 2016 13:41:42 +0200 Subject: [PATCH 06/41] Added rudimentary support for Viprinet VPN routers. https://www.viprinet.com/de/support/downloads --- html/images/os/viprinet.png | Bin 0 -> 1180 bytes includes/definitions.inc.php | 11 + includes/discovery/os/viprinet.inc.php | 7 + .../discovery/processors/viprinet.inc.php | 14 + includes/polling/os/viprinet.inc.php | 6 + includes/polling/processors/viprinet.inc.php | 10 + mibs/VIPRINET-MIB | 831 ++++++++++++++++++ 7 files changed, 879 insertions(+) create mode 100644 html/images/os/viprinet.png create mode 100644 includes/discovery/os/viprinet.inc.php create mode 100644 includes/discovery/processors/viprinet.inc.php create mode 100644 includes/polling/os/viprinet.inc.php create mode 100644 includes/polling/processors/viprinet.inc.php create mode 100644 mibs/VIPRINET-MIB diff --git a/html/images/os/viprinet.png b/html/images/os/viprinet.png new file mode 100644 index 0000000000000000000000000000000000000000..363aacf7cbfe2ea56a15277b5ae67498d75e241b GIT binary patch literal 1180 zcmV;N1Y`S&P)X0ssI2@}HD^00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-#n4G1m+L1)Gh000C#Nkl0xG&0Pp zHkAs`DiYPI+S;a7REsA~^f2PAJ7P!cX=>qK8mZ@kdfQY3(qNjDfO7hZDNZ28{ z#Ae}AY4%ig+Kl{WsR~HJS*S9^vcnt3O$ZAaDx%^$+3!8S_rCZ0^Vx1Hm&@>$#wmDv zqpsXkRg`Z#w z6h$>~e5$HZ6veX4p@5Mq=>872o{>$*%S%?wX>%-{>9s%gt?f+!$Q29#@U@+P5?=_1 zg;XjXiHyYK3&X>= z%yFNos^<2_VzXlSrlLGXsGBq@%42uH>U!F+mCUc-uCAv6AirrovmQOO9(h@}Voq=V zl>>l{SLTX2O?q<$!>|>Cn_(-4t&sGvg~=u*X~ISFHBR!OAOI{Tl3oL#5!%xLER63) z?nELZ92ba2f8e-4EH>+9zbFhU@?0b`Qj1!rTYR50-}GO;f8)dN0Km@w8d@`{_ zNLU>dMTJGdz2$=gnH^ZjRKvr!_m|C;3nIB_ZT9&)SXV^^ic9BjxFau~?I!@%nuHT>NG03tB&$o!_c z&uk$+Nb+G>#(S(S-s6u(XDp0qgovfO2k?d?{d~;5-r6qK^9V&z)hye^jpG6oMG?^_ zl1oRGSVa)hwx9Ml@N7#3xXHv)SQJ!M8ydQGRQdE@zJK`d$^q_^jH+1}>$*|PNQmuL z*k)tzV%0&E<}J{hhmwBP;WQICvIh}&S&j>_9Oc1{XYl}{2d@k u6RNhX$a5$E6i#wG$?c%gbn*}HSjIm)Th)TK{j)s)0000 Date: Wed, 13 Apr 2016 14:01:38 +0200 Subject: [PATCH 07/41] Removed copy pasted text --- includes/polling/processors/viprinet.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/polling/processors/viprinet.inc.php b/includes/polling/processors/viprinet.inc.php index e03d81a54f..09b1e92b14 100644 --- a/includes/polling/processors/viprinet.inc.php +++ b/includes/polling/processors/viprinet.inc.php @@ -1,6 +1,5 @@ Date: Wed, 13 Apr 2016 14:04:14 +0200 Subject: [PATCH 08/41] Removed memory graph, because device does not provide information about total memory --- includes/definitions.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index e9c427a5cc..1b90c8e658 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -104,7 +104,6 @@ $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Device Traffic'; $config['os'][$os]['over'][1]['graph'] = 'device_processor'; $config['os'][$os]['over'][1]['text'] = 'Processor Usage'; -$config['os'][$os]['over'][2]['graph'] = 'device_ucd_memory'; $os = 'edgeos'; $config['os'][$os]['text'] = 'EdgeOS'; From fb350e6d73c5b04798fb846e05e9d3da7f13070b Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Wed, 13 Apr 2016 16:00:22 +0200 Subject: [PATCH 09/41] fixed nagios dhcp check (-H changed to -s) --- includes/services/check_dhcp.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 includes/services/check_dhcp.inc.php diff --git a/includes/services/check_dhcp.inc.php b/includes/services/check_dhcp.inc.php new file mode 100644 index 0000000000..1b865c8a47 --- /dev/null +++ b/includes/services/check_dhcp.inc.php @@ -0,0 +1,6 @@ + Date: Thu, 14 Apr 2016 12:07:56 +0200 Subject: [PATCH 10/41] Update sql --- sql-schema/115.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sql-schema/115.sql diff --git a/sql-schema/115.sql b/sql-schema/115.sql new file mode 100644 index 0000000000..d097dec110 --- /dev/null +++ b/sql-schema/115.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); \ No newline at end of file From 0153b7ba753592b8a7d25c3d5e8bd90135e86dec Mon Sep 17 00:00:00 2001 From: HenocKA Date: Thu, 14 Apr 2016 12:08:11 +0200 Subject: [PATCH 11/41] udpate discovery support --- doc/Support/Discovery Support.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/Support/Discovery Support.md b/doc/Support/Discovery Support.md index acba7527d5..e6ca0f713a 100644 --- a/doc/Support/Discovery Support.md +++ b/doc/Support/Discovery Support.md @@ -44,6 +44,7 @@ $config['discovery_modules']['processors'] = 1; $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; +$config['discovery_modules']['route'] = 1; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; @@ -84,6 +85,8 @@ $config['discovery_modules']['charge'] = 1; `ipv6-addresses`: IPv6 Address detection +`route`: Route detection + `sensors`: Sensor detection such as Temperature, Humidity, Voltages + More `storage`: Storage detection for hard disks From 2b1cd86e0354cc4bd0121a1d30c14274856cb8b2 Mon Sep 17 00:00:00 2001 From: Sawachier Date: Tue, 19 Apr 2016 14:33:13 +0200 Subject: [PATCH 12/41] Update defaults.inc.php --- includes/defaults.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 4b792016b3..b49accfe95 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -439,8 +439,6 @@ $config['enable_pseudowires'] = 1; $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; -// Enable VRF lite cisco -$config['enable_route'] = 0; // Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support @@ -729,7 +727,7 @@ $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['cisco-vrf-lite'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; -$config['discovery_modules']['route'] = 1; +$config['discovery_modules']['route'] = 0; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; @@ -869,3 +867,10 @@ $config['default_port_association_mode'] = 'ifIndex'; // Ignore ports which can't be mapped using a devices port_association_mode // See include/polling/ports.inc.php for a lenghty explanation. $config['ignore_unmapable_port'] = False; +<<<<<<< 0153b7ba753592b8a7d25c3d5e8bd90135e86dec +======= + +// InfluxDB default configuration +$config['influxdb']['timeout'] = 0; +$config['influxdb']['verifySSL'] = false; +>>>>>>> Update defaults.inc.php From e866cdedafbeb92eb18bedb0a526b3ded84eb636 Mon Sep 17 00:00:00 2001 From: Casey Schoonover Date: Tue, 19 Apr 2016 15:18:52 -0500 Subject: [PATCH 13/41] Added CPU temperature discovery/polling for DNOS --- .../sensors/temperatures/dnos.inc.php | 22 +++++++++++++++++++ includes/polling/temperatures/dnos.inc.php | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 includes/discovery/sensors/temperatures/dnos.inc.php create mode 100644 includes/polling/temperatures/dnos.inc.php diff --git a/includes/discovery/sensors/temperatures/dnos.inc.php b/includes/discovery/sensors/temperatures/dnos.inc.php new file mode 100644 index 0000000000..827e42056b --- /dev/null +++ b/includes/discovery/sensors/temperatures/dnos.inc.php @@ -0,0 +1,22 @@ + $t) { + $t = explode(' ',$t); + $oid = $t[0]; + $val = $t[1]; + + if (substr($oid, -1) == '1') { + // This code will only pull CPU temp for each stack member, but there is no reason why the additional values couldn't be graphed + $counter = $counter + 1; + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos', + 'Unit '.$counter.' CPU temperature', '1', '1', null, null, null, null, $val); + } + } +} diff --git a/includes/polling/temperatures/dnos.inc.php b/includes/polling/temperatures/dnos.inc.php new file mode 100644 index 0000000000..9ec0b6bbd4 --- /dev/null +++ b/includes/polling/temperatures/dnos.inc.php @@ -0,0 +1,20 @@ + $t) { + $t = explode(' ',$t); + $oid = $t[0]; + $val = $t[1]; + + + if (substr($oid, -1) == '1') { + $counter = $counter + 1; + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos', + 'Unit '.$counter.' CPU temperature', '1', '1', null, null, null, null, $val); + } + } +} From 814fe46e8ad8da76cb5ebffc2358bdce831d12cd Mon Sep 17 00:00:00 2001 From: HenocKA Date: Wed, 16 Mar 2016 17:16:56 +0100 Subject: [PATCH 14/41] adding sql --- sql-schema/115.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sql-schema/115.sql diff --git a/sql-schema/115.sql b/sql-schema/115.sql new file mode 100644 index 0000000000..6698221ab2 --- /dev/null +++ b/sql-schema/115.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); From f17f061beaa8863eb5371161e7f0158a6b512e1b Mon Sep 17 00:00:00 2001 From: HenocKA Date: Wed, 16 Mar 2016 17:17:16 +0100 Subject: [PATCH 15/41] adding route for vrf lite --- includes/defaults.inc.php | 3 + includes/discovery/route.inc.php | 173 +++++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 includes/discovery/route.inc.php diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index c99bfd6f63..8b53ef48f8 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -440,6 +440,8 @@ $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; // Enable VRF lite cisco +$config['enable_route'] = 1; +// Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support $config['enable_sla'] = 0; @@ -728,6 +730,7 @@ $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['cisco-vrf-lite'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; +$config['discovery_modules']['route'] = 1; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; diff --git a/includes/discovery/route.inc.php b/includes/discovery/route.inc.php new file mode 100644 index 0000000000..8495da4982 --- /dev/null +++ b/includes/discovery/route.inc.php @@ -0,0 +1,173 @@ + and Mathieu Millet + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + +//This file is a litle diferent, because the route depend of the vrf, not of the context, +//like the others, so if i use the context, you will have the same information n time the context how have the same VRF +global $debug; + +if ($config['enable_route']) { + $ids = array(); + + // For the moment only will be cisco and the version 3 + if ($device['os_group'] == "cisco") { + + echo ("ROUTE : "); + //RFC1213-MIB + $mib = "RFC1213-MIB"; + //IpRouteEntry + $vrfs_lite_cisco = array(); + + if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco']) != 0)) { + + //i will only get one context of vrf, read the begin of this file + foreach ($device['vrf_lite_cisco'] as $vrf_lite) { + if (!key_exists($vrf_lite['vrf_name'], $vrfs_lite_cisco)) { + $vrfs_lite_cisco[$vrf_lite['vrf_name']] = $vrf_lite; + } + } + } + else { + $vrfs_lite_cisco = array(array('context_name' => null)); + } + + $tableRoute = array(); + + foreach ($vrfs_lite_cisco as $vrf_lite) { + $device['context_name'] = $vrf_lite['context_name']; + + ////////////////ipRouteDest////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.1'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteDest) { + list($ip, $value) = explode(" ", $ipRouteDest); + $tableRoute[$ip]['ipRouteDest'] = $value; + } + + /////////////////ipRouteIfIndex////////////// + $oid = '.1.3.6.1.2.1.4.21.1.2'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteIfIndex) { + list($ip, $value) = explode(" ", $ipRouteIfIndex); + $tableRoute[$ip]['ipRouteIfIndex'] = $value; + } + + ///////////////ipRouteMetric1/////////////// + $oid = '.1.3.6.1.2.1.4.21.1.3'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteMetric) { + list($ip, $value) = explode(" ", $ipRouteMetric); + $tableRoute[$ip]['ipRouteMetric'] = $value; + } + + ////////////ipRouteNextHop////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.7'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + foreach (explode("\n", $resultHelp) as $ipRouteNextHop) { + list($ip, $value) = explode(" ", $ipRouteNextHop); + $tableRoute[$ip]['ipRouteNextHop'] = $value; + } + + ////////////ipRouteType///////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.8'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteType) { + list($ip, $value) = explode(" ", $ipRouteType); + $tableRoute[$ip]['ipRouteType'] = $value; + } + + ///////////ipRouteProto////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.9'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + + foreach (explode("\n", $resultHelp) as $ipRouteProto) { + list($ip, $value) = explode(" ", $ipRouteProto); + $tableRoute[$ip]['ipRouteProto'] = $value; + } + + /* + ///////////ipRouteAge////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.10'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteAge) { + list($ip,$value)=explode(" ",$ipRouteAge); + $tableRoute[$ip]['ipRouteAge']=$value; + } */ + + ///////////ipRouteMask////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.11'; + $resultHelp = snmp_walk($device, $oid, "-Osqn -Ln", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteMask) { + list($ip, $value) = explode(" ", $ipRouteMask); + $tableRoute[$ip]['ipRouteMask'] = $value; + } + + if ($debug) { + echo 'Table routage'; + var_dump($tableRoute); + } + + foreach ($tableRoute as $ipRoute) { + if (empty($ipRoute['ipRouteDest']) || $ipRoute['ipRouteDest'] == '') { + continue; + } + + $oldRouteRow = dbFetchRow('select * from route where device_id = ? AND ipRouteDest = ? AND context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + if (!empty($oldRouteRow)) { + unset($oldRouteRow['discoveredAt']); + $changeRoute = array(); + foreach ($ipRoute as $key => $value) { + if ($oldRouteRow[$key] != $value) { + $changeRoute[$key] = $value; + } + } + if (!empty($changeRoute)) { + dbUpdate($changeRoute, 'route', 'device_id = ? and ipRouteDest = ? and context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + } + } else { + + $toInsert = array_merge($ipRoute, array('device_id' => $device['device_id'], 'context_name' => $device['context_name'], 'discoveredAt' => time())); + dbInsert($toInsert, 'route'); + } + } + // unset($tableRoute); + } + + unset($vrfs_lite_cisco); + } +} From c0697be9347722df3ff48941f02d9fed07b0d911 Mon Sep 17 00:00:00 2001 From: jpasquie Date: Tue, 12 Apr 2016 14:44:11 +0200 Subject: [PATCH 16/41] Update defaults.inc.php --- includes/defaults.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 8b53ef48f8..a8ce29957c 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -440,7 +440,7 @@ $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; // Enable VRF lite cisco -$config['enable_route'] = 1; +$config['enable_route'] = 0; // Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support From 698576c022548130c7884068fb31f5ecefa2dd07 Mon Sep 17 00:00:00 2001 From: HenocKA Date: Thu, 14 Apr 2016 12:07:56 +0200 Subject: [PATCH 17/41] Update sql --- sql-schema/115.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-schema/115.sql b/sql-schema/115.sql index 6698221ab2..d097dec110 100644 --- a/sql-schema/115.sql +++ b/sql-schema/115.sql @@ -1,2 +1,2 @@ CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); +ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); \ No newline at end of file From 4f2eac074782cad191c2bf6028d1d7093b1b7877 Mon Sep 17 00:00:00 2001 From: HenocKA Date: Thu, 14 Apr 2016 12:08:11 +0200 Subject: [PATCH 18/41] udpate discovery support --- doc/Support/Discovery Support.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/Support/Discovery Support.md b/doc/Support/Discovery Support.md index acba7527d5..e6ca0f713a 100644 --- a/doc/Support/Discovery Support.md +++ b/doc/Support/Discovery Support.md @@ -44,6 +44,7 @@ $config['discovery_modules']['processors'] = 1; $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; +$config['discovery_modules']['route'] = 1; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; @@ -84,6 +85,8 @@ $config['discovery_modules']['charge'] = 1; `ipv6-addresses`: IPv6 Address detection +`route`: Route detection + `sensors`: Sensor detection such as Temperature, Humidity, Voltages + More `storage`: Storage detection for hard disks From 683d0617c7ac0f834f2661811a5cb06ccec10c26 Mon Sep 17 00:00:00 2001 From: Sawachier Date: Tue, 19 Apr 2016 14:33:13 +0200 Subject: [PATCH 19/41] Update defaults.inc.php --- includes/defaults.inc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a8ce29957c..b1650a5660 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -439,8 +439,6 @@ $config['enable_pseudowires'] = 1; $config['enable_vrfs'] = 1; // Enable VRFs $config['enable_vrf_lite_cisco'] = 1; -// Enable VRF lite cisco -$config['enable_route'] = 0; // Enable routes for VRF lite cisco $config['enable_printers'] = 0; // Enable Printer support @@ -730,7 +728,7 @@ $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['cisco-vrf-lite'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; -$config['discovery_modules']['route'] = 1; +$config['discovery_modules']['route'] = 0; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; @@ -874,3 +872,4 @@ $config['ignore_unmapable_port'] = False; // InfluxDB default configuration $config['influxdb']['timeout'] = 0; $config['influxdb']['verifySSL'] = false; + From 5ce6fcdef85c5945b7efece455180dbd50c4cfd2 Mon Sep 17 00:00:00 2001 From: Sawachier Date: Wed, 20 Apr 2016 10:46:38 +0200 Subject: [PATCH 20/41] Update Discovery Support.md --- doc/Support/Discovery Support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Support/Discovery Support.md b/doc/Support/Discovery Support.md index e6ca0f713a..3fad51b0a0 100644 --- a/doc/Support/Discovery Support.md +++ b/doc/Support/Discovery Support.md @@ -44,7 +44,7 @@ $config['discovery_modules']['processors'] = 1; $config['discovery_modules']['mempools'] = 1; $config['discovery_modules']['ipv4-addresses'] = 1; $config['discovery_modules']['ipv6-addresses'] = 1; -$config['discovery_modules']['route'] = 1; +$config['discovery_modules']['route'] = 0; $config['discovery_modules']['sensors'] = 1; $config['discovery_modules']['storage'] = 1; $config['discovery_modules']['hr-device'] = 1; From 960d45ee46a05d66e54d1ddd4d32775d2e7ac25b Mon Sep 17 00:00:00 2001 From: Sawachier Date: Wed, 20 Apr 2016 14:09:04 +0200 Subject: [PATCH 21/41] Update route.inc.php Change if condition --- includes/discovery/route.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/route.inc.php b/includes/discovery/route.inc.php index 8495da4982..a3a4fc4323 100644 --- a/includes/discovery/route.inc.php +++ b/includes/discovery/route.inc.php @@ -19,7 +19,7 @@ //like the others, so if i use the context, you will have the same information n time the context how have the same VRF global $debug; -if ($config['enable_route']) { +if ($config['discovery_modules']['route']) { $ids = array(); // For the moment only will be cisco and the version 3 From 6bdb8fc0964a0c84c208dd6dbdd8a610890b7edf Mon Sep 17 00:00:00 2001 From: Casey Schoonover Date: Wed, 20 Apr 2016 15:39:44 -0500 Subject: [PATCH 22/41] Removed includes/polling/temperatures/dnos.inc.php - polling script appears unnecessary --- includes/polling/temperatures/dnos.inc.php | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 includes/polling/temperatures/dnos.inc.php diff --git a/includes/polling/temperatures/dnos.inc.php b/includes/polling/temperatures/dnos.inc.php deleted file mode 100644 index 9ec0b6bbd4..0000000000 --- a/includes/polling/temperatures/dnos.inc.php +++ /dev/null @@ -1,20 +0,0 @@ - $t) { - $t = explode(' ',$t); - $oid = $t[0]; - $val = $t[1]; - - - if (substr($oid, -1) == '1') { - $counter = $counter + 1; - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $counter, 'dnos', - 'Unit '.$counter.' CPU temperature', '1', '1', null, null, null, null, $val); - } - } -} From af192da3979b57a3bd273f1bd23948bc9fc8349a Mon Sep 17 00:00:00 2001 From: Sawachier Date: Thu, 21 Apr 2016 09:17:20 +0200 Subject: [PATCH 23/41] Update route.inc.php --- includes/discovery/route.inc.php | 251 +++++++++++++++---------------- 1 file changed, 125 insertions(+), 126 deletions(-) diff --git a/includes/discovery/route.inc.php b/includes/discovery/route.inc.php index a3a4fc4323..c50e44af60 100644 --- a/includes/discovery/route.inc.php +++ b/includes/discovery/route.inc.php @@ -19,155 +19,154 @@ //like the others, so if i use the context, you will have the same information n time the context how have the same VRF global $debug; -if ($config['discovery_modules']['route']) { - $ids = array(); - // For the moment only will be cisco and the version 3 - if ($device['os_group'] == "cisco") { +$ids = array(); - echo ("ROUTE : "); - //RFC1213-MIB - $mib = "RFC1213-MIB"; - //IpRouteEntry - $vrfs_lite_cisco = array(); +// For the moment only will be cisco and the version 3 +if ($device['os_group'] == "cisco") { - if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco']) != 0)) { + echo ("ROUTE : "); + //RFC1213-MIB + $mib = "RFC1213-MIB"; + //IpRouteEntry + $vrfs_lite_cisco = array(); - //i will only get one context of vrf, read the begin of this file - foreach ($device['vrf_lite_cisco'] as $vrf_lite) { - if (!key_exists($vrf_lite['vrf_name'], $vrfs_lite_cisco)) { - $vrfs_lite_cisco[$vrf_lite['vrf_name']] = $vrf_lite; - } + if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco']) != 0)) { + + //i will only get one context of vrf, read the begin of this file + foreach ($device['vrf_lite_cisco'] as $vrf_lite) { + if (!key_exists($vrf_lite['vrf_name'], $vrfs_lite_cisco)) { + $vrfs_lite_cisco[$vrf_lite['vrf_name']] = $vrf_lite; } - } - else { - $vrfs_lite_cisco = array(array('context_name' => null)); + } + } + else { + $vrfs_lite_cisco = array(array('context_name' => null)); + } + + $tableRoute = array(); + + foreach ($vrfs_lite_cisco as $vrf_lite) { + $device['context_name'] = $vrf_lite['context_name']; + + ////////////////ipRouteDest////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.1'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + + foreach (explode("\n", $resultHelp) as $ipRouteDest) { + list($ip, $value) = explode(" ", $ipRouteDest); + $tableRoute[$ip]['ipRouteDest'] = $value; } - $tableRoute = array(); + /////////////////ipRouteIfIndex////////////// + $oid = '.1.3.6.1.2.1.4.21.1.2'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach ($vrfs_lite_cisco as $vrf_lite) { - $device['context_name'] = $vrf_lite['context_name']; + foreach (explode("\n", $resultHelp) as $ipRouteIfIndex) { + list($ip, $value) = explode(" ", $ipRouteIfIndex); + $tableRoute[$ip]['ipRouteIfIndex'] = $value; + } - ////////////////ipRouteDest////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.1'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); + ///////////////ipRouteMetric1/////////////// + $oid = '.1.3.6.1.2.1.4.21.1.3'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach (explode("\n", $resultHelp) as $ipRouteDest) { - list($ip, $value) = explode(" ", $ipRouteDest); - $tableRoute[$ip]['ipRouteDest'] = $value; - } + foreach (explode("\n", $resultHelp) as $ipRouteMetric) { + list($ip, $value) = explode(" ", $ipRouteMetric); + $tableRoute[$ip]['ipRouteMetric'] = $value; + } - /////////////////ipRouteIfIndex////////////// - $oid = '.1.3.6.1.2.1.4.21.1.2'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); + ////////////ipRouteNextHop////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.7'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); + foreach (explode("\n", $resultHelp) as $ipRouteNextHop) { + list($ip, $value) = explode(" ", $ipRouteNextHop); + $tableRoute[$ip]['ipRouteNextHop'] = $value; + } - foreach (explode("\n", $resultHelp) as $ipRouteIfIndex) { - list($ip, $value) = explode(" ", $ipRouteIfIndex); - $tableRoute[$ip]['ipRouteIfIndex'] = $value; - } + ////////////ipRouteType///////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.8'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); - ///////////////ipRouteMetric1/////////////// - $oid = '.1.3.6.1.2.1.4.21.1.3'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); + foreach (explode("\n", $resultHelp) as $ipRouteType) { + list($ip, $value) = explode(" ", $ipRouteType); + $tableRoute[$ip]['ipRouteType'] = $value; + } - foreach (explode("\n", $resultHelp) as $ipRouteMetric) { - list($ip, $value) = explode(" ", $ipRouteMetric); - $tableRoute[$ip]['ipRouteMetric'] = $value; - } - - ////////////ipRouteNextHop////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.7'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach (explode("\n", $resultHelp) as $ipRouteNextHop) { - list($ip, $value) = explode(" ", $ipRouteNextHop); - $tableRoute[$ip]['ipRouteNextHop'] = $value; - } - - ////////////ipRouteType///////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.8'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); - - foreach (explode("\n", $resultHelp) as $ipRouteType) { - list($ip, $value) = explode(" ", $ipRouteType); - $tableRoute[$ip]['ipRouteType'] = $value; - } - - ///////////ipRouteProto////////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.9'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); + ///////////ipRouteProto////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.9'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach (explode("\n", $resultHelp) as $ipRouteProto) { - list($ip, $value) = explode(" ", $ipRouteProto); - $tableRoute[$ip]['ipRouteProto'] = $value; - } + foreach (explode("\n", $resultHelp) as $ipRouteProto) { + list($ip, $value) = explode(" ", $ipRouteProto); + $tableRoute[$ip]['ipRouteProto'] = $value; + } - /* - ///////////ipRouteAge////////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.10'; - $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); - $resultHelp = str_replace("$oid.", "", $resultHelp); + /* + ///////////ipRouteAge////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.10'; + $resultHelp = snmp_walk($device, $oid, "-Osqn", $mib, NULL); + $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach (explode("\n", $resultHelp) as $ipRouteAge) { + foreach (explode("\n", $resultHelp) as $ipRouteAge) { list($ip,$value)=explode(" ",$ipRouteAge); $tableRoute[$ip]['ipRouteAge']=$value; - } */ + } */ - ///////////ipRouteMask////////////////////// - $oid = '.1.3.6.1.2.1.4.21.1.11'; - $resultHelp = snmp_walk($device, $oid, "-Osqn -Ln", $mib, NULL); - $resultHelp = trim($resultHelp); - $resultHelp = str_replace("$oid.", "", $resultHelp); + ///////////ipRouteMask////////////////////// + $oid = '.1.3.6.1.2.1.4.21.1.11'; + $resultHelp = snmp_walk($device, $oid, "-Osqn -Ln", $mib, NULL); + $resultHelp = trim($resultHelp); + $resultHelp = str_replace("$oid.", "", $resultHelp); - foreach (explode("\n", $resultHelp) as $ipRouteMask) { - list($ip, $value) = explode(" ", $ipRouteMask); - $tableRoute[$ip]['ipRouteMask'] = $value; - } - - if ($debug) { - echo 'Table routage'; - var_dump($tableRoute); - } - - foreach ($tableRoute as $ipRoute) { - if (empty($ipRoute['ipRouteDest']) || $ipRoute['ipRouteDest'] == '') { - continue; - } - - $oldRouteRow = dbFetchRow('select * from route where device_id = ? AND ipRouteDest = ? AND context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); - if (!empty($oldRouteRow)) { - unset($oldRouteRow['discoveredAt']); - $changeRoute = array(); - foreach ($ipRoute as $key => $value) { - if ($oldRouteRow[$key] != $value) { - $changeRoute[$key] = $value; - } - } - if (!empty($changeRoute)) { - dbUpdate($changeRoute, 'route', 'device_id = ? and ipRouteDest = ? and context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); - } - } else { - - $toInsert = array_merge($ipRoute, array('device_id' => $device['device_id'], 'context_name' => $device['context_name'], 'discoveredAt' => time())); - dbInsert($toInsert, 'route'); - } - } - // unset($tableRoute); + foreach (explode("\n", $resultHelp) as $ipRouteMask) { + list($ip, $value) = explode(" ", $ipRouteMask); + $tableRoute[$ip]['ipRouteMask'] = $value; } - unset($vrfs_lite_cisco); + if ($debug) { + echo 'Table routage'; + var_dump($tableRoute); + } + + foreach ($tableRoute as $ipRoute) { + if (empty($ipRoute['ipRouteDest']) || $ipRoute['ipRouteDest'] == '') { + continue; + } + + $oldRouteRow = dbFetchRow('select * from route where device_id = ? AND ipRouteDest = ? AND context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + if (!empty($oldRouteRow)) { + unset($oldRouteRow['discoveredAt']); + $changeRoute = array(); + foreach ($ipRoute as $key => $value) { + if ($oldRouteRow[$key] != $value) { + $changeRoute[$key] = $value; + } + } + if (!empty($changeRoute)) { + dbUpdate($changeRoute, 'route', 'device_id = ? and ipRouteDest = ? and context_name = ?', array($device['device_id'], $ipRoute['ipRouteDest'], $device['context_name'])); + } + } else { + + $toInsert = array_merge($ipRoute, array('device_id' => $device['device_id'], 'context_name' => $device['context_name'], 'discoveredAt' => time())); + dbInsert($toInsert, 'route'); + } + } + // unset($tableRoute); } + + unset($vrfs_lite_cisco); } From 341869eaafd17c41a337e113e92e2c9e7d926e2e Mon Sep 17 00:00:00 2001 From: Adam Winberg Date: Thu, 21 Apr 2016 12:56:45 +0200 Subject: [PATCH 24/41] use existings webui option (global_search_result_limit) to set typeahead limit instead of introducing new config option --- html/includes/common/generic-graph.inc.php | 11 ++++++----- html/includes/print-menubar.php | 12 +++++++----- includes/defaults.inc.php | 3 --- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/html/includes/common/generic-graph.inc.php b/html/includes/common/generic-graph.inc.php index c7425d5a06..022fb0585c 100644 --- a/html/includes/common/generic-graph.inc.php +++ b/html/includes/common/generic-graph.inc.php @@ -204,7 +204,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_device.ttAdapter(), - limit: '.$config['typeahead_limit'].', + limit: '.$typeahead_limit.', async: false, templates: { header: "
 Devices
", @@ -241,7 +241,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_port.ttAdapter(), - limit: '.$config['typeahead_limit'].', + limit: '.$typeahead_limit.', async: false, templates: { header: "
 Ports
", @@ -277,7 +277,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_application.ttAdapter(), - limit: '.$config['typeahead_limit'].', + limit: '.$typeahead_limit.', async: false, templates: { header: "
 Applications
", @@ -315,7 +315,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_munin.ttAdapter(), - limit: '.$config['typeahead_limit'].', + limit: '.$typeahead_limit.', async: false, templates: { header: "
 Munin
", @@ -350,7 +350,7 @@ function '.$unique_id.'() { }, { source: '.$unique_id.'_bill.ttAdapter(), - limit: '.$config['typeahead_limit'].', + limit: '.$typeahead_limit.', async: false, templates: { header: "
 Bill
", @@ -437,3 +437,4 @@ else { $common_output[] = ''; } + diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 3bccd65900..1ccdb32d9c 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -3,8 +3,9 @@ require $config['install_dir'].'/includes/object-cache.inc.php'; // FIXME - this could do with some performance improvements, i think. possible rearranging some tables and setting flags at poller time (nothing changes outside of then anyways) -$service_status = get_service_status(); -$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'"); +$service_status = get_service_status(); +$typeahead_limit = $config['webui']['global_search_result_limit']; +$if_alerts = dbFetchCell("SELECT COUNT(port_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'"); if ($_SESSION['userlevel'] >= 5) { $links['count'] = dbFetchCell("SELECT COUNT(*) FROM `links`"); @@ -717,7 +718,7 @@ $('#gsearch').typeahead({ }, { source: devices.ttAdapter(), - limit: '', + limit: '', async: true, display: 'name', valueKey: 'name', @@ -728,7 +729,7 @@ $('#gsearch').typeahead({ }, { source: ports.ttAdapter(), - limit: '', + limit: '', async: true, display: 'name', valueKey: 'name', @@ -739,7 +740,7 @@ $('#gsearch').typeahead({ }, { source: bgp.ttAdapter(), - limit: '', + limit: '', async: true, display: 'name', valueKey: 'name', @@ -752,3 +753,4 @@ $('#gsearch').bind('typeahead:open', function(ev, suggestion) { $('#gsearch').addClass('search-box'); }); + diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 8d763310db..c99bfd6f63 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -871,6 +871,3 @@ $config['ignore_unmapable_port'] = False; // InfluxDB default configuration $config['influxdb']['timeout'] = 0; $config['influxdb']['verifySSL'] = false; - -// Typeahead default configuration -$config['typeahead_limit'] = 5; From 8ef8c33ba3a82836f3149983d5e52a03a9fea8a8 Mon Sep 17 00:00:00 2001 From: Adam Winberg Date: Thu, 21 Apr 2016 13:03:26 +0200 Subject: [PATCH 25/41] forgot setting typeahead_limit option for dash --- html/ajax_dash.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/ajax_dash.php b/html/ajax_dash.php index 0ffc580679..6b268f889b 100644 --- a/html/ajax_dash.php +++ b/html/ajax_dash.php @@ -35,6 +35,7 @@ if ($type == 'placeholder') { elseif (is_file('includes/common/'.$type.'.inc.php')) { $results_limit = 10; + $typeahead_limit = $config['webui']['global_search_result_limit']; $no_form = true; $title = ucfirst($type); $unique_id = str_replace(array("-","."),"_",uniqid($type,true)); From 78204f39715212cbbb34daff4bc89fc7c63e0a73 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 22 Apr 2016 13:41:38 +0000 Subject: [PATCH 26/41] Added api call for ipsec tunnels --- doc/API/API-Docs.md | 38 +++++++++++++++++++++++++++++ html/api_v0.php | 13 ++++++++++ html/includes/api_functions.inc.php | 30 +++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/doc/API/API-Docs.md b/doc/API/API-Docs.md index b23339ee84..55e28c5db8 100644 --- a/doc/API/API-Docs.md +++ b/doc/API/API-Docs.md @@ -30,6 +30,7 @@ - [`get_devices_by_group`](#api-route-get_devices_by_group) - [`routing`](#api-routing) - [`list_bgp`](#api-route-1) + - [`list_ipsec`](#list_ipsec) - [`switching`](#api-switching) - [`get_vlans`](#api-route-4) - [`alerts`](#api-alerts) @@ -866,6 +867,43 @@ Output: } ``` +### Function: `list_ipsec` [`top`](#top) + +List the current IPSec tunnels which are active. + +Route: /api/v0/routing/ipsec/data/:hostname + +- hostname can be either the device hostname or id + +Input: + + - + +Example: +```curl +curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/routing/ipsec/data/localhost +``` + +Output: +```text +{ + "status": "ok", + "err-msg": "", + "count": 0, + "ipsec": [ + "tunnel_id": "1", + "device_id": "1", + "peer_port": "0", + "peer_addr": "127.0.0.1", + "local_addr": "127.0.0.2", + "local_port": "0", + "tunnel_name": "", + "tunnel_status": "active" + ] +} +``` +> Please note, this will only show active VPN sessions not all configured. + ## `Switching` [`top`](#top) ### Function: `get_vlans` [`top`](#top) diff --git a/html/api_v0.php b/html/api_v0.php index 3ca6dc0ad4..021cbb327c 100644 --- a/html/api_v0.php +++ b/html/api_v0.php @@ -128,6 +128,19 @@ $app->group( } ); // End Inventory + // Routing section + $app->group( + '/routing', + function () use ($app) { + $app->group( + '/ipsec', + function () use ($app) { + $app->get('/data/:hostname', 'authToken', 'list_ipsec')->name('list_ipsec'); + } + ); + } + ); + // End Routing } ); $app->get('/v0', 'authToken', 'show_endpoints'); diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 9a26298909..40c64a9bca 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -1288,3 +1288,33 @@ function get_devices_by_group() { echo _json_encode($output); } + +function list_ipsec() { + $app = \Slim\Slim::getInstance(); + $router = $app->router()->getCurrentRoute()->getParams(); + $status = 'error'; + $code = 404; + $message = ''; + $hostname = $router['hostname']; + // use hostname as device_id if it's all digits + $device_id = ctype_digit($hostname) ? $hostname : getidbyname($hostname); + if (!is_numeric($device_id)) { + $message = "No valid hostname or device ID provided"; + } + else { + $ipsec = dbFetchRows("SELECT `D`.`hostname`, `I`.* FROM `ipsec_tunnels` AS `I`, `devices` AS `D` WHERE `I`.`device_id`=? `D`.`device_id` = `I`.`device_id`", array($device_id)); + $total = count($ipsec); + $status = 'ok'; + $code = 200; + } + + $output = array( + 'status' => $status, + 'err-msg' => $message, + 'count' => $total, + 'ipsec' => $ipsec, + ); + $app->response->setStatus($code); + $app->response->headers->set('Content-Type', 'application/json'); + echo _json_encode($output); +} From f801f63a997bc29a372ef24902b3437720fe81b3 Mon Sep 17 00:00:00 2001 From: laf Date: Fri, 22 Apr 2016 14:42:33 +0000 Subject: [PATCH 27/41] Missing AND --- html/includes/api_functions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 40c64a9bca..a3131c5472 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -1302,7 +1302,7 @@ function list_ipsec() { $message = "No valid hostname or device ID provided"; } else { - $ipsec = dbFetchRows("SELECT `D`.`hostname`, `I`.* FROM `ipsec_tunnels` AS `I`, `devices` AS `D` WHERE `I`.`device_id`=? `D`.`device_id` = `I`.`device_id`", array($device_id)); + $ipsec = dbFetchRows("SELECT `D`.`hostname`, `I`.* FROM `ipsec_tunnels` AS `I`, `devices` AS `D` WHERE `I`.`device_id`=? AND `D`.`device_id` = `I`.`device_id`", array($device_id)); $total = count($ipsec); $status = 'ok'; $code = 200; From 0fa29b6d2989dfddde5fd9279e5f13932c0eeec1 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 22 Apr 2016 21:39:06 -0500 Subject: [PATCH 28/41] Change poweralert os detection to case insensitive. Patch from Neil Lathwood --- includes/discovery/os/poweralert.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/os/poweralert.inc.php b/includes/discovery/os/poweralert.inc.php index fd4a4e1bcd..14c328ad69 100644 --- a/includes/discovery/os/poweralert.inc.php +++ b/includes/discovery/os/poweralert.inc.php @@ -1,7 +1,7 @@ Date: Sat, 23 Apr 2016 15:13:43 +0000 Subject: [PATCH 29/41] Added command to chown install dir to correct user --- validate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validate.php b/validate.php index 7bbdd04bc2..a130921cfc 100755 --- a/validate.php +++ b/validate.php @@ -109,7 +109,7 @@ if (isset($config['user'])) { // This isn't just the log directory, let's print the list to the user $files = explode(PHP_EOL, $find_result); if (is_array($files)) { - print_fail("We have found some files that are owned by a different user than $tmp_user, this will stop you updating automatically and / or rrd files being updated causing graphs to fail:\n"); + print_fail("We have found some files that are owned by a different user than $tmp_user, this will stop you updating automatically and / or rrd files being updated causing graphs to fail:\nIf you don't run a bespoke install then you can fix this by running `chown -R $tmp_user:$tmp_user ".$config['install_dir']."`"); foreach ($files as $file) { echo "$file\n"; } From 46a0bbfc8228f229e72e23847c8bb31adbdf5d2f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 23 Apr 2016 20:14:22 -0500 Subject: [PATCH 30/41] Add PoE state to Netonix devices Allow for non-numeric states. state_descr must match what is returned by the device. --- .../device/overview/generic/sensor.inc.php | 6 +- .../discovery/sensors/states/netonix.inc.php | 59 +++++++++++++++++++ includes/polling/functions.inc.php | 7 +++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 includes/discovery/sensors/states/netonix.inc.php diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index a2d8720bcd..f086825624 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,9 +1,11 @@ + * 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'] == 'netonix') { + + $temp = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.46242.5.1.2'); + $cur_oid = '.1.3.6.1.4.1.'; + + if (is_array($temp)) { + //Create State Index + $state_name = 'netonixPoeStatus'; + $state_index_id = create_state_index($state_name); + + $states_ids = array( + 'Off' => 1, + '24V' => 2, + '48V' => 3 + ); + + //Create State Translation + if ($state_index_id !== null) { + $states = array( + array($state_index_id,'Off',0,1,-1) , + array($state_index_id,'24V',0,2,0) , + array($state_index_id,'48V',0,3,1) , + ); + 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'); + } + } + + foreach ($temp as $index => $entry) { + $id = substr($index, strrpos($index, '.')+1); + $descr = 'Port ' . $id . ' PoE'; + $current = $states_ids[$entry['enterprises']]; + //Discover Sensors + discover_sensor($valid['sensor'], 'state', $device, $cur_oid.$index, $id, $state_name, $descr, '1', '1', null, null, null, null, $current); + + //Create Sensor To State Index + create_sensor_to_state_index($device, $state_name, $id); + } + } +} diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index e743495625..a34ba514e9 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -44,6 +44,13 @@ function poll_sensor($device, $class, $unit) { } else if ($class == 'state') { $sensor_value = trim(str_replace('"', '', snmp_walk($device, $sensor['sensor_oid'], '-Oevq', 'SNMPv2-MIB'))); + if (!is_numeric($sensor_value)) { + $state_value = dbFetchCell('SELECT `state_value` FROM `state_translations` LEFT JOIN `sensors_to_state_indexes` ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id` WHERE `sensors_to_state_indexes`.`sensor_id` = ? AND `state_translations`.`state_descr` LIKE ?', array($sensor['sensor_id'], $sensor_value)); + d_echo('State value of ' . $sensor_value . ' is ' . $state_value . "\n"); + if (is_numeric($state_value)) { + $sensor_value = $state_value; + } + } } else if ($class == 'signal') { $currentOS = $device['os']; From b98ba8c1a452982e496dca8a4b9ce0d5dc8f4fa7 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 24 Apr 2016 01:05:14 -0500 Subject: [PATCH 31/41] Remove some deprecated functions --- .../graphs/application/shoutcast_multi_bits.inc.php | 6 +++--- .../graphs/application/shoutcast_multi_stats.inc.php | 6 +++--- html/pages/device/apps/shoutcast.inc.php | 6 +++--- html/pages/front/map.php | 4 +--- includes/common.php | 4 ++-- irc.php | 2 +- scripts/ntpd-server.php | 2 +- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index a54d6b8d5a..1cadfa439e 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -27,7 +27,7 @@ $i = 0; if ($handle = opendir($rrddir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + if (stripos($file, 'app-shoutcast-'.$app['app_id'])) { array_push($files, $file); } } @@ -35,8 +35,8 @@ if ($handle = opendir($rrddir)) { } foreach ($files as $id => $file) { - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); + $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = str_ireplace('.rrd', '', $hostname); list($host, $port) = explode('_', $hostname, 2); $rrd_filenames[] = $rrddir.'/'.$file; $rrd_list[$i]['filename'] = $rrddir.'/'.$file; diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index a6618207e2..1af206bb8b 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -15,7 +15,7 @@ $x = 0; if ($handle = opendir($rrddir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + if (stripos($file, 'app-shoutcast-'.$app['app_id'])) { array_push($files, $file); } } @@ -23,8 +23,8 @@ if ($handle = opendir($rrddir)) { } foreach ($files as $id => $file) { - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); + $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = str_ireplace('.rrd', '', $hostname); list($host, $port) = explode('_', $hostname, 2); $rrd_filenames[] = $rrddir.'/'.$file; $rrd_list[$i]['filename'] = $rrddir.'/'.$file; diff --git a/html/pages/device/apps/shoutcast.inc.php b/html/pages/device/apps/shoutcast.inc.php index f2aadc7f18..f9278c650b 100644 --- a/html/pages/device/apps/shoutcast.inc.php +++ b/html/pages/device/apps/shoutcast.inc.php @@ -10,7 +10,7 @@ $files = array(); if ($handle = opendir($rrddir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (eregi('app-shoutcast-'.$app['app_id'], $file)) { + if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) { array_push($files, $file); } } @@ -45,8 +45,8 @@ if (isset($total) && $total === true) { } foreach ($files as $id => $file) { - $hostname = eregi_replace('app-shoutcast-'.$app['app_id'].'-', '', $file); - $hostname = eregi_replace('.rrd', '', $hostname); + $hostname = str_ireplace('app-shoutcast-'.$app['app_id'].'-', '', $file); + $hostname = str_ireplace('.rrd', '', $hostname); list($host, $port) = explode('_', $hostname, 2); $graphs = array( 'shoutcast_bits' => 'Traffic Statistics - '.$host.' (Port: '.$port.')', diff --git a/html/pages/front/map.php b/html/pages/front/map.php index e2b6b1e7ce..162c898218 100644 --- a/html/pages/front/map.php +++ b/html/pages/front/map.php @@ -157,7 +157,7 @@ echo ' //From default.php - This code is not part of above license. if ($config['enable_syslog']) { $sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY seq DESC LIMIT 20"; -$query = mysql_query($sql); + echo('
@@ -196,8 +196,6 @@ echo('
P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15"; } - $data = mysql_query($query); - echo('
diff --git a/includes/common.php b/includes/common.php index 36f2a5dc2d..a1a7ab38d5 100644 --- a/includes/common.php +++ b/includes/common.php @@ -699,8 +699,8 @@ function get_smokeping_files($device) { if ($handle = opendir($smokeping_dir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (eregi('.rrd', $file)) { - if (eregi('~', $file)) { + if (stripos($file, '.rrd') !== false) { + if (strpos($file, '~') !== false) { list($target,$slave) = explode('~', str_replace('.rrd', '', $file)); $target = str_replace('_', '.', $target); $smokeping_files['in'][$target][$slave] = $file; diff --git a/irc.php b/irc.php index 21d2b7260b..c1f4b7aefc 100755 --- a/irc.php +++ b/irc.php @@ -416,7 +416,7 @@ class ircbot { private function chkdb() { if (!is_resource($this->sql)) { - if (($this->sql = mysql_connect($this->config['db_host'], $this->config['db_user'], $this->config['db_pass'])) != false && mysql_select_db($this->config['db_name'])) { + if (($this->sql = mysqli_connect($this->config['db_host'], $this->config['db_user'], $this->config['db_pass'])) != false && mysqli_select_db($this->sql, $this->config['db_name'])) { return true; } else { diff --git a/scripts/ntpd-server.php b/scripts/ntpd-server.php index 508ca73893..aba7b1ffea 100644 --- a/scripts/ntpd-server.php +++ b/scripts/ntpd-server.php @@ -25,7 +25,7 @@ $cmd2 = shell_exec($ntpdc.' -c iostats'); $vars = array(); $vars2 = array(); $vars = explode(',', $cmd); -$vars2 = eregi_replace(' ', '', $cmd2); +$vars2 = str_replace(' ', '', $cmd2); $vars2 = explode("\n", $vars2); From 40759c511f5201bbe49172649b1ae912a834a8bc Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 24 Apr 2016 07:47:16 -0500 Subject: [PATCH 32/41] Correct stripos check --- html/includes/graphs/application/shoutcast_multi_bits.inc.php | 2 +- html/includes/graphs/application/shoutcast_multi_stats.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/includes/graphs/application/shoutcast_multi_bits.inc.php b/html/includes/graphs/application/shoutcast_multi_bits.inc.php index 1cadfa439e..06f1585109 100644 --- a/html/includes/graphs/application/shoutcast_multi_bits.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_bits.inc.php @@ -27,7 +27,7 @@ $i = 0; if ($handle = opendir($rrddir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (stripos($file, 'app-shoutcast-'.$app['app_id'])) { + if (stripos($file, 'app-shoutcast-'.$app['app_id']) != false) { array_push($files, $file); } } diff --git a/html/includes/graphs/application/shoutcast_multi_stats.inc.php b/html/includes/graphs/application/shoutcast_multi_stats.inc.php index 1af206bb8b..2e2819e84b 100644 --- a/html/includes/graphs/application/shoutcast_multi_stats.inc.php +++ b/html/includes/graphs/application/shoutcast_multi_stats.inc.php @@ -15,7 +15,7 @@ $x = 0; if ($handle = opendir($rrddir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { - if (stripos($file, 'app-shoutcast-'.$app['app_id'])) { + if (stripos($file, 'app-shoutcast-'.$app['app_id']) !== false) { array_push($files, $file); } } From 34281f2ccc86b0df1e7267daaaa280fb4823286b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 24 Apr 2016 08:03:59 -0500 Subject: [PATCH 33/41] Correct snmpwalk_cache_multi_oid() call --- includes/discovery/sensors/states/netonix.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/sensors/states/netonix.inc.php b/includes/discovery/sensors/states/netonix.inc.php index 470ce7b618..093e43b5be 100644 --- a/includes/discovery/sensors/states/netonix.inc.php +++ b/includes/discovery/sensors/states/netonix.inc.php @@ -12,7 +12,7 @@ if ($device['os'] == 'netonix') { - $temp = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.46242.5.1.2'); + $temp = snmpwalk_cache_multi_oid($device, '.1.3.6.1.4.1.46242.5.1.2', array()); $cur_oid = '.1.3.6.1.4.1.'; if (is_array($temp)) { From 1c4cf026d4943e3540f94283ad4452a642c0788c Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Mon, 25 Apr 2016 08:26:46 +0200 Subject: [PATCH 34/41] Renamed Viprinet to Viprinux. Icon size now 32x32 --- html/images/os/viprinet.png | Bin 1180 -> 0 bytes html/images/os/viprinux.png | Bin 0 -> 1674 bytes includes/definitions.inc.php | 6 +++--- .../os/{viprinet.inc.php => viprinux.inc.php} | 2 +- includes/discovery/processors/viprinet.inc.php | 2 +- .../os/{viprinet.inc.php => viprinux.inc.php} | 0 includes/polling/processors/viprinet.inc.php | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 html/images/os/viprinet.png create mode 100644 html/images/os/viprinux.png rename includes/discovery/os/{viprinet.inc.php => viprinux.inc.php} (75%) rename includes/polling/os/{viprinet.inc.php => viprinux.inc.php} (100%) diff --git a/html/images/os/viprinet.png b/html/images/os/viprinet.png deleted file mode 100644 index 363aacf7cbfe2ea56a15277b5ae67498d75e241b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1180 zcmV;N1Y`S&P)X0ssI2@}HD^00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-#n4G1m+L1)Gh000C#Nkl0xG&0Pp zHkAs`DiYPI+S;a7REsA~^f2PAJ7P!cX=>qK8mZ@kdfQY3(qNjDfO7hZDNZ28{ z#Ae}AY4%ig+Kl{WsR~HJS*S9^vcnt3O$ZAaDx%^$+3!8S_rCZ0^Vx1Hm&@>$#wmDv zqpsXkRg`Z#w z6h$>~e5$HZ6veX4p@5Mq=>872o{>$*%S%?wX>%-{>9s%gt?f+!$Q29#@U@+P5?=_1 zg;XjXiHyYK3&X>= z%yFNos^<2_VzXlSrlLGXsGBq@%42uH>U!F+mCUc-uCAv6AirrovmQOO9(h@}Voq=V zl>>l{SLTX2O?q<$!>|>Cn_(-4t&sGvg~=u*X~ISFHBR!OAOI{Tl3oL#5!%xLER63) z?nELZ92ba2f8e-4EH>+9zbFhU@?0b`Qj1!rTYR50-}GO;f8)dN0Km@w8d@`{_ zNLU>dMTJGdz2$=gnH^ZjRKvr!_m|C;3nIB_ZT9&)SXV^^ic9BjxFau~?I!@%nuHT>NG03tB&$o!_c z&uk$+Nb+G>#(S(S-s6u(XDp0qgovfO2k?d?{d~;5-r6qK^9V&z)hye^jpG6oMG?^_ zl1oRGSVa)hwx9Ml@N7#3xXHv)SQJ!M8ydQGRQdE@zJK`d$^q_^jH+1}>$*|PNQmuL z*k)tzV%0&E<}J{hhmwBP;WQICvIh}&S&j>_9Oc1{XYl}{2d@k u6RNhX$a5$E6i#wG$?c%gbn*}HSjIm)Th)TK{j)s)0000jt`S)Jy^Zi|)`#Zl&IOnKzIoy^hVfusq?sr3(i z@KwKcanDRDe-#7_lHkEpYkyvI`r5&fYl$~Qj7R_>2>8~uwKY6>^sP&KLLyV}=@0&f z2+M%`kBsh~$rdA^gh3K~*wXPc@zk{+$0lNjC6T#7sen&){#uw#?~WfDeO_{je%Q{! z1ET;inK&j?fJd^$2msu|g;Nv#vGE05E#av%@gt+(kzAr*HO!2*zWK|MQUH$}+;n~Z zoVrYSd^~mipnDUyhXm=vEd3 zBikbP3$a}IUq`lCx|Mr(4{&Zlw=$&=({qEjg-B#CE*oxG8E|gB8=%&+`c{Sb+kdu4 z8miXR0l>MbU$}=RUsC{}&inqlf1LkTBvYsyUu+WFF=a}G`h{2Nzi_w>%P!#Iz>}Ct z{BtLzg3wa?ksn@({skgcKnSTA_qsxOy!~bW_4zXv;hdM6$>7+&nMm@uCJL$w5ZI2P z0|29v3~-oMURzPUQGGQ0qIhbeKUM)Q9KP_p^~47b5DEaY;L|KekN32Fm$cON9%%4B z0>jF}v^8qkd1_c$)T&`TRM-21N5e0YlN0^dE5YBq_(D9Dp8x=q8jwI`9RO6Ret$>P zvwZ+IL^H#iO}mIt^~M1JX93{tE8m-rq)sZ8;B&bv5+&mQ2e`F5nx54FAf6o^&gs$f zoI4ai(X8vUL2(Bx}MPQPIj0Gb}-n>&7L z-ptfBIQIR6k<>fg67v8cpoHO*oxfT#E;0pOtzT2CLS&j!*0tpZoA&?C_%A{vdew%I%@({BU}0({mc( zoa2o%U*NW5=$zXG00<#qRAvAe0fBDiG>Wu*SfzFn%_5naNGcvsx?_RmXXj>u<0K(a+*X7T5|7mR` z`Oe2Jryy`}IF5;j>Uyggm39Ka=78A@tb*Ap;Wr8MKQ_I>2|)&0px z>coBV(qB;PS!LIHR@rwu1@C~T!@;dhv+1FirsoD9_Q(M$OFlf-zArqJ{MV1hq618o z8&p~FqN{aV=*IlN?}(QUqkFBp;2{8*N*wF+xEiYpW>Qj z_M)ceo(0mSRNh?MV_u2=d6QeJmy2dv^C``HXVXJ9rmgj73Nv{Cwj$Pylr!GZ2gPr# zOd+y?5W-YBsIG2&x=&*6oON^31qZhsb8bli%E1=`OamYYR;|Orz|w9gV$Dvk>wRtz z2!zt!2M$mU9?zba3&vc3PLJln9m}-yhZkROtl9v8U_APFeJ(e)eI|LrS5|;>E7$Y{ z*Nj+-5m9is<>ZaIlYcn-j06CeZ~ReJ<%Yewna;W8dinI^!JjnMe8_vRL6-tRbbffU z92@`yCPSnOI5+?T%g)2H3jlys!B1$9gr4bZuKlQo5{812xbL)00pQr>ms-lf7p5mK zkpyqG!!3&vMtw@t#?N%UVJx~u>S=qS)$0nC2Hkswpa5XlIb;iw%>8fxsQ0eX6{&Wo z#8h|DN;{lePrT$*?w0Y`A$HqYpj(+&7?A{l zxptKMd1l)AR~&9;ICp$5vHIJ$UoW^truYkH@+*`uFe=$8ZTu*s@`)O?t Date: Mon, 25 Apr 2016 10:10:25 +0200 Subject: [PATCH 35/41] renamed remaining viprinet.inc.php to viprinux.inc.php --- .../discovery/processors/{viprinet.inc.php => viprinux.inc.php} | 0 .../polling/processors/{viprinet.inc.php => viprinux.inc.php} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename includes/discovery/processors/{viprinet.inc.php => viprinux.inc.php} (100%) rename includes/polling/processors/{viprinet.inc.php => viprinux.inc.php} (100%) diff --git a/includes/discovery/processors/viprinet.inc.php b/includes/discovery/processors/viprinux.inc.php similarity index 100% rename from includes/discovery/processors/viprinet.inc.php rename to includes/discovery/processors/viprinux.inc.php diff --git a/includes/polling/processors/viprinet.inc.php b/includes/polling/processors/viprinux.inc.php similarity index 100% rename from includes/polling/processors/viprinet.inc.php rename to includes/polling/processors/viprinux.inc.php From f02bba3c11730e8b5804b595713e097af250e122 Mon Sep 17 00:00:00 2001 From: Sawachier Date: Mon, 25 Apr 2016 10:17:05 +0200 Subject: [PATCH 36/41] Rename 115.sql to 113.sql --- sql-schema/{115.sql => 113.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sql-schema/{115.sql => 113.sql} (97%) diff --git a/sql-schema/115.sql b/sql-schema/113.sql similarity index 97% rename from sql-schema/115.sql rename to sql-schema/113.sql index d097dec110..6698221ab2 100644 --- a/sql-schema/115.sql +++ b/sql-schema/113.sql @@ -1,2 +1,2 @@ CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); \ No newline at end of file +ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); From 2afb0fed9e148f060f0be7f1c7fe230952485a68 Mon Sep 17 00:00:00 2001 From: rschueler Date: Mon, 25 Apr 2016 11:51:20 +0200 Subject: [PATCH 37/41] 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 fec1d61546..9c8a165823 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -98,6 +98,7 @@ LibreNMS contributors: - Michael Nguyen (mnguyen1289) - Casey Schoonover (cschoonover91) - Chris A. Evans (thecityofguanyu) +- Rainer Schüler (rschueler) [1]: http://observium.org/ "Observium web site" Observium was written by: From 40b598d9af03f163ee5887a8cf15cbde03b70f35 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 25 Apr 2016 14:55:51 -0500 Subject: [PATCH 38/41] Don't drop an index on a table that was just created --- sql-schema/113.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-schema/113.sql b/sql-schema/113.sql index 6698221ab2..92b97729fc 100644 --- a/sql-schema/113.sql +++ b/sql-schema/113.sql @@ -1,2 +1,2 @@ CREATE TABLE IF NOT EXISTS `route` ( `device_id` int(11) NOT NULL, `context_name` varchar(128) CHARACTER SET utf8 collate utf8_general_ci not null, `ipRouteDest` varchar(256) not null, `ipRouteIfIndex` varchar(256), `ipRouteMetric` varchar(256) not null, `ipRouteNextHop` varchar(256) not null, `ipRouteType` varchar(256) not null, `ipRouteProto` varchar(256) not null, `discoveredAt` int(11) NOT NULL, `ipRouteMask` varchar(256) not null ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -ALTER TABLE `route` DROP INDEX `device` , ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); +ALTER TABLE `route` ADD INDEX `device` (`device_id` ASC, `context_name` ASC, `ipRouteDest`(255) ASC, `ipRouteNextHop` ASC); From a5617d4985df8cdb2b9b82fbb17b4949afea5365 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 26 Apr 2016 06:46:22 +1000 Subject: [PATCH 39/41] - Update Service Message in the database when it has changed. --- includes/services.inc.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/services.inc.php b/includes/services.inc.php index 2205a4f47c..fa40a33ffe 100644 --- a/includes/services.inc.php +++ b/includes/services.inc.php @@ -179,6 +179,11 @@ function poll_service($service) { $update['service_message'] = $msg; } + if ($service['service_message'] != $msg) { + // Message has changed, update. + $update['service_message'] = $msg; + } + if (count($update) > 0) { edit_service($update,$service['service_id']); } From 4545aea28d8f9fbeaf534e823030443f3be65847 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 26 Apr 2016 07:04:22 +1000 Subject: [PATCH 40/41] - Services widget on device overview page was still displaying legacy status while the database has been storing nagios style status. Modified to: 0=Ok, 1=Unknown, 2=Critical. --- html/pages/device/overview.inc.php | 2 +- html/pages/device/overview/services.inc.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/html/pages/device/overview.inc.php b/html/pages/device/overview.inc.php index 278960e766..60bbee5610 100644 --- a/html/pages/device/overview.inc.php +++ b/html/pages/device/overview.inc.php @@ -10,7 +10,7 @@ $ports['disabled'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = $services = get_service_status($device['device_id']); $services['total'] = array_sum($services); -if ($services[0]) { +if ($services[2]) { $services_colour = $warn_colour_a; } else { diff --git a/html/pages/device/overview/services.inc.php b/html/pages/device/overview/services.inc.php index ed5b5023bb..092b66cff2 100644 --- a/html/pages/device/overview/services.inc.php +++ b/html/pages/device/overview/services.inc.php @@ -3,14 +3,14 @@ if ($services['total']) { // Build the string. foreach (service_get ($device['device_id']) as $data) { - if ($data['service_status'] == '1') { + if ($data['service_status'] == '0') { // Ok $status = 'green'; - } elseif ($data['service_status'] == '0') { - // Critical + } elseif ($data['service_status'] == '1') { + // Warning $status = 'red'; } elseif ($data['service_status'] == '2') { - // Warning + // Critical $status = 'red'; } else { // Unknown @@ -29,9 +29,9 @@ if ($services['total']) { - - - + + + From 048b5539264adb3f0729762ae0f4089f34164958 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 26 Apr 2016 22:05:34 +1000 Subject: [PATCH 41/41] Nagios Services - Status update - Fixed summary widgets --- html/includes/common/device-summary-horiz.inc.php | 4 ++-- html/includes/common/device-summary-vert.inc.php | 4 ++-- includes/caches/services.inc.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/html/includes/common/device-summary-horiz.inc.php b/html/includes/common/device-summary-horiz.inc.php index 75d110a375..47ddd4a7ea 100644 --- a/html/includes/common/device-summary-horiz.inc.php +++ b/html/includes/common/device-summary-horiz.inc.php @@ -40,8 +40,8 @@ $temp_output .= ' - - + + '.($config['summary_errors'] ? '' : '').' diff --git a/html/includes/common/device-summary-vert.inc.php b/html/includes/common/device-summary-vert.inc.php index 647a036302..5f32137966 100644 --- a/html/includes/common/device-summary-vert.inc.php +++ b/html/includes/common/device-summary-vert.inc.php @@ -31,7 +31,7 @@ $temp_output .= ' if ($config['show_services']) { $temp_output .= ' - + '; } @@ -47,7 +47,7 @@ $temp_output .= ' if ($config['show_services']) { $temp_output .= ' - + '; } diff --git a/includes/caches/services.inc.php b/includes/caches/services.inc.php index 5024058841..65fa421b4a 100644 --- a/includes/caches/services.inc.php +++ b/includes/caches/services.inc.php @@ -2,8 +2,8 @@ if ($_SESSION['userlevel'] >= 5) { $data['count'] = array( 'query' => 'SELECT COUNT(*) FROM services'); - $data['up'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '1'"); - $data['down'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'"); + $data['up'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'"); + $data['down'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '2'"); $data['ignored'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '1' AND `service_disabled` = '0'"); $data['disabled'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_disabled` = '1'"); } @@ -14,12 +14,12 @@ else { ); $data['up'] = array( - 'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '1'", + 'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0'", 'params' => array($_SESSION['user_id']), ); $data['down'] = array( - 'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0'", + 'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '2'", 'params' => array($_SESSION['user_id']), );
Services '.$services['count'].''.$services['up'].' '.$services['down'].''.$services['up'].' '.$services['down'].' '.$services['ignored'].' '.$services['disabled'].'-'. $services['up'] .''. $services['up'] .''. $services['down'] .''. $services['down'] .'