2016-01-21 21:18:14 +10:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* LibreNMS module to capture Cisco Class-Based QoS Details
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Aaron Daniels <aaron@daniels.id.au>
|
|
|
|
*
|
|
|
|
* 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") {
|
|
|
|
|
2016-01-26 23:31:07 +10:00
|
|
|
$module = 'Cisco-CBQOS';
|
2016-01-21 21:18:14 +10:00
|
|
|
|
|
|
|
require_once 'includes/component.php';
|
2016-01-26 23:31:07 +10:00
|
|
|
$component = new component();
|
|
|
|
$options['filter']['type'] = array('=',$module);
|
2016-01-21 21:18:14 +10:00
|
|
|
$options['filter']['disabled'] = array('=',0);
|
|
|
|
$options['filter']['ignore'] = array('=',0);
|
2016-01-26 23:31:07 +10:00
|
|
|
$components = $component->getComponents($device['device_id'],$options);
|
2016-01-21 21:18:14 +10:00
|
|
|
|
|
|
|
// We only care about our device id.
|
2016-01-26 23:31:07 +10:00
|
|
|
$components = $components[$device['device_id']];
|
2016-01-21 21:18:14 +10:00
|
|
|
|
|
|
|
// Only collect SNMP data if we have enabled components
|
2016-01-26 23:31:07 +10:00
|
|
|
if (count($components > 0)) {
|
2016-01-21 21:18:14 +10:00
|
|
|
// 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.
|
2016-01-26 23:31:07 +10:00
|
|
|
foreach ($components as $key => $array) {
|
|
|
|
$type = $array['qos-type'];
|
2016-01-21 21:18:14 +10:00
|
|
|
|
|
|
|
// Get data from the class table.
|
2016-01-26 23:31:07 +10:00
|
|
|
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";
|
2016-01-21 21:18:14 +10:00
|
|
|
$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.
|
2016-01-26 23:31:07 +10:00
|
|
|
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");
|
2016-01-21 21:18:14 +10:00
|
|
|
|
2016-01-26 23:31:07 +10:00
|
|
|
$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']];
|
2016-01-21 21:18:14 +10:00
|
|
|
|
2016-01-26 23:31:07 +10:00
|
|
|
// Update rrd
|
|
|
|
rrdtool_update ($rrd_filename, $rrd);
|
2016-01-21 21:18:14 +10:00
|
|
|
|
|
|
|
// Clean-up after yourself!
|
|
|
|
unset($filename, $rrd_filename);
|
|
|
|
}
|
|
|
|
} // End foreach components
|
|
|
|
|
2016-01-26 23:31:07 +10:00
|
|
|
echo $module." ";
|
2016-01-21 21:18:14 +10:00
|
|
|
} // end if count components
|
|
|
|
|
|
|
|
// Clean-up after yourself!
|
2016-01-26 23:31:07 +10:00
|
|
|
unset($type, $components, $component, $options, $module);
|
2016-01-21 21:18:14 +10:00
|
|
|
}
|