From 7f32af4f7b02b6e04992c4e882eddba338260e63 Mon Sep 17 00:00:00 2001 From: pobradovic08 Date: Mon, 21 Oct 2019 02:39:14 +0200 Subject: [PATCH] Add CISCO-IF-EXTENSION port stats for IOS/IOS-XE (#10644) * Add CISCO-IF-EXTENSION polling and graph * Added test data * Code style * Move CISCO-IF-EXTENSION-MIB to cisco mib dir * Test data? * Recollect test data again * ios-xe variant 'ports' with ports test data * Removed unnecessary test data --- includes/html/graphs/port/cie.inc.php | 44 +++++++++++++++ .../html/pages/device/port/graphs.inc.php | 20 ++++++- includes/polling/ports.inc.php | 30 ++++++++++- .../polling/ports/cisco-if-extension.inc.php | 53 +++++++++++++++++++ mibs/{ => cisco}/CISCO-IF-EXTENSION-MIB | 0 5 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 includes/html/graphs/port/cie.inc.php create mode 100644 includes/polling/ports/cisco-if-extension.inc.php rename mibs/{ => cisco}/CISCO-IF-EXTENSION-MIB (100%) diff --git a/includes/html/graphs/port/cie.inc.php b/includes/html/graphs/port/cie.inc.php new file mode 100644 index 0000000000..bafcb40b87 --- /dev/null +++ b/includes/html/graphs/port/cie.inc.php @@ -0,0 +1,44 @@ + + */ + +$cisco_if_extension_ds = array( + 'InRuntsErrs' => 'In Runts', + 'InGiantsErrs' => 'In Giants', + 'InFramingErrs' => 'In Framing err', + 'InOverrunErrs' => 'In Overruns', + 'InIgnored' => 'In Ignored', + 'InAbortErrs' => 'In Aborts', + 'InputQueueDrops' => 'In Queue drops', + 'OutputQueueDrops' => 'Out Queue drops' +); + +$i = 0; +$rrd_filename = get_port_rrdfile_path($device['hostname'], $port['port_id'], 'cie'); + +if (rrdtool_check_rrd_exists($rrd_filename)) { + foreach ($cisco_if_extension_ds as $ds => $descr) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $descr; + $rrd_list[$i]['ds'] = $ds; + $i++; + } +} + +$colours = 'mixed'; +$nototal = 1; +$unit_text = 'Errors/sec'; +$simple_rrd = 1; + +require 'includes/html/graphs/generic_multi_simplex_seperated.inc.php'; diff --git a/includes/html/pages/device/port/graphs.inc.php b/includes/html/pages/device/port/graphs.inc.php index d38bc166b5..d6502028b0 100644 --- a/includes/html/pages/device/port/graphs.inc.php +++ b/includes/html/pages/device/port/graphs.inc.php @@ -49,7 +49,7 @@ if (rrdtool_check_rrd_exists(get_port_rrdfile_path($device['hostname'], $port['p

PoE

'; $graph_type = 'port_poe'; - + echo '
'; include 'includes/html/print-interface-graphs.inc.php'; echo '
'; @@ -61,9 +61,25 @@ if (rrdtool_check_rrd_exists(get_port_rrdfile_path($device['hostname'], $port['p

Ethernet Errors

'; $graph_type = 'port_etherlike'; - + echo '
'; include 'includes/html/print-interface-graphs.inc.php'; echo '
'; } + + /* + * CISCO-IF-EXTENSION MIB statistics + * Additional information about input and output errors as seen in `show interface` output. + */ + if (rrdtool_check_rrd_exists(get_port_rrdfile_path($device['hostname'], $port['port_id'], 'cie'))) { + echo '
+
+

Detailed interface errors

+
'; + $graph_type = 'port_cie'; + + echo '
'; + include 'includes/html/print-interface-graphs.inc.php'; + echo '
'; + } } diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index c921004fe9..2f6304e651 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -81,6 +81,20 @@ $cisco_oids = array( 'locIfOutputQueueDrops', ); +/* + * CISCO-IF-EXTENSION MIB + */ +$cisco_if_extension_oids = array( + 'cieIfInRuntsErrs', + 'cieIfInGiantsErrs', + 'cieIfInFramingErrs', + 'cieIfInOverrunErrs', + 'cieIfInIgnored', + 'cieIfInAbortErrs', + 'cieIfInputQueueDrops', + 'cieIfOutputQueueDrops' +); + $pagp_oids = array( 'pagpOperationMode', ); @@ -417,6 +431,16 @@ if ($device['os_group'] == 'cisco' && $device['os'] != 'asa') { $port_stats = snmpwalk_cache_oid($device, 'vlanTrunkPortNativeVlan', $port_stats, 'CISCO-VTP-MIB'); }//end if +/* + * Most (all) of the IOS/IOS-XE devices support CISCO-IF-EXTENSION MIB that provides + * additional informationa bout input and output errors as seen in `show interface` output. + */ +if ($device['os'] == 'ios' || $device['os'] == 'iosxe') { + foreach ($cisco_if_extension_oids as $oid) { + $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, 'CISCO-IF-EXTENSION-MIB'); + } +} + $polled = time(); // End Building SNMP Cache Array @@ -864,7 +888,7 @@ foreach ($ports as $port) { // Add delta rate between current poll and last poll. $fields['ifInBits_rate'] = $port['stats']['ifInBits_rate']; $fields['ifOutBits_rate'] = $port['stats']['ifOutBits_rate']; - + prometheus_push($device, 'ports', rrd_array_filter($tags), $fields); influx_update($device, 'ports', rrd_array_filter($tags), $fields); graphite_update($device, 'ports|' . $ifName, $tags, $fields); @@ -898,6 +922,10 @@ foreach ($ports as $port) { if (Config::get('enable_ports_poe')) { include 'ports/port-poe.inc.php'; } + + if ($device['os'] == 'ios' || $device['os'] == 'iosxe') { + include 'ports/cisco-if-extension.inc.php'; + } } foreach ($port['update'] as $key => $val_check) { diff --git a/includes/polling/ports/cisco-if-extension.inc.php b/includes/polling/ports/cisco-if-extension.inc.php new file mode 100644 index 0000000000..5d5bcd91a4 --- /dev/null +++ b/includes/polling/ports/cisco-if-extension.inc.php @@ -0,0 +1,53 @@ + + */ + +use LibreNMS\RRD\RrdDefinition; + +/* + * Check if port has one of the counters ('cieIfInRuntsErrs') from CISCO-IF-EXTENSION MIB + */ +if (isset($this_port['cieIfInRuntsErrs'])) { + /* + * Build interface RRD with filename in format of: + * port-id-cie.rrd + */ + $rrd_name = getPortRrdName($port_id, 'cie'); + $rrdfile = rrd_name($device['hostname'], $rrd_name); + $rrd_def = RrdDefinition::make() + ->addDataset('InRuntsErrs', 'DERIVE', 0) + ->addDataset('InGiantsErrs', 'DERIVE', 0) + ->addDataset('InFramingErrs', 'DERIVE', 0) + ->addDataset('InOverrunErrs', 'DERIVE', 0) + ->addDataset('InIgnored', 'DERIVE', 0) + ->addDataset('InAbortErrs', 'DERIVE', 0) + ->addDataset('InputQueueDrops', 'DERIVE', 0) + ->addDataset('OutputQueueDrops', 'DERIVE', 0); + + /* + * Populate data for RRD + */ + $rrd_data = array(); + foreach ($cisco_if_extension_oids as $oid) { + $ds_name = str_replace('cieIf', '', $oid); + $rrd_data[$ds_name] = $this_port[$oid]; + } + + /* + * Generate/update RRD + */ + $ifName = $port['ifName']; + $tags = compact('ifName', 'rrd_name', 'rrd_def'); + rrdtool_data_update($device, 'drops', $tags, $rrd_data); +} diff --git a/mibs/CISCO-IF-EXTENSION-MIB b/mibs/cisco/CISCO-IF-EXTENSION-MIB similarity index 100% rename from mibs/CISCO-IF-EXTENSION-MIB rename to mibs/cisco/CISCO-IF-EXTENSION-MIB