From bf37312bdcb708997e9335c2914a3bd34b621996 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Thu, 21 Jan 2016 21:18:14 +1000 Subject: [PATCH 01/42] Cisco CBQOS Implements the CISCO-CLASS-BASED-QOS-MIB to retrieve QOS counters from Cisco devices. Policy and Class-map details are collected and stored in the database. Details are presented on a new "CBQoS" tab of the interface that the policy is applied to. Includes a policy selector that allows you to select which policy-map to show graphs for. Each class-map has its own rrd file, in which 3 metrics are stored: Bytes, QoS Drops, Buffer Drops. This can produce a LOT of rrd files. As an example: A Cisco 4500 series switch, running MQC on 200 ports. Each port has a common 5 class queueing policy applied, this creates 1000 (5 x 200) RRD's. Because of this I have currently set: ``` $config['discovery_modules']['cisco-cbqos'] = 0; ``` Includes function snmpwalk_array_num, which performs a numeric SNMPWalk and returns an array containing $count indexes One Index: From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27.18']['655360'] = 0 Two Indexes: From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27']['18']['655360'] = 0 And so on... --- .../graphs/port/cbqos_bufferdrops.inc.php | 75 +++++++ .../graphs/port/cbqos_qosdrops.inc.php | 75 +++++++ .../graphs/port/cbqos_traffic.inc.php | 75 +++++++ html/pages/device/port.inc.php | 6 + html/pages/device/port/cbqos.inc.php | 131 +++++++++++++ includes/defaults.inc.php | 2 + includes/discovery/cisco-cbqos.inc.php | 184 ++++++++++++++++++ includes/polling/cisco-cbqos.inc.php | 72 +++++++ includes/snmp.inc.php | 66 +++++++ 9 files changed, 686 insertions(+) create mode 100644 html/includes/graphs/port/cbqos_bufferdrops.inc.php create mode 100644 html/includes/graphs/port/cbqos_qosdrops.inc.php create mode 100644 html/includes/graphs/port/cbqos_traffic.inc.php create mode 100644 html/pages/device/port/cbqos.inc.php create mode 100644 includes/discovery/cisco-cbqos.inc.php create mode 100644 includes/polling/cisco-cbqos.inc.php diff --git a/html/includes/graphs/port/cbqos_bufferdrops.inc.php b/html/includes/graphs/port/cbqos_bufferdrops.inc.php new file mode 100644 index 000000000..93626bc15 --- /dev/null +++ b/html/includes/graphs/port/cbqos_bufferdrops.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. + */ + +require_once "../includes/component.php"; +$COMPONENT = new component(); +$options['filter']['type'] = array('=','Cisco-CBQOS'); +$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + +// We only care about our device id. +$COMPONENTS = $COMPONENTS[$device['device_id']]; + +// Determine a policy to show. +if (!isset($vars['policy'])) { + foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + // Found the first policy + $vars['policy'] = $ID; + continue; + } + } +} + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; +$rrd_additions = ""; + +$COUNT = 0; +foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $STACK = ""; + if ($COUNT != 0) { + $STACK = ":STACK "; + } + + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { + $COLOR = $config['graph_colours']['mixed'][$COUNT]; + } + else { + $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + } + + $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; + $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + + $COUNT++; + } + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} +else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/port/cbqos_qosdrops.inc.php b/html/includes/graphs/port/cbqos_qosdrops.inc.php new file mode 100644 index 000000000..ea107b380 --- /dev/null +++ b/html/includes/graphs/port/cbqos_qosdrops.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. + */ + +require_once "../includes/component.php"; +$COMPONENT = new component(); +$options['filter']['type'] = array('=','Cisco-CBQOS'); +$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + +// We only care about our device id. +$COMPONENTS = $COMPONENTS[$device['device_id']]; + +// Determine a policy to show. +if (!isset($vars['policy'])) { + foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + // Found the first policy + $vars['policy'] = $ID; + continue; + } + } +} + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; +$rrd_additions = ""; + +$COUNT = 0; +foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $STACK = ""; + if ($COUNT != 0) { + $STACK = ":STACK "; + } + + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { + $COLOR = $config['graph_colours']['mixed'][$COUNT]; + } + else { + $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + } + + $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":qosdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; + $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + + $COUNT++; + } + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} +else { + $rrd_options .= $rrd_additions; +} diff --git a/html/includes/graphs/port/cbqos_traffic.inc.php b/html/includes/graphs/port/cbqos_traffic.inc.php new file mode 100644 index 000000000..3cf7291fd --- /dev/null +++ b/html/includes/graphs/port/cbqos_traffic.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. + */ + +require_once "../includes/component.php"; +$COMPONENT = new component(); +$options['filter']['type'] = array('=','Cisco-CBQOS'); +$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + +// We only care about our device id. +$COMPONENTS = $COMPONENTS[$device['device_id']]; + +// Determine a policy to show. +if (!isset($vars['policy'])) { + foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + // Found the first policy + $vars['policy'] = $ID; + continue; + } + } +} + +include "includes/graphs/common.inc.php"; +$rrd_options .= " -l 0 -E "; +$rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; +$rrd_additions = ""; + +$COUNT = 0; +foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); + + if (file_exists($rrd_filename)) { + // Stack the area on the second and subsequent DS's + $STACK = ""; + if ($COUNT != 0) { + $STACK = ":STACK "; + } + + // Grab a color from the array. + if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { + $COLOR = $config['graph_colours']['mixed'][$COUNT]; + } + else { + $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + } + + $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":postbits:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; + $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + + $COUNT++; + } + } +} + +if ($rrd_additions == "") { + // We didn't add any data points. +} +else { + $rrd_options .= $rrd_additions; +} diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index b00b36855..d1682ee56 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -87,6 +87,12 @@ if (dbFetchCell("SELECT COUNT(*) FROM `ports_vlans` WHERE `port_id` = '".$port[' $menu_options['vlans'] = 'VLANs'; } +// Are there any CBQoS rrd's for this ifIndex? +$cbqos = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); +if (!empty($cbqos)) { + $menu_options['cbqos'] = 'CBQoS'; +} + $sep = ''; foreach ($menu_options as $option => $text) { echo $sep; diff --git a/html/pages/device/port/cbqos.inc.php b/html/pages/device/port/cbqos.inc.php new file mode 100644 index 000000000..fbcfafdd0 --- /dev/null +++ b/html/pages/device/port/cbqos.inc.php @@ -0,0 +1,131 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +function find_child($COMPONENTS,$parent,$level) { + global $vars; + + foreach($COMPONENTS as $ID => $ARRAY) { + if ($ARRAY['qos-type'] == 3) { + continue; + } + if (($ARRAY['parent'] == $COMPONENTS[$parent]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$parent]['sp-id'])) { + echo ""; + } + } +} + +$rrdarr = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); +if (!empty($rrdarr)) { + require_once "../includes/component.php"; + $COMPONENT = new component(); + $options['filter']['type'] = array('=','Cisco-CBQOS'); + $COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + + // We only care about our device id. + $COMPONENTS = $COMPONENTS[$device['device_id']]; + + if (isset($vars['policy'])) { + // if a policy is set try to use it. + $graph_array['policy'] = $vars['policy']; + } + else { + // if not, find the first parent and use it. + foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + // Found the first policy + $graph_array['policy'] = $ID; + continue; + } + } + } + echo "\n\n"; + + // Display the ingress policy at the top of the page. + echo "
'; + + // Display the egress policy at the top of the page. + echo "
\n\n"; + + // Let's make sure the policy we are trying to access actually exists. + foreach ($COMPONENTS as $ID => $ARRAY) { + if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ID == $graph_array['policy']) ) { + // The policy exists. + + echo "
 
