Added Cisco QFP module (#10637)

* QFP Discovery module
* QFP Polling module - Utilization
* Add Cisco QFP module in module list
* Web UI QFP discovery module
* Add average packet size graph
* Health overview QFP graph
* Polling and UI improvements, test data
* Reformatting and style checks
* Readd snmprec data
* Fix module performance stats collecting
This commit is contained in:
pobradovic08
2019-10-05 11:10:34 +02:00
committed by PipoCanaja
parent 51e5521d9f
commit a2c69cd62f
17 changed files with 981 additions and 3 deletions

View File

@@ -815,6 +815,7 @@ $config['poller_modules']['cisco-asa-firewall'] = false;
$config['poller_modules']['cisco-voice'] = false;
$config['poller_modules']['cisco-cbqos'] = false;
$config['poller_modules']['cisco-otv'] = false;
$config['poller_modules']['cisco-qfp'] = false;
$config['poller_modules']['cisco-vpdn'] = false;
$config['poller_modules']['nac'] = false;
$config['poller_modules']['netscaler-vsvr'] = false;
@@ -846,6 +847,7 @@ $config['discovery_modules']['cisco-cef'] = false;
$config['discovery_modules']['cisco-sla'] = false;
$config['discovery_modules']['cisco-cbqos'] = false;
$config['discovery_modules']['cisco-otv'] = false;
$config['discovery_modules']['cisco-qfp'] = false;
$config['discovery_modules']['ipv4-addresses'] = true;
$config['discovery_modules']['ipv6-addresses'] = true;
$config['discovery_modules']['route'] = false;

View File

@@ -22,6 +22,7 @@ poller_modules:
cisco-otv: true
ipmi: false
cisco-vpdn: true
cisco-qfp: true
discovery_modules:
cisco-cef: true
cisco-sla: true
@@ -30,6 +31,7 @@ discovery_modules:
cisco-pw: true
vrf: true
cisco-vrf-lite: true
cisco-qfp: true
register_mibs:
ciscoAAASessionMIB: CISCO-AAA-SESSION-MIB
discovery:

View File

@@ -0,0 +1,123 @@
<?php
/**
* 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.
*
* LibreNMS module to capture Cisco QFP Statistics
*
* @package LibreNMS
* @subpackage discovery
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
if ($device['os_group'] == 'cisco') {
$module = 'cisco-qfp';
/*
* CISCO-ENTITY-QFP-MIB::ceqfpSystemState values
*/
$system_states = array(
1 => 'unknown',
2 => 'reset',
3 => 'init',
4 => 'active',
5 => 'activeSolo',
6 => 'standby',
7 => 'hotStandby'
);
/*
* CISCO-ENTITY-QFP-MIB::ceqfpSystemTrafficDirection values
*/
$system_traffic_direction = array (
1 => 'none',
2 => 'ingress',
3 => 'egress',
4 => 'both'
);
/*
* Get module's components for a device
*/
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], array('type'=>$module));
$components = $components[$device['device_id']];
/*
* Walk through CISCO-ENTITY-QFP-MIB::ceqfpSystemTable
*/
$qfp_general_data = snmpwalk_group($device, 'ceqfpSystemTable', 'CISCO-ENTITY-QFP-MIB');
if ($qfp_general_data) {
/*
* Loop through SNMP data and add or update components
*/
foreach ($qfp_general_data as $qfp_index => $data) {
/*
* Get entPhysicalName for QFP
*/
$qfp_name_oid = '.1.3.6.1.2.1.47.1.1.1.1.7.' . $qfp_index;
$qfp_name_data = snmp_get_multi_oid($device, [$qfp_name_oid]);
$qfp_name = $qfp_name_data[$qfp_name_oid];
/*
* Component data array for `component_prefs`
*/
$component_data = array(
'label' => 'qfp_' . $qfp_index,
'entPhysicalIndex' => $qfp_index,
'name' => $qfp_name,
'traffic_direction' => $system_traffic_direction[$data['ceqfpSystemTrafficDirection']],
'system_state' => $system_states[$data['ceqfpSystemState']],
'system_loads' => $data['ceqfpNumberSystemLoads'],
'system_last_load' => $data['ceqfpSystemLastLoadTime']
);
/*
* Find existing component ID if QFP is already known
*/
$component_id = false;
foreach ($components as $tmp_component_id => $tmp_component) {
if ($tmp_component['entPhysicalIndex'] == $qfp_index) {
$component_id = $tmp_component_id;
}
}
/*
* If $component_id is false QFP Component doesn't exist
* Create new component and add it to $components array
*/
if (!$component_id) {
$new_component = $component->createComponent($device['device_id'], $module);
$component_id = key($new_component);
$components[$component_id] = array_merge($new_component[$component_id], $component_data);
echo '+';
} else {
$components[$component_id] = array_merge($components[$component_id], $component_data);
echo '.';
}
}
}
/*
* Loop trough components, check against SNMP QFP indexes and delete if needed
*/
foreach ($components as $tmp_component_id => $tmp_component) {
$found = in_array($tmp_component['entPhysicalIndex'], array_keys($qfp_general_data));
if (!$found) {
$component->deleteComponent($tmp_component_id);
echo '-';
}
}
/*
* Save components
*/
$component->setComponentPrefs($device['device_id'], $components);
echo "\n";
}

