From efa0747564ff6fccdeb60d1208a7c3a7cb2e8074 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 20 Dec 2016 05:50:44 +1000 Subject: [PATCH] newdevice: Added additional support for F5 BigIP LTM objects --- LibreNMS/Component.php | 22 ++ .../device/bigip_ltm_allpm_bytesin.inc.php | 75 +++++ .../device/bigip_ltm_allpm_bytesout.inc.php | 75 +++++ .../device/bigip_ltm_allpm_conns.inc.php | 74 +++++ .../device/bigip_ltm_allpm_pktsin.inc.php | 74 +++++ .../device/bigip_ltm_allpm_pktsout.inc.php | 74 +++++ .../device/bigip_ltm_allvs_bytesin.inc.php | 53 ++++ .../device/bigip_ltm_allvs_bytesout.inc.php | 53 ++++ .../device/bigip_ltm_allvs_conns.inc.php | 52 ++++ .../device/bigip_ltm_allvs_pktsin.inc.php | 52 ++++ .../device/bigip_ltm_allvs_pktsout.inc.php | 52 ++++ .../graphs/device/bigip_ltm_vs_bytes.inc.php | 47 ++++ .../graphs/device/bigip_ltm_vs_conns.inc.php | 44 +++ .../graphs/device/bigip_ltm_vs_pkts.inc.php | 48 ++++ html/pages/device.inc.php | 19 +- html/pages/device/loadbalancer.inc.php | 11 +- .../device/loadbalancer/ltm_pool.inc.php | 38 +++ .../device/loadbalancer/ltm_pool_all.inc.php | 63 +++++ .../loadbalancer/ltm_pool_details.inc.php | 216 +++++++++++++++ html/pages/device/loadbalancer/ltm_vs.inc.php | 38 +++ .../device/loadbalancer/ltm_vs_all.inc.php | 167 ++++++++++++ .../device/loadbalancer/ltm_vs_common.inc.php | 68 +++++ .../device/loadbalancer/ltm_vs_det.inc.php | 82 ++++++ .../device/loadbalancer/ltm_vs_pool.inc.php | 208 ++++++++++++++ includes/defaults.inc.php | 2 + includes/definitions.inc.php | 2 + includes/discovery/loadbalancers.inc.php | 14 + .../discovery/loadbalancers/f5-ltm.inc.php | 258 ++++++++++++++++++ includes/polling/loadbalancers.inc.php | 14 + includes/polling/loadbalancers/f5-ltm.inc.php | 178 ++++++++++++ sql-schema/153.sql | 1 + 31 files changed, 2163 insertions(+), 11 deletions(-) create mode 100644 html/includes/graphs/device/bigip_ltm_allpm_bytesin.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allpm_bytesout.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allpm_conns.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allpm_pktsin.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allpm_pktsout.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allvs_bytesin.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allvs_bytesout.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allvs_conns.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allvs_pktsin.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_allvs_pktsout.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_vs_bytes.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_vs_conns.inc.php create mode 100644 html/includes/graphs/device/bigip_ltm_vs_pkts.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_pool.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_pool_all.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_pool_details.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_vs.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_vs_all.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_vs_common.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_vs_det.inc.php create mode 100644 html/pages/device/loadbalancer/ltm_vs_pool.inc.php create mode 100644 includes/discovery/loadbalancers.inc.php create mode 100644 includes/discovery/loadbalancers/f5-ltm.inc.php create mode 100644 includes/polling/loadbalancers.inc.php create mode 100644 includes/polling/loadbalancers/f5-ltm.inc.php create mode 100644 sql-schema/153.sql diff --git a/LibreNMS/Component.php b/LibreNMS/Component.php index 54779462a1..3671f631b7 100644 --- a/LibreNMS/Component.php +++ b/LibreNMS/Component.php @@ -41,6 +41,28 @@ class Component 'error' => '', ); + public function getComponentCount($device_id = null) + { + if (is_null($device_id)) { + // SELECT type, count(*) as count FROM component GROUP BY type + $SQL = "SELECT `type` as `name`, count(*) as count FROM `component` GROUP BY `type`"; + $rows = dbFetchRows($SQL, array()); + } else { + $SQL = "SELECT `type` as `name`, count(*) as count FROM `component` WHERE `device_id` = ? GROUP BY `type`"; + $rows = dbFetchRows($SQL, array($device_id)); + } + + if (isset($rows)) { + // We found some, lets re-process to make more accessible + $result = array(); + foreach ($rows as $value) { + $result[$value['name']] = $value['count']; + } + return $result; + } + // We didn't find any components + return false; + } public function getComponentType($TYPE = null) { if (is_null($TYPE)) { diff --git a/html/includes/graphs/device/bigip_ltm_allpm_bytesin.inc.php b/html/includes/graphs/device/bigip_ltm_allpm_bytesin.inc.php new file mode 100644 index 0000000000..d3dfbd40aa --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allpm_bytesin.inc.php @@ -0,0 +1,75 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// Is the ID we are looking for a valid LTM VS Pool
+if ($components[$vars['id']]['type'] == 'f5-ltm-pool') {
+    $parent = $components[$vars['id']]['UID'];
+
+    // Find all pool members
+    foreach ($components as $compid => $comp) {
+        if ($comp['type'] != 'f5-ltm-poolmember') {
+            continue;
+        }
+        if (!strstr($comp['UID'], $parent)) {
+            continue;
+        }
+
+        $label = $comp['label'];
+        $hash = $comp['hash'];
+        $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+        if (file_exists($rrd_filename)) {
+            d_echo("\n  Adding PM: " . $label . "\t+ added to the graph");
+
+            // Grab a colour from the array.
+            if (isset($colours[$count])) {
+                $colour = $colours[$count];
+            } else {
+                d_echo("\nError: Out of colours. Have: " . (count($colours) - 1) . ", Requesting:" . $count);
+            }
+
+            $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":bytesin:AVERAGE ";
+            $rrd_options .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* ";
+            $rrd_options .= " LINE1.25:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 40), 40) . "'";
+            $rrd_options .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
+            $rrd_options .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
+            $rrd_options .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\l ";
+            $count++;
+        }
+    } // End Foreach
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allpm_bytesout.inc.php b/html/includes/graphs/device/bigip_ltm_allpm_bytesout.inc.php new file mode 100644 index 0000000000..42f497120b --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allpm_bytesout.inc.php @@ -0,0 +1,75 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// Is the ID we are looking for a valid LTM VS Pool
+if ($components[$vars['id']]['type'] == 'f5-ltm-pool') {
+    $parent = $components[$vars['id']]['UID'];
+
+    // Find all pool members
+    foreach ($components as $compid => $comp) {
+        if ($comp['type'] != 'f5-ltm-poolmember') {
+            continue;
+        }
+        if (!strstr($comp['UID'], $parent)) {
+            continue;
+        }
+
+        $label = $comp['label'];
+        $hash = $comp['hash'];
+        $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+        if (file_exists($rrd_filename)) {
+            d_echo("\n  Adding PM: " . $label . "\t+ added to the graph");
+
+            // Grab a colour from the array.
+            if (isset($colours[$count])) {
+                $colour = $colours[$count];
+            } else {
+                d_echo("\nError: Out of colours. Have: " . (count($colours) - 1) . ", Requesting:" . $count);
+            }
+
+            $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":bytesout:AVERAGE ";
+            $rrd_options .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* ";
+            $rrd_options .= " LINE1.25:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 40), 40) . "'";
+            $rrd_options .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
+            $rrd_options .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
+            $rrd_options .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\l ";
+            $count++;
+        }
+    } // End Foreach
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allpm_conns.inc.php b/html/includes/graphs/device/bigip_ltm_allpm_conns.inc.php new file mode 100644 index 0000000000..11a263e553 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allpm_conns.inc.php @@ -0,0 +1,74 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// Is the ID we are looking for a valid LTM VS Pool
+if ($components[$vars['id']]['type'] == 'f5-ltm-pool') {
+    $parent = $components[$vars['id']]['UID'];
+
+    // Find all pool members
+    foreach ($components as $compid => $comp) {
+        if ($comp['type'] != 'f5-ltm-poolmember') {
+            continue;
+        }
+        if (!strstr($comp['UID'], $parent)) {
+            continue;
+        }
+
+        $label = $comp['label'];
+        $hash = $comp['hash'];
+        $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+        if (file_exists($rrd_filename)) {
+            d_echo("\n  Adding PM: " . $label . "\t+ added to the graph");
+
+            // Grab a colour from the array.
+            if (isset($colours[$count])) {
+                $colour = $colours[$count];
+            } else {
+                d_echo("\nError: Out of colours. Have: " . (count($colours) - 1) . ", Requesting:" . $count);
+            }
+
+            $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":totconns:AVERAGE ";
+            $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 40), 40) . "'";
+            $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+            $count++;
+        }
+    } // End Foreach
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allpm_pktsin.inc.php b/html/includes/graphs/device/bigip_ltm_allpm_pktsin.inc.php new file mode 100644 index 0000000000..cd1458ef34 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allpm_pktsin.inc.php @@ -0,0 +1,74 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// Is the ID we are looking for a valid LTM VS Pool
+if ($components[$vars['id']]['type'] == 'f5-ltm-pool') {
+    $parent = $components[$vars['id']]['UID'];
+
+    // Find all pool members
+    foreach ($components as $compid => $comp) {
+        if ($comp['type'] != 'f5-ltm-poolmember') {
+            continue;
+        }
+        if (!strstr($comp['UID'], $parent)) {
+            continue;
+        }
+
+        $label = $comp['label'];
+        $hash = $comp['hash'];
+        $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+        if (file_exists($rrd_filename)) {
+            d_echo("\n  Adding PM: " . $label . "\t+ added to the graph");
+
+            // Grab a colour from the array.
+            if (isset($colours[$count])) {
+                $colour = $colours[$count];
+            } else {
+                d_echo("\nError: Out of colours. Have: " . (count($colours) - 1) . ", Requesting:" . $count);
+            }
+
+            $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":pktsin:AVERAGE ";
+            $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 40), 40) . "'";
+            $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+            $count++;
+        }
+    } // End Foreach
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allpm_pktsout.inc.php b/html/includes/graphs/device/bigip_ltm_allpm_pktsout.inc.php new file mode 100644 index 0000000000..41c21bab31 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allpm_pktsout.inc.php @@ -0,0 +1,74 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// Is the ID we are looking for a valid LTM VS Pool
+if ($components[$vars['id']]['type'] == 'f5-ltm-pool') {
+    $parent = $components[$vars['id']]['UID'];
+
+    // Find all pool members
+    foreach ($components as $compid => $comp) {
+        if ($comp['type'] != 'f5-ltm-poolmember') {
+            continue;
+        }
+        if (!strstr($comp['UID'], $parent)) {
+            continue;
+        }
+
+        $label = $comp['label'];
+        $hash = $comp['hash'];
+        $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+        if (file_exists($rrd_filename)) {
+            d_echo("\n  Adding PM: " . $label . "\t+ added to the graph");
+
+            // Grab a colour from the array.
+            if (isset($colours[$count])) {
+                $colour = $colours[$count];
+            } else {
+                d_echo("\nError: Out of colours. Have: " . (count($colours) - 1) . ", Requesting:" . $count);
+            }
+
+            $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":pktsout:AVERAGE ";
+            $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 40), 40) . "'";
+            $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+            $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+            $count++;
+        }
+    } // End Foreach
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allvs_bytesin.inc.php b/html/includes/graphs/device/bigip_ltm_allvs_bytesin.inc.php new file mode 100644 index 0000000000..35e72a79cf --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allvs_bytesin.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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$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:'LTM Vitrual Servers Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// add all LTM VS on this device.
+foreach ($components as $compid => $comp) {
+    $label = $comp['label'];
+    $hash = $comp['hash'];
+    $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+    if (file_exists($rrd_filename)) {
+        d_echo("\n  Adding VS: ".$comp['label']."\t+ added to the graph");
+
+        // Grab a colour from the array.
+        if (isset($colours[$count])) {
+            $colour = $colours[$count];
+        } else {
+            d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count);
+        }
+
+        $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":bytesin:AVERAGE ";
+        $rrd_options .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* ";
+        $rrd_options .= " LINE1.25:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
+        $rrd_options .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
+        $rrd_options .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
+        $rrd_options .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\l ";
+        $count++;
+    }
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allvs_bytesout.inc.php b/html/includes/graphs/device/bigip_ltm_allvs_bytesout.inc.php new file mode 100644 index 0000000000..0b31477b44 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allvs_bytesout.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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$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:'LTM Vitrual Servers Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// add all LTM VS on this device.
+foreach ($components as $compid => $comp) {
+    $label = $comp['label'];
+    $hash = $comp['hash'];
+    $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+    if (file_exists($rrd_filename)) {
+        d_echo("\n  Adding VS: ".$comp['label']."\t+ added to the graph");
+
+        // Grab a colour from the array.
+        if (isset($colours[$count])) {
+            $colour = $colours[$count];
+        } else {
+            d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count);
+        }
+
+        $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":bytesout:AVERAGE ";
+        $rrd_options .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* ";
+        $rrd_options .= " LINE1.25:MOD" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
+        $rrd_options .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s ";
+        $rrd_options .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s ";
+        $rrd_options .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\l ";
+        $count++;
+    }
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allvs_conns.inc.php b/html/includes/graphs/device/bigip_ltm_allvs_conns.inc.php new file mode 100644 index 0000000000..611f756459 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allvs_conns.inc.php @@ -0,0 +1,52 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$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:'VS Total Connections Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// add all LTM VS on this device.
+foreach ($components as $compid => $comp) {
+    $label = $comp['label'];
+    $hash = $comp['hash'];
+    $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+    if (file_exists($rrd_filename)) {
+        d_echo("\n  Adding VS: ".$comp['label']."\t+ added to the graph");
+
+        // Grab a colour from the array.
+        if (isset($colours[$count])) {
+            $colour = $colours[$count];
+        } else {
+            d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count);
+        }
+
+        $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":totconns:AVERAGE ";
+        $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
+        $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+        $count++;
+    }
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allvs_pktsin.inc.php b/html/includes/graphs/device/bigip_ltm_allvs_pktsin.inc.php new file mode 100644 index 0000000000..dc52a6562a --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allvs_pktsin.inc.php @@ -0,0 +1,52 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$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:'LTM Vitrual Servers Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// add all LTM VS on this device.
+foreach ($components as $compid => $comp) {
+    $label = $comp['label'];
+    $hash = $comp['hash'];
+    $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+    if (file_exists($rrd_filename)) {
+        d_echo("\n  Adding VS: ".$comp['label']."\t+ added to the graph");
+
+        // Grab a colour from the array.
+        if (isset($colours[$count])) {
+            $colour = $colours[$count];
+        } else {
+            d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count);
+        }
+
+        $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":pktsin:AVERAGE ";
+        $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
+        $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+        $count++;
+    }
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_allvs_pktsout.inc.php b/html/includes/graphs/device/bigip_ltm_allvs_pktsout.inc.php new file mode 100644 index 0000000000..e05a4cfdb8 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_allvs_pktsout.inc.php @@ -0,0 +1,52 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$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:'LTM Vitrual Servers Now Avg Max\\n'"; +$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']); +$count = 0; +d_echo("
");
+
+// add all LTM VS on this device.
+foreach ($components as $compid => $comp) {
+    $label = $comp['label'];
+    $hash = $comp['hash'];
+    $rrd_filename = rrd_name($device['hostname'], array($comp['type'], $label, $hash));
+    if (file_exists($rrd_filename)) {
+        d_echo("\n  Adding VS: ".$comp['label']."\t+ added to the graph");
+
+        // Grab a colour from the array.
+        if (isset($colours[$count])) {
+            $colour = $colours[$count];
+        } else {
+            d_echo("\nError: Out of colours. Have: ".(count($colours)-1).", Requesting:".$count);
+        }
+
+        $rrd_options .= " DEF:DS" . $count . "=" . $rrd_filename . ":pktsout:AVERAGE ";
+        $rrd_options .= " LINE1.25:DS" . $count . "#" . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
+        $rrd_options .= " GPRINT:DS" . $count . ":LAST:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":AVERAGE:%6.2lf%s ";
+        $rrd_options .= " GPRINT:DS" . $count . ":MAX:%6.2lf%s\l ";
+        $count++;
+    }
+}
+d_echo("
"); diff --git a/html/includes/graphs/device/bigip_ltm_vs_bytes.inc.php b/html/includes/graphs/device/bigip_ltm_vs_bytes.inc.php new file mode 100644 index 0000000000..56a8fbb313 --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_vs_bytes.inc.php @@ -0,0 +1,47 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$components = $component->getComponents($device['device_id'], $options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// Is the ID we are looking for a valid LTM VS +if (isset($components[$vars['id']])) { + $label = $components[$vars['id']]['label']; + $hash = $components[$vars['id']]['hash']; + + include "includes/graphs/common.inc.php"; + $rrd_options .= " -l 0 -E "; + $rrd_options .= " COMMENT:'Bits Now Ave Max\\n'"; + + $rrd_filename = rrd_name($device['hostname'], array('f5-ltm-vs', $label, $hash)); + if (file_exists($rrd_filename)) { + $rrd_options .= " DEF:INBYTES=" . $rrd_filename . ":bytesin:AVERAGE "; + $rrd_options .= " CDEF:INBITS=INBYTES,8,* "; + $rrd_options .= " LINE1.25:INBITS#330033:'Bits In '"; + $rrd_options .= " GPRINT:INBITS:LAST:%6.2lf%s "; + $rrd_options .= " GPRINT:INBITS:AVERAGE:%6.2lf%s "; + $rrd_options .= " GPRINT:INBITS:MAX:%6.2lf%s\l "; + + $rrd_options .= " DEF:OUTBYTES=" . $rrd_filename . ":bytesout:AVERAGE "; + $rrd_options .= " CDEF:OUTBITS=OUTBYTES,8,* "; + $rrd_options .= " LINE1.25:OUTBITS#FF6600:'Bits Out'"; + $rrd_options .= " GPRINT:OUTBITS:LAST:%6.2lf%s "; + $rrd_options .= " GPRINT:OUTBITS:AVERAGE:%6.2lf%s "; + $rrd_options .= " GPRINT:OUTBITS:MAX:%6.2lf%s\l "; + } +} diff --git a/html/includes/graphs/device/bigip_ltm_vs_conns.inc.php b/html/includes/graphs/device/bigip_ltm_vs_conns.inc.php new file mode 100644 index 0000000000..a2c062a84e --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_vs_conns.inc.php @@ -0,0 +1,44 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$components = $component->getComponents($device['device_id'], $options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// Is the ID we are looking for a valid LTM VS +if (isset($components[$vars['id']])) { + $label = $components[$vars['id']]['label']; + $hash = $components[$vars['id']]['hash']; + + $rrd_filename = rrd_name($device['hostname'], array('f5-ltm-vs', $label, $hash)); + if (file_exists($rrd_filename)) { + require 'includes/graphs/common.inc.php'; + $ds = 'totconns'; + + $colour_area = '9999cc'; + $colour_line = '0000cc'; + + $colour_area_max = '9999cc'; + + $graph_max = 1; + $graph_min = 0; + + $unit_text = 'Total Connections'; + $line_text = 'Connections'; + require 'includes/graphs/generic_simplex.inc.php'; + } +} diff --git a/html/includes/graphs/device/bigip_ltm_vs_pkts.inc.php b/html/includes/graphs/device/bigip_ltm_vs_pkts.inc.php new file mode 100644 index 0000000000..0d38b7404a --- /dev/null +++ b/html/includes/graphs/device/bigip_ltm_vs_pkts.inc.php @@ -0,0 +1,48 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$options = array(); +$options['filter']['type'] = array('=','f5-ltm-vs'); +$components = $component->getComponents($device['device_id'], $options); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// Is the ID we are looking for a valid LTM VS +if (isset($components[$vars['id']])) { + $label = $components[$vars['id']]['label']; + $hash = $components[$vars['id']]['hash']; + + $rrd_filename = rrd_name($device['hostname'], array('f5-ltm-vs', $label, $hash)); + if (file_exists($rrd_filename)) { + $ds_in = 'pktsin'; + $ds_out = 'pktsout'; + + $colour_area_in = 'AA66AA'; + $colour_line_in = '330033'; + $colour_area_out = 'FFDD88'; + $colour_line_out = 'FF6600'; + + $in_text = 'Packets in'; + $out_text = 'Packets out'; + + $colour_area_in_max = 'cc88cc'; + $colour_area_out_max = 'FFefaa'; + + $graph_max = 1; + $unit_text = 'Packets'; + + require 'includes/graphs/generic_duplex.inc.php'; + } +} diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index caf05ae0db..5b8b6d28c5 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -32,6 +32,9 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { $device['os_group'] = $config['os'][$device['os']]['group']; } + $component = new LibreNMS\Component(); + $component_count = $component->getComponentCount($device['device_id']); + echo '
'; echo ''; require 'includes/device-header.inc.php'; @@ -170,6 +173,16 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { } } + // F5 LTM + if (isset($component_count['f5-ltm-vs'])) { + $device_loadbalancer_count['ltm_vs'] = $component_count['f5-ltm-vs']; + $loadbalancer_tabs[] = 'ltm_vs'; + } + if (isset($component_count['f5-ltm-pool'])) { + $device_loadbalancer_count['ltm_pool'] = $component_count['f5-ltm-pool']; + $loadbalancer_tabs[] = 'ltm_pool'; + } + if (is_array($loadbalancer_tabs)) { echo '
  • @@ -209,11 +222,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) { $routing_tabs[] = 'vrf'; } - $component = new LibreNMS\Component(); - $options['type'] = 'Cisco-OTV'; - $options['filter']['device_id'] = array('=',$device['device_id']); - $otv = $component->getComponents(null, $options); - $device_routing_count['cisco-otv'] = count($otv); + $device_routing_count['cisco-otv'] = $component_count['Cisco-OTV']; if ($device_routing_count['cisco-otv'] > 0) { $routing_tabs[] = 'cisco-otv'; } diff --git a/html/pages/device/loadbalancer.inc.php b/html/pages/device/loadbalancer.inc.php index 7e56c57567..1db40e82c3 100644 --- a/html/pages/device/loadbalancer.inc.php +++ b/html/pages/device/loadbalancer.inc.php @@ -6,12 +6,11 @@ $link_array = array( 'tab' => 'loadbalancer', ); -// Cisco ACE -$type_text['loadbalancer_rservers'] = 'Rservers'; -$type_text['loadbalancer_vservers'] = 'Serverfarms'; - -// Citrix Netscaler -$type_text['netscaler_vsvr'] = 'VServers'; +$type_text['loadbalancer_rservers'] = 'Rservers'; // Cisco ACE +$type_text['loadbalancer_vservers'] = 'Serverfarms'; // Cisco ACE +$type_text['netscaler_vsvr'] = 'VServers'; // Citrix Netscaler +$type_text['ltm_vs'] = 'LTM Virtual Servers'; // F5 BigIP +$type_text['ltm_pool'] = 'LTM Pools'; // F5 BigIP print_optionbar_start(); diff --git a/html/pages/device/loadbalancer/ltm_pool.inc.php b/html/pages/device/loadbalancer/ltm_pool.inc.php new file mode 100644 index 0000000000..80dde3f9ec --- /dev/null +++ b/html/pages/device/loadbalancer/ltm_pool.inc.php @@ -0,0 +1,38 @@ + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id'], array('filter' => array('ignore' => array('=', 0)))); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array($module, 'f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +global $config; + +if (is_file('pages/device/loadbalancer/'.mres($vars['subtype']).'.inc.php')) { + include 'pages/device/loadbalancer/'.mres($vars['subtype']).'.inc.php'; +} else { + include 'pages/device/loadbalancer/ltm_pool_all.inc.php'; +}//end if diff --git a/html/pages/device/loadbalancer/ltm_pool_all.inc.php b/html/pages/device/loadbalancer/ltm_pool_all.inc.php new file mode 100644 index 0000000000..4671dc34f4 --- /dev/null +++ b/html/pages/device/loadbalancer/ltm_pool_all.inc.php @@ -0,0 +1,63 @@ + + * + * 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. + */ + +?> +
  • + + + + + + + + + + + + $array) { + if ($array['type'] != 'f5-ltm-pool') { + continue; + } + if ($array['status'] != 0) { + $message = $array['error']; + $status = 2; + } else { + $message = 'Ok'; + $status = ''; + } + ?> + > + + + + + + + + + +
    poolidNameMinimum MembersCurrent MembersStatusStatus
    + diff --git a/html/pages/device/loadbalancer/ltm_pool_details.inc.php b/html/pages/device/loadbalancer/ltm_pool_details.inc.php new file mode 100644 index 0000000000..f462625024 --- /dev/null +++ b/html/pages/device/loadbalancer/ltm_pool_details.inc.php @@ -0,0 +1,216 @@ + + * + * 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. + */ + +// Determine a pool to show. +if (!isset($vars['poolid'])) { + foreach ($components as $id => $array) { + if ($array['type'] != 'f5-ltm-pool') { + continue; + } + $vars['poolid'] = $id; + } +} + +if ($components[$vars['poolid']]['type'] == 'f5-ltm-pool') { + $array = $components[$vars['poolid']]; + // Define some error messages + $error_poolaction = array (); + $error_poolaction[0] = "Unused"; + $error_poolaction[1] = "Reboot"; + $error_poolaction[2] = "Restart"; + $error_poolaction[3] = "Failover"; + $error_poolaction[4] = "Failover and Restart"; + $error_poolaction[5] = "Go Active"; + $error_poolaction[6] = "None"; + + $parent = $array['UID']; + ?> +
    +
    +
    +
    +
    +
    + Pool:
    + + + + + + + + + + + + + + + + + +
    Minimum Active Servers:
    Current Active Servers:
    Pool Down Action:
    Pool Monitor:
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + Pool Members +
    + + + + + + + + + + > + + + + + +
    NameIP : PortStatus
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Connections

    +
    +
    + +
    +
    + +
    +
    +

    Bytes In

    +
    +
    + +
    +
    + +
    +
    +

    Bytes Out

    +
    +
    + +
    +
    + +
    +
    +

    Packets In

    +
    +
    + +
    +
    + +
    +
    +

    Packets Out

    +
    +
    + +
    +
    +
    +
    +
    + + * + * 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. + */ + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id'], array('filter' => array('ignore' => array('=', 0)))); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array($module, 'f5-ltm-vs', 'f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +global $config; + +if (is_file('pages/device/loadbalancer/'.mres($vars['subtype']).'.inc.php')) { + include 'pages/device/loadbalancer/'.mres($vars['subtype']).'.inc.php'; +} else { + include 'pages/device/loadbalancer/ltm_vs_all.inc.php'; +}//end if diff --git a/html/pages/device/loadbalancer/ltm_vs_all.inc.php b/html/pages/device/loadbalancer/ltm_vs_all.inc.php new file mode 100644 index 0000000000..616cc5aa9a --- /dev/null +++ b/html/pages/device/loadbalancer/ltm_vs_all.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. + */ + +?> + + + + + + + + + + + + + + $array) { + if ($array['type'] != 'f5-ltm-vs') { + continue; + } + $string = $array['IP'].":".$array['port']; + if ($array['status'] != 0) { + $message = $array['error']; + $status = 2; + } else { + $message = 'Ok'; + $status = ''; + } + + // Find the ID for this pool + $id = 0; + foreach ($components as $k => $v) { + if ($v['type'] != 'f5-ltm-pool') { + continue; + } + if ($v['label'] == $array['pool']) { + $id = $k; + } + } + ?> + + + + + + + + + + + +
    vsidpoolidNameIP : PortDefault PoolStatusStatus
    + +
    +
    +

    Connections

    +
    +
    + +
    +
    + +
    +
    +

    Bytes In

    +
    +
    + +
    +
    + +
    +
    +

    Bytes Out

    +
    +
    + +
    +
    + +
    +
    +

    Packets In

    +
    +
    + +
    +
    + +
    +
    +

    Packets Out

    +
    +
    + +
    +
    + diff --git a/html/pages/device/loadbalancer/ltm_vs_common.inc.php b/html/pages/device/loadbalancer/ltm_vs_common.inc.php new file mode 100644 index 0000000000..e81f2f0d1a --- /dev/null +++ b/html/pages/device/loadbalancer/ltm_vs_common.inc.php @@ -0,0 +1,68 @@ + + * + * 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. + */ + +// Pages +$subtypes = array(); +$subtypes['ltm_vs_det'] = 'Virtual Server Details'; +// If we have a defautl pool, display the details. +if ($vars['poolid'] != 0) { + $subtypes['ltm_vs_pool'] = 'Default Pool Details'; +} + +if (!$vars['subtype']) { + $vars['subtype'] = 'ltm_vs_det'; +} + +// Determine a policy to show. +if (!isset($vars['vsid'])) { + foreach ($components as $id => $array) { + if ($array['type'] != 'f5-ltm-vs') { + continue; + } + $vars['vsid'] = $id; + } +} + +print_optionbar_start(); +?> +
    +
    + Virtual Server -
    +
    +
    +
    +
    + $text) { + echo $sep; + if ($vars['subtype'] == $page) { + echo ""; + } + + echo generate_link($text, $vars, array('subtype' => $page)); + if ($vars['subtype'] == $page) { + echo ''; + } + + $sep = ' | '; +} +unset($sep); + +?> +
    +
    + + * + * 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. + */ + +include 'pages/device/loadbalancer/ltm_vs_common.inc.php'; + +if ($components[$vars['vsid']]['type'] == 'f5-ltm-vs') { + ?> +
    +
    +
    +
    +
    +
    +

    Connections

    +
    +
    + +
    +
    + +
    +
    +

    Bytes

    +
    +
    + +
    +
    + +
    +
    +

    Packets

    +
    +
    + +
    +
    +
    +
    +
    + + * + * 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. + */ + +include 'pages/device/loadbalancer/ltm_vs_common.inc.php'; + +if ($components[$vars['poolid']]['type'] == 'f5-ltm-pool') { + $array = $components[$vars['poolid']]; + // Define some error messages + $error_poolaction = array (); + $error_poolaction[0] = "Unused"; + $error_poolaction[1] = "Reboot"; + $error_poolaction[2] = "Restart"; + $error_poolaction[3] = "Failover"; + $error_poolaction[4] = "Failover and Restart"; + $error_poolaction[5] = "Go Active"; + $error_poolaction[6] = "None"; + + $parent = $array['UID']; + ?> +
    +
    +
    +
    +
    +
    + Pool:
    + + + + + + + + + + + + + + + + + +
    Minimum Active Servers:
    Current Active Servers:
    Pool Down Action:
    Pool Monitor:
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + Pool Members +
    + + + + + + + + + + > + + + + + +
    NameIP : PortStatus
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Connections

    +
    +
    + +
    +
    + +
    +
    +

    Bytes In

    +
    +
    + +
    +
    + +
    +
    +

    Bytes Out

    +
    +
    + +
    +
    + +
    +
    +

    Packets In

    +
    +
    + +
    +
    + +
    +
    +

    Packets Out

    +
    +
    + +
    +
    +
    +
    +
    + + * + * 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. + */ + +// Define some error messages +$error_poolaction = array(); +$error_poolaction[0] = "Unused"; +$error_poolaction[1] = "Reboot"; +$error_poolaction[2] = "Restart"; +$error_poolaction[3] = "Failover"; +$error_poolaction[4] = "Failover and Restart"; +$error_poolaction[5] = "Go Active"; +$error_poolaction[6] = "None"; + +$component = new LibreNMS\Component(); +$components = $component->getComponents($device['device_id']); + +// We only care about our device id. +$components = $components[$device['device_id']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array($module, 'bigip', 'f5-ltm-vs', 'f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +// Begin our master array, all other values will be processed into this array. +$tblBigIP = array(); + +// Let's gather some data.. +$ltmVirtualServEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.10.1.2.1', 0); +$ltmVsStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.10.13.2.1', 0); +$ltmPoolEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.1.2.1', 0); +$ltmPoolMemberEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.3.2.1', 0); +$ltmPoolMbrStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.6.2.1', 0); + +/* + * False == no object found - this is not an error, OID doesn't exist. + * null == timeout or something else that caused an error, OID may exist but we couldn't get it. + */ +if (!is_null($ltmVirtualServEntry) || !is_null($ltmVsStatusEntry) || !is_null($ltmPoolEntry) || !is_null($ltmPoolMemberEntry) || !is_null($ltmPoolMbrStatusEntry)) { + // No Nulls, lets go.... + d_echo("Objects Found:\n"); + + // Process the Virtual Servers + if (is_array($ltmVsStatusEntry)) { + foreach ($ltmVsStatusEntry as $oid => $value) { + $result = array(); + + // Find all Virtual server names and UID's, then we can find everything else we need. + if (strpos($oid, '1.3.6.1.4.1.3375.2.2.10.13.2.1.1.') !== false) { + list($null, $index) = explode('1.3.6.1.4.1.3375.2.2.10.13.2.1.1.', $oid); + $result['type'] = 'f5-ltm-vs'; + $result['UID'] = (string)$index; + $result['label'] = $value; + // The UID is far too long to have in a RRD filename, use a hash of it instead. + $result['hash'] = hash('crc32', $result['UID']); + + // Now that we have our UID we can pull all the other data we need. + $result['IP'] = hex_to_ip($ltmVirtualServEntry['1.3.6.1.4.1.3375.2.2.10.1.2.1.3.'.$index]); + $result['port'] = $ltmVirtualServEntry['1.3.6.1.4.1.3375.2.2.10.1.2.1.6.'.$index]; + $result['pool'] = $ltmVirtualServEntry['1.3.6.1.4.1.3375.2.2.10.1.2.1.19.'.$index]; + + // 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue + $result['state'] = $ltmVsStatusEntry['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.'.$index]; + if ($result['state'] == 2) { + // Looks like one of the VS Pool members is down. + $result['status'] = 1; + $result['error'] = $ltmVsStatusEntry['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index]; + } elseif ($result['state'] == 3) { + // Looks like ALL of the VS Pool members is down. + $result['status'] = 2; + $result['error'] = $ltmVsStatusEntry['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$index]; + } else { + // All is good. + $result['status'] = 0; + $result['error'] = ''; + } + } + + // Do we have any results + if (count($result) > 0) { + // Let's log some debugging + d_echo("\n\n".$result['type'].": ".$result['label']."\n"); + d_echo(" Status: ".$result['status']."\n"); + d_echo(" Message: ".$result['error']."\n"); + + // Add this result to the master array. + $tblBigIP[] = $result; + } + } + } + + // Process the Pools + if (is_array($ltmPoolEntry)) { + foreach ($ltmPoolEntry as $oid => $value) { + $result = array (); + + // Find all Pool names and UID's, then we can find everything else we need. + if (strpos($oid, '1.3.6.1.4.1.3375.2.2.5.1.2.1.1.') !== false) { + list($null, $index) = explode('1.3.6.1.4.1.3375.2.2.5.1.2.1.1.', $oid); + $result['type'] = 'f5-ltm-pool'; + $result['UID'] = (string)$index; + $result['label'] = $value; + // The UID is far too long to have in a RRD filename, use a hash of it instead. + $result['hash'] = hash('crc32', $result['UID']); + + // Now that we have our UID we can pull all the other data we need. + $result['mode'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.2.'.$index]; + $result['minup'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.'.$index]; + $result['minupstatus'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.'.$index]; + $result['currentup'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.'.$index]; + $result['minupaction'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.'.$index]; + $result['monitor'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.17.'.$index]; + + // If we have less pool members than the minimum, we should error. + if ($result['currentup'] < $result['minup']) { + // Danger Will Robinson... We dont have enough Pool Members! + $result['status'] = 2; + $result['error'] = "Minimum Pool Members not met. Action taken: ".$error_poolaction[$result['minupaction']]; + } else { + // All is good. + $result['status'] = 0; + $result['error'] = ''; + } + } + + // Do we have any results + if (count($result) > 0) { + // Let's log some debugging + d_echo("\n\n".$result['type'].": ".$result['label']."\n"); + d_echo(" Status: ".$result['status']."\n"); + d_echo(" Message: ".$result['error']."\n"); + + // Add this result to the master array. + $tblBigIP[] = $result; + } + } + } + + // Process the Pool Members + if (is_array($ltmPoolMemberEntry)) { + foreach ($ltmPoolMemberEntry as $oid => $value) { + $result = array (); + + // Find all Pool member names and UID's, then we can find everything else we need. + if (strpos($oid, '1.3.6.1.4.1.3375.2.2.5.3.2.1.19.') !== false) { + list($null, $index) = explode('1.3.6.1.4.1.3375.2.2.5.3.2.1.19.', $oid); + $result['type'] = 'f5-ltm-poolmember'; + $result['UID'] = (string)$index; + $result['label'] = $value; + // The UID is far too long to have in a RRD filename, use a hash of it instead. + $result['hash'] = hash('crc32', $result['UID']); + + // Now that we have our UID we can pull all the other data we need. + $result['IP'] = hex_to_ip($ltmPoolMemberEntry['1.3.6.1.4.1.3375.2.2.5.3.2.1.3.'.$index]); + $result['port'] = $ltmPoolMemberEntry['1.3.6.1.4.1.3375.2.2.5.3.2.1.4.'.$index]; + $result['ratio'] = $ltmPoolMemberEntry['1.3.6.1.4.1.3375.2.2.5.3.2.1.6.'.$index]; + $result['weight'] = $ltmPoolMemberEntry['1.3.6.1.4.1.3375.2.2.5.3.2.1.7.'.$index]; + $result['priority'] = $ltmPoolMemberEntry['1.3.6.1.4.1.3375.2.2.5.3.2.1.8.'.$index]; + $result['state'] = $ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.'.$index]; + $result['available'] = $ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.'.$index]; + + // If available and bad state + // 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue + if (($result['available'] == 1) && ($result['state'] == 3)) { + // Warning Alarm, the pool member is down. + $result['status'] = 1; + $result['error'] = "Pool Member is Down: ".$ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.'.$index]; + } else { + // All is good. + $result['status'] = 0; + $result['error'] = ''; + } + } + + // Do we have any results + if (count($result) > 0) { + // Let's log some debugging + d_echo("\n\n".$result['type'].": ".$result['label']."\n"); + d_echo(" Status: ".$result['status']."\n"); + d_echo(" Message: ".$result['error']."\n"); + + // Add this result to the master array. + $tblBigIP[] = $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 ($tblBigIP 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']) && ($child['type'] === $array['type'])) { + $component_key = $compid; + } + } + + if (!$component_key) { + // The component doesn't exist, we need to ADD it - ADD. + $new_component = $component->createComponent($device['device_id'], $array['type']); + $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 ($tblBigIP as $k => $v) { + if (($array['UID'] == $v['UID']) && ($array['type'] == $v['type'])) { + // 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 diff --git a/includes/polling/loadbalancers.inc.php b/includes/polling/loadbalancers.inc.php new file mode 100644 index 0000000000..22cf922e46 --- /dev/null +++ b/includes/polling/loadbalancers.inc.php @@ -0,0 +1,14 @@ + + * + * 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. + */ + +// Define some error messages +$error_poolaction = array(); +$error_poolaction[0] = "Unused"; +$error_poolaction[1] = "Reboot"; +$error_poolaction[2] = "Restart"; +$error_poolaction[3] = "Failover"; +$error_poolaction[4] = "Failover and Restart"; +$error_poolaction[5] = "Go Active"; +$error_poolaction[6] = "None"; + +$component = new LibreNMS\Component(); +$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']]; + +// We extracted all the components for this device, now lets only get the LTM ones. +$keep = array(); +$types = array('f5-ltm-vs', 'f5-ltm-pool', 'f5-ltm-poolmember'); +foreach ($components as $k => $v) { + foreach ($types as $type) { + if ($v['type'] == $type) { + $keep[$k] = $v; + } + } +} +$components = $keep; + +// Only collect SNMP data if we have enabled components +if (count($components > 0)) { + // Let's gather the stats.. + $ltmVirtualServStatEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.3375.2.2.10.2.3.1', 0); + $ltmPoolMemberStatEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.3375.2.2.5.4.3.1', 0); + $sysGlobalHttpStat = snmpwalk_array_num($device, '.1.3.6.1.4.1.3375.2.1.1.2.4', 0); + + // and check the status + $ltmVsStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.10.13.2.1', 0); + $ltmPoolMbrStatusEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.6.2.1', 0); + $ltmPoolEntry = snmpwalk_array_num($device, '1.3.6.1.4.1.3375.2.2.5.1.2.1', 0); + + // Loop through the components and extract the data. + foreach ($components as $key => &$array) { + $type = $array['type']; + $UID = $array['UID']; + $label = $array['label']; + $hash = $array['hash']; + $rrd_name = array($type, $label, $hash); + + if ($type == 'f5-ltm-vs') { + $rrd_def = array( + 'DS:pktsin:COUNTER:600:0:U', + 'DS:pktsout:COUNTER:600:0:U', + 'DS:bytesin:COUNTER:600:0:U', + 'DS:bytesout:COUNTER:600:0:U', + 'DS:totconns:COUNTER:600:0:U', + ); + + $fields = array( + 'pktsin' => $ltmVirtualServStatEntry['1.3.6.1.4.1.3375.2.2.10.2.3.1.6.'.$UID], + 'pktsout' => $ltmVirtualServStatEntry['1.3.6.1.4.1.3375.2.2.10.2.3.1.8.'.$UID], + 'bytesin' => $ltmVirtualServStatEntry['1.3.6.1.4.1.3375.2.2.10.2.3.1.7.'.$UID], + 'bytesout' => $ltmVirtualServStatEntry['1.3.6.1.4.1.3375.2.2.10.2.3.1.9.'.$UID], + 'totconns' => $ltmVirtualServStatEntry['1.3.6.1.4.1.3375.2.2.10.2.3.1.11.'.$UID], + ); + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Type: ".$type."\n"); + d_echo(" Label: ".$label."\n"); + + // Let's check the status. + $array['state'] = $ltmVsStatusEntry['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.'.$UID]; + if (($array['state'] == 2) || ($array['state'] == 3)) { + // The Virtual Server is unavailable. + $array['status'] = 2; + $array['error'] = $ltmVsStatusEntry['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$UID]; + } else { + // All is good. + $array['status'] = 0; + $array['error'] = ''; + } + } elseif ($type == 'f5-ltm-pool') { + $rrd_def = array( + 'DS:minup:GAUGE:600:0:U', + 'DS:currup:GAUGE:600:0:U', + ); + + $array['minup'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.'.$UID]; + $array['minupstatus'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.'.$index]; + $array['currentup'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.'.$UID]; + $array['minupaction'] = $ltmPoolEntry['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.'.$UID]; + + $fields = array( + 'minup' => $array['minup'], + 'currup' => $array['currentup'], + ); + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Type: ".$type."\n"); + d_echo(" Label: ".$label."\n"); + + // If we have less pool members than the minimum, we should error. + if ($array['currentup'] < $array['minup']) { + // Danger Will Robinson... We dont have enough Pool Members! + $array['status'] = 2; + $array['error'] = "Minimum Pool Members not met. Action taken: ".$error_poolaction[$array['minupaction']]; + } else { + // All is good. + $array['status'] = 0; + $array['error'] = ''; + } + } elseif ($type == 'f5-ltm-poolmember') { + $rrd_def = array( + 'DS:pktsin:COUNTER:600:0:U', + 'DS:pktsout:COUNTER:600:0:U', + 'DS:bytesin:COUNTER:600:0:U', + 'DS:bytesout:COUNTER:600:0:U', + 'DS:totconns:COUNTER:600:0:U', + ); + + $array['state'] = $ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.'.$UID]; + $array['available'] = $ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.'.$UID]; + + $fields = array( + 'pktsin' => $ltmPoolMemberStatEntry['1.3.6.1.4.1.3375.2.2.5.4.3.1.5.'.$UID], + 'pktsout' => $ltmPoolMemberStatEntry['1.3.6.1.4.1.3375.2.2.5.4.3.1.7.'.$UID], + 'bytesin' => $ltmPoolMemberStatEntry['1.3.6.1.4.1.3375.2.2.5.4.3.1.6.'.$UID], + 'bytesout' => $ltmPoolMemberStatEntry['1.3.6.1.4.1.3375.2.2.5.4.3.1.8.'.$UID], + 'totalconns' => $ltmPoolMemberStatEntry['1.3.6.1.4.1.3375.2.2.5.4.3.1.10.'.$UID], + ); + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Type: ".$type."\n"); + d_echo(" Label: ".$label."\n"); + + // If available and bad state + // 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue + if (($array['available'] == 1) && ($array['state'] == 3)) { + // Warning Alarm, the pool member is down. + $array['status'] = 1; + $array['error'] = "Pool Member is Down: ".$ltmPoolMbrStatusEntry['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.'.$UID]; + } else { + // All is good. + $array['status'] = 0; + $array['error'] = ''; + } + } else { + d_echo("Type is unknown: ".$type."\n"); + continue; + } + + $tags = compact('rrd_name', 'rrd_def', 'type', 'hash', 'label'); + data_update($device, $type, $tags, $fields); + } // 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); diff --git a/sql-schema/153.sql b/sql-schema/153.sql new file mode 100644 index 0000000000..b0dfeb4858 --- /dev/null +++ b/sql-schema/153.sql @@ -0,0 +1 @@ +ALTER TABLE `component_prefs` CHANGE `value` `value` text NOT NULL COMMENT 'Value for the Component';