\n\n"; + + // Display each graph row. + echo "
"; + echo "
Traffic by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
"; + $graph_type = 'port_cbqos_traffic'; + include 'includes/print-interface-graphs.inc.php'; + + echo "
QoS Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
"; + $graph_type = 'port_cbqos_bufferdrops'; + include 'includes/print-interface-graphs.inc.php'; + + echo "
Buffer Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
"; + $graph_type = 'port_cbqos_qosdrops'; + include 'includes/print-interface-graphs.inc.php'; + echo "
\n\n"; + } + } +} diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 328ae2ce0..dff8f976d 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -710,6 +710,7 @@ $config['poller_modules']['applications'] = 1; $config['poller_modules']['cisco-asa-firewall'] = 1; $config['poller_modules']['mib'] = 0; $config['poller_modules']['cisco-voice'] = 1; +$config['poller_modules']['cisco-cbqos'] = 1; $config['poller_modules']['stp'] = 1; // List of discovery modules. Need to be in this array to be @@ -742,6 +743,7 @@ $config['discovery_modules']['toner'] = 1; $config['discovery_modules']['ucd-diskio'] = 1; $config['discovery_modules']['services'] = 1; $config['discovery_modules']['charge'] = 1; +$config['discovery_modules']['cisco-cbqos'] = 0; $config['discovery_modules']['stp'] = 1; $config['modules_compat']['rfc1628']['liebert'] = 1; diff --git a/includes/discovery/cisco-cbqos.inc.php b/includes/discovery/cisco-cbqos.inc.php new file mode 100644 index 000000000..86eec8d9c --- /dev/null +++ b/includes/discovery/cisco-cbqos.inc.php @@ -0,0 +1,184 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os_group'] == 'cisco') { + + $MODULE = 'Cisco-CBQOS'; + echo $MODULE.': '; + + require_once 'includes/component.php'; + $COMPONENT = new component(); + $COMPONENTS = $COMPONENT->getComponents($device['device_id'],array('type'=>$MODULE)); + + // We only care about our device id. + $COMPONENTS = $COMPONENTS[$device['device_id']]; + + + // Begin our master array, all other values will be processed into this array. + $tblCBQOS = array(); + + // Let's gather some data.. + $tblcbQosServicePolicy = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.1'); + $tblcbQosObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.5', 2); + $tblcbQosPolicyMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.6'); + $tblcbQosClassMapCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.7'); + $tblcbQosMatchStmtCfg = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.8'); + + /* + * False == no object found - this is not an error, there is no QOS configured + * null == timeout or something else that caused an error, there may be QOS configured but we couldn't get it. + */ + if ( is_null($tblcbQosServicePolicy) || is_null($tblcbQosObjects) || is_null($tblcbQosPolicyMapCfg) || is_null($tblcbQosClassMapCfg) || is_null($tblcbQosMatchStmtCfg) ) { + // We have to error here or we will end up deleting all our QoS components. + echo "Error\n"; + } + else { + // No Error, lets process things. + d_echo("QoS Objects Found:\n"); + + foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'] as $spid => $array) { + + foreach ($array as $spobj => $index) { + $RESULT = array(); + + // Produce a unique reproducible index for this entry. + $RESULT['UID'] = hash('crc32', $spid."-".$spobj); + + // Now that we have a valid identifiers, lets add some more data + $RESULT['sp-id'] = $spid; + $RESULT['sp-obj'] = $spobj; + + // Add the Type, Policy-map, Class-map, etc. + $type = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$spobj]; + $RESULT['qos-type'] = $type; + + // Add the Parent, this lets us work out our hierarchy for display later. + $RESULT['parent'] = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid][$spobj]; + $RESULT['direction'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.3'][$spid]; + $RESULT['ifindex'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.4'][$spid]; + + // Gather different data depending on the type. + switch ($type) { + case 1: + // Policy-map, get data from that table. + d_echo("\nIndex: ".$index."\n"); + d_echo(" UID: ".$RESULT['UID']."\n"); + d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); + d_echo(" If-Index: ".$RESULT['ifindex']."\n"); + d_echo(" Type: 1 - Policy-Map\n"); + $RESULT['label'] = $tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.1'][$index]; + if ($tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index] != "") { + $RESULT['label'] .= " - ".$tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index]; + } + d_echo(" Label: ".$RESULT['label']."\n"); + break; + case 2: + // Class-map, get data from that table. + d_echo("\nIndex: ".$index."\n"); + d_echo(" UID: ".$RESULT['UID']."\n"); + d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); + d_echo(" If-Index: ".$RESULT['ifindex']."\n"); + d_echo(" Type: 2 - Class-Map\n"); + $RESULT['label'] = $tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.1'][$index]; + if($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index] != "") { + $RESULT['label'] .= " - ".$tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index]; + } + d_echo(" Label: ".$RESULT['label']."\n"); + if ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 2) { + $RESULT['map-type'] = 'Match-All'; + } + elseif ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 3) { + $RESULT['map-type'] = 'Match-Any'; + } + else { + $RESULT['map-type'] = 'None'; + } + + // Find a child, this will be a type 3 + foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid] as $ID => $VALUE) { + if ($VALUE == $RESULT['sp-obj']) { + // We have our child, import the match + if ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$ID] == 3) { + $RESULT['match'] = $RESULT['map-type'].": ".$tblcbQosMatchStmtCfg['1.3.6.1.4.1.9.9.166.1.8.1.1.1'][$tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'][$spid][$ID]]; + d_echo(" Match: ".$RESULT['match']."\n"); + } + } + } + break; + default: + continue 2; + } + + $tblCBQOS[] = $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 ($tblCBQOS as $key => $array) { + $COMPONENT_KEY = false; + + // Loop over our components to determine if the component exists, or we need to add it. + foreach ($COMPONENTS as $COMPID => $CHILD) { + if ($CHILD['UID'] === $array['UID']) { + $COMPONENT_KEY = $COMPID; + } + } + + if (!$COMPONENT_KEY) { + // The component doesn't exist, we need to ADD it - ADD. + $NEW_COMPONENT = $COMPONENT->createComponent($device['device_id'],$MODULE); + $COMPONENT_KEY = key($NEW_COMPONENT); + $COMPONENTS[$COMPONENT_KEY] = array_merge($NEW_COMPONENT[$COMPONENT_KEY], $array); + echo "+"; + } + else { + // The component does exist, merge the details in - UPDATE. + $COMPONENTS[$COMPONENT_KEY] = array_merge($COMPONENTS[$COMPONENT_KEY], $array); + echo "."; + } + + } + + /* + * Loop over the Component data to see if we need to DELETE any components. + */ + foreach ($COMPONENTS as $key => $array) { + // Guilty until proven innocent + $FOUND = false; + + foreach ($tblCBQOS as $k => $v) { + if ($array['UID'] == $v['UID']) { + // Yay, we found it... + $FOUND = true; + } + } + + if ($FOUND === false) { + // The component has not been found. we should delete it. + echo "-"; + $COMPONENT->deleteComponent($key); + } + } + + // Write the Components back to the DB. + $COMPONENT->setComponentPrefs($device['device_id'],$COMPONENTS); + echo "\n"; + + } // End if not error + +} diff --git a/includes/polling/cisco-cbqos.inc.php b/includes/polling/cisco-cbqos.inc.php new file mode 100644 index 000000000..7d8fea76d --- /dev/null +++ b/includes/polling/cisco-cbqos.inc.php @@ -0,0 +1,72 @@ + + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +if ($device['os_group'] == "cisco") { + + $MODULE = 'Cisco-CBQOS'; + + require_once 'includes/component.php'; + $COMPONENT = new component(); + $options['filter']['type'] = array('=',$MODULE); + $options['filter']['disabled'] = array('=',0); + $options['filter']['ignore'] = array('=',0); + $COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + + // We only care about our device id. + $COMPONENTS = $COMPONENTS[$device['device_id']]; + + // Only collect SNMP data if we have enabled components + if (count($COMPONENTS > 0)) { + // Let's gather the stats.. + $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2); + + // Loop through the components and extract the data. + foreach ($COMPONENTS as $KEY => $ARRAY) { + $TYPE = $ARRAY['qos-type']; + + // Get data from the class table. + if ($TYPE == 2) { + // Let's make sure the RRD is setup for this class. + $filename = "port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"; + $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); + + if (!file_exists ($rrd_filename)) { + rrdtool_create ($rrd_filename, " DS:postbits:COUNTER:600:0:U DS:bufferdrops:COUNTER:600:0:U DS:qosdrops:COUNTER:600:0:U" . $config['rrd_rra']); + } + + // Let's print some debugging info. + d_echo("\n\nComponent: ".$KEY."\n"); + d_echo(" Class-Map: ".$ARRAY['label']."\n"); + d_echo(" SPID.SPOBJ: ".$ARRAY['sp-id'].".".$ARRAY['sp-obj']."\n"); + d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); + d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); + d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); + + $RRD['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; + $RRD['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; + $RRD['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; + + // Update RRD + rrdtool_update ($rrd_filename, $RRD); + + // Clean-up after yourself! + unset($filename, $rrd_filename); + } + } // End foreach components + + echo $MODULE." "; + } // end if count components + + // Clean-up after yourself! + unset($TYPE, $COMPONENTS, $COMPONENT, $options, $MODULE); +} \ No newline at end of file diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index e2d4bac01..cee0032cc 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1268,4 +1268,70 @@ function register_mibs($device, $mibs, $included_by) } echo "\n"; + } // register_mibs + +/** + * SNMPWalk_array_num - performs a numeric SNMPWalk and returns an array containing $count indexes + * One Index: + * From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 + * To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27.18']['655360'] = 0 + * Two Indexes: + * From: 1.3.6.1.4.1.9.9.166.1.15.1.1.27.18.655360 = 0 + * To: $array['1.3.6.1.4.1.9.9.166.1.15.1.1.27']['18']['655360'] = 0 + * And so on... + * Think snmpwalk_cache_*_oid but for numeric data. + * + * Why is this useful? + * Some SNMP data contains a single index (eg. ifIndex in IF-MIB) and some is dual indexed + * (eg. PolicyIndex/ObjectsIndex in CISCO-CLASS-BASED-QOS-MIB). + * The resulting array allows us to easily access the top level index we want and iterate over the data from there. + * + * @param $device + * @param $OID + * @param int $indexes + * @internal param $string + * @return array + */ +function snmpwalk_array_num($device,$OID,$indexes=1) { + $array = array(); + $string = snmp_walk($device, $OID, '-Osqn'); + + if ( $string === false) { + // False means: No Such Object. + return false; + } + if ($string == "") { + // Empty means SNMP timeout or some such. + return null; + } + + // Let's turn the string into something we can work with. + foreach (explode("\n", $string) as $line) { + if ($line[0] == '.') { + // strip the leading . if it exists. + $line = substr($line,1); + } + list($key, $value) = explode(' ', $line, 2); + $prop_id = explode('.', $key); + $value = trim($value); + + // if we have requested more levels that exist, set to the max. + if ($indexes > count($prop_id)) { + $indexes = count($prop_id)-1; + } + + for ($i=0;$i<$indexes;$i++) { + // Pop the index off. + $index = array_pop($prop_id); + $value = array($index => $value); + } + + // Rebuild our key + $key = implode('.',$prop_id); + + // Add the entry to the master array + $array = array_replace_recursive($array,array($key => $value)); + } + return $array; +} From 686bffd39fac702a847d2a2335910c9233652bc7 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 24 Jan 2016 18:42:27 +0100 Subject: [PATCH 02/42] Removes duplicate alerts from table alerts then adds uniqueness in alerts table for (device_id+rule_id) --- sql-schema/094.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sql-schema/094.sql diff --git a/sql-schema/094.sql b/sql-schema/094.sql new file mode 100644 index 000000000..dd0f72667 --- /dev/null +++ b/sql-schema/094.sql @@ -0,0 +1,3 @@ +DELETE a1 FROM alerts a1, alerts a2 WHERE a1.id < a2.id AND a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id; +ALTER TABLE `alerts` ADD UNIQUE `unique_alert`(`device_id`, `rule_id`); + From b476c5bf99db035511323daf1efe46ab85d825bb Mon Sep 17 00:00:00 2001 From: vitalisator Date: Thu, 14 Jan 2016 16:54:07 +0100 Subject: [PATCH 03/42] add STP Ports --- html/pages/device/stp.inc.php | 14 ++++--- includes/discovery/stp.inc.php | 67 +++++++++++++++++++++++++++++++++- includes/polling/stp.inc.php | 55 +++++++++++++++++++++++++++- 3 files changed, 129 insertions(+), 7 deletions(-) diff --git a/html/pages/device/stp.inc.php b/html/pages/device/stp.inc.php index 74a803b0b..52dda8028 100644 --- a/html/pages/device/stp.inc.php +++ b/html/pages/device/stp.inc.php @@ -15,7 +15,7 @@ if (!$vars['view']) { } $menu_options['basic'] = 'Basic'; -// $menu_options['details'] = 'Details'; +$menu_options['ports'] = 'Ports'; $sep = ''; foreach ($menu_options as $option => $text) { echo $sep; @@ -37,12 +37,16 @@ print_optionbar_end(); echo ''; -$i = '1'; - -foreach (dbFetchRows("SELECT * FROM `stp` WHERE `device_id` = ? ORDER BY 'stp_id'", array($device['device_id'])) as $stp) { +if ($vars['view'] == 'basic') { + //$i = '1'; + foreach (dbFetchRows("SELECT * FROM `stp` WHERE `device_id` = ? ORDER BY 'stp_id'", array($device['device_id'])) as $stp) { include 'includes/print-stp.inc.php'; + // $i++; + } +} - $i++; +if ($vars['view'] == 'ports') { + include 'includes/print-stp-ports.inc.php'; } echo '
'; diff --git a/includes/discovery/stp.inc.php b/includes/discovery/stp.inc.php index c6be49f56..6e85a8ff0 100644 --- a/includes/discovery/stp.inc.php +++ b/includes/discovery/stp.inc.php @@ -112,7 +112,72 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { log_event('STP removed', $device, 'stp'); echo '-'; } + + // STP port related stuff + foreach ($stp_raw as $port => $value){ + if ($port) { // $stp_raw[0] ist not port related so we skip this one + $stp_port = array( + 'priority' => $stp_raw[$port]['dot1dStpPortPriority'], + 'state' => $stp_raw[$port]['dot1dStpPortState'], + 'enable' => $stp_raw[$port]['dot1dStpPortEnable'], + 'pathCost' => $stp_raw[$port]['dot1dStpPortPathCost'], + 'designatedCost' => $stp_raw[$port]['dot1dStpPortDesignatedCost'], + 'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'], + 'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions'] + ); + + // set device binding + $stp_port['device_id'] = $device['device_id']; + + // set port binding + $stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort'])); + + $dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot'])); + $dr = substr($dr, -12); //remove first two octets + $stp_port['designatedRoot'] = $dr; + + $db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge'])); + $db = substr($db, -12); //remove first two octets + $stp_port['designatedBridge'] = $db; + + if ($device['os'] == 'pbn') { + // It seems that PBN guys don't care about ieee 802.1d :-( + // So try to find the right port with some crazy conversations + $dp_value = dechex($stp_port['priority']); + $dp_value = $dp_value.'00'; + $dp_value = hexdec($dp_value); + if ($stp_raw[$port]['dot1dStpPortDesignatedPort']) { + $dp = $stp_raw[$port]['dot1dStpPortDesignatedPort'] - $dp_value; + $stp_port['designatedPort'] = $dp; + } + } + else { + // Port saved in format priority+port (ieee 802.1d-1998: clause 8.5.5.1) + $dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part) + $stp_port['designatedPort'] = hexdec($dp); + } + + d_echo($stp_port); + + // Write to db + if (!dbFetchCell('SELECT 1 FROM `ports_stp` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $stp_port['port_id']))) { + dbInsert($stp_port,'ports_stp'); + echo '+'; + } + } + } + + // Delete STP ports from db if absent in SNMP query + $stp_port_db = dbFetchRows('SELECT * FROM `ports_stp` WHERE `device_id` = ?', array($device['device_id'])); + //d_echo($stp_port_db); + foreach($stp_port_db as $port => $value){ + $if_index = dbFetchCell('SELECT `ifIndex` FROM `ports` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id'])); + if ($if_index != $stp_raw[$if_index]['dot1dStpPort']){ + dbDelete('ports_stp', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id'])); + echo '-'; + } + } } -unset($stp_raw, $stp, $stp_db); +unset($stp_raw, $stp, $stp_db, $stp_port, $stp_port_db); echo "\n"; diff --git a/includes/polling/stp.inc.php b/includes/polling/stp.inc.php index d9886a58c..a7003659c 100644 --- a/includes/polling/stp.inc.php +++ b/includes/polling/stp.inc.php @@ -39,6 +39,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { // read the 802.1D subtree $stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', array(), 'RSTP-MIB'); + d_echo($stp_raw); $stp = array( 'protocolSpecification' => $stp_raw[0]['dot1dStpProtocolSpecification'], 'priority' => $stp_raw[0]['dot1dStpPriority'], @@ -121,7 +122,59 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { dbUpdate($stp,'stp','device_id = ?', array($device['device_id'])); echo '.'; } + + // STP port related stuff + foreach ($stp_raw as $port => $value){ + if ($port) { // $stp_raw[0] ist not port related so we skip this one + $stp_port = array( + 'priority' => $stp_raw[$port]['dot1dStpPortPriority'], + 'state' => $stp_raw[$port]['dot1dStpPortState'], + 'enable' => $stp_raw[$port]['dot1dStpPortEnable'], + 'pathCost' => $stp_raw[$port]['dot1dStpPortPathCost'], + 'designatedCost' => $stp_raw[$port]['dot1dStpPortDesignatedCost'], + 'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'], + 'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions'] + ); + + // set device binding + $stp_port['device_id'] = $device['device_id']; + + // set port binding + $stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort'])); + + $dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot'])); + $dr = substr($dr, -12); //remove first two octets + $stp_port['designatedRoot'] = $dr; + + $db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge'])); + $db = substr($db, -12); //remove first two octets + $stp_port['designatedBridge'] = $db; + + if ($device['os'] == 'pbn') { + // It seems that PBN guys don't care about ieee 802.1d :-( + // So try to find the right port with some crazy conversations + $dp_value = dechex($stp_port['priority']); + $dp_value = $dp_value.'00'; + $dp_value = hexdec($dp_value); + if ($stp_raw[$port]['dot1dStpPortDesignatedPort']) { + $dp = $stp_raw[$port]['dot1dStpPortDesignatedPort'] - $dp_value; + $stp_port['designatedPort'] = $dp; + } + } + else { + // Port saved in format priority+port (ieee 802.1d-1998: clause 8.5.5.1) + $dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2); //discard the first octet (priority part) + $stp_port['designatedPort'] = hexdec($dp); + } + + //d_echo($stp_port); + + // Update db + dbUpdate($stp_port,'ports_stp','`device_id` = ? AND `port_id` = ?', array($device['device_id'], $stp_port['port_id'])); + echo '.'; + } + } } -unset($stp_raw, $stp, $stp_db); +unset($stp_raw, $stp, $stp_db, $stp_port); echo "\n"; From 0e2a9f59aac64245ce212389b7ead1a3938acfb7 Mon Sep 17 00:00:00 2001 From: vitalisator Date: Thu, 14 Jan 2016 17:33:25 +0100 Subject: [PATCH 04/42] add print-stp-ports --- html/includes/print-stp-ports.inc.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 html/includes/print-stp-ports.inc.php diff --git a/html/includes/print-stp-ports.inc.php b/html/includes/print-stp-ports.inc.php new file mode 100644 index 000000000..504a6af27 --- /dev/null +++ b/html/includes/print-stp-ports.inc.php @@ -0,0 +1,26 @@ +PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions'; +//SELECT ps.*, p.ifIndex FROM `ports_stp` ps JOIN `ports` p ON ps.port_id=p.port_id WHERE ps.device_id = 67 ORDER BY ps.port_id +foreach (dbFetchRows("SELECT * FROM `ports_stp` WHERE `device_id` = ? ORDER BY 'port_id'", array($device['device_id'])) as $stp_ports_db) { + + $stp_ports = [ + $stp_ports_db['port_id'], + $stp_ports_db['priority'], + $stp_ports_db['state'], + $stp_ports_db['enable'], + $stp_ports_db['pathCost'], + $stp_ports_db['designatedRoot'], + $stp_ports_db['designatedCost'], + $stp_ports_db['designatedBridge'], + $stp_ports_db['designatedPort'], + $stp_ports_db['forwardTransitions'] + ]; + echo ''; + + foreach ($stp_ports as $value) { + echo "$value"; + } + + echo ''; +} From 41d5d097ef65c2a1adaec19fa9c0c78e7a5bc08d Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 17 Jan 2016 18:05:13 +0100 Subject: [PATCH 05/42] add some html page formatting --- html/includes/print-stp-ports.inc.php | 48 +++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/html/includes/print-stp-ports.inc.php b/html/includes/print-stp-ports.inc.php index 504a6af27..665b946fb 100644 --- a/html/includes/print-stp-ports.inc.php +++ b/html/includes/print-stp-ports.inc.php @@ -1,22 +1,56 @@ "; +echo ' + + + + + + + + + + + '; -echo ''; -//SELECT ps.*, p.ifIndex FROM `ports_stp` ps JOIN `ports` p ON ps.port_id=p.port_id WHERE ps.device_id = 67 ORDER BY ps.port_id -foreach (dbFetchRows("SELECT * FROM `ports_stp` WHERE `device_id` = ? ORDER BY 'port_id'", array($device['device_id'])) as $stp_ports_db) { +switch ($vars["sort"]) { + case 'transitions': + $sort = "ps.forwardTransitions DESC"; + break; + default: + $sort = "ps.port_id ASC"; + break; +} +$i='1'; + +// FIXME Table sorting don't working, why? +//echo "$sort"; +foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ? ORDER BY ?", array($device['device_id'], $sort)) as $stp_ports_db) { + + $bridge_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedBridge'])); + $root_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedRoot'])); $stp_ports = [ - $stp_ports_db['port_id'], + generate_port_link($stp_ports_db, $stp_ports_db['ifName'])."
".$stp_ports_db['ifAlias'], $stp_ports_db['priority'], $stp_ports_db['state'], $stp_ports_db['enable'], $stp_ports_db['pathCost'], - $stp_ports_db['designatedRoot'], + //$stp_ports_db['designatedRoot'], + generate_device_link($root_device, $root_device['hostname'])."
".$stp_ports_db['designatedRoot'], $stp_ports_db['designatedCost'], - $stp_ports_db['designatedBridge'], + generate_device_link($bridge_device, $bridge_device['hostname'])."
".$stp_ports_db['designatedBridge'], $stp_ports_db['designatedPort'], $stp_ports_db['forwardTransitions'] ]; - echo ''; + $i++; + if (!is_integer($i / 2)) { + $row_colour = $list_colour_b; + } + else { + $row_colour = $list_colour_a; + } + echo ""; foreach ($stp_ports as $value) { echo ""; From 1eaf7d7aab6dc4c949c1fae6c92e6ff53c3829ea Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 17 Jan 2016 23:22:43 +0100 Subject: [PATCH 06/42] 1st try to make bootgrid table --- html/includes/print-stp-ports.inc.php | 74 ++++++++++++++------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/html/includes/print-stp-ports.inc.php b/html/includes/print-stp-ports.inc.php index 665b946fb..83916b307 100644 --- a/html/includes/print-stp-ports.inc.php +++ b/html/includes/print-stp-ports.inc.php @@ -1,31 +1,23 @@
PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions
PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions
$value
"; +echo "
"; +echo "
"; +echo ''; echo ' - - - - - - - - - - + + + + + + + + + + '; +echo ''; +echo ''; -switch ($vars["sort"]) { - case 'transitions': - $sort = "ps.forwardTransitions DESC"; - break; - default: - $sort = "ps.port_id ASC"; - break; -} -$i='1'; - -// FIXME Table sorting don't working, why? -//echo "$sort"; -foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ? ORDER BY ?", array($device['device_id'], $sort)) as $stp_ports_db) { +foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ?", array($device['device_id'])) as $stp_ports_db) { $bridge_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedBridge'])); $root_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedRoot'])); @@ -36,25 +28,37 @@ foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p $stp_ports_db['state'], $stp_ports_db['enable'], $stp_ports_db['pathCost'], - //$stp_ports_db['designatedRoot'], generate_device_link($root_device, $root_device['hostname'])."
".$stp_ports_db['designatedRoot'], $stp_ports_db['designatedCost'], generate_device_link($bridge_device, $bridge_device['hostname'])."
".$stp_ports_db['designatedBridge'], $stp_ports_db['designatedPort'], $stp_ports_db['forwardTransitions'] ]; - $i++; - if (!is_integer($i / 2)) { - $row_colour = $list_colour_b; - } - else { - $row_colour = $list_colour_a; - } - echo ""; - + + echo ""; foreach ($stp_ports as $value) { echo ""; } - echo ''; } +echo ''; +echo '
PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitionsPortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions
$value
'; +echo ''; +// FIXME make table with links and searcheable +// +?> + + From dc933184f0c6df97b44a2dcec123444d7854679f Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 24 Jan 2016 18:17:09 +0100 Subject: [PATCH 07/42] stp-ports bootgrid 1 --- html/includes/common/stp-ports.inc.php | 37 +++++++++++++++ html/includes/print-stp-ports.inc.php | 64 -------------------------- html/includes/table/stp-ports.inc.php | 55 ++++++++++++++++++++++ html/pages/device/stp.inc.php | 3 +- 4 files changed, 94 insertions(+), 65 deletions(-) create mode 100644 html/includes/common/stp-ports.inc.php delete mode 100644 html/includes/print-stp-ports.inc.php create mode 100644 html/includes/table/stp-ports.inc.php diff --git a/html/includes/common/stp-ports.inc.php b/html/includes/common/stp-ports.inc.php new file mode 100644 index 000000000..34b863952 --- /dev/null +++ b/html/includes/common/stp-ports.inc.php @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + +
PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions
+ + + +'; diff --git a/html/includes/print-stp-ports.inc.php b/html/includes/print-stp-ports.inc.php deleted file mode 100644 index 83916b307..000000000 --- a/html/includes/print-stp-ports.inc.php +++ /dev/null @@ -1,64 +0,0 @@ -"; -echo "
"; -echo ''; -echo ' - - - - - - - - - - - '; -echo ''; -echo ''; - -foreach (dbFetchRows("SELECT `ps`.*, `p`.* FROM `ports_stp` `ps` JOIN `ports` `p` ON `ps`.`port_id`=`p`.`port_id` WHERE `ps`.`device_id` = ?", array($device['device_id'])) as $stp_ports_db) { - - $bridge_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedBridge'])); - $root_device = dbFetchRow("SELECT `devices`.*, `stp`.`device_id`, `stp`.`bridgeAddress` FROM `devices` JOIN `stp` ON `devices`.`device_id`=`stp`.`device_id` WHERE `stp`.`bridgeAddress` = ?", array($stp_ports_db['designatedRoot'])); - - $stp_ports = [ - generate_port_link($stp_ports_db, $stp_ports_db['ifName'])."
".$stp_ports_db['ifAlias'], - $stp_ports_db['priority'], - $stp_ports_db['state'], - $stp_ports_db['enable'], - $stp_ports_db['pathCost'], - generate_device_link($root_device, $root_device['hostname'])."
".$stp_ports_db['designatedRoot'], - $stp_ports_db['designatedCost'], - generate_device_link($bridge_device, $bridge_device['hostname'])."
".$stp_ports_db['designatedBridge'], - $stp_ports_db['designatedPort'], - $stp_ports_db['forwardTransitions'] - ]; - - echo ""; - foreach ($stp_ports as $value) { - echo ""; - } - echo ''; -} -echo ''; -echo '
PortPriorityStateEnablePath costDesignated rootDesignated costDesignated bridgeDesignated portFwd trasitions
$value
'; -echo ''; -// FIXME make table with links and searcheable -// -?> - - diff --git a/html/includes/table/stp-ports.inc.php b/html/includes/table/stp-ports.inc.php new file mode 100644 index 000000000..f3e31b5fb --- /dev/null +++ b/html/includes/table/stp-ports.inc.php @@ -0,0 +1,55 @@ + generate_port_link($stp_ports_db, $stp_ports_db['ifName'])."
".$stp_ports_db['ifAlias'], + 'priority' => $stp_ports_db['priority'], + 'state' => $stp_ports_db['state'], + 'enable' => $stp_ports_db['enable'], + 'pathCost' => $stp_ports_db['pathCost'], + 'designatedRoot' => generate_device_link($root_device, $root_device['hostname'])."
".$stp_ports_db['designatedRoot'], + 'designatedCost' => $stp_ports_db['designatedCost'], + 'designatedBridge' => generate_device_link($bridge_device, $bridge_device['hostname'])."
".$stp_ports_db['designatedBridge'], + 'designatedPort' => $stp_ports_db['designatedPort'], + 'forwardTransitions' => $stp_ports_db['forwardTransitions'] + ); +} + +$output = array( + 'current' => $current, + 'rowCount' => $rowCount, + 'rows' => $response, + 'total' => $total, +); +echo _json_encode($output); diff --git a/html/pages/device/stp.inc.php b/html/pages/device/stp.inc.php index 52dda8028..ad8733aa1 100644 --- a/html/pages/device/stp.inc.php +++ b/html/pages/device/stp.inc.php @@ -46,7 +46,8 @@ if ($vars['view'] == 'basic') { } if ($vars['view'] == 'ports') { - include 'includes/print-stp-ports.inc.php'; + include 'includes/common/stp-ports.inc.php'; + echo implode('',$common_output); } echo ''; From 1de495ac0f91ef792ad52306f029a445b6243bd0 Mon Sep 17 00:00:00 2001 From: vitalisator Date: Sun, 24 Jan 2016 18:39:30 +0100 Subject: [PATCH 08/42] rebase --- sql-schema/094.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sql-schema/094.sql diff --git a/sql-schema/094.sql b/sql-schema/094.sql new file mode 100644 index 000000000..f6a4af91e --- /dev/null +++ b/sql-schema/094.sql @@ -0,0 +1,3 @@ +CREATE TABLE IF NOT EXISTS `ports_stp` (`port_stp_id` int(11) NOT NULL,`device_id` int(11) NOT NULL,`port_id` int(11) NOT NULL,`priority` tinyint(3) unsigned NOT NULL,`state` varchar(11) NOT NULL,`enable` varchar(8) NOT NULL,`pathCost` int(10) unsigned NOT NULL,`designatedRoot` varchar(32) NOT NULL,`designatedCost` smallint(5) unsigned NOT NULL,`designatedBridge` varchar(32) NOT NULL,`designatedPort` mediumint(9) NOT NULL,`forwardTransitions` int(10) unsigned NOT NULL) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +ALTER TABLE `ports_stp` ADD PRIMARY KEY (`port_stp_id`), ADD UNIQUE KEY `device_id` (`device_id`,`port_id`); +ALTER TABLE `ports_stp` MODIFY `port_stp_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1; From 7c1dd867f52dca5834f437bced04289037bc2656 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 24 Jan 2016 18:57:52 +0100 Subject: [PATCH 09/42] cleanup --- sql-schema/094.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/sql-schema/094.sql b/sql-schema/094.sql index dd0f72667..a0a27c248 100644 --- a/sql-schema/094.sql +++ b/sql-schema/094.sql @@ -1,3 +1,2 @@ DELETE a1 FROM alerts a1, alerts a2 WHERE a1.id < a2.id AND a1.device_id = a2.device_id AND a1.rule_id = a2.rule_id; ALTER TABLE `alerts` ADD UNIQUE `unique_alert`(`device_id`, `rule_id`); - From 6b72da4a00d5790316e0a1a82213e9fa4763ac35 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 Jan 2016 23:45:46 +0000 Subject: [PATCH 10/42] Updated global rules --- html/includes/print-alert-rules.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/includes/print-alert-rules.php b/html/includes/print-alert-rules.php index 6a287604b..2e5efdb16 100644 --- a/html/includes/print-alert-rules.php +++ b/html/includes/print-alert-rules.php @@ -53,7 +53,7 @@ if (isset($_POST['create-default'])) { ); $default_rules[] = array( 'device_id' => '-1', - 'rule' => '%macros.port_usage_perc >= "80"', + 'rule' => '%macros.port_usage_perc >= "80" && %macros.port_up = 1', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, @@ -61,7 +61,7 @@ if (isset($_POST['create-default'])) { ); $default_rules[] = array( 'device_id' => '-1', - 'rule' => '%sensors.sensor_current > %sensors.sensor_limit', + 'rule' => '%sensors.sensor_current > %sensors.sensor_limit && %sensors.sensor_alert = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, @@ -69,7 +69,7 @@ if (isset($_POST['create-default'])) { ); $default_rules[] = array( 'device_id' => '-1', - 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low', + 'rule' => '%sensors.sensor_current < %sensors.sensor_limit_low && %sensors.sensor_alert = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, From 87347bc8f852ba564b272537906982726f814bd5 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 Jan 2016 23:47:00 +0000 Subject: [PATCH 11/42] Updated global rules --- html/includes/print-alert-rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/print-alert-rules.php b/html/includes/print-alert-rules.php index 2e5efdb16..eac1ae6fd 100644 --- a/html/includes/print-alert-rules.php +++ b/html/includes/print-alert-rules.php @@ -53,7 +53,7 @@ if (isset($_POST['create-default'])) { ); $default_rules[] = array( 'device_id' => '-1', - 'rule' => '%macros.port_usage_perc >= "80" && %macros.port_up = 1', + 'rule' => '%macros.port_usage_perc >= "80" && %macros.port_up = "1" && %macros.port = "1"', 'severity' => 'critical', 'extra' => '{"mute":false,"count":"-1","delay":"300"}', 'disabled' => 0, From f10c42678d31d90984ffefb0f32e0dc96ef5c3fa Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 26 Jan 2016 01:06:21 +0000 Subject: [PATCH 12/42] Added bgpPeers_cbgp delta and prev --- includes/polling/bgp-peers.inc.php | 71 ++++++++++-------------------- sql-schema/099.sql | 1 + 2 files changed, 24 insertions(+), 48 deletions(-) create mode 100644 sql-schema/099.sql diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 56863ec10..199f25ca4 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -142,10 +142,10 @@ if ($config['enable_bgp']) { $peerrrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('bgp-'.$peer['bgpPeerIdentifier'].'.rrd'); if (!is_file($peerrrd)) { - $create_rrd = 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 - DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 - DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 - DS:bgpPeerInTotal:COUNTER:600:U:100000000000 + $create_rrd = 'DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 + DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 + DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 + DS:bgpPeerInTotal:COUNTER:600:U:100000000000 DS:bgpPeerEstablished:GAUGE:600:0:U '.$config['rrd_rra']; rrdtool_create($peerrrd, $create_rrd); @@ -172,7 +172,7 @@ if ($config['enable_bgp']) { dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); - if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') { + if ($device['os_group'] == 'cisco' || $device['os'] == 'junos' || $device['os'] == 'edgeos') { // Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB) $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); foreach ($peer_afis as $peer_afi) { @@ -254,45 +254,6 @@ if ($config['enable_bgp']) { list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data); }//end if - if ($device['os'] == 'junos') { - // Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes - $safis['unicast'] = 1; - $safis['multicast'] = 2; - - if (!isset($peerIndexes)) { - $j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - foreach ($j_bgp as $index => $entry) { - switch ($entry['jnxBgpM2PeerRemoteAddrType']) { - case 'ipv4': - $ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr'])); - $j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex']; - break; - - case 'ipv6': - $ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"'); - $ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4); - $ip6 = Net_IPv6::compress($ip6); - $j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex']; - break; - - default: - echo "PANIC: Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n"; - break; - } - } - }//end if - - $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos'); - - $cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted']; - $cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected']; - $cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes']; - - unset($j_prefixes); - unset($j_bgp); - unset($j_peerIndexes); - }//end if - // FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE! $update = 'UPDATE bgpPeers_cbgp SET'; $peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes; @@ -304,14 +265,28 @@ if ($config['enable_bgp']) { $peer['c_update']['SuppressedPrefixes'] = $cbgpPeerSuppressedPrefixes; $peer['c_update']['WithdrawnPrefixes'] = $cbgpPeerWithdrawnPrefixes; + + $oids = array( + 'AcceptedPrefixes', + 'DeniedPrefixes', + 'AdvertisedPrefixes', + 'SuppressedPrefixes', + 'WithdrawnPrefixes', + ); + + foreach ($oids as $oid) { + $peer['c_update'][$oid.'_delta'] = $peer['c_update'][$oid] - $peer_afi[$oid]; + $peer['c_update'][$oid.'_prev'] = $peer_afi[$oid]; + } + dbUpdate($peer['c_update'], 'bgpPeers_cbgp', '`device_id` = ? AND bgpPeerIdentifier = ? AND afi = ? AND safi = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $afi, $safi)); $cbgp_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('cbgp-'.$peer['bgpPeerIdentifier'].".$afi.$safi.rrd"); if (!is_file($cbgp_rrd)) { - $rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000 - DS:DeniedPrefixes:GAUGE:600:U:100000000000 - DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 - DS:SuppressedPrefixes:GAUGE:600:U:100000000000 + $rrd_create = 'DS:AcceptedPrefixes:GAUGE:600:U:100000000000 + DS:DeniedPrefixes:GAUGE:600:U:100000000000 + DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 + DS:SuppressedPrefixes:GAUGE:600:U:100000000000 DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 '.$config['rrd_rra']; rrdtool_create($cbgp_rrd, $rrd_create); } diff --git a/sql-schema/099.sql b/sql-schema/099.sql new file mode 100644 index 000000000..f9a25728f --- /dev/null +++ b/sql-schema/099.sql @@ -0,0 +1 @@ +ALTER TABLE `bgpPeers_cbgp` ADD `AcceptedPrefixes_delta` INT NOT NULL ,ADD `AcceptedPrefixes_prev` INT NOT NULL ,ADD `DeniedPrefixes_delta` INT NOT NULL ,ADD `DeniedPrefixes_prev` INT NOT NULL ,ADD `AdvertisedPrefixes_delta` INT NOT NULL ,ADD `AdvertisedPrefixes_prev` INT NOT NULL ,ADD `SuppressedPrefixes_delta` INT NOT NULL ,ADD `SuppressedPrefixes_prev` INT NOT NULL ,ADD `WithdrawnPrefixes_delta` INT NOT NULL ,ADD `WithdrawnPrefixes_prev` INT NOT NULL ; From a40b609bfaf3c9d49d0cf1b9141b604e0c9f16ce Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 26 Jan 2016 01:19:44 +0000 Subject: [PATCH 13/42] Removed edgeos test --- includes/polling/bgp-peers.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 199f25ca4..eb91eb935 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -172,7 +172,7 @@ if ($config['enable_bgp']) { dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); - if ($device['os_group'] == 'cisco' || $device['os'] == 'junos' || $device['os'] == 'edgeos') { + if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') { // Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB) $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); foreach ($peer_afis as $peer_afi) { From 60603520dfeaca4b6d2994766084a8437252144c Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 26 Jan 2016 01:40:08 +0000 Subject: [PATCH 14/42] Updated stp branch --- html/includes/common/stp-ports.inc.php | 3 ++- html/includes/table/stp-ports.inc.php | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/html/includes/common/stp-ports.inc.php b/html/includes/common/stp-ports.inc.php index 34b863952..862b514d5 100644 --- a/html/includes/common/stp-ports.inc.php +++ b/html/includes/common/stp-ports.inc.php @@ -27,7 +27,8 @@ var grid = $("#stp-ports").bootgrid( { post: function () { return { - id: "stp-ports" + id: "stp-ports", + device_id: ' . $device['device_id'] . ', }; }, url: "ajax_table.php" diff --git a/html/includes/table/stp-ports.inc.php b/html/includes/table/stp-ports.inc.php index f3e31b5fb..3a2113b0b 100644 --- a/html/includes/table/stp-ports.inc.php +++ b/html/includes/table/stp-ports.inc.php @@ -1,8 +1,10 @@ Date: Tue, 26 Jan 2016 09:18:00 +0100 Subject: [PATCH 15/42] rename --- sql-schema/{094.sql => 098.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql-schema/{094.sql => 098.sql} (100%) diff --git a/sql-schema/094.sql b/sql-schema/098.sql similarity index 100% rename from sql-schema/094.sql rename to sql-schema/098.sql From 2c9df26bbf22af94c354bcf445b55a56eaece81a Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Tue, 26 Jan 2016 13:49:30 +0100 Subject: [PATCH 16/42] Update discovery and poller to allow stable interface mapping by ifName/ifDescr based port mapping. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default libreNMS used the ifIndex to associate ports just found via SNMP with ports discoverd/polled before and stored in the database. On Linux boxes this is a problem as ifIndexes are rather likely to be unstable between reboots or (re)configuration of tunnel interfaces (think: GRE/OpenVPN/Tinc/...), bridges, Vlan interfaces, Bonding interfaces, etc. This patch adds a »port association mode« configuration option per device which allows to map discovered and known ports by their ifIndex, ifName, ifDescr, or maybe other means in the future. The default port association mode still is ifIndex for compatibility reasons. As port RRD files were stored by their ifIndex before, they are now identified by their unique and stable port_id to ensure a stable and unique mapping and allow future port association modes to be added without requireing any further internal changes. Existing RRD files are renamend accordingly in discovery and poller tools to ensure stability of port associations in both modules as we don't know which might run first after an update. Signed-off-by: Maximilian Wilhelm --- config.php.default | 3 + includes/common.php | 163 +++++++++++++++++++++++- includes/defaults.inc.php | 3 + includes/discovery/ports.inc.php | 75 ++++++++--- includes/polling/port-adsl.inc.php | 12 +- includes/polling/port-etherlike.inc.php | 9 +- includes/polling/port-poe.inc.php | 9 +- includes/polling/ports.inc.php | 111 +++++++++++----- scripts/tune_port.php | 3 +- sql-schema/096.sql | 5 + 10 files changed, 320 insertions(+), 73 deletions(-) create mode 100644 sql-schema/096.sql diff --git a/config.php.default b/config.php.default index f6b031cd7..2da0514e0 100755 --- a/config.php.default +++ b/config.php.default @@ -49,3 +49,6 @@ $config['poller-wrapper']['alerter'] = FALSE; # Uncomment to submit callback stats via proxy #$config['callback_proxy'] = "hostname:port"; + +# Set default port association mode for new devices (default: ifIndex) +#$config['default_port_association_mode'] = 'ifIndex'; diff --git a/includes/common.php b/includes/common.php index d32f836ab..0cbb6b007 100644 --- a/includes/common.php +++ b/includes/common.php @@ -114,7 +114,7 @@ function delete_port($int_id) { dbDelete('links', "`remote_port_id` = ?", array($int_id)); dbDelete('bill_ports', "`port_id` = ?", array($int_id)); - unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/port-".$interface['ifIndex'].".rrd"); + unlink(get_port_rrdfile_path ($interface['hostname'], $interface['port_id'])); } function sgn($int) { @@ -143,6 +143,15 @@ function get_sensor_rrd($device, $sensor) { return($rrd_file); } +function get_port_rrdfile_path ($hostname, $port_id, $suffix = '') { + global $config; + + if (! empty ($suffix)) + $suffix = '-' . $suffix; + + return trim ($config['rrd_dir']) . '/' . safename ($hostname) . '/' . 'port-id' . safename($port_id) . safename ($suffix) . '.rrd'; +} + function get_port_by_index_cache($device_id, $ifIndex) { global $port_index_cache; @@ -1093,3 +1102,155 @@ function ip_to_sysname($device,$ip) { } return $ip; }//end ip_to_sysname + +/** + * Return valid port association modes + * @param bool $no_cache No-Cache flag (optional, default false) + * @return array + */ +function get_port_assoc_modes ($no_cache = false) { + global $config; + + if ($config['memcached']['enable'] && $no_cache === false) { + $assoc_modes = $config['memcached']['resource']->get (hash ('sha512', "port_assoc_modes")); + if (! empty ($assoc_modes)) + return $assoc_modes; + } + + $assoc_modes = Null; + foreach (dbFetchRows ("SELECT `name` FROM `port_association_mode` ORDER BY pom_id") as $row) + $assoc_modes[] = $row['name']; + + if ($config['memcached']['enable'] && $no_cache === false) + $config['memcached']['resource']->set (hash ('sha512', "port_assoc_modes"), $assoc_modes, $config['memcached']['ttl']); + + return $assoc_modes; +} + +/** + * Validate port_association_mode + * @param string $port_assoc_mode + * @return bool + */ +function is_valid_port_assoc_mode ($port_assoc_mode) { + return in_array ($port_assoc_mode, get_port_assoc_modes ()); +} + +/** + * Get DB id of given port association mode name + * @param string $port_assoc_mode + * @param bool $no_cache No-Cache flag (optional, default false) + */ +function get_port_assoc_mode_id ($port_assoc_mode, $no_cache = false) { + global $config; + + if ($config['memcached']['enable'] && $no_cache === false) { + $id = $config['memcached']['resource']->get (hash ('sha512', "port_assoc_mode_id|$port_assoc_mode")); + if (! empty ($id)) + return $id; + } + + $id = Null; + $row = dbFetchRow ("SELECT `pom_id` FROM `port_association_mode` WHERE name = ?", array ($port_assoc_mode)); + if ($row) { + $id = $row['pom_id']; + if ($config['memcached']['enable'] && $no_cache === false) + $config['memcached']['resource']->set (hash ('sha512', "port_assoc_mode_id|$port_assoc_mode"), $id, $config['memcached']['ttl']); + } + + return $id; +} + +/** + * Get name of given port association_mode ID + * @param int $port_assoc_mode_id Port association mode ID + * @param bool $no_cache No-Cache flag (optional, default false) + * @return bool + */ +function get_port_assoc_mode_name ($port_assoc_mode_id, $no_cache = false) { + global $config; + + if ($config['memcached']['enable'] && $no_cache === false) { + $name = $config['memcached']['resource']->get (hash ('sha512', "port_assoc_mode_name|$port_assoc_mode_id")); + if (! empty ($name)) + return $name; + } + + $name = Null; + $row = dbFetchRow ("SELECT `name` FROM `port_association_mode` WHERE pom_id = ?", array ($port_assoc_mode_id)); + if ($row) { + $name = $row['name']; + if ($config['memcached']['enable'] && $no_cache === false) + $config['memcached']['resource']->set (hash ('sha512', "port_assoc_mode_name|$port_assoc_mode_id"), $name, $config['memcached']['ttl']); + } + + return $name; +} + +/** + * Query all ports of the given device (by ID) and build port array and + * port association maps for ifIndex, ifName, ifDescr. Query port stats + * if told to do so, too. + * @param int $device_id ID of device to query ports for + * @param bool $with_statistics Query port statistics, too. (optional, default false) + * @return array + */ +function get_ports_mapped ($device_id, $with_statistics = false) { + $ports = []; + $maps = [ + 'ifIndex' => [], + 'ifName' => [], + 'ifDescr' => [], + ]; + + /* Query all information available for ports for this device ... */ + $query = 'SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY port_id'; + if ($with_statistics) { + /* ... including any related ports_statistics if requested */ + $query = 'SELECT *, `ports_statistics`.`port_id` AS `ports_statistics_port_id`, `ports`.`port_id` AS `port_id` FROM `ports` LEFT OUTER JOIN `ports_statistics` ON `ports`.`port_id` = `ports_statistics`.`port_id` WHERE `ports`.`device_id` = ? ORDER BY ports.port_id'; + } + + // Query known ports in order of discovery to make sure the latest + // discoverd/polled port is in the mapping tables. + foreach (dbFetchRows ($query, array ($device_id)) as $port) { + // Store port information by ports port_id from DB + $ports[$port['port_id']] = $port; + + // Build maps from ifIndex, ifName, ifDescr to port_id + $maps['ifIndex'][$port['ifIndex']] = $port['port_id']; + $maps['ifName'][$port['ifName']] = $port['port_id']; + $maps['ifDescr'][$port['ifDescr']] = $port['port_id']; + } + + return [ + 'ports' => $ports, + 'maps' => $maps, + ]; +} + +/** + * Calculate port_id of given port using given devices port information and port association mode + * @param array $ports_mapped Port information of device queried by get_ports_mapped() + * @param array $port Port information as fetched from DB + * @param string $port_association_mode Port association mode to use for mapping + * @return int port_id (or Null) + */ +function get_port_id ($ports_mapped, $port, $port_association_mode) { + // Get port_id according to port_association_mode used for this device + $port_id = Null; + + /* + * Information an all ports is available through $ports_mapped['ports'] + * This might come in handy sometime in the future to add you nifty new + * port mapping schema: + * + * $ports = $ports_mapped['ports']; + */ + $maps = $ports_mapped['maps']; + + if (in_array ($port_association_mode, array ('ifIndex', 'ifName', 'ifDescr'))) { + $port_id = $maps[$port_association_mode][$port[$port_association_mode]]; + } + + return $port_id; +} diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 328ae2ce0..d11245ae4 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -853,3 +853,6 @@ $config['notifications']['local'] = 'misc/notifications.rs // Update channel (Can be 'master' or 'release') $config['update_channel'] = 'master'; + +// Default port association mode +$config['default_port_association_mode'] = 'ifIndex'; diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 32067fa05..c682fa6e5 100644 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -9,27 +9,61 @@ $port_stats = snmpwalk_cache_oid($device, 'ifType', $port_stats, 'IF-MIB'); // End Building SNMP Cache Array d_echo($port_stats); -// Build array of ports in the database -// FIXME -- this stuff is a little messy, looping the array to make an array just seems wrong. :> -// -- i can make it a function, so that you don't know what it's doing. -// -- $ports_db = adamasMagicFunction($ports_db); ? -foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id'])) as $port) { - $ports_db[$port['ifIndex']] = $port; - $ports_db_l[$port['ifIndex']] = $port['port_id']; + +// By default libreNMS uses the ifIndex to associate ports on devices with ports discoverd/polled +// before and stored in the database. On Linux boxes this is a problem as ifIndexes may be +// unstable between reboots or (re)configuration of tunnel interfaces (think: GRE/OpenVPN/Tinc/...) +// The port association configuration allows to choose between association via ifIndex, ifName, +// or maybe other means in the future. The default port association mode still is ifIndex for +// compatibility reasons. +$port_association_mode = $config['default_port_association_mode']; +if ($device['port_association_mode']) + $port_association_mode = get_port_assoc_mode_name ($device['port_association_mode']); + +// Build array of ports in the database and an ifIndex/ifName -> port_id map +$ports_mapped = get_ports_mapped ($device['id']); +$ports_db = $ports_mapped['ports']; + +// +// Rename any old RRD files still named after the previous ifIndex based naming schema. +foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) { + foreach (array ('', 'adsl', 'dot3') as $suffix) { + $suffix_tmp = ''; + if ($suffix) + $suffix_tmp = "-$suffix"; + + $old_rrd_path = trim ($config['rrd_dir']) . '/' . $device['hostname'] . "/port-$ifIndex$suffix_tmp.rrd"; + $new_rrd_path = get_port_rrdfile_path ($device['hostname'], $port_id, $suffix); + + if (is_file ($old_rrd_path)) { + rename ($old_rrd_path, $new_rrd_path); + } + } } + // New interface detection foreach ($port_stats as $ifIndex => $port) { - // Check the port against our filters. + // Store ifIndex in port entry and prefetch ifName as we'll need it multiple times + $port['ifIndex'] = $ifIndex; + $ifName = $port['ifName']; + + // Get port_id according to port_association_mode used for this device + $port_id = get_port_id ($ports_mapped, $port, $port_association_mode); + if (is_port_valid($port, $device)) { - if (!is_array($ports_db[$ifIndex])) { - $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); - $ports_db[$ifIndex] = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $ifIndex)); - echo 'Adding: '.$port['ifName'].'('.$ifIndex.')('.$ports_db[$port['ifIndex']]['port_id'].')'; + + // Port newly discovered? + if (! is_array($ports_db[$port_id])) { + $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifName' => $ifName), 'ports'); + $ports[$port_id] = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port_id)); + echo 'Adding: '.$ifName.'('.$ifIndex.')('.$port_id.')'; } - else if ($ports_db[$ifIndex]['deleted'] == '1') { - dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports_db[$ifIndex]['port_id'])); - $ports_db[$ifIndex]['deleted'] = '0'; + + // Port re-discovered after previous deletion? + else if ($ports_db[$port_id]['deleted'] == '1') { + dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports_db[$port_id])); + $ports_db[$port_id]['deleted'] = '0'; echo 'U'; } else { @@ -39,11 +73,13 @@ foreach ($port_stats as $ifIndex => $port) { // We've seen it. Remove it from the cache. unset($ports_l[$ifIndex]); } + + // Port vanished (mark as deleted) else { - if (is_array($ports_db[$port['ifIndex']])) { - if ($ports_db[$port['ifIndex']]['deleted'] != '1') { - dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports_db[$ifIndex]['port_id'])); - $ports_db[$ifIndex]['deleted'] = '1'; + if (is_array($ports_db[$port_id])) { + if ($ports_db[$port_id]['deleted'] != '1') { + dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports_db[$port_id])); + $ports_db[$port_id]['deleted'] = '1'; echo '-'; } } @@ -68,4 +104,3 @@ echo "\n"; // Clear Variables Here unset($port_stats); unset($ports_db); -unset($ports_db_db); diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index 883cfcced..e3567e26b 100644 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -39,11 +39,11 @@ // adslAturPerfESs.1 = 0 seconds // adslAturPerfValidIntervals.1 = 0 // adslAturPerfInvalidIntervals.1 = 0 -if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) { +if (isset($port_stats[$port_id]['adslLineCoding'])) { // Check to make sure Port data is cached. - $this_port = &$port_stats[$port['ifIndex']]; + $this_port = &$port_stats[$port_id]; - $rrdfile = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('port-'.$port['ifIndex'].'-adsl.rrd'); + $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id, 'adsl'); $rrd_create = ' --step 300'; $rrd_create .= ' DS:AtucCurrSnrMgn:GAUGE:600:0:635'; @@ -130,8 +130,8 @@ if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) { $this_port[$oid] = ($this_port[$oid] / 10); } - if (dbFetchCell('SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?', array($port['port_id'])) == '0') { - dbInsert(array('port_id' => $port['port_id']), 'ports_adsl'); + if (dbFetchCell('SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?', array($port_id)) == '0') { + dbInsert(array('port_id' => $port_id), 'ports_adsl'); } $port['adsl_update'] = array('port_adsl_updated' => array('NOW()')); @@ -141,7 +141,7 @@ if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) { $port['adsl_update'][$oid] = $data; } - dbUpdate($port['adsl_update'], 'ports_adsl', '`port_id` = ?', array($port['port_id'])); + dbUpdate($port['adsl_update'], 'ports_adsl', '`port_id` = ?', array($port_id)); if ($this_port['adslAtucCurrSnrMgn'] > '1280') { $this_port['adslAtucCurrSnrMgn'] = 'U'; diff --git a/includes/polling/port-etherlike.inc.php b/includes/polling/port-etherlike.inc.php index 0576d4b19..bf947b92d 100644 --- a/includes/polling/port-etherlike.inc.php +++ b/includes/polling/port-etherlike.inc.php @@ -1,13 +1,14 @@ -// -- i can make it a function, so that you don't know what it's doing. -// -- $ports = adamasMagicFunction($ports_db); ? -// select * doesn't do what we want if multiple tables have the same column name -- last one wins :/ -$ports_db = dbFetchRows('SELECT *, `ports_statistics`.`port_id` AS `ports_statistics_port_id`, `ports`.`port_id` AS `port_id` FROM `ports` LEFT OUTER JOIN `ports_statistics` ON `ports`.`port_id` = `ports_statistics`.`port_id` WHERE `ports`.`device_id` = ?', array($device['device_id'])); +// By default libreNMS uses the ifIndex to associate ports on devices with ports discoverd/polled +// before and stored in the database. On Linux boxes this is a problem as ifIndexes may be +// unstable between reboots or (re)configuration of tunnel interfaces (think: GRE/OpenVPN/Tinc/...) +// The port association configuration allows to choose between association via ifIndex, ifName, +// or maybe other means in the future. The default port association mode still is ifIndex for +// compatibility reasons. +$port_association_mode = $config['default_port_association_mode']; +if ($device['port_association_mode']) + $port_association_mode = get_port_assoc_mode_name ($device['port_association_mode']); -foreach ($ports_db as $port) { - $ports[$port['ifIndex']] = $port; +// Query known ports and mapping table in order of discovery to make sure +// the latest discoverd/polled port is in the mapping tables. +$ports_mapped = get_ports_mapped ($device['device_id'], true); +$ports = $ports_mapped['ports']; + +// +// Rename any old RRD files still named after the previous ifIndex based naming schema. +foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) { + foreach (array ('', 'adsl', 'dot3') as $suffix) { + $suffix_tmp = ''; + if ($suffix) + $suffix_tmp = "-$suffix"; + + $old_rrd_path = trim ($config['rrd_dir']) . '/' . $device['hostname'] . "/port-$ifIndex$suffix_tmp.rrd"; + $new_rrd_path = get_port_rrdfile_path ($device['hostname'], $port_id, $suffix); + + if (is_file ($old_rrd_path)) { + rename ($old_rrd_path, $new_rrd_path); + } + } } + // New interface detection foreach ($port_stats as $ifIndex => $port) { + // Store ifIndex in port entry and prefetch ifName as we'll need it multiple times + $port['ifIndex'] = $ifIndex; + $ifName = $port['ifName']; + + // Get port_id according to port_association_mode used for this device + $port_id = get_port_id ($ports_mapped, $port, $port_association_mode); + if (is_port_valid($port, $device)) { echo 'valid'; - if (!is_array($ports[$port['ifIndex']])) { - $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex), 'ports'); + + // Port newly discovered? + if (! $ports[$port_id]) { + $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifName' => $ifName), 'ports'); dbInsert(array('port_id' => $port_id), 'ports_statistics'); - $ports[$port['ifIndex']] = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($port_id)); - echo 'Adding: '.$port['ifName'].'('.$ifIndex.')('.$ports[$port['ifIndex']]['port_id'].')'; + $ports[$port_id] = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($port_id)); + echo 'Adding: '.$ifName.'('.$ifIndex.')('.$port_id.')'; // print_r($ports); } - else if ($ports[$ifIndex]['deleted'] == '1') { - dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($ports[$ifIndex]['port_id'])); - $ports[$ifIndex]['deleted'] = '0'; - } - if ($ports[$ifIndex]['ports_statistics_port_id'] === null) { - // in case the port was created before we created the table - dbInsert(array('port_id' => $ports[$ifIndex]['port_id']), 'ports_statistics'); - } - } - else { - if ($ports[$port['ifIndex']]['deleted'] != '1') { - dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($ports[$ifIndex]['port_id'])); - $ports[$ifIndex]['deleted'] = '1'; - } - } -} -// End New interface detection + // Port re-discovered after previous deletion? + else if ($ports[$port_id]['deleted'] == 1) { + dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($port_id)); + $ports[$port_id]['deleted'] = '0'; + } + if ($ports[$port_id]['ports_statistics_port_id'] === null) { + // in case the port was created before we created the table + dbInsert(array('port_id' => $port_id), 'ports_statistics'); + } + + // Assure stable mapping + $port_stats[$ifIndex]['port_id'] = $port_id; + $ports[$port_id]['ifIndex'] = $ifIndex; + } + + // Port vanished (mark as deleted) + else { + if ($ports[$port_id]['deleted'] != '1') { + dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($port_id)); + $ports[$port_id]['deleted'] = '1'; + } + } +} // End new interface detection + + echo "\n"; // Loop ports in the DB and update where necessary foreach ($ports as $port) { - echo 'Port '.$port['ifDescr'].'('.$port['ifIndex'].') '; + $port_id = $port['port_id']; + + echo 'Port ' . $port['ifName'] . ': ' . $port['ifDescr'] . '(' . $port['ifIndex'] . ') '; if ($port_stats[$port['ifIndex']] && $port['disabled'] != '1') { // Check to make sure Port data is cached. $this_port = &$port_stats[$port['ifIndex']]; @@ -477,7 +518,7 @@ foreach ($ports as $port) { } // Update RRDs - $rrdfile = $host_rrd.'/port-'.safename($port['ifIndex'].'.rrd'); + $rrdfile = get_port_rrdfile_path ($device['hostname'], $port_id); if (!is_file($rrdfile)) { rrdtool_create( $rrdfile, @@ -576,9 +617,9 @@ foreach ($ports as $port) { // Update Database if (count($port['update'])) { - $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port['port_id'])); + $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port_id)); // do we want to do something else with this? - $updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', array($port['port_id'])); + $updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', array($port_id)); d_echo("$updated updated"); } @@ -588,7 +629,7 @@ foreach ($ports as $port) { echo 'Port Deleted'; // Port missing from SNMP cache. if ($port['deleted'] != '1') { - dbUpdate(array('deleted' => '1'), 'ports', '`device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $port['ifIndex'])); + dbUpdate(array('deleted' => '1'), 'ports', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $port_id)); } } else { @@ -599,7 +640,7 @@ foreach ($ports as $port) { // Clear Per-Port Variables Here unset($this_port); -}//end foreach +} //end port update // Clear Variables Here unset($port_stats); diff --git a/scripts/tune_port.php b/scripts/tune_port.php index 2798469cc..14b62abe6 100755 --- a/scripts/tune_port.php +++ b/scripts/tune_port.php @@ -24,8 +24,7 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` WHERE `hostna echo "Found hostname " . $device['hostname'].".......\n"; foreach (dbFetchRows("SELECT `ifIndex`,`ifName`,`ifSpeed` FROM `ports` WHERE `ifName` LIKE ? AND `device_id` = ?", array('%'.$ports.'%',$device['device_id'])) as $port) { echo "Tuning port " . $port['ifName'].".......\n"; - $host_rrd = $config['rrd_dir'].'/'.$device['hostname']; - $rrdfile = $host_rrd.'/port-'.safename($port['ifIndex'].'.rrd'); + $rrdfile = get_port_rrdfile_path ($device['hostname'], $port['port_id']); rrdtool_tune('port',$rrdfile,$port['ifSpeed']); } } diff --git a/sql-schema/096.sql b/sql-schema/096.sql new file mode 100644 index 000000000..58ae65201 --- /dev/null +++ b/sql-schema/096.sql @@ -0,0 +1,5 @@ +CREATE TABLE IF NOT EXISTS `port_association_mode` (pom_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(12) NOT NULL); +INSERT INTO port_association_mode (pom_id, name) values (1, 'ifIndex'); +INSERT INTO port_association_mode (name) values ('ifName'); +INSERT INTO port_association_mode (name) values ('ifDescr'); +ALTER TABLE devices ADD port_association_mode int(11) NOT NULL DEFAULT 1; From 4d78a0261e8417cc2c6c7f1a235feac57151ed73 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Thu, 21 Jan 2016 22:04:33 +0100 Subject: [PATCH 17/42] Update graph and port pages to use new RRD naming schema. Signed-off-by: Maximilian Wilhelm --- html/includes/graphs/bill/bits.inc.php | 5 ++-- html/includes/graphs/customer/bits.inc.php | 5 ++-- html/includes/graphs/device/bits.inc.php | 2 +- html/includes/graphs/global/bits.inc.php | 2 +- html/includes/graphs/location/bits.inc.php | 5 ++-- html/includes/graphs/multiport/bits.inc.php | 7 ++--- .../graphs/multiport/bits_duo.inc.php | 18 +++++++------ .../graphs/multiport/bits_separate.inc.php | 5 ++-- .../graphs/multiport/bits_trio.inc.php | 27 ++++++++++--------- .../graphs/port/adsl_attainable.inc.php | 2 +- .../graphs/port/adsl_attenuation.inc.php | 2 +- html/includes/graphs/port/adsl_power.inc.php | 2 +- html/includes/graphs/port/adsl_snr.inc.php | 2 +- html/includes/graphs/port/adsl_speed.inc.php | 2 +- html/includes/graphs/port/auth.inc.php | 2 +- html/includes/graphs/port/etherlike.inc.php | 2 +- html/includes/graphs/port/nupkts.inc.php | 12 +++++---- html/includes/graphs/port/pagp_bits.inc.php | 5 ++-- html/includes/print-interface.inc.php | 4 +-- html/pages/device/port/adsl.inc.php | 2 +- html/pages/device/port/graphs.inc.php | 4 +-- html/pages/iftype.inc.php | 2 +- 22 files changed, 65 insertions(+), 54 deletions(-) diff --git a/html/includes/graphs/bill/bits.inc.php b/html/includes/graphs/bill/bits.inc.php index 2e80ef792..266fa86a2 100644 --- a/html/includes/graphs/bill/bits.inc.php +++ b/html/includes/graphs/bill/bits.inc.php @@ -4,8 +4,9 @@ $i = 0; foreach ($ports as $port) { - if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) { - $rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_file = get_port_rrdfile_path ($port['hostname'], $port['port_id']); + if (is_file($rrd_file)) { + $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $port['ifDescr']; $i++; } diff --git a/html/includes/graphs/customer/bits.inc.php b/html/includes/graphs/customer/bits.inc.php index f66f91df0..ee3d4a741 100644 --- a/html/includes/graphs/customer/bits.inc.php +++ b/html/includes/graphs/customer/bits.inc.php @@ -10,8 +10,8 @@ if (!is_array($config['customers_descr'])) { $descr_type = "'".implode("', '", $config['customers_descr'])."'"; foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id', array(array($descr_type), $vars['id'])) as $port) { - if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) { - $rrd_filename = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']); // FIXME: Unification OK? + if (is_file($rrd_filename)) { $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $port['hostname'].'-'.$port['ifDescr']; $rrd_list[$i]['descr_in'] = shorthost($port['hostname']); @@ -20,7 +20,6 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_des } } -// echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")); $units = 'bps'; $total_units = 'B'; $colours_in = 'greens'; diff --git a/html/includes/graphs/device/bits.inc.php b/html/includes/graphs/device/bits.inc.php index eaeed92f4..f796490f2 100644 --- a/html/includes/graphs/device/bits.inc.php +++ b/html/includes/graphs/device/bits.inc.php @@ -22,7 +22,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($devic } } - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id']); if ($ignore != 1 && is_file($rrd_filename)) { $port = ifLabel($port); // Fix Labels! ARGH. This needs to be in the bloody database! diff --git a/html/includes/graphs/global/bits.inc.php b/html/includes/graphs/global/bits.inc.php index 763a9d103..350d96f87 100644 --- a/html/includes/graphs/global/bits.inc.php +++ b/html/includes/graphs/global/bits.inc.php @@ -21,7 +21,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` AS D WHERE D.device_ } } - $rrd_filename = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']); if (!$ignore && $i < 1100 && is_file($rrd_filename)) { $rrd_filenames[] = $rrd_filename; $rrd_list[$i]['filename'] = $rrd_filename; diff --git a/html/includes/graphs/location/bits.inc.php b/html/includes/graphs/location/bits.inc.php index 53b0a656e..7f77108a9 100644 --- a/html/includes/graphs/location/bits.inc.php +++ b/html/includes/graphs/location/bits.inc.php @@ -24,8 +24,9 @@ foreach ($devices as $device) { } } - if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($int['ifIndex'].'.rrd')) && $ignore != 1) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'); + $rrd_file = get_port_rrdfile_path ($device['hostname'], $int['port_id']); + if (is_file($rrd_file) && $ignore != 1) { + $rrd_filename = $rrd_file; // FIXME: Can this be unified without side-effects? $rrd_list[$i]['filename'] = $rrd_filename; $rrd_list[$i]['descr'] = $port['label']; $rrd_list[$i]['descr_in'] = $device['hostname']; diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index de3206c23..e64e39b31 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -8,9 +8,10 @@ foreach (explode(',', $vars['id']) as $ifid) { $ifid = str_replace('!', '', $ifid); } - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'))) { - $rrd_filenames[$i] = $config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'); + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { + $rrd_filenames[$i] = $rrd_file; $i++; } } diff --git a/html/includes/graphs/multiport/bits_duo.inc.php b/html/includes/graphs/multiport/bits_duo.inc.php index 205ca3834..cc9892dde 100644 --- a/html/includes/graphs/multiport/bits_duo.inc.php +++ b/html/includes/graphs/multiport/bits_duo.inc.php @@ -13,10 +13,11 @@ if ($height < '99') { $i = 1; foreach (explode(',', $_GET['id']) as $ifid) { - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) { - $rrd_options .= ' DEF:inoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:INOCTETS:AVERAGE'; - $rrd_options .= ' DEF:outoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:OUTOCTETS:AVERAGE'; + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { + $rrd_options .= ' DEF:inoctets'.$i.'='.$rrd_file.':INOCTETS:AVERAGE'; + $rrd_options .= ' DEF:outoctets'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE'; $in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF'; $out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF'; $pluses .= $plus; @@ -30,10 +31,11 @@ unset($seperator); unset($plus); foreach (explode(',', $_GET['idb']) as $ifid) { - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) { - $rrd_options .= ' DEF:inoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:INOCTETS:AVERAGE'; - $rrd_options .= ' DEF:outoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:OUTOCTETS:AVERAGE'; + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { + $rrd_options .= ' DEF:inoctetsb'.$i.'='.$rrd_file.':INOCTETS:AVERAGE'; + $rrd_options .= ' DEF:outoctetsb'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE'; $in_thingb .= $seperator.'inoctetsb'.$i.',UN,0,'.'inoctetsb'.$i.',IF'; $out_thingb .= $seperator.'outoctetsb'.$i.',UN,0,'.'outoctetsb'.$i.',IF'; $plusesb .= $plus; diff --git a/html/includes/graphs/multiport/bits_separate.inc.php b/html/includes/graphs/multiport/bits_separate.inc.php index d54259d02..980386286 100644 --- a/html/includes/graphs/multiport/bits_separate.inc.php +++ b/html/includes/graphs/multiport/bits_separate.inc.php @@ -4,9 +4,10 @@ $i = 0; foreach (explode(',', $vars['id']) as $ifid) { $port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) { + $rrd_file = get_port_rrdfile_path ($port['hostname'], $ifid); + if (is_file($rrd_file)) { $port = ifLabel($port); - $rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'); + $rrd_list[$i]['filename'] = $rrd_file; $rrd_list[$i]['descr'] = $port['hostname'].' '.$port['ifDescr']; $rrd_list[$i]['descr_in'] = $port['hostname']; $rrd_list[$i]['descr_out'] = makeshortif($port['label']); diff --git a/html/includes/graphs/multiport/bits_trio.inc.php b/html/includes/graphs/multiport/bits_trio.inc.php index a1112a677..563ae1b9b 100644 --- a/html/includes/graphs/multiport/bits_trio.inc.php +++ b/html/includes/graphs/multiport/bits_trio.inc.php @@ -14,8 +14,9 @@ if ($height < '99') { $i = 1; foreach (explode(',', $_GET['id']) as $ifid) { - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) { + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { if (strstr($inverse, 'a')) { $in = 'OUT'; $out = 'IN'; @@ -25,8 +26,8 @@ foreach (explode(',', $_GET['id']) as $ifid) { $out = 'OUT'; } - $rrd_options .= ' DEF:inoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE'; - $rrd_options .= ' DEF:outoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:inoctets'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:outoctets'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE'; $in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF'; $out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF'; $pluses .= $plus; @@ -40,8 +41,9 @@ unset($seperator); unset($plus); foreach (explode(',', $_GET['idb']) as $ifid) { - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) { + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { if (strstr($inverse, 'b')) { $in = 'OUT'; $out = 'IN'; @@ -51,8 +53,8 @@ foreach (explode(',', $_GET['idb']) as $ifid) { $out = 'OUT'; } - $rrd_options .= ' DEF:inoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE'; - $rrd_options .= ' DEF:outoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:inoctetsb'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:outoctetsb'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE'; $in_thingb .= $seperator.'inoctetsb'.$i.',UN,0,'.'inoctetsb'.$i.',IF'; $out_thingb .= $seperator.'outoctetsb'.$i.',UN,0,'.'outoctetsb'.$i.',IF'; $plusesb .= $plus; @@ -66,8 +68,9 @@ unset($seperator); unset($plus); foreach (explode(',', $_GET['idc']) as $ifid) { - $int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); - if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) { + $int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid)); + $rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid); + if (is_file($rrd_file)) { if (strstr($inverse, 'c')) { $in = 'OUT'; $out = 'IN'; @@ -77,8 +80,8 @@ foreach (explode(',', $_GET['idc']) as $ifid) { $out = 'OUT'; } - $rrd_options .= ' DEF:inoctetsc'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE'; - $rrd_options .= ' DEF:outoctetsc'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:inoctetsc'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE'; + $rrd_options .= ' DEF:outoctetsc'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE'; $in_thingc .= $seperator.'inoctetsc'.$i.',UN,0,'.'inoctetsc'.$i.',IF'; $out_thingc .= $seperator.'outoctetsc'.$i.',UN,0,'.'outoctetsc'.$i.',IF'; $plusesc .= $plus; diff --git a/html/includes/graphs/port/adsl_attainable.inc.php b/html/includes/graphs/port/adsl_attainable.inc.php index ad84314a0..7f2e2f33a 100644 --- a/html/includes/graphs/port/adsl_attainable.inc.php +++ b/html/includes/graphs/port/adsl_attainable.inc.php @@ -1,6 +1,6 @@ '; // If we're showing graphs, generate the graph and print the img tags if ($graph_type == 'etherlike') { - $graph_file = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex']).'-dot3.rrd'; + $graph_file = get_port_rrdfile_path ($device['hostname'], $if_id, 'dot3'); } else { - $graph_file = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex']).'.rrd'; + $graph_file = get_port_rrdfile_path ($device['hostname'], $if_id); } if ($graph_type && is_file($graph_file)) { diff --git a/html/pages/device/port/adsl.inc.php b/html/pages/device/port/adsl.inc.php index 170f2a2c5..b9230ccfb 100644 --- a/html/pages/device/port/adsl.inc.php +++ b/html/pages/device/port/adsl.inc.php @@ -1,6 +1,6 @@ ADSL Line Speed'; $graph_type = 'port_adsl_speed'; diff --git a/html/pages/device/port/graphs.inc.php b/html/pages/device/port/graphs.inc.php index e56f24bf3..64fdde60a 100644 --- a/html/pages/device/port/graphs.inc.php +++ b/html/pages/device/port/graphs.inc.php @@ -1,6 +1,6 @@
@@ -41,7 +41,7 @@ if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifInd include 'includes/print-interface-graphs.inc.php'; echo '
'; - if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-dot3.rrd')) { + if (is_file(get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'dot3'))) { echo '

Ethernet Errors

diff --git a/html/pages/iftype.inc.php b/html/pages/iftype.inc.php index 05cfa2217..266b98fb6 100644 --- a/html/pages/iftype.inc.php +++ b/html/pages/iftype.inc.php @@ -94,7 +94,7 @@ if ($if_list) { echo '
'; - if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) { + if (file_exists(get_port_rrdfile_path ($port['hostname'], $port['port_id']))) { $graph_type = 'port_bits'; include 'includes/print-interface-graphs.inc.php'; From 2ae99e50f5bee33e09847f1c1f9f9c3b2a575ef1 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Thu, 21 Jan 2016 22:04:52 +0100 Subject: [PATCH 18/42] Add support for setting port association mode when adding a host. This adds a '-p' switch to addhost.php and a select box to the WebUI to set the port association mode for newly added devices. Signed-off-by: Maximilian Wilhelm --- addhost.php | 42 ++++++++++++++++++++++++++++---------- html/pages/addhost.inc.php | 21 ++++++++++++++++++- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/addhost.php b/addhost.php index 2280c54e3..381c602da 100755 --- a/addhost.php +++ b/addhost.php @@ -19,7 +19,7 @@ require 'config.php'; require 'includes/definitions.inc.php'; require 'includes/functions.php'; -$options = getopt('g:f::'); +$options = getopt('g:p:f::'); if (isset($options['g']) && $options['g'] >= 0) { $cmd = array_shift($argv); @@ -39,6 +39,22 @@ if (isset($options['f']) && $options['f'] == 0) { $force_add = 1; } +$port_assoc_mode = $config['default_port_association_mode']; +$valid_assoc_modes = get_port_assoc_modes (); +if (isset ($options['p'])) { + $port_assoc_mode = $options['p']; + if (! in_array ($port_assoc_mode, $valid_assoc_modes)) { + echo "Invalid port association mode '" . $port_assoc_mode . "'\n"; + echo 'Valid modes: ' . join (', ', $valid_assoc_modes) . "\n"; + exit; + } + + $cmd = array_shift($argv); + array_shift($argv); + array_shift($argv); + array_unshift($argv, $cmd); +} + if (!empty($argv[1])) { $host = strtolower($argv[1]); $community = $argv[2]; @@ -82,7 +98,7 @@ if (!empty($argv[1])) { array_push($config['snmp']['v3'], $v3); } - $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); } else if ($seclevel === 'anp' or $seclevel === 'authNoPriv') { $v3['authlevel'] = 'authNoPriv'; @@ -108,7 +124,7 @@ if (!empty($argv[1])) { } array_push($config['snmp']['v3'], $v3); - $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); } else if ($seclevel === 'ap' or $seclevel === 'authPriv') { $v3['authlevel'] = 'authPriv'; @@ -138,7 +154,7 @@ if (!empty($argv[1])) { }//end while array_push($config['snmp']['v3'], $v3); - $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); } else { // Error or do nothing ? @@ -164,7 +180,7 @@ if (!empty($argv[1])) { $config['snmp']['community'] = array($community); } - $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); }//end if if ($snmpver) { @@ -180,7 +196,7 @@ if (!empty($argv[1])) { while (!$device_id && count($snmpversions)) { $snmpver = array_shift($snmpversions); - $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $device_id = addHost($host, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); } if ($device_id) { @@ -193,14 +209,18 @@ if (!empty($argv[1])) { print $console_color->convert( "\n".$config['project_name_version'].' Add Host Tool - Usage (SNMPv1/2c): ./addhost.php [-g ] [-f] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).'] - Usage (SNMPv3) : Config Defaults : ./addhost.php [-g ] [-f]<%Whostname%n> any v3 [user] [port] ['.implode('|', $config['snmp']['transports']).'] - No Auth, No Priv : ./addhost.php [-g ] [-f]<%Whostname%n> nanp v3 [user] [port] ['.implode('|', $config['snmp']['transports']).'] - Auth, No Priv : ./addhost.php [-g ] [-f]<%Whostname%n> anp v3 [md5|sha] [port] ['.implode('|', $config['snmp']['transports']).'] - Auth, Priv : ./addhost.php [-g ] [-f]<%Whostname%n> ap v3 [md5|sha] [aes|dsa] [port] ['.implode('|', $config['snmp']['transports']).'] + Usage (SNMPv1/2c): ./addhost.php [-g ] [-f] [-p ] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).'] + Usage (SNMPv3) : Config Defaults : ./addhost.php [-g ] [-f] [-p ] <%Whostname%n> any v3 [user] [port] ['.implode('|', $config['snmp']['transports']).'] + No Auth, No Priv : ./addhost.php [-g ] [-f] [-p ] <%Whostname%n> nanp v3 [user] [port] ['.implode('|', $config['snmp']['transports']).'] + Auth, No Priv : ./addhost.php [-g ] [-f] [-p ] <%Whostname%n> anp v3 [md5|sha] [port] ['.implode('|', $config['snmp']['transports']).'] + Auth, Priv : ./addhost.php [-g ] [-f] [-p ] <%Whostname%n> ap v3 [md5|sha] [aes|dsa] [port] ['.implode('|', $config['snmp']['transports']).'] -g allows you to add a device to be pinned to a specific poller when using distributed polling. X can be any number associated with a poller group -f forces the device to be added by skipping the icmp and snmp check against the host. + -p allow you to set a port association mode for this device. By default ports are associated by \'ifIndex\'. + For Linux/Unix based devices \'ifName\' or \'ifDescr\' might be useful for a stable iface mapping. + The default for this installation is \'' . $config['default_port_association_mode'] . '\' + Valid port assoc modes are: ' . join (', ', $valid_assoc_modes) . ' %rRemember to run discovery for the host afterwards.%n ' diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index 2844982d7..fdbf9b0e3 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -65,7 +65,8 @@ if ($_POST['hostname']) { $force_add = 0; } - $result = addHost($hostname, $snmpver, $port, $transport, 0, $poller_group, $force_add); + $port_assoc_mode = $_POST['port_assoc_mode']; + $result = addHost($hostname, $snmpver, $port, $transport, 0, $poller_group, $force_add, $port_assoc_mode); if ($result) { print_message("Device added ($result)"); } @@ -120,6 +121,24 @@ foreach ($config['snmp']['transports'] as $transport) { echo '>'.$transport.''; } +?> + +
+
+
+ +
+
From 8c704f7bdf16811ea8adaacdd49161ae05d29656 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Thu, 21 Jan 2016 22:05:11 +0100 Subject: [PATCH 19/42] Allow editing port association mode of a device. Add a select box to the device SNMP edit page in the WebUI to update the port association mode of a device. Signed-off-by: Maximilian Wilhelm --- html/pages/device/edit/snmp.inc.php | 23 ++++++++++++++++++- includes/functions.php | 35 ++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index cf2054cfc..b77f3dcc4 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -9,6 +9,7 @@ if ($_POST['editing']) { $timeout = mres($_POST['timeout']); $retries = mres($_POST['retries']); $poller_group = mres($_POST['poller_group']); + $port_assoc_mode = mres($_POST['port_assoc_mode']); $v3 = array( 'authlevel' => mres($_POST['authlevel']), 'authname' => mres($_POST['authname']), @@ -25,6 +26,7 @@ if ($_POST['editing']) { 'port' => $port, 'transport' => $transport, 'poller_group' => $poller_group, + 'port_association_mode' => $port_assoc_mode, ); if ($_POST['timeout']) { @@ -43,7 +45,7 @@ if ($_POST['editing']) { $update = array_merge($update, $v3); - $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3); + $device_tmp = deviceArray($device['hostname'], $community, $snmpver, $port, $transport, $v3, $port_assoc_mode); if (isSNMPable($device_tmp)) { $rows_updated = dbUpdate($update, 'devices', '`device_id` = ?', array($device['device_id'])); @@ -116,6 +118,25 @@ echo "
+
+ +
+ +
+
diff --git a/includes/functions.php b/includes/functions.php index f97dd4177..e399a10ae 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -239,12 +239,20 @@ function delete_device($id) { return $ret; } -function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0', $poller_group = '0', $force_add = '0') { +function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0', $poller_group = '0', $force_add = '0', $port_assoc_mode = 'ifIndex') { global $config; list($hostshort) = explode(".", $host); // Test Database Exists if (host_exists($host) === false) { + // Valid port assoc mode + if (! is_valid_port_assoc_mode ($port_assoc_mode)) { + if ($quiet == 0) { + print_error ("Invalid port association_mode '$port_assoc_mode'. Valid modes are: " . join (', ', get_port_assoc_modes ())); + return 0; + } + } + if ($config['addhost_alwayscheckip'] === TRUE) { $ip = gethostbyname($host); } else { @@ -257,15 +265,15 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0 if (empty($snmpver)) { // Try SNMPv2c $snmpver = 'v2c'; - $ret = addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add); + $ret = addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add, $port_assoc_mode); if (!$ret) { //Try SNMPv3 $snmpver = 'v3'; - $ret = addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add); + $ret = addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add, $port_assoc_mode); if (!$ret) { // Try SNMPv1 $snmpver = 'v1'; - return addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add); + return addHost($host, $snmpver, $port, $transport, $quiet, $poller_group, $force_add, $port_assoc_mode); } else { return $ret; @@ -279,12 +287,12 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0 if ($snmpver === "v3") { // Try each set of parameters from config foreach ($config['snmp']['v3'] as $v3) { - $device = deviceArray($host, NULL, $snmpver, $port, $transport, $v3); + $device = deviceArray($host, NULL, $snmpver, $port, $transport, $v3, $port_assoc_mode); if($quiet == '0') { print_message("Trying v3 parameters " . $v3['authname'] . "/" . $v3['authlevel'] . " ... "); } if ($force_add == 1 || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); if (empty($snmphost) or ($snmphost == $host || $hostshort = $host)) { - $device_id = createHost ($host, NULL, $snmpver, $port, $transport, $v3, $poller_group); + $device_id = createHost ($host, NULL, $snmpver, $port, $transport, $v3, $poller_group, $port_assoc_mode); return $device_id; } else { @@ -303,14 +311,14 @@ function addHost($host, $snmpver, $port = '161', $transport = 'udp', $quiet = '0 elseif ($snmpver === "v2c" or $snmpver === "v1") { // try each community from config foreach ($config['snmp']['community'] as $community) { - $device = deviceArray($host, $community, $snmpver, $port, $transport, NULL); + $device = deviceArray($host, $community, $snmpver, $port, $transport, NULL, $port_assoc_mode); if($quiet == '0') { print_message("Trying community $community ..."); } if ($force_add == 1 || isSNMPable($device)) { $snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB"); if (empty($snmphost) || ($snmphost && ($snmphost == $host || $hostshort = $host))) { - $device_id = createHost ($host, $community, $snmpver, $port, $transport,array(),$poller_group); + $device_id = createHost ($host, $community, $snmpver, $port, $transport,array(),$poller_group, $port_assoc_mode); return $device_id; } else { @@ -382,12 +390,18 @@ next; } } -function deviceArray($host, $community, $snmpver, $port = 161, $transport = 'udp', $v3) { +function deviceArray($host, $community, $snmpver, $port = 161, $transport = 'udp', $v3, $port_assoc_mode = 'ifIndex') { $device = array(); $device['hostname'] = $host; $device['port'] = $port; $device['transport'] = $transport; + /* Get port_assoc_mode id if neccessary + * We can work with names of IDs here */ + if (! is_int ($port_assoc_mode)) + $port_assoc_mode = get_port_assoc_mode_id ($port_assoc_mode); + $device['port_association_mode'] = $port_assoc_mode; + $device['snmpver'] = $snmpver; if ($snmpver === "v2c" or $snmpver === "v1") { $device['community'] = $community; @@ -554,7 +568,7 @@ function getpollergroup($poller_group='0') { } } -function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group='0') { +function createHost($host, $community = NULL, $snmpver, $port = 161, $transport = 'udp', $v3 = array(), $poller_group='0', $port_assoc_mode = 'ifIndex') { global $config; $host = trim(strtolower($host)); @@ -569,6 +583,7 @@ function createHost($host, $community = NULL, $snmpver, $port = 161, $transport 'snmpver' => $snmpver, 'poller_group' => $poller_group, 'status_reason' => '', + 'port_association_mode' => $port_assoc_mode, ); $device = array_merge($device, $v3); From 63f18a86d4d08110a8372cea4fb0e1860ac5c54e Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Tue, 26 Jan 2016 14:06:53 +0100 Subject: [PATCH 20/42] Dear Scrutinizer, please check my code. Thank you. From e54e22b56ed91bd319a011208bb1f4a6aa216297 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Tue, 26 Jan 2016 23:31:07 +1000 Subject: [PATCH 21/42] - Changed upper case variables to lower case. --- .../graphs/port/cbqos_bufferdrops.inc.php | 46 ++++----- .../graphs/port/cbqos_qosdrops.inc.php | 46 ++++----- .../graphs/port/cbqos_traffic.inc.php | 46 ++++----- html/pages/device/port/cbqos.inc.php | 81 ++++++++------- includes/discovery/cisco-cbqos.inc.php | 98 +++++++++---------- includes/polling/cisco-cbqos.inc.php | 48 ++++----- includes/snmp.inc.php | 4 +- 7 files changed, 184 insertions(+), 185 deletions(-) diff --git a/html/includes/graphs/port/cbqos_bufferdrops.inc.php b/html/includes/graphs/port/cbqos_bufferdrops.inc.php index 93626bc15..ea3350762 100644 --- a/html/includes/graphs/port/cbqos_bufferdrops.inc.php +++ b/html/includes/graphs/port/cbqos_bufferdrops.inc.php @@ -12,19 +12,19 @@ */ require_once "../includes/component.php"; -$COMPONENT = new component(); +$component = new component(); $options['filter']['type'] = array('=','Cisco-CBQOS'); -$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); +$components = $component->getComponents($device['device_id'],$options); // We only care about our device id. -$COMPONENTS = $COMPONENTS[$device['device_id']]; +$components = $components[$device['device_id']]; // Determine a policy to show. if (!isset($vars['policy'])) { - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { // Found the first policy - $vars['policy'] = $ID; + $vars['policy'] = $id; continue; } } @@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; -$COUNT = 0; -foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); +$count = 0; +foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's - $STACK = ""; - if ($COUNT != 0) { - $STACK = ":STACK "; + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; } // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { - $COLOR = $config['graph_colours']['mixed'][$COUNT]; + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; } else { - $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + $color = $config['graph_colours']['oranges'][$count-7]; } - $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; - $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":bufferdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - $COUNT++; + $count++; } } } diff --git a/html/includes/graphs/port/cbqos_qosdrops.inc.php b/html/includes/graphs/port/cbqos_qosdrops.inc.php index ea107b380..36f856eed 100644 --- a/html/includes/graphs/port/cbqos_qosdrops.inc.php +++ b/html/includes/graphs/port/cbqos_qosdrops.inc.php @@ -12,19 +12,19 @@ */ require_once "../includes/component.php"; -$COMPONENT = new component(); +$component = new component(); $options['filter']['type'] = array('=','Cisco-CBQOS'); -$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); +$components = $component->getComponents($device['device_id'],$options); // We only care about our device id. -$COMPONENTS = $COMPONENTS[$device['device_id']]; +$components = $components[$device['device_id']]; // Determine a policy to show. if (!isset($vars['policy'])) { - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { // Found the first policy - $vars['policy'] = $ID; + $vars['policy'] = $id; continue; } } @@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; -$COUNT = 0; -foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); +$count = 0; +foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's - $STACK = ""; - if ($COUNT != 0) { - $STACK = ":STACK "; + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; } // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { - $COLOR = $config['graph_colours']['mixed'][$COUNT]; + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; } else { - $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + $color = $config['graph_colours']['oranges'][$count-7]; } - $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":qosdrops:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; - $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":qosdrops:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - $COUNT++; + $count++; } } } diff --git a/html/includes/graphs/port/cbqos_traffic.inc.php b/html/includes/graphs/port/cbqos_traffic.inc.php index 3cf7291fd..eabd91909 100644 --- a/html/includes/graphs/port/cbqos_traffic.inc.php +++ b/html/includes/graphs/port/cbqos_traffic.inc.php @@ -12,19 +12,19 @@ */ require_once "../includes/component.php"; -$COMPONENT = new component(); +$component = new component(); $options['filter']['type'] = array('=','Cisco-CBQOS'); -$COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); +$components = $component->getComponents($device['device_id'],$options); // We only care about our device id. -$COMPONENTS = $COMPONENTS[$device['device_id']]; +$components = $components[$device['device_id']]; // Determine a policy to show. if (!isset($vars['policy'])) { - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { // Found the first policy - $vars['policy'] = $ID; + $vars['policy'] = $id; continue; } } @@ -35,34 +35,34 @@ $rrd_options .= " -l 0 -E "; $rrd_options .= " COMMENT:'Class-Map Now Avg Max\\n'"; $rrd_additions = ""; -$COUNT = 0; -foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 2) && ($ARRAY['parent'] == $COMPONENTS[$vars['policy']]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$vars['policy']]['sp-id'])) { - $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"); +$count = 0; +foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 2) && ($array['parent'] == $components[$vars['policy']]['sp-obj']) && ($array['sp-id'] == $components[$vars['policy']]['sp-id'])) { + $rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"); if (file_exists($rrd_filename)) { // Stack the area on the second and subsequent DS's - $STACK = ""; - if ($COUNT != 0) { - $STACK = ":STACK "; + $stack = ""; + if ($count != 0) { + $stack = ":STACK "; } // Grab a color from the array. - if ( isset($config['graph_colours']['mixed'][$COUNT]) ) { - $COLOR = $config['graph_colours']['mixed'][$COUNT]; + if ( isset($config['graph_colours']['mixed'][$count]) ) { + $color = $config['graph_colours']['mixed'][$count]; } else { - $COLOR = $config['graph_colours']['oranges'][$COUNT-7]; + $color = $config['graph_colours']['oranges'][$count-7]; } - $rrd_additions .= " DEF:DS" . $COUNT . "=" . $rrd_filename . ":postbits:AVERAGE "; - $rrd_additions .= " CDEF:MOD" . $COUNT . "=DS" . $COUNT . ",8,* "; - $rrd_additions .= " AREA:MOD" . $COUNT . "#" . $COLOR . ":'" . str_pad(substr($COMPONENTS[$ID]['label'],0,15),15) . "'" . $STACK; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":LAST:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":AVERAGE:%6.2lf%s "; - $rrd_additions .= " GPRINT:MOD" . $COUNT . ":MAX:%6.2lf%s\\\l "; + $rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":postbits:AVERAGE "; + $rrd_additions .= " CDEF:MOD" . $count . "=DS" . $count . ",8,* "; + $rrd_additions .= " AREA:MOD" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'],0,15),15) . "'" . $stack; + $rrd_additions .= " GPRINT:MOD" . $count . ":LAST:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":AVERAGE:%6.2lf%s "; + $rrd_additions .= " GPRINT:MOD" . $count . ":MAX:%6.2lf%s\\\l "; - $COUNT++; + $count++; } } } diff --git a/html/pages/device/port/cbqos.inc.php b/html/pages/device/port/cbqos.inc.php index fbcfafdd0..e85d3de25 100644 --- a/html/pages/device/port/cbqos.inc.php +++ b/html/pages/device/port/cbqos.inc.php @@ -11,29 +11,29 @@ * the source code distribution for details. */ -function find_child($COMPONENTS,$parent,$level) { +function find_child($components,$parent,$level) { global $vars; - foreach($COMPONENTS as $ID => $ARRAY) { - if ($ARRAY['qos-type'] == 3) { + foreach($components as $id => $array) { + if ($array['qos-type'] == 3) { continue; } - if (($ARRAY['parent'] == $COMPONENTS[$parent]['sp-obj']) && ($ARRAY['sp-id'] == $COMPONENTS[$parent]['sp-id'])) { + if (($array['parent'] == $components[$parent]['sp-obj']) && ($array['sp-id'] == $components[$parent]['sp-id'])) { echo "
    "; echo "
  • "; - if ($ARRAY['qos-type'] == 1) { + if ($array['qos-type'] == 1) { // Its a policy, we need to make it a link. - echo('' . $ARRAY['label'] . ''); + echo('' . $array['label'] . ''); } else { // No policy, no link - echo $ARRAY['label']; + echo $array['label']; } - if (isset($ARRAY['match'])) { - echo ' ('.$ARRAY['match'].')'; + if (isset($array['match'])) { + echo ' ('.$array['match'].')'; } - find_child($COMPONENTS,$ID,$level+1); + find_child($components,$id,$level+1); echo "
  • "; echo "
"; @@ -44,23 +44,19 @@ function find_child($COMPONENTS,$parent,$level) { $rrdarr = glob($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-cbqos-*.rrd'); if (!empty($rrdarr)) { require_once "../includes/component.php"; - $COMPONENT = new component(); + $component = new component(); $options['filter']['type'] = array('=','Cisco-CBQOS'); - $COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. - $COMPONENTS = $COMPONENTS[$device['device_id']]; + $components = $components[$device['device_id']]; - if (isset($vars['policy'])) { - // if a policy is set try to use it. - $graph_array['policy'] = $vars['policy']; - } - else { - // if not, find the first parent and use it. - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['parent'] == 0) ) { + if (!isset($vars['policy'])) { + // not set, find the first parent and use it. + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['parent'] == 0) ) { // Found the first policy - $graph_array['policy'] = $ID; + $vars['policy'] = $id; continue; } } @@ -70,17 +66,17 @@ if (!empty($rrdarr)) { // Display the ingress policy at the top of the page. echo "
    "; echo '
     Ingress Policy:
    '; - $FOUND = false; - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['direction'] == 1) && ($ARRAY['parent'] == 0) ) { + $found = false; + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['direction'] == 1) && ($array['parent'] == 0) ) { echo "
  • "; - echo('' . $ARRAY['label'] . ''); - find_child($COMPONENTS,$ID,1); + echo('' . $array['label'] . ''); + find_child($components,$id,1); echo "
  • "; - $FOUND = true; + $found = true; } } - if (!$FOUND) { + if (!$found) { // No Ingress policies echo '
    No Policies
    '; } @@ -89,40 +85,43 @@ if (!empty($rrdarr)) { // Display the egress policy at the top of the page. echo "
      "; echo '
       Egress Policy:
      '; - $FOUND = false; - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ARRAY['direction'] == 2) && ($ARRAY['parent'] == 0) ) { + $found = false; + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($array['direction'] == 2) && ($array['parent'] == 0) ) { echo "
    • "; - echo('' . $ARRAY['label'] . ''); - find_child($COMPONENTS,$ID,1); + echo('' . $array['label'] . ''); + find_child($components,$id,1); echo "
    • "; - $FOUND = true; + $found = true; } } - if (!$FOUND) { + if (!$found) { // No Egress policies echo '
      No Policies
      '; } echo "
    \n\n"; // Let's make sure the policy we are trying to access actually exists. - foreach ($COMPONENTS as $ID => $ARRAY) { - if ( ($ARRAY['qos-type'] == 1) && ($ARRAY['ifindex'] == $port['ifIndex']) && ($ID == $graph_array['policy']) ) { + foreach ($components as $id => $array) { + if ( ($array['qos-type'] == 1) && ($array['ifindex'] == $port['ifIndex']) && ($id == $vars['policy']) ) { // The policy exists. echo "
     
    \n\n"; // Display each graph row. echo "
    "; - echo "
    Traffic by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
    "; + echo "
    Traffic by CBQoS Class - ".$components[$vars['policy']]['label']."
    "; + $graph_array['policy'] = $vars['policy']; $graph_type = 'port_cbqos_traffic'; include 'includes/print-interface-graphs.inc.php'; - echo "
    QoS Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
    "; + echo "
    QoS Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
    "; + $graph_array['policy'] = $vars['policy']; $graph_type = 'port_cbqos_bufferdrops'; include 'includes/print-interface-graphs.inc.php'; - echo "
    Buffer Drops by CBQoS Class - ".$COMPONENTS[$graph_array['policy']]['label']."
    "; + echo "
    Buffer Drops by CBQoS Class - ".$components[$vars['policy']]['label']."
    "; + $graph_array['policy'] = $vars['policy']; $graph_type = 'port_cbqos_qosdrops'; include 'includes/print-interface-graphs.inc.php'; echo "
    \n\n"; diff --git a/includes/discovery/cisco-cbqos.inc.php b/includes/discovery/cisco-cbqos.inc.php index 86eec8d9c..2082c950e 100644 --- a/includes/discovery/cisco-cbqos.inc.php +++ b/includes/discovery/cisco-cbqos.inc.php @@ -13,15 +13,15 @@ if ($device['os_group'] == 'cisco') { - $MODULE = 'Cisco-CBQOS'; - echo $MODULE.': '; + $module = 'Cisco-CBQOS'; + echo $module.': '; require_once 'includes/component.php'; - $COMPONENT = new component(); - $COMPONENTS = $COMPONENT->getComponents($device['device_id'],array('type'=>$MODULE)); + $component = new component(); + $components = $component->getComponents($device['device_id'],array('type'=>$module)); // We only care about our device id. - $COMPONENTS = $COMPONENTS[$device['device_id']]; + $components = $components[$device['device_id']]; // Begin our master array, all other values will be processed into this array. @@ -49,68 +49,68 @@ if ($device['os_group'] == 'cisco') { foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'] as $spid => $array) { foreach ($array as $spobj => $index) { - $RESULT = array(); + $result = array(); // Produce a unique reproducible index for this entry. - $RESULT['UID'] = hash('crc32', $spid."-".$spobj); + $result['UID'] = hash('crc32', $spid."-".$spobj); // Now that we have a valid identifiers, lets add some more data - $RESULT['sp-id'] = $spid; - $RESULT['sp-obj'] = $spobj; + $result['sp-id'] = $spid; + $result['sp-obj'] = $spobj; // Add the Type, Policy-map, Class-map, etc. $type = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$spobj]; - $RESULT['qos-type'] = $type; + $result['qos-type'] = $type; // Add the Parent, this lets us work out our hierarchy for display later. - $RESULT['parent'] = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid][$spobj]; - $RESULT['direction'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.3'][$spid]; - $RESULT['ifindex'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.4'][$spid]; + $result['parent'] = $tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid][$spobj]; + $result['direction'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.3'][$spid]; + $result['ifindex'] = $tblcbQosServicePolicy['1.3.6.1.4.1.9.9.166.1.1.1.1.4'][$spid]; // Gather different data depending on the type. switch ($type) { case 1: // Policy-map, get data from that table. d_echo("\nIndex: ".$index."\n"); - d_echo(" UID: ".$RESULT['UID']."\n"); - d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); - d_echo(" If-Index: ".$RESULT['ifindex']."\n"); + d_echo(" UID: ".$result['UID']."\n"); + d_echo(" SPID.SPOBJ: ".$result['sp-id'].".".$result['sp-obj']."\n"); + d_echo(" If-Index: ".$result['ifindex']."\n"); d_echo(" Type: 1 - Policy-Map\n"); - $RESULT['label'] = $tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.1'][$index]; + $result['label'] = $tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.1'][$index]; if ($tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index] != "") { - $RESULT['label'] .= " - ".$tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index]; + $result['label'] .= " - ".$tblcbQosPolicyMapCfg['1.3.6.1.4.1.9.9.166.1.6.1.1.2'][$index]; } - d_echo(" Label: ".$RESULT['label']."\n"); + d_echo(" Label: ".$result['label']."\n"); break; case 2: // Class-map, get data from that table. d_echo("\nIndex: ".$index."\n"); - d_echo(" UID: ".$RESULT['UID']."\n"); - d_echo(" SPID.SPOBJ: ".$RESULT['sp-id'].".".$RESULT['sp-obj']."\n"); - d_echo(" If-Index: ".$RESULT['ifindex']."\n"); + d_echo(" UID: ".$result['UID']."\n"); + d_echo(" SPID.SPOBJ: ".$result['sp-id'].".".$result['sp-obj']."\n"); + d_echo(" If-Index: ".$result['ifindex']."\n"); d_echo(" Type: 2 - Class-Map\n"); - $RESULT['label'] = $tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.1'][$index]; + $result['label'] = $tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.1'][$index]; if($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index] != "") { - $RESULT['label'] .= " - ".$tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index]; + $result['label'] .= " - ".$tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.2'][$index]; } - d_echo(" Label: ".$RESULT['label']."\n"); + d_echo(" Label: ".$result['label']."\n"); if ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 2) { - $RESULT['map-type'] = 'Match-All'; + $result['map-type'] = 'Match-All'; } elseif ($tblcbQosClassMapCfg['1.3.6.1.4.1.9.9.166.1.7.1.1.3'][$index] == 3) { - $RESULT['map-type'] = 'Match-Any'; + $result['map-type'] = 'Match-Any'; } else { - $RESULT['map-type'] = 'None'; + $result['map-type'] = 'None'; } // Find a child, this will be a type 3 - foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid] as $ID => $VALUE) { - if ($VALUE == $RESULT['sp-obj']) { + foreach ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.4'][$spid] as $id => $value) { + if ($value == $result['sp-obj']) { // We have our child, import the match - if ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$ID] == 3) { - $RESULT['match'] = $RESULT['map-type'].": ".$tblcbQosMatchStmtCfg['1.3.6.1.4.1.9.9.166.1.8.1.1.1'][$tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'][$spid][$ID]]; - d_echo(" Match: ".$RESULT['match']."\n"); + if ($tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.3'][$spid][$id] == 3) { + $result['match'] = $result['map-type'].": ".$tblcbQosMatchStmtCfg['1.3.6.1.4.1.9.9.166.1.8.1.1.1'][$tblcbQosObjects['1.3.6.1.4.1.9.9.166.1.5.1.1.2'][$spid][$id]]; + d_echo(" Match: ".$result['match']."\n"); } } } @@ -119,7 +119,7 @@ if ($device['os_group'] == 'cisco') { continue 2; } - $tblCBQOS[] = $RESULT; + $tblCBQOS[] = $result; } } @@ -130,25 +130,25 @@ if ($device['os_group'] == 'cisco') { * Let's loop over the SNMP data to see if we need to ADD or UPDATE any components. */ foreach ($tblCBQOS as $key => $array) { - $COMPONENT_KEY = false; + $component_key = false; // Loop over our components to determine if the component exists, or we need to add it. - foreach ($COMPONENTS as $COMPID => $CHILD) { - if ($CHILD['UID'] === $array['UID']) { - $COMPONENT_KEY = $COMPID; + foreach ($components as $compid => $child) { + if ($child['UID'] === $array['UID']) { + $component_key = $compid; } } - if (!$COMPONENT_KEY) { + if (!$component_key) { // The component doesn't exist, we need to ADD it - ADD. - $NEW_COMPONENT = $COMPONENT->createComponent($device['device_id'],$MODULE); - $COMPONENT_KEY = key($NEW_COMPONENT); - $COMPONENTS[$COMPONENT_KEY] = array_merge($NEW_COMPONENT[$COMPONENT_KEY], $array); + $new_component = $component->createComponent($device['device_id'],$module); + $component_key = key($new_component); + $components[$component_key] = array_merge($new_component[$component_key], $array); echo "+"; } else { // The component does exist, merge the details in - UPDATE. - $COMPONENTS[$COMPONENT_KEY] = array_merge($COMPONENTS[$COMPONENT_KEY], $array); + $components[$component_key] = array_merge($components[$component_key], $array); echo "."; } @@ -157,26 +157,26 @@ if ($device['os_group'] == 'cisco') { /* * Loop over the Component data to see if we need to DELETE any components. */ - foreach ($COMPONENTS as $key => $array) { + foreach ($components as $key => $array) { // Guilty until proven innocent - $FOUND = false; + $found = false; foreach ($tblCBQOS as $k => $v) { if ($array['UID'] == $v['UID']) { // Yay, we found it... - $FOUND = true; + $found = true; } } - if ($FOUND === false) { + if ($found === false) { // The component has not been found. we should delete it. echo "-"; - $COMPONENT->deleteComponent($key); + $component->deleteComponent($key); } } // Write the Components back to the DB. - $COMPONENT->setComponentPrefs($device['device_id'],$COMPONENTS); + $component->setComponentPrefs($device['device_id'],$components); echo "\n"; } // End if not error diff --git a/includes/polling/cisco-cbqos.inc.php b/includes/polling/cisco-cbqos.inc.php index 7d8fea76d..e113b4fa2 100644 --- a/includes/polling/cisco-cbqos.inc.php +++ b/includes/polling/cisco-cbqos.inc.php @@ -13,31 +13,31 @@ if ($device['os_group'] == "cisco") { - $MODULE = 'Cisco-CBQOS'; + $module = 'Cisco-CBQOS'; require_once 'includes/component.php'; - $COMPONENT = new component(); - $options['filter']['type'] = array('=',$MODULE); + $component = new component(); + $options['filter']['type'] = array('=',$module); $options['filter']['disabled'] = array('=',0); $options['filter']['ignore'] = array('=',0); - $COMPONENTS = $COMPONENT->getComponents($device['device_id'],$options); + $components = $component->getComponents($device['device_id'],$options); // We only care about our device id. - $COMPONENTS = $COMPONENTS[$device['device_id']]; + $components = $components[$device['device_id']]; // Only collect SNMP data if we have enabled components - if (count($COMPONENTS > 0)) { + if (count($components > 0)) { // Let's gather the stats.. $tblcbQosClassMapStats = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.166.1.15.1.1', 2); // Loop through the components and extract the data. - foreach ($COMPONENTS as $KEY => $ARRAY) { - $TYPE = $ARRAY['qos-type']; + foreach ($components as $key => $array) { + $type = $array['qos-type']; // Get data from the class table. - if ($TYPE == 2) { - // Let's make sure the RRD is setup for this class. - $filename = "port-".$ARRAY['ifindex']."-cbqos-".$ARRAY['sp-id']."-".$ARRAY['sp-obj'].".rrd"; + if ($type == 2) { + // Let's make sure the rrd is setup for this class. + $filename = "port-".$array['ifindex']."-cbqos-".$array['sp-id']."-".$array['sp-obj'].".rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename ($filename); if (!file_exists ($rrd_filename)) { @@ -45,28 +45,28 @@ if ($device['os_group'] == "cisco") { } // Let's print some debugging info. - d_echo("\n\nComponent: ".$KEY."\n"); - d_echo(" Class-Map: ".$ARRAY['label']."\n"); - d_echo(" SPID.SPOBJ: ".$ARRAY['sp-id'].".".$ARRAY['sp-obj']."\n"); - d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); - d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); - d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$ARRAY['sp-id'].".".$ARRAY['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]."\n"); + d_echo("\n\nComponent: ".$key."\n"); + d_echo(" Class-Map: ".$array['label']."\n"); + d_echo(" SPID.SPOBJ: ".$array['sp-id'].".".$array['sp-obj']."\n"); + d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']]."\n"); + d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]."\n"); + d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]."\n"); - $RRD['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; - $RRD['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; - $RRD['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$ARRAY['sp-id']][$ARRAY['sp-obj']]; + $rrd['postbytes'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']]; + $rrd['bufferdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]; + $rrd['qosdrops'] = $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]; - // Update RRD - rrdtool_update ($rrd_filename, $RRD); + // Update rrd + rrdtool_update ($rrd_filename, $rrd); // Clean-up after yourself! unset($filename, $rrd_filename); } } // End foreach components - echo $MODULE." "; + echo $module." "; } // end if count components // Clean-up after yourself! - unset($TYPE, $COMPONENTS, $COMPONENT, $options, $MODULE); +unset($type, $components, $component, $options, $module); } \ No newline at end of file diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index cee0032cc..7707b18fe 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1293,9 +1293,9 @@ function register_mibs($device, $mibs, $included_by) * @internal param $string * @return array */ -function snmpwalk_array_num($device,$OID,$indexes=1) { +function snmpwalk_array_num($device,$oid,$indexes=1) { $array = array(); - $string = snmp_walk($device, $OID, '-Osqn'); + $string = snmp_walk($device, $oid, '-Osqn'); if ( $string === false) { // False means: No Such Object. From 0e66ddf0882fd90264cf7c5786e478f252679bde Mon Sep 17 00:00:00 2001 From: vitalisator Date: Thu, 28 Jan 2016 13:07:33 +0100 Subject: [PATCH 22/42] some bugfixing --- html/includes/common/stp-ports.inc.php | 7 ++++--- html/includes/print-stp.inc.php | 6 ++++-- html/includes/table/stp-ports.inc.php | 2 +- html/pages/device/stp.inc.php | 8 -------- sql-schema/095.sql | 3 +++ 5 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 sql-schema/095.sql diff --git a/html/includes/common/stp-ports.inc.php b/html/includes/common/stp-ports.inc.php index 862b514d5..c77ab7603 100644 --- a/html/includes/common/stp-ports.inc.php +++ b/html/includes/common/stp-ports.inc.php @@ -2,7 +2,7 @@ $common_output[] = '
    - +
    @@ -14,16 +14,17 @@ $common_output[] = ' - + -
    PortDesignated cost Designated bridge Designated portFwd trasitionsForward transitions
    +
    '; } else { - $widget_settings['title'] = ""; $type = explode('_',$widget_settings['graph_type'],2); $type = array_shift($type); $widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true)?:$widget_settings['graph_'.$type]; if ($type == 'device') { - $widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type']; + if (empty($widget_settings['title'])) { + $widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type']; + } $param = 'device='.$widget_settings['graph_device']['device_id']; } elseif ($type == 'application') { @@ -394,27 +403,31 @@ else { $type_where .= " $or `port_descr_type` = ?"; $or = 'OR'; $type_param[] = $type; - $type_where .= ') '; + $type_where .= ') '; foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE $type_where ORDER BY ifAlias", $type_param) as $port) { $tmp[] = $port['port_id']; } - $param = 'id='.implode(',',$tmp); - $widget_settings['graph_type']= 'multiport_bits_separate'; - $widget_settings['title'] = 'Overall '.ucfirst($type).' Bits ('.$widget_settings['graph_range'].')'; + $param = 'id='.implode(',',$tmp); + $widget_settings['graph_type'] = 'multiport_bits_separate'; + if (empty($widget_settings['title'])) { + $widget_settings['title'] = 'Overall '.ucfirst($type).' Bits ('.$widget_settings['graph_range'].')'; + } } elseif ($type == 'custom') { foreach (dbFetchRows("SELECT port_id FROM `ports` WHERE `port_descr_type` = ? ORDER BY ifAlias", array($widget_settings['graph_custom'])) as $port) { $tmp[] = $port['port_id']; } - $param = 'id='.implode(',',$tmp); - $widget_settings['graph_type']= 'multiport_bits_separate'; - $widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($widget_settings['graph_custom'])).' Bits ('.$widget_settings['graph_range'].')'; + $param = 'id='.implode(',',$tmp); + $widget_settings['graph_type'] = 'multiport_bits_separate'; + if (empty($widget_settings['title'])) { + $widget_settings['title'] = 'Overall '.ucfirst(htmlspecialchars($widget_settings['graph_custom'])).' Bits ('.$widget_settings['graph_range'].')'; + } } else { - $param = 'id='.$widget_settings['graph_'.$type][$type.'_id']; + $param = 'id='.$widget_settings['graph_'.$type][$type.'_id']; } if (empty($widget_settings['title'])) { - $widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type']; + $widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type']; } - $common_output[] = ''; + $common_output[] = ''; } From f4820dad90468f6307e67729e3f8171de2dfb7f5 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 30 Jan 2016 10:05:46 +0000 Subject: [PATCH 30/42] Fixed code to run with php 5.3 --- includes/common.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/common.php b/includes/common.php index 0cbb6b007..ef554798b 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1196,12 +1196,12 @@ function get_port_assoc_mode_name ($port_assoc_mode_id, $no_cache = false) { * @return array */ function get_ports_mapped ($device_id, $with_statistics = false) { - $ports = []; - $maps = [ - 'ifIndex' => [], - 'ifName' => [], - 'ifDescr' => [], - ]; + $ports = array(); + $maps = ( + 'ifIndex' => array(), + 'ifName' => array(), + 'ifDescr' => array(), + ); /* Query all information available for ports for this device ... */ $query = 'SELECT * FROM `ports` WHERE `device_id` = ? ORDER BY port_id'; @@ -1222,10 +1222,10 @@ function get_ports_mapped ($device_id, $with_statistics = false) { $maps['ifDescr'][$port['ifDescr']] = $port['port_id']; } - return [ + return array( 'ports' => $ports, 'maps' => $maps, - ]; + ); } /** From 725fbd2c089bf5e9bf623f7d8ff430ae2e6fbba2 Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 30 Jan 2016 10:10:16 +0000 Subject: [PATCH 31/42] Another fix --- includes/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/common.php b/includes/common.php index ef554798b..d74a512a9 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1197,7 +1197,7 @@ function get_port_assoc_mode_name ($port_assoc_mode_id, $no_cache = false) { */ function get_ports_mapped ($device_id, $with_statistics = false) { $ports = array(); - $maps = ( + $maps = array( 'ifIndex' => array(), 'ifName' => array(), 'ifDescr' => array(), From d29d84a67fc0478fe259478611ccee1b00133579 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sat, 30 Jan 2016 20:03:26 +0100 Subject: [PATCH 32/42] Adjust Leaflet GreenCluster color --- html/css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/css/styles.css b/html/css/styles.css index ea9dde575..ead23f407 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -1847,7 +1847,7 @@ label { .greenCluster { background-color: rgba(0,255,0); - background-color: rgba(0,255,0,0.7); + background-color: rgba(110, 204, 57, 0.6); text-align: center; width: 25px !important; height: 25px !important; From ac572e155800a66691b29211ee738399c2298b45 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Sat, 30 Jan 2016 23:02:09 +0100 Subject: [PATCH 33/42] Sort sensors by OID to more logically group sensors on device overview --- html/pages/device/overview/generic/sensor.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index 076f5b049..ef4288e7c 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -1,6 +1,6 @@ From 3139239240fce1a7bb59a17fe3a9aa6d7679b025 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 31 Jan 2016 00:16:39 +0100 Subject: [PATCH 34/42] Do not discover a temp sensor which is not present #2848 --- .../discovery/sensors/temperatures/cisco-envmon.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/discovery/sensors/temperatures/cisco-envmon.inc.php b/includes/discovery/sensors/temperatures/cisco-envmon.inc.php index 74408318d..2bf2a80d8 100644 --- a/includes/discovery/sensors/temperatures/cisco-envmon.inc.php +++ b/includes/discovery/sensors/temperatures/cisco-envmon.inc.php @@ -15,8 +15,10 @@ if ($device['os_group'] == 'cisco') { if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.'; foreach ($temp as $index => $entry) { - $descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']); - discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index); + if ($temp[$index]['ciscoEnvMonTemperatureThreshold'] != 'notPresent') { + $descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']); + discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index); + } } } } From 5dd9fed3e0482c5a3d8f5dbd86c798c5182a05ae Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 31 Jan 2016 00:18:30 +0100 Subject: [PATCH 35/42] Wrong array value --- includes/discovery/sensors/temperatures/cisco-envmon.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/sensors/temperatures/cisco-envmon.inc.php b/includes/discovery/sensors/temperatures/cisco-envmon.inc.php index 2bf2a80d8..2268f2b33 100644 --- a/includes/discovery/sensors/temperatures/cisco-envmon.inc.php +++ b/includes/discovery/sensors/temperatures/cisco-envmon.inc.php @@ -15,7 +15,7 @@ if ($device['os_group'] == 'cisco') { if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.'; foreach ($temp as $index => $entry) { - if ($temp[$index]['ciscoEnvMonTemperatureThreshold'] != 'notPresent') { + if ($temp[$index]['ciscoEnvMonTemperatureState'] != 'notPresent') { $descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']); discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index); } From 437d1fc40c927ce4330022bb2272dd1703e29f10 Mon Sep 17 00:00:00 2001 From: Jameson Finney Date: Sat, 30 Jan 2016 21:06:58 -0500 Subject: [PATCH 36/42] Removed extra spaces from ends of lines. --- doc/API/API-Docs.md | 34 +++++----- doc/Developing/Code-Structure.md | 2 +- doc/Developing/Dynamic-Config.md | 4 +- doc/Developing/Style-Guidelines.md | 22 +++---- doc/Developing/Using-Git.md | 30 ++++----- doc/Extensions/Agent-Setup.md | 20 +++--- doc/Extensions/Alerting.md | 64 +++++++++---------- doc/Extensions/Authentication.md | 10 +-- doc/Extensions/Component.md | 10 +-- doc/Extensions/Device-Groups.md | 8 +-- doc/Extensions/Distributed-Poller.md | 8 +-- doc/Extensions/Globe-Frontpage.md | 2 +- doc/Extensions/Graylog.md | 6 +- doc/Extensions/IRC-Bot-Extensions.md | 2 +- doc/Extensions/InfluxDB.md | 10 +-- doc/Extensions/Network-Map.md | 4 +- doc/Extensions/Oxidized.md | 2 +- doc/Extensions/Port-Description-Parser.md | 2 +- doc/Extensions/RRDCached.md | 4 +- doc/Extensions/RRDTune.md | 4 +- doc/Extensions/Services.md | 4 +- doc/Extensions/Smokeping.md | 4 +- doc/Extensions/Sub-Directory.md | 8 +-- doc/Extensions/Syslog.md | 10 +-- doc/Extensions/Two-Factor-Auth.md | 22 +++---- doc/Extensions/Varnish.md | 12 ++-- doc/General/Changelog.md | 6 +- doc/General/Contributing.md | 2 +- .../Installation-(RHEL-CentOS).md | 4 +- doc/Support/Configuration.md | 24 +++---- doc/Support/Discovery Support.md | 20 +++--- doc/Support/FAQ.md | 12 ++-- doc/Support/Features.md | 2 +- doc/Support/Install Validation.md | 4 +- doc/Support/Poller Support.md | 12 ++-- doc/Support/Support-New-OS.md | 2 +- 36 files changed, 198 insertions(+), 198 deletions(-) diff --git a/doc/API/API-Docs.md b/doc/API/API-Docs.md index 4f9d4362f..eacdcfada 100644 --- a/doc/API/API-Docs.md +++ b/doc/API/API-Docs.md @@ -112,7 +112,7 @@ Route: /api/v0/devices/:hostname Input: - - + - Example: ```curl @@ -146,7 +146,7 @@ Route: /api/v0/devices/:hostname Input: - - + - Example: ```curl @@ -179,7 +179,7 @@ Route: /api/v0/devices/:hostname/graphs Input: - - + - Example: ```curl @@ -511,8 +511,8 @@ Route: /api/v0/oxidized Input (JSON): - - - + - + Examples: ```curl curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized @@ -548,7 +548,7 @@ Input (JSON): Examples: ```curl -curl -X PATCH -d '{"field": "notes", "data": "This server should be kept online"}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices/localhost +curl -X PATCH -d '{"field": "notes", "data": "This server should be kept online"}' -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/devices/localhost ``` Output: @@ -751,7 +751,7 @@ Route: /api/v0/devices/:hostname/vlans Input: - - + - Example: ```curl @@ -787,7 +787,7 @@ Route: /api/v0/alerts/:id Input: - - + - Example: ```curl @@ -824,7 +824,7 @@ Route: /api/v0/alerts/:id Input: - - + - Example: ```curl @@ -913,7 +913,7 @@ Route: /api/v0/rules/:id Input: - - + - Example: ```curl @@ -950,7 +950,7 @@ Route: /api/v0/rules/:id Input: - - + - Example: ```curl @@ -972,11 +972,11 @@ List the alert rules. Route: /api/v0/rules - - + - Input: - - + - Example: ```curl @@ -1008,7 +1008,7 @@ Add a new alert rule. Route: /api/v0/rules - - + - Input (JSON): @@ -1017,7 +1017,7 @@ Input (JSON): - severity: The severity level the alert will be raised against, Ok, Warning, Critical. - disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled - count: This is how many polling runs before an alert will trigger and the frequency. - - delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one. + - delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one. - mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false). - invert: This would invert the rules check. - name: This is the name of the rule and is mandatory. @@ -1043,7 +1043,7 @@ Edit an existing alert rule Route: /api/v0/rules - - + - Input (JSON): @@ -1053,7 +1053,7 @@ Input (JSON): - severity: The severity level the alert will be raised against, Ok, Warning, Critical. - disabled: Whether the rule will be disabled or not, 0 = enabled, 1 = disabled - count: This is how many polling runs before an alert will trigger and the frequency. - - delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one. + - delay: Delay is when to start alerting and how frequently. The value is stored in seconds but you can specify minutes, hours or days by doing 5 m, 5 h, 5 d for each one. - mute: If mute is enabled then an alert will never be sent but will show up in the Web UI (true or false). - invert: This would invert the rules check. - name: This is the name of the rule and is mandatory. diff --git a/doc/Developing/Code-Structure.md b/doc/Developing/Code-Structure.md index 32fe6a60a..9e1b4782a 100644 --- a/doc/Developing/Code-Structure.md +++ b/doc/Developing/Code-Structure.md @@ -14,7 +14,7 @@ This is the main file which all links within LibreNMS are parsed through. It loa ### html/css All used css files are located here. Apart from legacy files, anything in here is now a symlink. ### html/forms -This folder contains all of the files that are dynamically included from an ajax call to html/ajax_form.php. +This folder contains all of the files that are dynamically included from an ajax call to html/ajax_form.php. ### html/includes This is where the majority of the website core files are located. These tend to be files that contain functions or often used code segments that can be included where needed rather than duplicating code. ### html/includes/api_functions.inc.php diff --git a/doc/Developing/Dynamic-Config.md b/doc/Developing/Dynamic-Config.md index acc9d3079..14c97beba 100644 --- a/doc/Developing/Dynamic-Config.md +++ b/doc/Developing/Dynamic-Config.md @@ -1,6 +1,6 @@ # Adding new config options to WebUI -Adding support for users to update a new config option via the WebUI is now a lot easier for general options. This +Adding support for users to update a new config option via the WebUI is now a lot easier for general options. This document shows you how to add a new config option and even section to the WebUI. #### Update DB @@ -15,7 +15,7 @@ This will determine the default config option for `$config['alert']['tolerance_w #### Update WebUI -If the sub-section you want to add the new config option already exists then update the relevant file within +If the sub-section you want to add the new config option already exists then update the relevant file within `html/pages/settings/` otherwise you will need to create the new sub-section page. Here's an example of this: [Commit example](https://github.com/librenms/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c) diff --git a/doc/Developing/Style-Guidelines.md b/doc/Developing/Style-Guidelines.md index d6acb1265..e8f06b78f 100644 --- a/doc/Developing/Style-Guidelines.md +++ b/doc/Developing/Style-Guidelines.md @@ -1,26 +1,26 @@ # Style guidelines -This document is here to help style standards for contributions towards LibreNMS. These aren't strict rules but it is in +This document is here to help style standards for contributions towards LibreNMS. These aren't strict rules but it is in the users interest that a consistent well thought out Web UI is available. ### Responsiveness -The Web UI is designed to be mobile friendly and for the most part is and works well. It's worth spending sometime to +The Web UI is designed to be mobile friendly and for the most part is and works well. It's worth spending sometime to read through the [Boostrap website](http://getbootstrap.com/css/#grid) to learn more about how to keep things responsive. ### Navigation bar -- Always pick the best location for new links to go, think about where users would expect the link to be located and name +- Always pick the best location for new links to go, think about where users would expect the link to be located and name it so that it's obvious what it does. - Ensure sub sections within the Navigation are separated correctly using ``. -- Only use [Font Awesome icons](http://fontawesome.io/icons/) within the Navigation. It speeds up page load times quite +- Only use [Font Awesome icons](http://fontawesome.io/icons/) within the Navigation. It speeds up page load times quite considerably. ### Buttons -Try to keep buttons colored to reflect the action they will take. Buttons are set using Bootstrap classes. The size of +Try to keep buttons colored to reflect the action they will take. Buttons are set using Bootstrap classes. The size of the buttons will depend on the area of the website being used but btn-sm is probably the most common. - Delete / Remove buttons: btn btn-danger @@ -31,20 +31,20 @@ the buttons will depend on the area of the website being used but btn-sm is prob ### Tables -Unless the table being used will only ever display a handful of items - yeah that's what we all said, then you need to -write your table using [JQuery Bootgrid](http://www.jquery-bootgrid.com/). This shouldn't take that much more code to -do this but provides so much flexibility along with stopping the need for retrieving all the data from SQL in the first +Unless the table being used will only ever display a handful of items - yeah that's what we all said, then you need to +write your table using [JQuery Bootgrid](http://www.jquery-bootgrid.com/). This shouldn't take that much more code to +do this but provides so much flexibility along with stopping the need for retrieving all the data from SQL in the first place. -As an example pull request, see [PR 706](https://github.com/librenms/librenms/pull/706/files) to get an idea of what +As an example pull request, see [PR 706](https://github.com/librenms/librenms/pull/706/files) to get an idea of what it's like to convert an existing pure html table to Bootgrid. ### Datetime format -When displaying datetimes, please ensure you use the format YYYY-MM-DD mm:hh:ss where possible, you shouldn't change the +When displaying datetimes, please ensure you use the format YYYY-MM-DD mm:hh:ss where possible, you shouldn't change the order of this as it will be confusing to users. Cutting it short to just display YYYY-MM-DD mm:hh is fine :). -To keep things consistent we have the following variables which should be used rather than to format dates yourself. +To keep things consistent we have the following variables which should be used rather than to format dates yourself. This has the added benefit that users can customise the format: ```php diff --git a/doc/Developing/Using-Git.md b/doc/Developing/Using-Git.md index ae2dc43fa..c66400405 100644 --- a/doc/Developing/Using-Git.md +++ b/doc/Developing/Using-Git.md @@ -8,7 +8,7 @@ Some assumptions: - LibreNMS is to be installed in /opt/librenms - You have git installed. - You have a [GitHub Account](https://github.com/). -- You are using ssh to connect to GitHub (If not, replace git@github.com:/yourusername/librenms.git with +- You are using ssh to connect to GitHub (If not, replace git@github.com:/yourusername/librenms.git with https://github.com/yourusername/librenms.git. ** Replace yourusername with your GitHub username. ** @@ -16,7 +16,7 @@ https://github.com/yourusername/librenms.git. #### Fork LibreNMS repo You do this directly within [GitHub](https://github.com/librenms/librenms/fork), click the 'Fork' button near the top right. -If you are associated with multiple organisations within GitHub then you might need to select which account you want to +If you are associated with multiple organisations within GitHub then you might need to select which account you want to push the fork to. #### Prepare your git environment @@ -29,7 +29,7 @@ git config --global user.email johndoe@example.com ``` #### Clone the repo -Ok so now that you have forked the repo, you now need to clone it to your local install where you can then make the +Ok so now that you have forked the repo, you now need to clone it to your local install where you can then make the changes you need and submit them back. ```bash @@ -50,7 +50,7 @@ Now you have two configured remotes: - upstream: This is the main LibreNMS repository and you can only pull changes. #### Workflow guide -As you become more familiar you may find a better workflow that fits your needs, until then this should be a safe +As you become more familiar you may find a better workflow that fits your needs, until then this should be a safe workflow for you to follow. Before you start work on a new branch / feature. Make sure you are upto date. @@ -61,19 +61,19 @@ git pull upstream master git push origin master ``` -Now, create a new branch to do you work on. It's important that you do this as you are then able to work on more than -one feature at a time and submit them as pull requests individually. If you did all your work in the master branch then +Now, create a new branch to do you work on. It's important that you do this as you are then able to work on more than +one feature at a time and submit them as pull requests individually. If you did all your work in the master branch then it gets a bit messy! -Ideally you want to create your new branch name based of the issue number. So firstly create an issue on -[GitHub](https://github.com/librenms/librenms/issues) so that others are aware of the work going on. If the issue number +Ideally you want to create your new branch name based of the issue number. So firstly create an issue on +[GitHub](https://github.com/librenms/librenms/issues) so that others are aware of the work going on. If the issue number you created is 123 then use issue-123 as the branch name. ```bash git checkout -b issue-123 ``` -Now, code away. Make the changes you need, test, change and test again :) When you are ready to submit the updates as a +Now, code away. Make the changes you need, test, change and test again :) When you are ready to submit the updates as a pull request then commit away. ```bash @@ -89,20 +89,20 @@ git push origin issue-123 If after do this you get some merge conflicts then you need to resolve these before carrying on. -Now you will be ready to submit a pull request from within GitHub. To do this, go to your GitHub page for the LibreNMS -repo. Now select the branch you have just been working on (issue-123) from the drop down to the left and then click +Now you will be ready to submit a pull request from within GitHub. To do this, go to your GitHub page for the LibreNMS +repo. Now select the branch you have just been working on (issue-123) from the drop down to the left and then click 'Pull Request'. Fill in the details to describe the work you have done and click 'Create pull request'. -Thanks for your first pull request :) Now, that might have been a simple update, if things get a bit more complicated -then you will need to break down your pull request into separate commits (still a single pull request). This is usually +Thanks for your first pull request :) Now, that might have been a simple update, if things get a bit more complicated +then you will need to break down your pull request into separate commits (still a single pull request). This is usually done when: - You want to add / update MIBS. Do this in a separate commit including the link to where you got them from. - You are adding say 3 related features in one go, try and break them down into 3 separate commits. - Icons for new OS support need to be added as a separate commit including a link to where you got the logo from. -Ok, that should get you started on the contributing path. If you have any other questions then stop by our IRC Channel -on Freenode ##librenms. +Ok, that should get you started on the contributing path. If you have any other questions then stop by our IRC Channel +on Freenode ##librenms. [1]: http://gitready.com [2]: http://git-scm.com/book \ No newline at end of file diff --git a/doc/Extensions/Agent-Setup.md b/doc/Extensions/Agent-Setup.md index f72e64f35..62a9ec473 100644 --- a/doc/Extensions/Agent-Setup.md +++ b/doc/Extensions/Agent-Setup.md @@ -65,7 +65,7 @@ options { ``` Restart your bind9/named after changing the configuration. -Verify that everything works by executing `rndc stats && cat /etc/bind/named.stats`. +Verify that everything works by executing `rndc stats && cat /etc/bind/named.stats`. In case you get a `Permission Denied` error, make sure you chown'ed correctly. Note: if you change the path you will need to change the path in `scripts/agent-local/bind`. @@ -75,26 +75,26 @@ Note: if you change the path you will need to change the path in `scripts/agent- __Installation__: 1. Get tinystats sources from http://www.morettoni.net/tinystats.en.html -2. Compile like as advised. - _Note_: In case you get `Makefile:9: *** missing separator. Stop.`, compile manually using: - * With IPv6: `gcc -Wall -O2 -fstack-protector -DWITH_IPV6 -o tinystats tinystats.c` - * Without IPv6: `gcc -Wall -O2 -fstack-protector -o tinystats tinystats.c` +2. Compile like as advised. + _Note_: In case you get `Makefile:9: *** missing separator. Stop.`, compile manually using: + * With IPv6: `gcc -Wall -O2 -fstack-protector -DWITH_IPV6 -o tinystats tinystats.c` + * Without IPv6: `gcc -Wall -O2 -fstack-protector -o tinystats tinystats.c` 3. Install into preferred path, like `/usr/bin/`. __Configuration__: -_Note_: In this part we assume that you use DJB's [Daemontools](http://cr.yp.to/daemontools.html) to start/stop tinydns. +_Note_: In this part we assume that you use DJB's [Daemontools](http://cr.yp.to/daemontools.html) to start/stop tinydns. And that your tinydns-instance is located in `/service/dns`, adjust this path if necessary. -1. Replace your _log_'s `run` file, typically located in `/service/dns/log/run` with: +1. Replace your _log_'s `run` file, typically located in `/service/dns/log/run` with: ``` #!/bin/sh - + exec setuidgid dnslog tinystats ./main/tinystats/ multilog t n3 s250000 ./main/ ``` -2. Create tinystats directory and chown: +2. Create tinystats directory and chown: `mkdir /service/dns/log/main/tinystats && chown dnslog:nofiles /service/dns/log/main/tinystats` -3. Restart TinyDNS and Daemontools: `/etc/init.d/svscan restart` +3. Restart TinyDNS and Daemontools: `/etc/init.d/svscan restart` _Note_: Some say `svc -t /service/dns` is enough, on my install (Gentoo) it doesn't rehook the logging and I'm forced to restart it entirely. ### MySQL diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 02d1958e9..87a542a7c 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -38,7 +38,7 @@ Table of Content: # About -LibreNMS includes a highly customizable alerting system. +LibreNMS includes a highly customizable alerting system. The system requires a set of user-defined rules to evaluate the situation of each device, port, service or any other entity. > You can configure all options for alerting and transports via the WebUI, config options in this document are crossed out but left for reference. @@ -47,15 +47,15 @@ This document only covers the usage of it. See the [DEVELOPMENT.md](https://gith # Rules -Rules are defined using a logical language. -The GUI provides a simple way of creating basic as well as complex Rules in a self-describing manner. +Rules are defined using a logical language. +The GUI provides a simple way of creating basic as well as complex Rules in a self-describing manner. More complex rules can be written manually. ## Syntax -Rules must consist of at least 3 elements: An __Entity__, a __Condition__ and a __Value__. -Rules can contain braces and __Glues__. -__Entities__ are provided as `%`-Noted pair of Table and Field. For Example: `%ports.ifOperStatus`. +Rules must consist of at least 3 elements: An __Entity__, a __Condition__ and a __Value__. +Rules can contain braces and __Glues__. +__Entities__ are provided as `%`-Noted pair of Table and Field. For Example: `%ports.ifOperStatus`. __Conditions__ can be any of: - Equals `=` @@ -67,10 +67,10 @@ __Conditions__ can be any of: - Smaller `<` - Smaller or Equal `<=` -__Values__ can be Entities or any single-quoted data. +__Values__ can be Entities or any single-quoted data. __Glues__ can be either `&&` for `AND` or `||` for `OR`. -__Note__: The difference between `Equals` and `Matches` (and its negation) is that `Equals` does a strict comparison and `Matches` allows the usage of RegExp. +__Note__: The difference between `Equals` and `Matches` (and its negation) is that `Equals` does a strict comparison and `Matches` allows the usage of RegExp. Arithmetics are allowed as well. ## Examples @@ -90,17 +90,17 @@ Alert when: # Templates -Templates can be assigned to a single or a group of rules. -They can contain any kind of text. -The template-parser understands `if` and `foreach` controls and replaces certain placeholders with information gathered about the alert. +Templates can be assigned to a single or a group of rules. +They can contain any kind of text. +The template-parser understands `if` and `foreach` controls and replaces certain placeholders with information gathered about the alert. ## Syntax Controls: -- if-else (Else can be omitted): +- if-else (Else can be omitted): `{if %placeholder == 'value'}Some Text{else}Other Text{/if}` -- foreach-loop: +- foreach-loop: `{foreach %placeholder}Key: %key
    Value: %value{/foreach}` Placeholders: @@ -123,7 +123,7 @@ Templates can be matched against several rules. ## Examples -Default Template: +Default Template: ```text %title\r\n Severity: %severity\r\n @@ -138,13 +138,13 @@ Alert sent to: {foreach %contacts}%value <%key> {/foreach} # Transports -Transports are located within `$config['install_dir']/includes/alerts/transports.*.php` and defined as well as configured via ~~`$config['alert']['transports']['Example'] = 'Some Options'`~~. +Transports are located within `$config['install_dir']/includes/alerts/transports.*.php` and defined as well as configured via ~~`$config['alert']['transports']['Example'] = 'Some Options'`~~. -Contacts will be gathered automatically and passed to the configured transports. +Contacts will be gathered automatically and passed to the configured transports. By default the Contacts will be only gathered when the alert triggers and will ignore future changes in contacts for the incident. If you want contacts to be re-gathered before each dispatch, please set ~~`$config['alert']['fixed-contacts'] = false;`~~ in your config.php. -The contacts will always include the `SysContact` defined in the Device's SNMP configuration and also every LibreNMS-User that has at least `read`-permissions on the entity that is to be alerted. -At the moment LibreNMS only supports Port or Device permissions. +The contacts will always include the `SysContact` defined in the Device's SNMP configuration and also every LibreNMS-User that has at least `read`-permissions on the entity that is to be alerted. +At the moment LibreNMS only supports Port or Device permissions. You can exclude the `SysContact` by setting: ~~ ```php @@ -170,7 +170,7 @@ $config['alert']['transports']['mail'] = true; ``` ~~ -The E-Mail transports uses the same email-configuration like the rest of LibreNMS. +The E-Mail transports uses the same email-configuration like the rest of LibreNMS. As a small reminder, here is it's configuration directives including defaults: ~~ ```php @@ -195,13 +195,13 @@ $config['alert']['default_mail'] = ''; //Default ema > You can configure these options within the WebUI now, please avoid setting these options within config.php -API transports definitions are a bit more complex than the E-Mail configuration. -The basis for configuration is ~~`$config['alert']['transports']['api'][METHOD]`~~ where `METHOD` can be `get`,`post` or `put`. -This basis has to contain an array with URLs of each API to call. -The URL can have the same placeholders as defined in the [Template-Syntax](#templates-syntax). -If the `METHOD` is `get`, all placeholders will be URL-Encoded. -The API transport uses cURL to call the APIs, therefore you might need to install `php5-curl` or similar in order to make it work. -__Note__: it is highly recommended to define own [Templates](#templates) when you want to use the API transport. The default template might exceed URL-length for GET requests and therefore cause all sorts of errors. +API transports definitions are a bit more complex than the E-Mail configuration. +The basis for configuration is ~~`$config['alert']['transports']['api'][METHOD]`~~ where `METHOD` can be `get`,`post` or `put`. +This basis has to contain an array with URLs of each API to call. +The URL can have the same placeholders as defined in the [Template-Syntax](#templates-syntax). +If the `METHOD` is `get`, all placeholders will be URL-Encoded. +The API transport uses cURL to call the APIs, therefore you might need to install `php5-curl` or similar in order to make it work. +__Note__: it is highly recommended to define own [Templates](#templates) when you want to use the API transport. The default template might exceed URL-length for GET requests and therefore cause all sorts of errors. Example: ~~ @@ -214,7 +214,7 @@ $config['alert']['transports']['api']['get'][] = "https://api.thirdparti.es/issu > You can configure these options within the WebUI now, please avoid setting these options within config.php -The nagios transport will feed a FIFO at the defined location with the same format that nagios would. +The nagios transport will feed a FIFO at the defined location with the same format that nagios would. This allows you to use other Alerting-Systems to work with LibreNMS, for example [Flapjack](http://flapjack.io). ~~ ```php @@ -226,7 +226,7 @@ $config['alert']['transports']['nagios'] = "/path/to/my.fifo"; //Flapjack expect > You can configure these options within the WebUI now, please avoid setting these options within config.php -The IRC transports only works together with the LibreNMS IRC-Bot. +The IRC transports only works together with the LibreNMS IRC-Bot. Configuration of the LibreNMS IRC-Bot is described [here](https://github.com/librenms/librenms/blob/master/doc/Extensions/IRC-Bot.md). ~~ ```php @@ -349,7 +349,7 @@ $config['alert']['transports']['pushover'][] = array( ## Boxcar -Enabling Boxcar support is super easy. +Enabling Boxcar support is super easy. Copy your access token from the Boxcar app or from the Boxcar.io website and setup the transport in your config.php like: ~~ @@ -384,7 +384,7 @@ $config['alert']['transports']['pushbullet'] = 'MYFANCYACCESSTOKEN'; ## Clickatell -Clickatell provides a REST-API requiring an Authorization-Token and at least one Cellphone number. +Clickatell provides a REST-API requiring an Authorization-Token and at least one Cellphone number. Please consult Clickatell's documentation regarding number formatting. Here an example using 3 numbers, any amount of numbers is supported: @@ -399,8 +399,8 @@ $config['alert']['transports']['clickatell']['to'][] = '+1234567892'; ## PlaySMS -PlaySMS is an OpenSource SMS-Gateway that can be used via their HTTP-API using a Username and WebService-Token. -Please consult PlaySMS's documentation regarding number formating. +PlaySMS is an OpenSource SMS-Gateway that can be used via their HTTP-API using a Username and WebService-Token. +Please consult PlaySMS's documentation regarding number formating. Here an example using 3 numbers, any amount of numbers is supported: ~~ diff --git a/doc/Extensions/Authentication.md b/doc/Extensions/Authentication.md index 2f0a0eccc..d84145db6 100644 --- a/doc/Extensions/Authentication.md +++ b/doc/Extensions/Authentication.md @@ -1,6 +1,6 @@ # Authentication modules -LibreNMS supports multiple authentication modules along with [Two Factor Auth](http://docs.librenms.org/Extensions/Two-Factor-Auth/). +LibreNMS supports multiple authentication modules along with [Two Factor Auth](http://docs.librenms.org/Extensions/Two-Factor-Auth/). Here we will provide configuration details for these modules. #### Available authentication modules @@ -50,9 +50,9 @@ $config['db_name'] = "DBNAME"; Config option: `http-auth` -LibreNMS will expect the user to have authenticated via your webservice already. At this stage it will need to assign a +LibreNMS will expect the user to have authenticated via your webservice already. At this stage it will need to assign a userlevel for that user which is done in one of two ways: - + - A user exists in MySQL still where the usernames match up. - A global guest user (which still needs to be added into MySQL: @@ -132,7 +132,7 @@ If you have issues with secure LDAP try setting `$config['auth_ad_check_certific ##### Require actual membership of the configured groups -If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authenticated user has to be a member of the specific group. Otherwise all users can authenticate, but are limited to user level 0 and only have access to shared dashboards. +If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authenticated user has to be a member of the specific group. Otherwise all users can authenticate, but are limited to user level 0 and only have access to shared dashboards. > Cleanup of old accounts is done using the authlog. You will need to set the cleanup date for when old accounts will be purged which will happen AUTOMATICALLY. > Please ensure that you set the $config['authlog_purge'] value to be greater than $config['active_directory]['users_purge'] otherwise old users won't be removed. @@ -163,5 +163,5 @@ $config['radius']['port'] = '1812'; $config['radius']['secret'] = 'testing123'; $config['radius']['timeout'] = 3; $config['radius']['users_purge'] = 14;//Purge users who haven't logged in for 14 days. -$config['radius']['default_level'] = 1;//Set the default user level when automatically creating a user. +$config['radius']['default_level'] = 1;//Set the default user level when automatically creating a user. ``` diff --git a/doc/Extensions/Component.md b/doc/Extensions/Component.md index 235335380..40331981d 100644 --- a/doc/Extensions/Component.md +++ b/doc/Extensions/Component.md @@ -118,7 +118,7 @@ $ARRAY = $COMPONENT->getComponents($DEVICE_ID,$OPTIONS); [status] => 0 [ignore] => 1 [disabled] => 1 - [error] => + [error] => ), [Y2] => Array ( @@ -129,7 +129,7 @@ $ARRAY = $COMPONENT->getComponents($DEVICE_ID,$OPTIONS); [status] => 0 [ignore] => 1 [disabled] => 0 - [error] => + [error] => ), ) ) @@ -155,7 +155,7 @@ Where: There are 2 filtering shortcuts: - + $DEVICE_ID is a synonym for: ```php @@ -201,11 +201,11 @@ This will return a new, empty array with a component ID and Type set, all other [1] => Array ( [type] => TESTING - [label] => + [label] => [status] => 1 [ignore] => 0 [disabled] => 0 - [error] => + [error] => ) ) diff --git a/doc/Extensions/Device-Groups.md b/doc/Extensions/Device-Groups.md index c38db06a8..f7207b195 100644 --- a/doc/Extensions/Device-Groups.md +++ b/doc/Extensions/Device-Groups.md @@ -4,10 +4,10 @@ LibreNMS supports grouping your devices together in much the same way as you can ### Pattern -Patterns work in the same was as Entities within the alerting system, the format of the pattern is based on the MySQL structure your data is in such +Patterns work in the same was as Entities within the alerting system, the format of the pattern is based on the MySQL structure your data is in such as __tablename.columnname__. If you are ensure of what the entity is you want then have a browse around inside MySQL using `show tables` and `desc `. -As a working example and a common question, let's assume you want to group devices by hostname. If you hostname format is dcX.[devicetype].example.com. You would use the pattern +As a working example and a common question, let's assume you want to group devices by hostname. If you hostname format is dcX.[devicetype].example.com. You would use the pattern devices.hostname. Select the condition which in this case would Like and then enter `dc1\..*\.example.com`. This would then match dc1.sw01.example.com, dc1.rtr01.example.com but not dc2.sw01.example.com. @@ -23,8 +23,8 @@ Please see our [Alerting docs](http://docs.librenms.org/Extensions/Alerting/#syn ### Connection -If you only want to group based on one pattern then select And. If however you want to build a group based on multiple patterns then you can build a SQL like +If you only want to group based on one pattern then select And. If however you want to build a group based on multiple patterns then you can build a SQL like query using And / Or. As an example, we want to base our group on the devices hostname AND it's type. Use the pattern as before, devices.hostname, select the condition which in this case would Like and then enter dc1.@.example.com then click And. Now enter devices.type in the pattern, select Equals and enter firewall. This would then match dc1.fw01.example.com but not dc1.sw01.example.com as that is a network type. -You can now select this group from the Devices -> All Devices link in the navigation at the top. You can also use the group to map alert rules to by creating an alert mapping +You can now select this group from the Devices -> All Devices link in the navigation at the top. You can also use the group to map alert rules to by creating an alert mapping Overview -> Alerts -> Rule Mapping. diff --git a/doc/Extensions/Distributed-Poller.md b/doc/Extensions/Distributed-Poller.md index ee706a8b7..97b9cb253 100644 --- a/doc/Extensions/Distributed-Poller.md +++ b/doc/Extensions/Distributed-Poller.md @@ -7,13 +7,13 @@ Devices can also be groupped together into a `poller_group` to pin these devices ~~All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached.~~ -> This is no longer a strict requirement with the use of rrdtool 1.5 and above. If you are NOT running 1.5 then you will still +> This is no longer a strict requirement with the use of rrdtool 1.5 and above. If you are NOT running 1.5 then you will still need to share the RRD-folder. It is also required that all pollers can access the central memcached to communicate with eachother. -In order to enable distributed polling, set `$config['distributed_poller'] = true` and your memcached details into `$config['distributed_poller_memcached_host']` and `$config['distributed_poller_memcached_port']`. -By default, all hosts are shared and have the `poller_group = 0`. To pin a device to a poller, set it to a value greater than 0 and set the same value in the poller's config with `$config['distributed_poller_group']`. +In order to enable distributed polling, set `$config['distributed_poller'] = true` and your memcached details into `$config['distributed_poller_memcached_host']` and `$config['distributed_poller_memcached_port']`. +By default, all hosts are shared and have the `poller_group = 0`. To pin a device to a poller, set it to a value greater than 0 and set the same value in the poller's config with `$config['distributed_poller_group']`. Usually the poller's name is equal to the machine's hostname, if you want to change it set `$config['distributed_poller_name']`. One can also specify a comma seperated string of poller groups in $config['distributed_poller_group']. The poller will then poll devices from any of the groups listed. If new devices get added from the poller they will be assigned to the first poller group in the list unless the group is specified when adding the device. @@ -55,7 +55,7 @@ Central storage should be provided so all RRD files can be read from and written For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles ~~with the rrd directory also exported by NFS for simple access and maintenance.~~ -Sharing rrd files via something like NFS is no longer required if you run rrdtool 1.5 or greater. If you don't - please share your rrd folder as before. If you run rrdtool +Sharing rrd files via something like NFS is no longer required if you run rrdtool 1.5 or greater. If you don't - please share your rrd folder as before. If you run rrdtool 1.5 or greater then add this config to your pollers: ```php diff --git a/doc/Extensions/Globe-Frontpage.md b/doc/Extensions/Globe-Frontpage.md index adac26f45..6e2d31662 100644 --- a/doc/Extensions/Globe-Frontpage.md +++ b/doc/Extensions/Globe-Frontpage.md @@ -31,7 +31,7 @@ $config['leaflet']['default_zoom'] = 8; ### Jquery-Mapael config -Further custom options are available to load different maps of the world, set default coordinates of where the map will zoom and the zoom level by default. An example of +Further custom options are available to load different maps of the world, set default coordinates of where the map will zoom and the zoom level by default. An example of this is: ```php diff --git a/doc/Extensions/Graylog.md b/doc/Extensions/Graylog.md index 7dd6654ce..1c0da5501 100644 --- a/doc/Extensions/Graylog.md +++ b/doc/Extensions/Graylog.md @@ -1,10 +1,10 @@ # Graylog integration -We have simple integration for Graylog, you will be able to view any logs from within LibreNMS that have been parsed by the syslog input from within -Graylog itself. This includes logs from devices which aren't in LibreNMS still, you can also see logs for a specific device under the logs section +We have simple integration for Graylog, you will be able to view any logs from within LibreNMS that have been parsed by the syslog input from within +Graylog itself. This includes logs from devices which aren't in LibreNMS still, you can also see logs for a specific device under the logs section for the device. -Graylog itself isn't included within LibreNMS, you will need to install this separately either on the same infrastructure as LibreNMS or as a totally +Graylog itself isn't included within LibreNMS, you will need to install this separately either on the same infrastructure as LibreNMS or as a totally standalone appliance. Config is simple, here's an example: diff --git a/doc/Extensions/IRC-Bot-Extensions.md b/doc/Extensions/IRC-Bot-Extensions.md index 0debac380..71f6d1180 100644 --- a/doc/Extensions/IRC-Bot-Extensions.md +++ b/doc/Extensions/IRC-Bot-Extensions.md @@ -41,7 +41,7 @@ Function( (Type) $Variable [= Default] [,...] ) | Returns | Description ### Attributes Attribute | Type | Description ---- | --- | --- +--- | --- | --- `$params` | `String` | Contains all arguments that are passed to the `.command`. `$this->chan` | `Array` | Channels that are configured. `$this->commands` | `Array` | Contains accessible `commands`. diff --git a/doc/Extensions/InfluxDB.md b/doc/Extensions/InfluxDB.md index e96d3393b..d24b441f3 100644 --- a/doc/Extensions/InfluxDB.md +++ b/doc/Extensions/InfluxDB.md @@ -1,15 +1,15 @@ # Enabling support for InfluxDB. -Before we get started it is important that you know and understand that InfluxDB support is currently alpha at best. -All it provides is the sending of data to a InfluxDB install. Due to the current changes that are constantly being -made to InfluxDB itself then we cannot guarantee that your data will be ok so enabling this support is at your own +Before we get started it is important that you know and understand that InfluxDB support is currently alpha at best. +All it provides is the sending of data to a InfluxDB install. Due to the current changes that are constantly being +made to InfluxDB itself then we cannot guarantee that your data will be ok so enabling this support is at your own risk! ### Requirements - InfluxDB 0.94 - Grafana -The setup of the above is completely out of scope here and we aren't really able to provide any help with this side +The setup of the above is completely out of scope here and we aren't really able to provide any help with this side of things. ### What you don't get @@ -31,5 +31,5 @@ $config['influxdb']['password'] = 'admin'; UDP is a supported transport and no credentials are needed if you don't use InfluxDB authentication. -The same data then stored within rrd will be sent to InfluxDB and recorded. You can then create graphs within Grafana +The same data then stored within rrd will be sent to InfluxDB and recorded. You can then create graphs within Grafana to display the information you need. diff --git a/doc/Extensions/Network-Map.md b/doc/Extensions/Network-Map.md index 63a74352c..c0e580ae5 100644 --- a/doc/Extensions/Network-Map.md +++ b/doc/Extensions/Network-Map.md @@ -13,10 +13,10 @@ $config['network_map_items'] = array('mac','xdp'); Either remove mac or xdp depending on which you want. -A global map will be drawn from the information in the database, it is worth noting that this could lead to a large network map. +A global map will be drawn from the information in the database, it is worth noting that this could lead to a large network map. Network maps for individual devices are available showing the relationship with other devices. -One can also specicify the parameters to be used for drawing and updating the network map. +One can also specicify the parameters to be used for drawing and updating the network map. Please see http://visjs.org/docs/network/ for details on the configuration parameters. ```php $config['network_map_vis_options'] = '{ diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index 23153780b..e74bf5c3c 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -4,7 +4,7 @@ You can integrate LibreNMS with [Oxidized](https://github.com/ytti/oxidized-web) ### Config viewing -This is a straight forward use of Oxidized, it relies on you having a working Oxidized setup which is already taking config snapshots for your devices. +This is a straight forward use of Oxidized, it relies on you having a working Oxidized setup which is already taking config snapshots for your devices. When you have that, you only need the following config to enable the display of device configs within the device page itself: ```php diff --git a/doc/Extensions/Port-Description-Parser.md b/doc/Extensions/Port-Description-Parser.md index ccdf8740d..f07a2878e 100644 --- a/doc/Extensions/Port-Description-Parser.md +++ b/doc/Extensions/Port-Description-Parser.md @@ -9,7 +9,7 @@ The following information is used from interface descriptions: - Notes - Speed -When setting the description, you use the type followed directly with : and then the information on that port. Some examples based on +When setting the description, you use the type followed directly with : and then the information on that port. Some examples based on configuring a Cisco 2960 interface #### Customer port diff --git a/doc/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index 4728686fe..f6059234e 100644 --- a/doc/Extensions/RRDCached.md +++ b/doc/Extensions/RRDCached.md @@ -2,7 +2,7 @@ This document will explain how to setup RRDCached for LibreNMS. -> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To +> If you are using rrdtool / rrdcached version 1.5 or above then this now supports creating rrd files over rrdcached. To enable this set the following config: ```php @@ -21,7 +21,7 @@ vi /etc/yum.repos.d/rpmforge.repo ```ssh yum update rrdtool -vi /etc/yum.repos.d/rpmforge.repo +vi /etc/yum.repos.d/rpmforge.repo ``` - Disable the [rpmforge] and [rpmforge-extras] repos again diff --git a/doc/Extensions/RRDTune.md b/doc/Extensions/RRDTune.md index 7ee7095d2..c7a961ffc 100644 --- a/doc/Extensions/RRDTune.md +++ b/doc/Extensions/RRDTune.md @@ -1,6 +1,6 @@ # RRDTune? -When we create rrd files for ports, we currently do so with a max value of 12500000000 (100G). Because of this if a device sends us bad data back then it can appear as though +When we create rrd files for ports, we currently do so with a max value of 12500000000 (100G). Because of this if a device sends us bad data back then it can appear as though a 100M port is doing 40G+ which is impossible. To counter this you can enable the rrdtool tune option which will fix the max value to the interfaces physical speed (minimum of 10M). To enable this you can do so in three ways! @@ -9,7 +9,7 @@ To enable this you can do so in three ways! - For the actual device, Edit Device -> Misc - For each port, Edit Device -> Port Settings -Now when a port interface speed changes (this can happen because of a physical change or just because the device has mis-reported) the max value is set. If you don't want to wait until +Now when a port interface speed changes (this can happen because of a physical change or just because the device has mis-reported) the max value is set. If you don't want to wait until a port speed changes then you can run the included script: script/tune_port.php -h -p diff --git a/doc/Extensions/Services.md b/doc/Extensions/Services.md index dba098588..fe2608552 100644 --- a/doc/Extensions/Services.md +++ b/doc/Extensions/Services.md @@ -2,7 +2,7 @@ Services within LibreNMS provides the ability to use Nagios plugins to perform additional monitoring outside of SNMP. -These services are tied into an existing device so you need at least one device that supports SNMP to be able to add it +These services are tied into an existing device so you need at least one device that supports SNMP to be able to add it to LibreNMS - localhost is a good one. ## Setup @@ -29,7 +29,7 @@ Finally, you now need to add check-services.php to the current cron file (/etc/c Now you can add services via the main Services link in the navbar, or via the Services link within the device page. -> **Please note that at present the service checks will only return the status and the response from the check +> **Please note that at present the service checks will only return the status and the response from the check no graphs will be generated. ** ## Supported checks diff --git a/doc/Extensions/Smokeping.md b/doc/Extensions/Smokeping.md index c04436eb7..92c4e6078 100644 --- a/doc/Extensions/Smokeping.md +++ b/doc/Extensions/Smokeping.md @@ -1,6 +1,6 @@ # Smokeping integration -We currently have two ways to use Smokeping with LibreNMS, the first is using the included script generator to generate the config for Smokeping. The +We currently have two ways to use Smokeping with LibreNMS, the first is using the included script generator to generate the config for Smokeping. The second is to utilise an existing Smokeping setup. ### Included Smokeping script @@ -11,7 +11,7 @@ To use this, please add something similar to your smokeping config file: @include /opt/smokeping/etc/librenms.conf ``` -Then you need to generate the config file (maybe even add a cron to schedule this in and reload smokeping). We've assumed a few locations for smokeping, the config file you want +Then you need to generate the config file (maybe even add a cron to schedule this in and reload smokeping). We've assumed a few locations for smokeping, the config file you want to call it and where LibreNMS is: ```bash diff --git a/doc/Extensions/Sub-Directory.md b/doc/Extensions/Sub-Directory.md index 11a74d67c..a5a99a4b8 100644 --- a/doc/Extensions/Sub-Directory.md +++ b/doc/Extensions/Sub-Directory.md @@ -1,6 +1,6 @@ -To run LibreNMS under a subdirectory on your Apache server, the directives for the LibreNMS directory are placed in the base server configuration, or in a virtual host -container of your choosing. If using a virtual host, place the directives in the file where the virtual host is configured. If using the base server on RHEL distributions -(CentOS, Scientific Linux, etc.) the directives can be placed in `/etc/httpd/conf.d/librenms.conf`. For Debian distributions (Ubuntu, etc.) place the directives in +To run LibreNMS under a subdirectory on your Apache server, the directives for the LibreNMS directory are placed in the base server configuration, or in a virtual host +container of your choosing. If using a virtual host, place the directives in the file where the virtual host is configured. If using the base server on RHEL distributions +(CentOS, Scientific Linux, etc.) the directives can be placed in `/etc/httpd/conf.d/librenms.conf`. For Debian distributions (Ubuntu, etc.) place the directives in `/etc/apache2/sites-available/default`. ```apache @@ -14,7 +14,7 @@ Alias /librenms /opt/librenms/html ``` -The `RewriteBase` directive in `html/.htaccess` must be rewritten to reference the subdirectory name. Assuming LibreNMS is running at http://example.com/librenms/, +The `RewriteBase` directive in `html/.htaccess` must be rewritten to reference the subdirectory name. Assuming LibreNMS is running at http://example.com/librenms/, you will need to change `RewriteBase /` to `RewriteBase /librenms`. Finally, ensure `$config["base_url"]` -- if configured -- is correct as well. diff --git a/doc/Extensions/Syslog.md b/doc/Extensions/Syslog.md index b34f9405a..cb0ef8a0b 100644 --- a/doc/Extensions/Syslog.md +++ b/doc/Extensions/Syslog.md @@ -33,7 +33,7 @@ options { stats_freq(0); bad_hostname("^gconfd$"); }; - + ######################## # Sources ######################## @@ -41,19 +41,19 @@ source s_sys { system(); internal(); }; - + source s_net { tcp(port(514) flags(syslog-protocol)); udp(port(514) flags(syslog-protocol)); }; - + ######################## # Destinations ######################## destination d_librenms { program("/opt/librenms/syslog.php" template ("$HOST||$FACILITY||$PRIORITY||$LEVEL||$TAG||$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC||$MSG||$PROGRAM\n") template-escape(yes)); }; - + ######################## # Log paths ######################## @@ -62,7 +62,7 @@ log { source(s_sys); destination(d_librenms); }; - + ### # Include all config files in /etc/syslog-ng/conf.d/ ### diff --git a/doc/Extensions/Two-Factor-Auth.md b/doc/Extensions/Two-Factor-Auth.md index 0b9c7513a..1ee4a9b20 100644 --- a/doc/Extensions/Two-Factor-Auth.md +++ b/doc/Extensions/Two-Factor-Auth.md @@ -9,32 +9,32 @@ Table of Content: # About -Over the last couple of years, the primary attack vector for internet accounts has been static passwords. -Therefore static passwords are no longer sufficient to protect unauthorized access to accounts. -Two Factor Authentication adds a variable part in authentication procedures. +Over the last couple of years, the primary attack vector for internet accounts has been static passwords. +Therefore static passwords are no longer sufficient to protect unauthorized access to accounts. +Two Factor Authentication adds a variable part in authentication procedures. A user is now required to supply a changing 6-digit passcode in addition to it's password to obtain access to the account. -LibreNMS has a RFC4226 conform implementation of both Time and Counter based One-Time-Passwords. +LibreNMS has a RFC4226 conform implementation of both Time and Counter based One-Time-Passwords. It also allows the administrator to configure a throttle time to enforce after 3 failures exceeded. Unlike RFC4226 suggestions, this throttle time will not stack on the amount of failures. # Types -In general, these two types do not differ in algorithmic terms. -The types only differ in the variable being used to derive the passcodes from. +In general, these two types do not differ in algorithmic terms. +The types only differ in the variable being used to derive the passcodes from. The underlying HMAC-SHA1 remains the same for both types, security advantages or disadvantages of each are discussed further down. ## Timebased One-Time-Password (TOTP) -Like the name suggests, this type uses the current Time or a subset of it to generate the passcodes. -These passcodes solely rely on the secrecy of their Secretkey in order to provide passcodes. -An attacker only needs to guess that Secretkey and the other variable part is any given time, presumably the time upon login. +Like the name suggests, this type uses the current Time or a subset of it to generate the passcodes. +These passcodes solely rely on the secrecy of their Secretkey in order to provide passcodes. +An attacker only needs to guess that Secretkey and the other variable part is any given time, presumably the time upon login. RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of upto +/- 3 Minutes to create passcodes. ## Counterbased One-Time-Password (TOTP) -This type uses an internal counter that needs to be in sync with the server's counter to successfully authenticate the passcodes. -The main advantage over timebased OTP is the attacker doesn't only need to know the Secretkey but also the server's Counter in order to create valid passcodes. +This type uses an internal counter that needs to be in sync with the server's counter to successfully authenticate the passcodes. +The main advantage over timebased OTP is the attacker doesn't only need to know the Secretkey but also the server's Counter in order to create valid passcodes. RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of upto +4 increments from the actual counter to create passcodes. # Configuration diff --git a/doc/Extensions/Varnish.md b/doc/Extensions/Varnish.md index 98fda2adf..78cced5a9 100644 --- a/doc/Extensions/Varnish.md +++ b/doc/Extensions/Varnish.md @@ -11,7 +11,7 @@ Varnish is caching software that sits logically between an HTTP client and an HT ### CentOS 7 Varnish Installation ### -In this example we will assume your Apache 2.4.X HTTP server is working and +In this example we will assume your Apache 2.4.X HTTP server is working and configured to process HTTP requests on port 80. If not, please see [Using HTTPd Apache2](http://librenms.readthedocs.org/Installation/Installation-(RHEL-CentOS)/#using-httpd-apache2) @@ -30,7 +30,7 @@ By default Varnish listens for HTTP requests on port 6081. - Temporarily add a firewalld rule for testing Varnish. ```bash -firewall-cmd --zone=public --add-port=6081/tcp +firewall-cmd --zone=public --add-port=6081/tcp ``` #### Test Varnish #### @@ -127,16 +127,16 @@ Edit librenms.conf and modify the Apache Virtual Host listening port. - Modify:`` to: `` ```bash -vim /etc/httpd/conf.d/librenms.conf +vim /etc/httpd/conf.d/librenms.conf ``` Varnish can not share a port with Apache. Change the Apache listening port to 8080. - Modify:`Listen 80` to:`Listen 8080` -```bash +```bash vim /etc/httpd/conf/httpd.conf ``` - + - Create the librenms.vcl ```bash cd /etc/varnish @@ -205,7 +205,7 @@ sub vcl_backend_response { # 'sub vcl_backend_response' is the same function as 'sub vcl_fetch' in Varnish 3, however, # the syntax is slightly different # This function happens after we read the response headers from the backend (Apache). - # First function 'if (bereq.url ~ "\' removes cookies from the Apache HTTP responses + # First function 'if (bereq.url ~ "\' removes cookies from the Apache HTTP responses # that match the file extensions that are between the quotes, and cache the files for 24 hours. # This assumes you update LibreNMS once a day, otherwise restart Varnish to clear cache. # Second function 'if (bereq.url ~ "^/' removes the Pragma no-cache statements and sets the age diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index 67d4e2bf0..60a0cbfb0 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -623,7 +623,7 @@ - Enable alerting on tables with relative / indirect glues (PR932) - Added bills support in rulesuggest and alert system (PR934) - Added detection for Sentry Smart CDU (PR938) - - Added basic detection for Netgear devices (PR942) + - Added basic detection for Netgear devices (PR942) - addhost.php now uses distributed_poller_group config if set (PR944) - Added port rewrite function (PR946) - Added basic detection for Ubiquiti Edgeswitch (PR947) @@ -921,7 +921,7 @@ - Fixed layout issue for ports list (PR286) - Removed session regeneration (PR287) - Updated edit button on edit user screen (PR288) - + ####Improvements - Added email field for add user form (PR278) - V0 of API release (PR282) @@ -1043,7 +1043,7 @@ ###Nov 2013 ####Bug fixes - - Updates to fix arp discovery + - Updates to fix arp discovery ####Improvements - Added poller-wrapper (f8debf4) diff --git a/doc/General/Contributing.md b/doc/General/Contributing.md index 31d7b0bc1..09353800c 100644 --- a/doc/General/Contributing.md +++ b/doc/General/Contributing.md @@ -170,7 +170,7 @@ project. Proposed workflow for submitting pull requests ---------------------------------------------- -Please see the new [Using Git](http://docs.librenms.org/Developing/Using-Git/) document which gives you step-by-step +Please see the new [Using Git](http://docs.librenms.org/Developing/Using-Git/) document which gives you step-by-step instructions on using git to submit a pull request. [1]: http://www.gnu.org/licenses/license-list.html diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index b899aa242..493b8a746 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -153,8 +153,8 @@ Next, add the following to `/etc/httpd/conf.d/librenms.conf` ``` -__Notes:__ -If you are running Apache 2.2.18 or higher then change `AllowEncodedSlashes` to `NoDecode` and append `Require all granted` underneath `Options FollowSymLinks MultiViews`. +__Notes:__ +If you are running Apache 2.2.18 or higher then change `AllowEncodedSlashes` to `NoDecode` and append `Require all granted` underneath `Options FollowSymLinks MultiViews`. If the file `/etc/httpd/conf.d/welcome.conf` exists, you might want to remove that as well unless you're familiar with [Name-based Virtual Hosts](https://httpd.apache.org/docs/2.2/vhosts/name-based.html) ### Using Nginx and PHP-FPM ### diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 15be9ed6c..4197a3c26 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -60,7 +60,7 @@ $config['fping_options']['millisec'] = 200; * `millisec` (`fping` parameter `-p`): Time in milliseconds that fping waits between successive packets to an individual target. You can disable the fping / icmp check that is done for a device to be determined to be up on a global or per device basis. -**We don't advice disabling the fping / icmp check unless you know the impact, at worst if you have a large number of devices down +**We don't advice disabling the fping / icmp check unless you know the impact, at worst if you have a large number of devices down then it's possible that the poller would no longer complete in 5 minutes due to waiting for snmp to timeout.** Globally disable fping / icmp check: @@ -107,7 +107,7 @@ $config['rrdcached'] = "unix:/var/run/rrdcached.sock"; // or a tcp connection $config['rrdcached_dir'] = FALSE; ``` To enable rrdcached you need to set at least the `rrdcached` option. If `rrdcached` is a tcp socket then you need to configure `rrdcached_dir` as well. -This should be set based on your base directory for running rrdcached. For instance if -b for rrdcached is set to /var/lib/rrd but you are expecting +This should be set based on your base directory for running rrdcached. For instance if -b for rrdcached is set to /var/lib/rrd but you are expecting LibreNMS to store them in /var/lib/rrd/librenms then you would need to set `rrdcached_dir` to librenms. #### WebUI Settings @@ -141,7 +141,7 @@ $config['vertical_summary'] = 0; // Enable to use vertical summary on front page $config['top_ports'] = 1; // This enables the top X ports box $config['top_devices'] = 1; // This enables the top X devices box ``` -A number of home pages are provided within the install and can be found in html/pages/front/. You can change the default by +A number of home pages are provided within the install and can be found in html/pages/front/. You can change the default by setting `front_page`. The other options are used to alter the look of those pages that support it (default.php supports these options). ```php @@ -289,7 +289,7 @@ $config['email_smtp_auth'] = FALSE; $config['email_smtp_username'] = NULL; $config['email_smtp_password'] = NULL; ``` -What type of mail transport to use for delivering emails. Valid options for `email_backend` are mail, sendmail or smtp. +What type of mail transport to use for delivering emails. Valid options for `email_backend` are mail, sendmail or smtp. The varying options after that are to support the different transports. #### Alerting @@ -333,14 +333,14 @@ Enable / disable additional port statistics. $config['rancid_configs'][] = '/var/lib/rancid/network/configs/'; $config['rancid_ignorecomments'] = 0; ``` -Rancid configuration, `rancid_configs` is an array containing all of the locations of your rancid files. +Rancid configuration, `rancid_configs` is an array containing all of the locations of your rancid files. Setting `rancid_ignorecomments` will disable showing lines that start with # ```php $config['oxidized']['enabled'] = FALSE; $config['oxidized']['url'] = 'http://127.0.0.1:8888'; ``` -To enable Oxidized support set enabled to `TRUE`. URL needs to be configured to point to the REST API for Oxidized. This +To enable Oxidized support set enabled to `TRUE`. URL needs to be configured to point to the REST API for Oxidized. This is then used to retrieve the config for devices. @@ -390,7 +390,7 @@ The above is an example, this will rewrite basic snmp locations so you don't nee $config['bad_if'][] = "voip-null"; $config['bad_iftype'][] = "voiceEncap"; ``` -Numerous defaults exist for this array already (see includes/defaults.inc.php for the full list). You can expand this list +Numerous defaults exist for this array already (see includes/defaults.inc.php for the full list). You can expand this list by continuing the array. `bad_if` is matched against the ifDescr value. `bad_iftype` is matched against the ifType value. @@ -446,8 +446,8 @@ Please see [IRC Bot](http://docs.librenms.org/Extensions/IRC-Bot/) section of th ```php $config['auth_mechanism'] = "mysql"; ``` -This is the authentication type to use for the WebUI. MySQL is the default and configured when following the installation -instructions. ldap and http-auth are also valid options. For instructions on the different authentication modules please +This is the authentication type to use for the WebUI. MySQL is the default and configured when following the installation +instructions. ldap and http-auth are also valid options. For instructions on the different authentication modules please see [Authentication](http://docs.librenms.org/Extensions/Authentication/). ```php @@ -459,7 +459,7 @@ If the user selects to be remembered on the login page, how long in days do we r $config['allow_unauth_graphs'] = 0; $config['allow_unauth_graphs_cidr'] = array(); ``` -This option will enable unauthenticated access to the graphs from `allow_unauth_graphs_cidr` ranges that you allow. Use +This option will enable unauthenticated access to the graphs from `allow_unauth_graphs_cidr` ranges that you allow. Use of this option is highly discouraged in favour of the [API](http://docs.librenms.org/API/API-Docs/) that is now available. #### Cleanup options @@ -473,7 +473,7 @@ $config['authlog_purge'] = 30; $config['perf_times_purge'] = 30; $config['device_perf_purge'] = 30; ``` -This option will ensure data within LibreNMS over 1 month old is automatically purged. You can alter these individually, +This option will ensure data within LibreNMS over 1 month old is automatically purged. You can alter these individually, values are in days. #### Syslog options @@ -504,7 +504,7 @@ to indicate how you connect to libvirt. You also need to: To test your setup, run `virsh -c qemu+ssh://vmhost/system list` or `virsh -c xen+ssh://vmhost list` as your librenms polling user. - + #### BGP Support ```php diff --git a/doc/Support/Discovery Support.md b/doc/Support/Discovery Support.md index d08a663aa..acba7527d 100644 --- a/doc/Support/Discovery Support.md +++ b/doc/Support/Discovery Support.md @@ -9,30 +9,30 @@ This document will explain how to use discovery.php to debug issues or manually -h even Poll even numbered devices (same as -i 2 -n 1) -h all Poll all devices -h new Poll all devices that have not had a discovery run before - + -i -n Poll as instance of Instances start at 0. 0-3 for -n 4 - - + + Debugging and testing options: -d Enable debugging output -m Specify single module to be run ``` -`-h` Use this to specify a device via either id or hostname (including wildcard using *). You can also specify odd and -even. all will run discovery against all devices whilst +`-h` Use this to specify a device via either id or hostname (including wildcard using *). You can also specify odd and +even. all will run discovery against all devices whilst new will poll only those devices that have recently been added or have been selected for rediscovery. `-i` This can be used to stagger the discovery process. -`-d` Enables debugging output (verbose output) so that you can see what is happening during a discovery run. This includes +`-d` Enables debugging output (verbose output) so that you can see what is happening during a discovery run. This includes things like rrd updates, SQL queries and response from snmp. `-m` This enables you to specify the module you want to run for discovery. #### Discovery config -These are the default discovery config items. You can globally disable a module by setting it to 0. If you just want to +These are the default discovery config items. You can globally disable a module by setting it to 0. If you just want to disable it for one device then you can do this within the WebUI -> Settings -> Modules. ```php @@ -135,7 +135,7 @@ Here are some examples of running discovery from within your install directory. #### Debugging -To provide debugging output you will need to run the discovery process with the `-d` flag. You can do this either against +To provide debugging output you will need to run the discovery process with the `-d` flag. You can do this either against all modules, single or multiple modules: All Modules @@ -153,7 +153,7 @@ Multiple Modules ./discovery.php -h localhost -m ports,entity-physical -d ``` -It is then advisable to sanitise the output before pasting it somewhere as the debug output will contain snmp details +It is then advisable to sanitise the output before pasting it somewhere as the debug output will contain snmp details amongst other items including port descriptions. The output will contain: @@ -181,5 +181,5 @@ Usage: ./snmp-scan.php -r [-d] [-l] [-h] Example: 192.168.0.0/24 -d Enable Debug -l Show Legend - -h Print this text + -h Print this text ``` diff --git a/doc/Support/FAQ.md b/doc/Support/FAQ.md index d6da5de50..8f9147e88 100644 --- a/doc/Support/FAQ.md +++ b/doc/Support/FAQ.md @@ -71,8 +71,8 @@ If the page you are trying to load has a substantial amount of data in it then i #### Why do I not see any graphs? -This is usually due to there being blank spaces outside of the `` php tags within config.php. Remove these and retry. -It's also worth removing the final `?>` at the end of config.php as this is not required. +This is usually due to there being blank spaces outside of the `` php tags within config.php. Remove these and retry. +It's also worth removing the final `?>` at the end of config.php as this is not required. #### How do I debug pages not loading correctly? @@ -92,12 +92,12 @@ Please see the [Poller Support](http://docs.librenms.org/Support/Poller Support) #### Why do I get a lot apache or rrdtool zombies in my process list? -If this is related to your web service for LibreNMS then this has been tracked down to an issue within php which the developers aren't fixing. We have implemented a work around which means you +If this is related to your web service for LibreNMS then this has been tracked down to an issue within php which the developers aren't fixing. We have implemented a work around which means you shouldn't be seeing this. If you are, please report this in [issue 443](https://github.com/librenms/librenms/issues/443). #### Why do I see traffic spikes in my graphs? -This occurs either when a counter resets or the device sends back bogus data making it look like a counter reset. We have enabled support for setting a maximum value for rrd files for ports. +This occurs either when a counter resets or the device sends back bogus data making it look like a counter reset. We have enabled support for setting a maximum value for rrd files for ports. Before this all rrd files were set to 100G max values, now you can enable support to limit this to the actual port speed. rrdtool tune will change the max value when the interface speed is detected as being changed (min value will be set for anything 10M or over) or when you run the included script (scripts/tune_port.php). @@ -136,7 +136,7 @@ Thanks for asking, sometimes it's not quite so obvious and everyone can contribu #### How can I test another users branch? -LibreNMS can and is developed by anyone, this means someone may be working on a new feature or support for a device that you want. +LibreNMS can and is developed by anyone, this means someone may be working on a new feature or support for a device that you want. It can be helpful for others to test these new features, using Git, this is made easy. ```bash @@ -151,7 +151,7 @@ git status If you see `nothing to commit, working directory clean` then let's go for it :) Let's say that you want to test a users (f0o) new development branch (issue-1337) then you can do the following: - + ```bash git remote add f0o https://github.com/librenms/librenms.git git remote update f0o diff --git a/doc/Support/Features.md b/doc/Support/Features.md index 2d994c4bc..a8fc360ce 100644 --- a/doc/Support/Features.md +++ b/doc/Support/Features.md @@ -16,7 +16,7 @@ If you think something is missing, feel free to ask us. * Traffic Billing (Quota, 95th Percentile) * Two Factor Authentication -### Vendors +### Vendors Here's a brief list of supported vendors, some might be missing. If you are unsure of whether your device is supported or not, feel free to ask us. diff --git a/doc/Support/Install Validation.md b/doc/Support/Install Validation.md index 6283a9972..ba90879de 100644 --- a/doc/Support/Install Validation.md +++ b/doc/Support/Install Validation.md @@ -1,10 +1,10 @@ Install validation ------------------ -With a lot of configuration possibilities and at present the only way to do this being by manually editing config.php then it's not +With a lot of configuration possibilities and at present the only way to do this being by manually editing config.php then it's not uncommon that mistakes get made. It's also impossible to validate user input in config.php when you're just using a text editor :) -So, to try and help with some of the general issues people come across we've put together a simple validation tool which at present will: +So, to try and help with some of the general issues people come across we've put together a simple validation tool which at present will: - Validate config.php from a php perspective including whitespace where it shouldn't be. - Connection to your MySQL server to verify credentials. diff --git a/doc/Support/Poller Support.md b/doc/Support/Poller Support.md index ad99c4219..1ac444c7c 100644 --- a/doc/Support/Poller Support.md +++ b/doc/Support/Poller Support.md @@ -20,21 +20,21 @@ Debugging and testing options: -m Specify module(s) to be run ``` -`-h` Use this to specify a device via either id or hostname (including wildcard using *). You can also specify odd and +`-h` Use this to specify a device via either id or hostname (including wildcard using *). You can also specify odd and even. all will run poller against all devices. `-i` This can be used to stagger the poller process. `-r` This option will suppress the creation or update of RRD files. -`-d` Enables debugging output (verbose output) so that you can see what is happening during a poller run. This includes +`-d` Enables debugging output (verbose output) so that you can see what is happening during a poller run. This includes things like rrd updates, SQL queries and response from snmp. `-m` This enables you to specify the module you want to run for poller. #### Poller config -These are the default poller config items. You can globally disable a module by setting it to 0. If you just want to +These are the default poller config items. You can globally disable a module by setting it to 0. If you just want to disable it for one device then you can do this within the WebUI -> Settings -> Modules. ```php @@ -131,7 +131,7 @@ $config['poller_modules']['mib'] = 0; `netscaler-vsvr`: Netscaler support. `aruba-controller`: Arube wireless controller support. - + `entity-physical`: Module to pick up the devices hardware support. `applications`: Device application support. @@ -151,7 +151,7 @@ Here are some examples of running poller from within your install directory. #### Debugging -To provide debugging output you will need to run the poller process with the `-d` flag. You can do this either against +To provide debugging output you will need to run the poller process with the `-d` flag. You can do this either against all modules, single or multiple modules: All Modules @@ -169,7 +169,7 @@ Multiple Modules ./poller.php -h localhost -m ports,entity-physical -d ``` -It is then advisable to sanitise the output before pasting it somewhere as the debug output will contain snmp details +It is then advisable to sanitise the output before pasting it somewhere as the debug output will contain snmp details amongst other items including port descriptions. The output will contain: diff --git a/doc/Support/Support-New-OS.md b/doc/Support/Support-New-OS.md index e63244a26..be2bec7c9 100644 --- a/doc/Support/Support-New-OS.md +++ b/doc/Support/Support-New-OS.md @@ -69,7 +69,7 @@ $hardware = "Juniper " . trim(snmp_get($device, "productName.0", "-OQv", "PULSES $hostname = trim(snmp_get($device, "sysName.0", "-OQv", "SNMPv2-MIB"),'"'); ``` -Quick explanation and examples : +Quick explanation and examples : ```bash snmpwalk -v2c -c public -m SNMPv2-MIB -M mibs From 8ec50f11cd50f07ccd976ff953cfbb87eb2fd43b Mon Sep 17 00:00:00 2001 From: Jameson Finney Date: Sat, 30 Jan 2016 22:37:28 -0500 Subject: [PATCH 37/42] Fixed some typos and formatting issues in docs --- doc/Developing/Code-Structure.md | 2 +- doc/Developing/Style-Guidelines.md | 2 +- doc/Developing/Using-Git.md | 2 +- doc/Extensions/Alerting.md | 6 ++--- doc/Extensions/Authentication.md | 2 +- doc/Extensions/Distributed-Poller.md | 13 +++++----- doc/Extensions/IRC-Bot-Extensions.md | 2 +- doc/Extensions/IRC-Bot.md | 2 +- doc/Extensions/Memcached.md | 2 +- doc/Extensions/Network-Map.md | 2 +- doc/Extensions/Plugin-System.md | 4 ++-- doc/Extensions/Port-Description-Parser.md | 8 +++---- doc/Extensions/Proxmox.md | 2 +- doc/Extensions/RRDCached.md | 2 +- doc/Extensions/RRDTune.md | 2 +- doc/Extensions/Two-Factor-Auth.md | 4 ++-- doc/Extensions/Varnish.md | 2 +- doc/General/Changelog.md | 24 +++++++++---------- doc/General/Contributing.md | 6 ++--- doc/General/Credits.md | 4 ++-- .../Installation-(RHEL-CentOS).md | 4 ++-- doc/Support/Configuration.md | 4 ++-- doc/Support/Features.md | 2 +- doc/Support/Poller Support.md | 2 +- 24 files changed, 52 insertions(+), 53 deletions(-) diff --git a/doc/Developing/Code-Structure.md b/doc/Developing/Code-Structure.md index 9e1b4782a..0448aae26 100644 --- a/doc/Developing/Code-Structure.md +++ b/doc/Developing/Code-Structure.md @@ -41,7 +41,7 @@ All the discovery and polling code. The format is usually quite similar between This is for all of the libraries used by LibreNMS. If you are including a 3rd party module, you would add the files in here either via git subtree if it's hosted on GitHub or just by copying the folder. Please ensure you maintain any copyright notices. You will then need to either reference the files in this folder directly from where you need them or alternatively as is the case with css and js libraries then symlink the needed files. ### logs/ -Usually contains your web servers logs but can also contrain poller logs and other items, +Usually contains your web servers logs but can also contain poller logs and other items, ### mibs/ Here is where all of the mibs are located, traditionally this has meant having all mibs in one directory but for certain vendors this has changed and these are now located in sub folders. diff --git a/doc/Developing/Style-Guidelines.md b/doc/Developing/Style-Guidelines.md index e8f06b78f..4d7ac9f2a 100644 --- a/doc/Developing/Style-Guidelines.md +++ b/doc/Developing/Style-Guidelines.md @@ -6,7 +6,7 @@ the users interest that a consistent well thought out Web UI is available. ### Responsiveness The Web UI is designed to be mobile friendly and for the most part is and works well. It's worth spending sometime to -read through the [Boostrap website](http://getbootstrap.com/css/#grid) to learn more about how to keep things responsive. +read through the [Bootstrap website](http://getbootstrap.com/css/#grid) to learn more about how to keep things responsive. ### Navigation bar diff --git a/doc/Developing/Using-Git.md b/doc/Developing/Using-Git.md index c66400405..075d41684 100644 --- a/doc/Developing/Using-Git.md +++ b/doc/Developing/Using-Git.md @@ -53,7 +53,7 @@ Now you have two configured remotes: As you become more familiar you may find a better workflow that fits your needs, until then this should be a safe workflow for you to follow. -Before you start work on a new branch / feature. Make sure you are upto date. +Before you start work on a new branch / feature. Make sure you are up to date. ```bash cd /opt/librenms git checkout master diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index 87a542a7c..6ce8431f8 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -399,8 +399,8 @@ $config['alert']['transports']['clickatell']['to'][] = '+1234567892'; ## PlaySMS -PlaySMS is an OpenSource SMS-Gateway that can be used via their HTTP-API using a Username and WebService-Token. -Please consult PlaySMS's documentation regarding number formating. +PlaySMS is an open source SMS-Gateway that can be used via their HTTP-API using a Username and WebService-Token. +Please consult PlaySMS's documentation regarding number formatting. Here an example using 3 numbers, any amount of numbers is supported: ~~ @@ -529,7 +529,7 @@ And in the Rule: This Example-macro is a Boolean-macro, it applies a form of filter to the set of results defined by the rule. All macros that are not unary should return Boolean. -You can only apply _Equal_ or _Not-Equal_ Operations on Bollean-macros where `True` is represented by `"1"` and `False` by `"0"`. +You can only apply _Equal_ or _Not-Equal_ Operations on Boolean-macros where `True` is represented by `"1"` and `False` by `"0"`. ## Device (Boolean) diff --git a/doc/Extensions/Authentication.md b/doc/Extensions/Authentication.md index d84145db6..adafa6526 100644 --- a/doc/Extensions/Authentication.md +++ b/doc/Extensions/Authentication.md @@ -67,7 +67,7 @@ Config option: `ldap` This one is a little more complicated :) -First of all, install ___php-ldap___ forCentOS/RHEL or ___php5-ldap___ for Ubuntu/Debian. +First of all, install ___php-ldap___ for CentOS/RHEL or ___php5-ldap___ for Ubuntu/Debian. ```php $config['auth_ldap_version'] = 3; # v2 or v3 diff --git a/doc/Extensions/Distributed-Poller.md b/doc/Extensions/Distributed-Poller.md index 97b9cb253..a951642ec 100644 --- a/doc/Extensions/Distributed-Poller.md +++ b/doc/Extensions/Distributed-Poller.md @@ -3,19 +3,19 @@ LibreNMS has the ability to distribute polling of devices to other machines. These machines can be in a different physical location and therefore minimize network latencies for colocations. -Devices can also be groupped together into a `poller_group` to pin these devices to a single or a group of designated pollers. +Devices can also be grouped together into a `poller_group` to pin these devices to a single or a group of designated pollers. ~~All pollers need to share their RRD-folder, for example via NFS or a combination of NFS and rrdcached.~~ > This is no longer a strict requirement with the use of rrdtool 1.5 and above. If you are NOT running 1.5 then you will still need to share the RRD-folder. -It is also required that all pollers can access the central memcached to communicate with eachother. +It is also required that all pollers can access the central memcached to communicate with each other. In order to enable distributed polling, set `$config['distributed_poller'] = true` and your memcached details into `$config['distributed_poller_memcached_host']` and `$config['distributed_poller_memcached_port']`. By default, all hosts are shared and have the `poller_group = 0`. To pin a device to a poller, set it to a value greater than 0 and set the same value in the poller's config with `$config['distributed_poller_group']`. Usually the poller's name is equal to the machine's hostname, if you want to change it set `$config['distributed_poller_name']`. -One can also specify a comma seperated string of poller groups in $config['distributed_poller_group']. The poller will then poll devices from any of the groups listed. If new devices get added from the poller they will be assigned to the first poller group in the list unless the group is specified when adding the device. +One can also specify a comma separated string of poller groups in $config['distributed_poller_group']. The poller will then poll devices from any of the groups listed. If new devices get added from the poller they will be assigned to the first poller group in the list unless the group is specified when adding the device. ## Configuration ```php @@ -28,8 +28,7 @@ $config['distributed_poller_memcached_port'] = '11211'; ``` ## Example Setup -Below is an example setup based on a real deployment which at the time of writing covers over 2,500 devices and 50,000 ports. The setup is running within an Openstack environment with some commodity ha -rdware for remote pollers. Here's a diagram of how you can scale LibreNMS out: +Below is an example setup based on a real deployment which at the time of writing covers over 2,500 devices and 50,000 ports. The setup is running within an OpenStack environment with some commodity hardware for remote pollers. Here's a diagram of how you can scale LibreNMS out: ![Example Setup](http://docs.librenms.org/img/librenms-distributed-diagram.png) @@ -53,7 +52,7 @@ The pollers, web and API layers should all be able to access the database server ####RRD Storage Central storage should be provided so all RRD files can be read from and written to in one location. As suggested above, it's recommended that RRD Cached is configured and used. -For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd iles ~~with the rrd directory also exported by NFS for simple access and maintenance.~~ +For this example, we are running RRDCached to allow all pollers and web/api servers to read/write to the rrd files ~~with the rrd directory also exported by NFS for simple access and maintenance.~~ Sharing rrd files via something like NFS is no longer required if you run rrdtool 1.5 or greater. If you don't - please share your rrd folder as before. If you run rrdtool 1.5 or greater then add this config to your pollers: @@ -81,7 +80,7 @@ Another benefit to this is that you can provide N+x pollers, i.e if you know tha It is extremely advisable to either run a central recursive dns server such as pdns-recursor and have all of your pollers use this or install a recursive dns server on each poller - the volume of DNS requests on large installs can be significant. ####Discovery -It's not necessary to run discovery services on all pollers. In fact, you should only run one discovery process per poller group. Designate a single poller to run discovery (or a seperate server if required). +It's not necessary to run discovery services on all pollers. In fact, you should only run one discovery process per poller group. Designate a single poller to run discovery (or a separate server if required). ####Config sample Memcache: diff --git a/doc/Extensions/IRC-Bot-Extensions.md b/doc/Extensions/IRC-Bot-Extensions.md index 71f6d1180..c36b4d3cf 100644 --- a/doc/Extensions/IRC-Bot-Extensions.md +++ b/doc/Extensions/IRC-Bot-Extensions.md @@ -51,7 +51,7 @@ Attribute | Type | Description `$this->external` | `Array` | Contains loaded extra `commands`. `$this->nick` | `String` | Bot's `nick` on the IRC. `$this->pass` | `String` | IRC-Server's passphrase. -`$this->port` | `Int` | IRC-Sever's port-number. +`$this->port` | `Int` | IRC-Server's port-number. `$this->server` | `String` | IRC-Server's hostname. `$this->ssl` | `Boolean` | SSL-Flag. `$this->tick` | `Int` | Interval to check buffers in microseconds. diff --git a/doc/Extensions/IRC-Bot.md b/doc/Extensions/IRC-Bot.md index 58d0b9c70..eda0bef37 100644 --- a/doc/Extensions/IRC-Bot.md +++ b/doc/Extensions/IRC-Bot.md @@ -48,7 +48,7 @@ Command | Description `.port ` | Prints Port-related information from `ifname` on given `hostname`. `.quit` | Disconnect from IRC and exit. `.reload` | Reload configuration. -`.status ` | Prints status informations for given `type`. Type can be `devices`, `services`, `ports`. Shorthands are: `dev`,`srv`,`prt` +`.status ` | Prints status information for given `type`. Type can be `devices`, `services`, `ports`. Shorthands are: `dev`,`srv`,`prt` `.version` | Prints `$this->config['project_name_version']`. ( __/!\__ All commands are case-_insensitive_ but their arguments are case-_sensitive_) diff --git a/doc/Extensions/Memcached.md b/doc/Extensions/Memcached.md index 3d226e83a..80063c787 100644 --- a/doc/Extensions/Memcached.md +++ b/doc/Extensions/Memcached.md @@ -11,7 +11,7 @@ $config['memcached']['port'] = 11211; ``` By default values are kept for 4 Minutes inside the memcached, you can adjust this retention time by modifying the `$config['memcached']['ttl']` value to any desired amount of seconds. -It's strongly discouraged to set this above `300` (5 Minutes) to avoid interferences with the polling, discovery and alerting processes. +It's strongly discouraged to set this above `300` (5 Minutes) to avoid interference with the polling, discovery and alerting processes. If you use the Distributed Poller, you can point this to the same memcached instance. However a local memcached will perform better in any case. diff --git a/doc/Extensions/Network-Map.md b/doc/Extensions/Network-Map.md index c0e580ae5..d2e092e35 100644 --- a/doc/Extensions/Network-Map.md +++ b/doc/Extensions/Network-Map.md @@ -16,7 +16,7 @@ Either remove mac or xdp depending on which you want. A global map will be drawn from the information in the database, it is worth noting that this could lead to a large network map. Network maps for individual devices are available showing the relationship with other devices. -One can also specicify the parameters to be used for drawing and updating the network map. +One can also specify the parameters to be used for drawing and updating the network map. Please see http://visjs.org/docs/network/ for details on the configuration parameters. ```php $config['network_map_vis_options'] = '{ diff --git a/doc/Extensions/Plugin-System.md b/doc/Extensions/Plugin-System.md index 544f7a1a0..7307a7ff0 100644 --- a/doc/Extensions/Plugin-System.md +++ b/doc/Extensions/Plugin-System.md @@ -2,7 +2,7 @@ This documentation will hopefully give you a basis for how to write a plugin for LibreNMS. -A test plugin is available on GitHib: https://github.com/laf/Test +A test plugin is available on GitHub: https://github.com/laf/Test Plugins need to be installed into html/plugins @@ -45,7 +45,7 @@ PluginName.inc.php - This file is the main included file when browsing to the pl ### System Hooks ### -System hooks are called as functions within your plugin class, so for example to create a menu entry within the PLugin dropdown you would do: +System hooks are called as functions within your plugin class, so for example to create a menu entry within the Plugin dropdown you would do: ``` public function menu() { diff --git a/doc/Extensions/Port-Description-Parser.md b/doc/Extensions/Port-Description-Parser.md index f07a2878e..4eb7a9635 100644 --- a/doc/Extensions/Port-Description-Parser.md +++ b/doc/Extensions/Port-Description-Parser.md @@ -1,6 +1,6 @@ # Configuring interface descriptions for parsing. -LibreNMS includes the ability to parse your interface descriptions for set information to diplay and segment in the WebUI. +LibreNMS includes the ability to parse your interface descriptions for set information to display and segment in the WebUI. The following information is used from interface descriptions: @@ -57,7 +57,7 @@ description Cust: Customer A (This customer is gold) [] i.e: -description Cust: Customer A [100Mbs] +description Cust: Customer A [100Mbps] You can use any of these additional options like: @@ -66,10 +66,10 @@ description Cust: Customer A {ID4321} [1Gbps] This information is then held within the ports table within the database, as an example: -description Core: Nas bond [1Gbps] +description Core: NAS bond [1Gbps] ```sh port_descr_type: core -port_descr_descr: Nas bond +port_descr_descr: NAS bond port_descr_circuit: NULL port_descr_speed: 1Gbps port_descr_notes: NULL diff --git a/doc/Extensions/Proxmox.md b/doc/Extensions/Proxmox.md index 4b7f8a2a1..0733876b9 100644 --- a/doc/Extensions/Proxmox.md +++ b/doc/Extensions/Proxmox.md @@ -1,5 +1,5 @@ # Proxmox graphing -It is possible to create graphs of the Proxmox **VMs** that run on your monitored machines. Currently, only trafficgraphs are created. One for each interface on each VM. Possibly, IO grahps will be added later on. +It is possible to create graphs of the Proxmox **VMs** that run on your monitored machines. Currently, only traffic graphs are created. One for each interface on each VM. Possibly, IO graphs will be added later on. The ultimate goal is to be able to create traffic bills for VMs, no matter on which physical machine that VM runs. diff --git a/doc/Extensions/RRDCached.md b/doc/Extensions/RRDCached.md index f6059234e..72609cadc 100644 --- a/doc/Extensions/RRDCached.md +++ b/doc/Extensions/RRDCached.md @@ -45,7 +45,7 @@ service rrdcached start $config['rrdcached'] = "unix:/var/run/rrdcached/rrdcached.sock"; ``` ### RRDCached installation CentOS 7 -This example is based on a fresh LibreNMS install, on a minimimal CentOS 7.x installation. +This example is based on a fresh LibreNMS install, on a minimal CentOS 7.x installation. We'll use the epel-release and setup a RRDCached as a service. It is recommended that you monitor your LibreNMS server with LibreNMS so you can view the disk I/O usage delta. See [Installation (RHEL CentOS)][1] for localhost monitoring. diff --git a/doc/Extensions/RRDTune.md b/doc/Extensions/RRDTune.md index c7a961ffc..5cd1ed483 100644 --- a/doc/Extensions/RRDTune.md +++ b/doc/Extensions/RRDTune.md @@ -9,7 +9,7 @@ To enable this you can do so in three ways! - For the actual device, Edit Device -> Misc - For each port, Edit Device -> Port Settings -Now when a port interface speed changes (this can happen because of a physical change or just because the device has mis-reported) the max value is set. If you don't want to wait until +Now when a port interface speed changes (this can happen because of a physical change or just because the device has misreported) the max value is set. If you don't want to wait until a port speed changes then you can run the included script: script/tune_port.php -h -p diff --git a/doc/Extensions/Two-Factor-Auth.md b/doc/Extensions/Two-Factor-Auth.md index 1ee4a9b20..daa8b3e86 100644 --- a/doc/Extensions/Two-Factor-Auth.md +++ b/doc/Extensions/Two-Factor-Auth.md @@ -28,14 +28,14 @@ The underlying HMAC-SHA1 remains the same for both types, security advantages or Like the name suggests, this type uses the current Time or a subset of it to generate the passcodes. These passcodes solely rely on the secrecy of their Secretkey in order to provide passcodes. An attacker only needs to guess that Secretkey and the other variable part is any given time, presumably the time upon login. -RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of upto +/- 3 Minutes to create passcodes. +RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of up to +/- 3 Minutes to create passcodes. ## Counterbased One-Time-Password (TOTP) This type uses an internal counter that needs to be in sync with the server's counter to successfully authenticate the passcodes. The main advantage over timebased OTP is the attacker doesn't only need to know the Secretkey but also the server's Counter in order to create valid passcodes. -RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of upto +4 increments from the actual counter to create passcodes. +RFC4226 suggests a resynchronization attempt in case the passcode mismatches, providing the attacker a range of up to +4 increments from the actual counter to create passcodes. # Configuration diff --git a/doc/Extensions/Varnish.md b/doc/Extensions/Varnish.md index 78cced5a9..6e4421508 100644 --- a/doc/Extensions/Varnish.md +++ b/doc/Extensions/Varnish.md @@ -209,7 +209,7 @@ sub vcl_backend_response { # that match the file extensions that are between the quotes, and cache the files for 24 hours. # This assumes you update LibreNMS once a day, otherwise restart Varnish to clear cache. # Second function 'if (bereq.url ~ "^/' removes the Pragma no-cache statements and sets the age - # of how long the client brower will cache the matching urls. + # of how long the client browser will cache the matching urls. # LibreNMS graphs are updated every 300 seconds, 'max-age=300' is set to match this behavior. # We could cache these URLs in Varnish but it would add to the complexity of the config. diff --git a/doc/General/Changelog.md b/doc/General/Changelog.md index 60a0cbfb0..54a97dacc 100644 --- a/doc/General/Changelog.md +++ b/doc/General/Changelog.md @@ -43,7 +43,7 @@ - Added support for Samsung SCX printers (PR2760) - Added additional support for HP MSM (PR2766, PR2768) - Added additional support for Cisco ASA and RouterOS (PR2784) - - Added support for Lenovo EMC Nas (PR2795) + - Added support for Lenovo EMC NAS (PR2795) - Added support for Infoblox (PR2801) - API: - Added support for Oxidized groups (PR2745) @@ -157,7 +157,7 @@ - Added RIPE NCC API support for lookups (PR2455, PR2474) - Improved ports page for device with large number of neighbours (PR2460) - Merged all CPU graphs into one on overview page (PR2470) - - Added support for sortting by traffic on device port page (PR2508) + - Added support for sorting by traffic on device port page (PR2508) - Added support for dynamic graph sizes based on browser size (PR2510) - Made device location clickable in device header (PR2515) - Visual improvements to bills page (PR2519) @@ -174,7 +174,7 @@ - Alerting: - Added ability to globally disable sending alerts (PR2385) - Added support for Clickatell, PlaySMS and VictorOps (PR24104, PR2443) - - Documnetation: + - Documentation: - Improved CentOS install docs (PR2462) - Improved Proxmox setup docs (PR2483) - Misc: @@ -227,7 +227,7 @@ - Update Font Awesome (PR2167) - Allow user to influence when devices are grouped on world map (PR2170) - Centralised the date selector for graphs for re-use (PR2183) - - Dont show dashboard settings if `/bare=yes/` (PR2364) + - Don't show dashboard settings if `/bare=yes/` (PR2364) - API: - Added unmute alert function to API (PR2082) - Discovery / Polling: @@ -259,7 +259,7 @@ - Fixed IRC bot reconnect if socket dies (PR2061) - Updated default crons (PR2177) - Reverts: - - "Removed what appears to be unecessary STACK text" (PR2128) + - "Removed what appears to be unnecessary STACK text" (PR2128) ### September 2015 @@ -270,7 +270,7 @@ - Issue alert-trigger as test object (PR1850) - WebUI: - Fix permissions for World-map widget (PR1866) - - Clean up Gloabl / World Map name mixup (PR1874) + - Clean up Global / World Map name mixup (PR1874) - Removed required flag for community when adding new hosts (PR1961) - Stop duplicate devices showing in map (PR1963) - Fix adduser bug storing users real name (PR1990) @@ -381,7 +381,7 @@ - Misc UI fixes (Titles, Headers, ...) (PR1797,PR1798,PR1800,PR1801,PR1802,PR1803,PR1804,PR1805) - Move packages to overview dropdown (PR1810) - API Updates: - - Improvided billing support in API (PR1599) + - Improved billing support in API (PR1599) - Extended support for list devices to support mac/ipv4 and ipv6 filtering (PR1744) - Added detection for: - Perle Media convertors (PR1607) @@ -586,7 +586,7 @@ - Fix SQL query for restricted users in /devices/ (PR990) - Fix for post-formatting time-macros (PR1006) - Honour disabling alerts for hosts (PR1051) - - Make OSPF and ARP discovery independant xDP (PR1053) + - Make OSPF and ARP discovery independent xDP (PR1053) - Fixed ospf_nbrs lookup to use device_id (PR1088) - Removed trailing / from some urls (PR1089 / PR1100) - Fix to device search for Device type and location (PR1101) @@ -674,7 +674,7 @@ - Show ifName in ARP search if devices are set to use this (PR1133) - Added FibreHome CPU and Mempool support (PR1134) - Added config options for region and resolution on globe map (PR1137) - - Addded RRDCached example docs (PR1148) + - Added RRDCached example docs (PR1148) - Updated support for additional NetBotz models (PR1152) - Updated /iftype/ page to include speed/circuit/notes (PR1155) - Added detection for PowerConnect 55XX devices (PR1165) @@ -687,7 +687,7 @@ - Added missing CPU id for Cisco SB (PR744) - Changed Processors table name to lower case in processors discovery (PR751) - Fixed alerts path issue (PR756, PR760) - - Supress further port alerts when interface goes down (PR745) + - Suppress further port alerts when interface goes down (PR745) - Fixed login so redirects via 303 when POST data sent (PR775) - Fixed missing link to errored or ignored ports (PR787) - Updated alert log query for performance improvements (PR783) @@ -901,7 +901,7 @@ - Added names to all API routes (PR314) - Added route to call list of API endpoints (PR315) - Added options to $config to specify fping retry and timeout (PR323) - - Added icmp / snnmp to device down alerts for debugging (PR324) + - Added icmp / snmp to device down alerts for debugging (PR324) - Added function to page results for large result pages (PR333) ###Sep 2014 @@ -950,7 +950,7 @@ ####Improvements - Updated index page (PR224) - Updated global search visually (PR223) - - Added contributors aggrement (PR225) + - Added contributors agreement (PR225) - Added ability to update health values (PR226) - Tidied up search box on devices list page (PR229) - Updated port search box and port table list (PR230) diff --git a/doc/General/Contributing.md b/doc/General/Contributing.md index 09353800c..4027cfeae 100644 --- a/doc/General/Contributing.md +++ b/doc/General/Contributing.md @@ -5,7 +5,7 @@ required to sign over their rights to any other party. Contributor Agreement --------------------- -By contributing code to LibreNMS (whether by a github pull request, or by +By contributing code to LibreNMS (whether by a GitHub pull request, or by any other means), you assert that: - You have the rights to include the code, either as its original author, @@ -29,9 +29,9 @@ any other means), you assert that: systems. -To agree with these assertions, please submit a Github pull request against +To agree with these assertions, please submit a GitHub pull request against [AUTHORS.md][5], adding or altering a **single line** *containing your name, -email address, and Github user id* in the file (so that it can be matched to +email address, and GitHub user id* in the file (so that it can be matched to your commits), and stating in the *commit log* (not the pull request text): ``` I agree to the conditions of the Contributor Agreement diff --git a/doc/General/Credits.md b/doc/General/Credits.md index b67b5d7b1..72dcf627d 100644 --- a/doc/General/Credits.md +++ b/doc/General/Credits.md @@ -28,11 +28,11 @@ LibreNMS ships with the following software components: - Code for UBNT Devices Mark Gibbons - Initial code base submited via PR721 + Initial code base submitted via PR721 - Jquery LazyLoad http://www.appelsiini.net/projects/lazyload - Mika Tuupola (@tuupola on github) + Mika Tuupola (@tuupola on GitHub) MIT License - influxdb-php diff --git a/doc/Installation/Installation-(RHEL-CentOS).md b/doc/Installation/Installation-(RHEL-CentOS).md index 493b8a746..46100d078 100644 --- a/doc/Installation/Installation-(RHEL-CentOS).md +++ b/doc/Installation/Installation-(RHEL-CentOS).md @@ -327,8 +327,8 @@ Create the cronjob ### Daily Updates ### -LibreNMS performs daily updates by default. At 00:15 system time every day, a `git pull --no-edit --quiet` is performed. You can override this default by edit -ing your `config.php` file. Remove the comment (the `#` mark) on the line: +LibreNMS performs daily updates by default. At 00:15 system time every day, a `git pull --no-edit --quiet` is performed. You can override this default by editing +your `config.php` file. Remove the comment (the `#` mark) on the line: #$config['update'] = 0; diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 4197a3c26..44c904e6d 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -7,7 +7,7 @@ If you would like to alter any of these then please add your config option to `c ```php $config['install_dir'] = "/opt/librenms"; ``` -Set the installation directory (defaults to /opt/librenms), if you clone the github branch to another location ensure you alter this. +Set the installation directory (defaults to /opt/librenms), if you clone the GitHub branch to another location ensure you alter this. ```php $config['temp_dir'] = "/tmp"; @@ -214,7 +214,7 @@ $config['gui']['network-map']['style'] = 'old'; #### Add host settings The following setting controls how hosts are added. If a host is added as an ip address it is checked to ensure the ip is not already present. If the ip is present the host is not added. -If host is added by hostname this check is not performed. If the setting is true hostnames are resovled and the check is also performed. This helps prevents accidental duplicate hosts. +If host is added by hostname this check is not performed. If the setting is true hostnames are resolved and the check is also performed. This helps prevents accidental duplicate hosts. ```php $config['addhost_alwayscheckip'] = FALSE; #TRUE - check for duplicate ips even when adding host by name. #FALSE- only check when adding host by ip. diff --git a/doc/Support/Features.md b/doc/Support/Features.md index a8fc360ce..e65e697f6 100644 --- a/doc/Support/Features.md +++ b/doc/Support/Features.md @@ -74,7 +74,7 @@ If you are unsure of whether your device is supported or not, feel free to ask u * Mellanox * Meraki * MGE -* Mikrotic +* Mikrotik * MRVLD * Multimatic * NetApp diff --git a/doc/Support/Poller Support.md b/doc/Support/Poller Support.md index 1ac444c7c..9ab377378 100644 --- a/doc/Support/Poller Support.md +++ b/doc/Support/Poller Support.md @@ -130,7 +130,7 @@ $config['poller_modules']['mib'] = 0; `netscaler-vsvr`: Netscaler support. -`aruba-controller`: Arube wireless controller support. +`aruba-controller`: Aruba wireless controller support. `entity-physical`: Module to pick up the devices hardware support. From 8795d06e4632c16558cc3d2e1af4fbae3078ad33 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 31 Jan 2016 19:11:47 +0100 Subject: [PATCH 38/42] change schema number --- sql-schema/{098.sql => 097.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql-schema/{098.sql => 097.sql} (100%) diff --git a/sql-schema/098.sql b/sql-schema/097.sql similarity index 100% rename from sql-schema/098.sql rename to sql-schema/097.sql From 34ddc51a19712a2eec5691b05dc055ad64be2901 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 31 Jan 2016 18:17:56 +0000 Subject: [PATCH 39/42] renamed sql-schema file --- sql-schema/{099.sql => 098.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sql-schema/{099.sql => 098.sql} (100%) diff --git a/sql-schema/099.sql b/sql-schema/098.sql similarity index 100% rename from sql-schema/099.sql rename to sql-schema/098.sql From 4150b862058e2130f94b2cdb743bf9aa33253e69 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Tue, 2 Feb 2016 11:05:59 +0100 Subject: [PATCH 40/42] Make ceph.inc.php compatible with the new graph_array-method, which gets reset after each include. --- html/pages/device/apps/ceph.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/html/pages/device/apps/ceph.inc.php b/html/pages/device/apps/ceph.inc.php index 988d64803..50dedc8c4 100644 --- a/html/pages/device/apps/ceph.inc.php +++ b/html/pages/device/apps/ceph.inc.php @@ -17,6 +17,8 @@ foreach ($graphs as $key => $text) { if ($key == "ceph_poolstats") { foreach (glob($rrddir."/app-ceph-".$app['app_id']."-pool-*") as $rrd_filename) { + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; if (preg_match("/.*-pool-(.+)\.rrd$/", $rrd_filename, $pools)) { $pool = $pools[1]; echo '

    '.$pool.' Reads/Writes

    '; @@ -39,6 +41,8 @@ foreach ($graphs as $key => $text) { } elseif ($key == "ceph_osdperf") { foreach (glob($rrddir."/app-ceph-".$app['app_id']."-osd-*") as $rrd_filename) { + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; if (preg_match("/.*-osd-(.+)\.rrd$/", $rrd_filename, $osds)) { $osd = $osds[1]; echo '

    '.$osd.' Latency

    '; @@ -57,6 +61,8 @@ foreach ($graphs as $key => $text) { $pool = $pools[1]; if ($pool == "c") { echo '

    Cluster Usage

    '; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; $graph_array['type'] = 'application_ceph_pool_df'; $graph_array['pool'] = $pool; @@ -66,6 +72,8 @@ foreach ($graphs as $key => $text) { } else { echo '

    '.$pool.' Usage

    '; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; $graph_array['type'] = 'application_ceph_pool_df'; $graph_array['pool'] = $pool; @@ -74,6 +82,8 @@ foreach ($graphs as $key => $text) { echo ''; echo '

    '.$pool.' Objects

    '; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; $graph_array['type'] = 'application_ceph_pool_objects'; $graph_array['pool'] = $pool; From a53f7c3df1cf81f5e32275df41653dd38157583d Mon Sep 17 00:00:00 2001 From: awlx Date: Tue, 2 Feb 2016 11:14:09 +0100 Subject: [PATCH 41/42] Added description of AD configuration options --- doc/Extensions/Authentication.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/Extensions/Authentication.md b/doc/Extensions/Authentication.md index adafa6526..481809811 100644 --- a/doc/Extensions/Authentication.md +++ b/doc/Extensions/Authentication.md @@ -137,6 +137,8 @@ If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authentica > Cleanup of old accounts is done using the authlog. You will need to set the cleanup date for when old accounts will be purged which will happen AUTOMATICALLY. > Please ensure that you set the $config['authlog_purge'] value to be greater than $config['active_directory]['users_purge'] otherwise old users won't be removed. +```$config['auth_ad_groups']['']['level'] = 10``` defines the active directory group which gets admin privileges at login. ```$config['auth_ad_groups']['']['level'] = 7``` defines the group with user privileges after login. + ##### Sample configuration ``` @@ -144,8 +146,8 @@ $config['auth_ad_url'] = "ldaps://your-domain.controll.er"; $config['auth_ad_check_certificates'] = 1; // or 0 $config['auth_ad_domain'] = "your-domain.com"; $config['auth_ad_base_dn'] = "dc=your-domain,dc=com"; -$config['auth_ad_groups']['admin']['level'] = 10; -$config['auth_ad_groups']['pfy']['level'] = 7; +$config['auth_ad_groups']['']['level'] = 10; +$config['auth_ad_groups']['']['level'] = 7; $config['auth_ad_require_groupmembership'] = 0; $config['active_directory']['users_purge'] = 14;//Purge users who haven't logged in for 14 days. ``` From 53be46ed7ded56feb2d8e046a697ca3a00aabd70 Mon Sep 17 00:00:00 2001 From: awlx Date: Tue, 2 Feb 2016 11:37:23 +0100 Subject: [PATCH 42/42] Changed the text to make it more clear what to change. --- doc/Extensions/Authentication.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Extensions/Authentication.md b/doc/Extensions/Authentication.md index 481809811..adb468a51 100644 --- a/doc/Extensions/Authentication.md +++ b/doc/Extensions/Authentication.md @@ -137,7 +137,6 @@ If you set ```$config['auth_ad_require_groupmembership']``` to 1, the authentica > Cleanup of old accounts is done using the authlog. You will need to set the cleanup date for when old accounts will be purged which will happen AUTOMATICALLY. > Please ensure that you set the $config['authlog_purge'] value to be greater than $config['active_directory]['users_purge'] otherwise old users won't be removed. -```$config['auth_ad_groups']['']['level'] = 10``` defines the active directory group which gets admin privileges at login. ```$config['auth_ad_groups']['']['level'] = 7``` defines the group with user privileges after login. ##### Sample configuration @@ -152,6 +151,8 @@ $config['auth_ad_require_groupmembership'] = 0; $config['active_directory']['users_purge'] = 14;//Purge users who haven't logged in for 14 days. ``` +Replace `` with your Active Directory admin-user group and `` with your standard user group. + #### Radius Authentication Please note that a mysql user is created for each user the logs in successfully. User level 1 is assigned to those accounts so you will then need to assign the relevant permissions unless you set `$config['radius']['userlevel']` to be something other than 1.