View File

@@ -0,0 +1,52 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
/*
* Get module's components for a device
*/
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], array('type' => 'cisco-qfp'));
$components = $components[$device['device_id']];
/*
* Iterate over QFP components and create rrd_list array entry for each of them
*/
$i = 1;
foreach ($components as $component_id => $tmp_component) {
$rrd_filename = rrd_name($device['hostname'], array('cisco-qfp', 'util', $tmp_component['entPhysicalIndex']));
if (rrdtool_check_rrd_exists($rrd_filename)) {
$descr = short_hrDeviceDescr($tmp_component['name']);
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;
$rrd_list[$i]['ds'] = 'ProcessingLoad';
$rrd_list[$i]['area'] = 1;
$i++;
}
}
$unit_text = 'Util %';
$units = '';
$total_units = '%';
$colours = 'mixed';
$scale_min = '0';
$scale_max = '100';
$nototal = 1;
require 'includes/html/graphs/generic_multi_line.inc.php';

View File

@@ -0,0 +1,62 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage Authentication
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
/*
* Get a single module component with specified ID
*/
if (isset($vars['id'])) {
$component = new LibreNMS\Component();
$filter = array(
'filter' => array(
'type' => array('=', 'cisco-qfp'),
'id' => array('=', $vars['id'])
)
);
$components = $component->getComponents(null, $filter);
/*
* Fist (and only) key is the device ID
*/
$device_id = key($components);
/*
* Check if component exists and we're authenticated
*/
if ($components && isset($components[$device_id][$vars['id']]) && ($auth || device_permitted($device_id))) {
$components = $components[$device_id][$vars['id']];
$device = device_by_id_cache($device_id);
/*
* Data is split into just two RRD files, memory resources and utilization
*/
if ($subtype == 'memory') {
$rrd_filename = rrd_name($device['hostname'], array('cisco-qfp', 'memory', $components['entPhysicalIndex']));
} else {
$rrd_filename = rrd_name($device['hostname'], array('cisco-qfp', 'util', $components['entPhysicalIndex']));
}
/*
* Build title with breadcrumbs for module's main subpage
*/
$link_array = array(
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'health',
);
$title = generate_device_link($device);
$title .= ' :: ' . generate_link("QFP", $link_array, array('metric' => 'qfp'));
$title .= ' :: ' . $components['name'];
$auth = true;
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
$colour_area_in = 'AA66AA';
$colour_line_in = '330033';
$colour_area_out = 'FFDD88';
$colour_line_out = 'FF6600';
$colour_area_in_max = 'cc88cc';
$colour_area_out_max = 'FFefaa';
$graph_max = 1;
require 'includes/html/graphs/common.inc.php';
$stacked = generate_stacked_graphs();
$length = '10';
if (!isset($out_text)) {
$out_text = 'Out';
}
if (!isset($in_text)) {
$in_text = 'In';
}
$unit_text = str_pad(truncate($unit_text, $length), $length);
$in_text = str_pad(truncate($in_text, $length), $length);
$out_text = str_pad(truncate($out_text, $length), $length);
$rrd_options .= ' DEF:in_packets=' . $rrd_filename . ':InTotalPps:AVERAGE';
$rrd_options .= ' DEF:out_packets=' . $rrd_filename . ':OutTotalPps:AVERAGE';
$rrd_options .= ' DEF:in_bits=' . $rrd_filename . ':InTotalBps:AVERAGE';
$rrd_options .= ' DEF:out_bits=' . $rrd_filename . ':OutTotalBps:AVERAGE';
$rrd_options .= ' CDEF:in_throughput=in_bits,8,/';
$rrd_options .= ' CDEF:out_throughput=out_bits,8,/';
$rrd_options .= ' CDEF:in_avg=in_throughput,in_packets,/';
$rrd_options .= ' CDEF:out_avg_tmp=out_throughput,out_packets,/';
$rrd_options .= ' CDEF:out_avg=out_avg_tmp,-1,*';
$rrd_options .= ' AREA:in_avg#' . $colour_area_in . $stacked['transparency'] . ':';
$rrd_options .= " COMMENT:'Average packet size\\n'";
$rrd_options .= ' LINE1.25:in_avg#' . $colour_line_in . ":'" . $in_text . "'";
$rrd_options .= ' GPRINT:in_avg:AVERAGE:%6.2lf%sB';
$rrd_options .= " COMMENT:\\n";
$rrd_options .= ' AREA:out_avg#' . $colour_area_out . $stacked['transparency'] . ':';
$rrd_options .= ' LINE1.25:out_avg#' . $colour_line_out . ":'" . $out_text . "'";
$rrd_options .= ' GPRINT:out_avg_tmp:AVERAGE:%6.2lf%sB';
$rrd_options .= " COMMENT:\\n";
$rrd_options .= ' HRULE:0#999999';
unset($stacked);

View File

@@ -0,0 +1,86 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
require 'includes/html/graphs/common.inc.php';
$rrd_options .= ' -u 100 -l 0 -E -b 1024 ';
$iter = '1';
if ($width > '500') {
$descr_len = 13;
} else {
$descr_len = 8;
$descr_len += round(($width - 250) / 8);
}
if ($width > '500') {
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Total Used Free (Min Max Ave)'";
$rrd_options .= " COMMENT:'\l'";
} else {
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))."Total Used Free\l'";
}
$descr = rrdtool_escape(short_hrDeviceDescr($components['name']), $descr_len);
$perc = $components['memory_used']*100/$components['memory_total'];
$background = get_percentage_colours($perc, 75);
$rrd_options .= " DEF:qfp_used=$rrd_filename:InUse:AVERAGE";
$rrd_options .= " DEF:qfp_free=$rrd_filename:Free:AVERAGE";
$rrd_options .= " DEF:qfp_size=$rrd_filename:Total:AVERAGE";
$rrd_options .= " DEF:qfp_low_watermark=$rrd_filename:LowFreeWatermark:AVERAGE";
$rrd_options .= " DEF:qfp_ok_th=$rrd_filename:FallingThreshold:AVERAGE";
$rrd_options .= " DEF:qfp_warn_th=$rrd_filename:RisingThreshold:AVERAGE";
$rrd_options .= " CDEF:qfp_perc=qfp_used,qfp_size,/,100,*";
$rrd_options .= " CDEF:qfp_percx=100,qfp_perc,-";
$rrd_options .= " AREA:qfp_perc#".$background['right'].':';
$rrd_options .= " CDEF:qfp_tmp_wmark=qfp_low_watermark,qfp_size,/,100,*";
$rrd_options .= " CDEF:qfp_perc_wmark=100,qfp_tmp_wmark,-";
if ($width > '500') {
$rrd_options .= " LINE1.25:qfp_perc#".$background['left'].":'$descr'";
$rrd_options .= " GPRINT:qfp_size:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:qfp_used:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:qfp_free:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:qfp_free:MIN:%5.2lf%sB";
$rrd_options .= " GPRINT:qfp_free:MAX:%5.2lf%sB";
$rrd_options .= " GPRINT:qfp_free:AVERAGE:%5.2lf%sB\\n";
$rrd_options .= " COMMENT:'".substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12))." '";
$rrd_options .= " GPRINT:qfp_perc:LAST:'%6.2lf%% '";
$rrd_options .= " GPRINT:qfp_percx:LAST:'%6.2lf%% '";
$rrd_options .= " GPRINT:qfp_perc:MIN:'%5.2lf%% '";
$rrd_options .= " GPRINT:qfp_perc:MAX:'%5.2lf%% '";
$rrd_options .= " GPRINT:qfp_perc:AVERAGE:%5.2lf%%\\n";
$rrd_options .= " LINE2:qfp_perc_wmark#ffaaaa:'Most used'";
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " LINE1:qfp_warn_th#aa0000:'Threshold':dashes";
} else {
$rrd_options .= " LINE1.25:qfp_perc#".$background['left'].":'$descr'";
$rrd_options .= " GPRINT:qfp_size:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:qfp_used:LAST:%6.2lf%sB";
$rrd_options .= " GPRINT:qfp_free:LAST:%6.2lf%sB";
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " COMMENT:'".substr(str_pad('', ($descr_len + 12)), 0, ($descr_len + 12))." '";
$rrd_options .= " GPRINT:qfp_perc:LAST:'%5.2lf%% '";
$rrd_options .= " GPRINT:qfp_percx:LAST:'%5.2lf%% '";
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " LINE2:qfp_perc_wmark#ffaaaa:'Most used'";
$rrd_options .= " COMMENT:'\l'";
$rrd_options .= " LINE1:qfp_warn_th#aa0000:'Threshold':dashes";
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
/*
* Priority packets handled by QFP
*/
$i = 1;
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $components['name'];
$rrd_list[$i]['ds_in'] = 'InPriorityPps';
$rrd_list[$i]['ds_out'] = 'OutPriorityPps';
$rrd_list[$i]['descr'] = 'Priority';
$rrd_list[$i]['colour_area_in'] = 'FACF5A';
$rrd_list[$i]['colour_area_out'] = 'FF5959';
/*
* Non-priority packets handled by QFP
*/
$i =2;
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $components['name'];
$rrd_list[$i]['ds_in'] = 'InNonPriorityPps';
$rrd_list[$i]['ds_out'] = 'OutNonPriorityPps';
$rrd_list[$i]['descr'] = 'NonPriority';
$rrd_list[$i]['colour_area_in'] = '085F63';
$rrd_list[$i]['colour_area_out'] = '49BEB7';
$units = 'pps';
$units_descr = 'Packets/s';
$colours_in = 'purples';
$multiplier = '1';
$colours_out = 'oranges';
$args['nototal'] = 1;
include 'includes/html/graphs/generic_multi_seperated.inc.php';

View File

@@ -0,0 +1,38 @@
<?php
/**
* 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.
*
* Display relative QFP utilization (in %) to kpps processed
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
$colour_line = 'cc0000';
$colour_area = 'FFBBBB';
$colour_minmax = 'c5c5c5';
$graph_max = 1;
$line_text = $components['name'];
include 'includes/html/graphs/common.inc.php';
$line_text = str_pad(substr($line_text, 0, 12), 12);
$rrd_options .= ' DEF:in_pkts='.$rrd_filename.':InTotalPps:AVERAGE';
$rrd_options .= ' DEF:out_pkts='.$rrd_filename.':OutTotalPps:AVERAGE';
$rrd_options .= ' DEF:load='.$rrd_filename.':ProcessingLoad:AVERAGE';
$rrd_options .= ' CDEF:total_kpps=in_pkts,out_pkts,+,1000,/';
$rrd_options .= ' CDEF:relative=load,total_kpps,/';
$rrd_options .= ' AREA:relative#'.$colour_area.':';
$rrd_options .= " COMMENT:'Load % per 1kpps'\\n";
$rrd_options .= ' LINE1.25:relative#'.$colour_line.":'".$line_text."'";
$rrd_options .= " COMMENT:\\n";

View File

@@ -0,0 +1,50 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
/*
* Priority packets handled by QFP
*/
$i = 1;
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $components['name'];
$rrd_list[$i]['ds_in'] = 'InPriorityBps';
$rrd_list[$i]['ds_out'] = 'OutPriorityBps';
$rrd_list[$i]['descr'] = 'Priority';
$rrd_list[$i]['colour_area_in'] = 'FACF5A';
$rrd_list[$i]['colour_area_out'] = 'FF5959';
/*
* Non-priority packets handled by QFP
*/
$i = 2;
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $components['name'];
$rrd_list[$i]['ds_in'] = 'InNonPriorityBps';
$rrd_list[$i]['ds_out'] = 'OutNonPriorityBps';
$rrd_list[$i]['descr'] = 'NonPriority';
$rrd_list[$i]['colour_area_in'] = '608720';
$rrd_list[$i]['colour_area_out'] = '606090';
$units = 'pps';
$units_descr = 'Bits/s';
$colours_in = 'purples';
$multiplier = '1';
$colours_out = 'oranges';
$args['nototal'] = 1;
include 'includes/html/graphs/generic_multi_seperated.inc.php';

View File

@@ -0,0 +1,29 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
$scale_min = '0';
$scale_max = '100';
$ds = 'ProcessingLoad';
$colour_line = 'cc0000';
$colour_area = 'FFBBBB';
$colour_minmax = 'c5c5c5';
$graph_max = 1;
$unit_text = 'Utilization';
$line_text = $components['name'];
require 'includes/html/graphs/generic_simplex.inc.php';

View File

@@ -5,6 +5,18 @@ $diskio = get_disks($device['device_id']);
$mempools = dbFetchCell('select count(*) from mempools WHERE device_id = ?', array($device['device_id'])) + count_mib_mempools($device);
$processor = dbFetchCell('select count(*) from processors WHERE device_id = ?', array($device['device_id'])) + count_mib_processors($device);
/*
* QFP count for cisco devices
*/
$qfp = 0;
if ($device['os_group'] == 'cisco') {
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], array('type'=> 'cisco-qfp'));
$components = $components[$device['device_id']];
$qfp = count($components);
}
$count = dbFetchCell("select count(*) from sensors WHERE sensor_class='count' AND device_id = ?", array($device['device_id']));
$temperatures = dbFetchCell("select count(*) from sensors WHERE sensor_class='temperature' AND device_id = ?", array($device['device_id']));
$humidity = dbFetchCell("select count(*) from sensors WHERE sensor_class='humidity' AND device_id = ?", array($device['device_id']));
@@ -38,6 +50,10 @@ if ($processor) {
$datas[] = 'processor';
}
if ($qfp) {
$datas[] = 'qfp';
}
if ($mempools) {
$datas[] = 'mempool';
}
@@ -185,6 +201,7 @@ $type_text['chromatic_dispersion'] = 'Chromatic Dispersion';
$type_text['ber'] = 'Bit Error Rate';
$type_text['eer'] = 'Energy Efficiency Ratio';
$type_text['waterflow'] = 'Water Flow Rate';
$type_text['qfp'] = 'QFP';
$link_array = array(
'page' => 'device',
@@ -225,7 +242,6 @@ if (is_file("includes/html/pages/device/health/$metric.inc.php")) {
if ($type != 'overview') {
$graph_title = $type_text[$type];
$graph_array['type'] = 'device_'.$type;
include 'includes/html/print-device-graph.php';
}
}

View File

@@ -0,0 +1,214 @@
<?php
/**
* 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.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
/*
* Get module's components for a device
*/
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], array('type' => 'cisco-qfp'));
$components = $components[$device['device_id']];
foreach ($components as $component_id => $tmp_component) {
$default_graph_array = array(
'from' => \LibreNMS\Config::get('time.day'),
'to' => \LibreNMS\Config::get('time.now'),
'id' => $component_id,
'page' => 'graphs'
);
/*
* Main container for QFP component
* Header with system data
*/
switch ($tmp_component['system_state']) {
case 'active':
case 'activeSolo':
case 'standby':
case 'hotStandby':
$state_label = 'label-success';
break;
case 'reset':
$state_label = 'label-danger';
break;
case 'init':
$state_label = 'label-warning';
break;
default:
$state_label = 'label-default';
}
switch ($tmp_component['traffic_direction']) {
case 'none':
$direction_label = 'label-danger';
break;
case 'ingress':
case 'egress':
$direction_label = 'label-wanring';
break;
case 'both':
$direction_label = 'label-success';
break;
default:
$direction_label = 'label-default';
}
$text_descr = $tmp_component['name'];
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<div class='pull-left'>
<h2 style='margin: 0 5pt 0 0'><i class=\"fa fa-microchip fa-lg icon-theme\" aria-hidden=\"true\"></i></h2>
</div>
<h2 class='panel-title'><b>$text_descr</b>
<div class='pull-right'>
<span class='label {$state_label}'>State: {$tmp_component['system_state']}</span>
<span class='label {$direction_label}'>
Traffic direction: {$tmp_component['traffic_direction']}
</span>
</div>
</h2>
Last system load at <b>{$tmp_component['system_last_load']}</b>
</div>";
echo "<div class='panel-body'>";
/*
* QFP Utilization (Load)
*/
if ($tmp_component['utilization'] < 50) {
$util_label = 'label-success';
} elseif ($tmp_component['utilization'] < 75) {
$util_label = 'label-warning';
} else {
$util_label = 'label-danger';
}
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_util';
$text_descr = 'QFP Utilization';
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
$text_descr
<div class='pull-right'><span class='label {$util_label}'>{$tmp_component['utilization']} %</span></div>
</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
/*
* Relative QFP utilization to packets processed
*/
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_relativeutil';
$text_descr = 'QFP Relative utilization per kpps';
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>$text_descr</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
/*
* QFP Packets In/Out
*/
$packets_label = 'label-default';
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_packets';
$text_descr = 'QFP packets';
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
$text_descr
<div class='pull-right'>
<span class='label {$packets_label}'>" . format_bi($tmp_component['packets']) . "pps</span>
</div>
</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
/*
* QFP Throughput In/Out
*/
$throughput_label = 'label-default';
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_throughput';
$text_descr = 'QFP Throughput';
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
$text_descr
<div class='pull-right'>
<span class='label {$throughput_label}'>" . format_bi($tmp_component['throughput']) . "bps</span>
</div>
</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
/*
* QFP Average packet size
*/
$psize_label = 'label-default';
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_avgpktsize';
$text_descr = 'QFP Average packet size';
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
$text_descr
<div class='pull-right'>
<span class='label {$psize_label}'>" . ceil($tmp_component['average_packet']) . " Bytes</span>
</div>
</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
/*
* QFP Memory resources
*/
$mem_prec = $tmp_component['memory_used']*100/$tmp_component['memory_total'];
if ($mem_prec < 75) {
$mem_label = 'label-success';
} elseif ($mem_prec < 90) {
$mem_label = 'label-warning';
} else {
$mem_label = 'label-danger';
}
$graph_array = $default_graph_array;
$graph_array['type'] = 'qfp_memory';
$text_descr = 'QFP Memory';
$label_text = sprintf("%sB / %sB", format_bi($tmp_component['memory_used']), format_bi($tmp_component['memory_total']));
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>
$text_descr
<div class='pull-right'><span class='label {$mem_label}'>{$label_text}</span></div>
</h3>
</div>";
echo "<div class='panel-body'>";
include 'includes/html/print-graphrow.inc.php';
echo "</div></div>";
echo "</div></div>";
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* 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.
*
* LibreNMS module to capture Cisco QFP Statistics
*
* @package LibreNMS
* @subpackage polling
* @link http://librenms.org
* @copyright 2019 LibreNMS
* @author Pavle Obradovic <pobradovic08@gmail.com>
*/
use LibreNMS\RRD\RrdDefinition;
$module = 'cisco-qfp';
/*
* Fetch device components and filter ignored or disabled ones
*/
$options = array(
'filter' => array(
'type' => array('=', $module),
'disabled' => array('=', 0),
'ignore' => array('=', 0)
)
);
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], $options);
$components = $components[$device['device_id']];
/*
* SNMP makes available multiple datapoints dependnet on the time interval
* Use 5min for now but if in future LibreNMS polling interval is set through
* config file we can use this to quickly select best time interval
*/
$time_interval_array = array(
'5sec' => 1,
'1min' => 2,
'5min' => 3,
'1h' => 4
);
$ti = $time_interval_array['5min'];
if (!empty($components) && is_array($components)) {
foreach ($components as $component_id => $tmp_component) {
/*
* Build OIDs and use snmpget to fetch multiple OIDs at once instead of snmpwalk
*/
$qfp_index = $tmp_component['entPhysicalIndex'];
/*
* ceqfpUtilizationEntry table has `entPhysicalIndex` and `ceqfpUtilTimeInterval` indexes
*/
$util_oid_suffix = $qfp_index . '.' . $ti;
$util_oids = array(
'InPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.2.' . $util_oid_suffix,
'InPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.3.' . $util_oid_suffix,
'InNonPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.4.' . $util_oid_suffix,
'InNonPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.5.' . $util_oid_suffix,
'InTotalPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.6.' . $util_oid_suffix,
'InTotalBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.7.' . $util_oid_suffix,
'OutPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.8.' . $util_oid_suffix,
'OutPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.9.' . $util_oid_suffix,
'OutNonPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.10.' . $util_oid_suffix,
'OutNonPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.11.' . $util_oid_suffix,
'OutTotalPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.12.' . $util_oid_suffix,
'OutTotalBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.13.' . $util_oid_suffix,
'ProcessingLoad' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.14.' . $util_oid_suffix
);
/*
* ceqfpMemoryResourceEntry table has `entPhysicalIndex` and `ceqfpMemoryResType` indexes
* ceqfpMemoryResType has the only one valid value (1: dram)
*/
$mem_oid_suffix = $qfp_index . '.1';
$memory_oids = array(
'RisingThreshold' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.6.' . $mem_oid_suffix,
'FallingThreshold' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.7.' . $mem_oid_suffix,
'LowFreeWatermark' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.15.' . $mem_oid_suffix,
'Total' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.9.' . $mem_oid_suffix,
'InUse' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.11.' . $mem_oid_suffix,
'Free' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.13.' . $mem_oid_suffix
);
/*
* Get SNMP data
*/
$util_data = snmp_get_multi_oid($device, array_values($util_oids));
$memory_data = snmp_get_multi_oid($device, array_values($memory_oids));
/*
* Check if the oids exist
* Possible FP linecard OIR between discovery and polling calls
*/
if (!empty($util_data) && !empty($memory_data)) {
$total_packets = $util_data[$util_oids['InTotalPps']] + $util_data[$util_oids['OutTotalPps']];
$throughput = $util_data[$util_oids['InTotalBps']] + $util_data[$util_oids['OutTotalBps']];
$average_packet = $throughput / 8 / $total_packets;
/*
* Create component data array for `component_prefs`
* and update components
*/
$component_data = array(
'utilization' => $util_data[$util_oids['ProcessingLoad']],
'packets' => $total_packets,
'throughput' => $throughput,
'average_packet' => $average_packet,
'memory_total' => $memory_data[$memory_oids['Total']],
'memory_used' => $memory_data[$memory_oids['InUse']],
'memory_free' => $memory_data[$memory_oids['Free']]
);
$components[$component_id] = array_merge($components[$component_id], $component_data);
/*
* Create Utilization RRDs
*/
$rrd_name = array($module, 'util', $qfp_index);
$rrd_def = RrdDefinition::make();
foreach ($util_oids as $name => $oid) {
$rrd_def->addDataset($name, 'GAUGE', 0);
$rrd[$name] = $util_data[$util_oids[$name]];
}
$tags = compact('module', 'rrd_name', 'rrd_def', 'qfp_index');
data_update($device, $module, $tags, $rrd);
unset($filename, $rrd_filename, $rrd_name, $rrd_def, $rrd);
/*
* Create Utilization RRDs
*/
$rrd_name = array($module, 'memory', $qfp_index);
$rrd_def = RrdDefinition::make();
foreach ($memory_oids as $name => $oid) {
$rrd_def->addDataset($name, 'GAUGE', 0);
$rrd[$name] = $memory_data[$memory_oids[$name]];
}
$tags = compact('module', 'rrd_name', 'rrd_def', 'qfp_index');
data_update($device, $module, $tags, $rrd);
unset($filename, $rrd_filename, $rrd_name, $rrd_def, $rrd);
}
}
/*
* Update DB Components
*/
$component->setComponentPrefs($device['device_id'], $components);
}
unset($component, $components);

View File

@@ -62,6 +62,9 @@
"cisco-cbqos": {
"type": "boolean"
},
"cisco-qfp": {
"type": "boolean"
},
"cisco-cef": {
"type": "boolean"
},
@@ -203,6 +206,9 @@
"discovery_modules": {
"type": "object",
"properties": {
"cisco-qfp": {
"type": "boolean"
},
"cisco-cef": {
"type": "boolean"
},

View File

@@ -492,7 +492,7 @@
"processor_oid": ".1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.3",
"processor_index": "9026.3",
"processor_type": "qfp",
"processor_usage": 7,
"processor_usage": 6,
"processor_descr": "qfp F0/0",
"processor_precision": 1,
"processor_perc_warn": 75

View File

@@ -131,8 +131,30 @@
1.3.6.1.4.1.9.9.187.1.2.8.1.7.2.16.32.1.13.184.133.163.0.0.52.26.138.46.3.226.0.161.2.128|66|0
1.3.6.1.4.1.9.9.187.1.2.8.1.8.2.16.32.1.13.184.133.163.0.0.52.26.138.46.3.225.0.13.2.128|66|0
1.3.6.1.4.1.9.9.187.1.2.8.1.8.2.16.32.1.13.184.133.163.0.0.52.26.138.46.3.226.0.161.2.128|66|0
1.3.6.1.4.1.9.9.715.1.1.1.1.1.9026|2|4
1.3.6.1.4.1.9.9.715.1.1.1.1.2.9026|2|5
1.3.6.1.4.1.9.9.715.1.1.1.1.3.9026|65|1
1.3.6.1.4.1.9.9.715.1.1.1.1.4.9026|4x|07E301120F263B00
1.3.6.1.4.1.9.9.715.1.1.6.1.2.9026.3|70|5
1.3.6.1.4.1.9.9.715.1.1.6.1.3.9026.3|70|4256
1.3.6.1.4.1.9.9.715.1.1.6.1.4.9026.3|70|539531
1.3.6.1.4.1.9.9.715.1.1.6.1.5.9026.3|70|3423105432
1.3.6.1.4.1.9.9.715.1.1.6.1.6.9026.3|70|539536
1.3.6.1.4.1.9.9.715.1.1.6.1.7.9026.3|70|3423109688
1.3.6.1.4.1.9.9.715.1.1.6.1.8.9026.3|70|27
1.3.6.1.4.1.9.9.715.1.1.6.1.9.9026.3|70|30912
1.3.6.1.4.1.9.9.715.1.1.6.1.10.9026.3|70|539536
1.3.6.1.4.1.9.9.715.1.1.6.1.11.9026.3|70|3441364544
1.3.6.1.4.1.9.9.715.1.1.6.1.12.9026.3|70|539563
1.3.6.1.4.1.9.9.715.1.1.6.1.13.9026.3|70|3441395456
1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.1|66|7
1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.2|66|7
1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.3|66|7
1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.3|66|6
1.3.6.1.4.1.9.9.715.1.1.6.1.14.9026.4|66|7
1.3.6.1.4.1.9.9.715.1.1.7.1.6.9026.1|66|97
1.3.6.1.4.1.9.9.715.1.1.7.1.7.9026.1|66|93
1.3.6.1.4.1.9.9.715.1.1.7.1.9.9026.1|70|2147483648
1.3.6.1.4.1.9.9.715.1.1.7.1.11.9026.1|70|355310592
1.3.6.1.4.1.9.9.715.1.1.7.1.13.9026.1|70|1792173056
1.3.6.1.4.1.9.9.715.1.1.7.1.15.9026.1|70|1715415040
1.3.6.1.6.3.10.2.1.3.0|2|8523