librenms-librenms/includes/polling/cisco-sla.inc.php

62 lines
1.7 KiB
PHP
Raw Normal View History

<?php
$uptime = snmp_get($device, 'sysUpTime.0', '-Otv');
$time_offset = (time() - intval($uptime) / 100);
$slavals = snmp_walk($device, 'ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl.rttMonLatestRttOperTable', '-OUsqt', '+CISCO-RTTMON-MIB');
$sla_table = array();
foreach (explode("\n", $slavals) as $sla) {
$key_val = explode(' ', $sla, 2);
if (count($key_val) != 2) {
$key_val[] = '';
}
$key = $key_val[0];
$value = $key_val[1];
$prop_id = explode('.', $key);
if ((count($prop_id) != 2) || !ctype_digit($prop_id[1])) {
continue;
}
$property = str_replace('rttMonLatestRttOper', '', $prop_id[0]);
$id = intval($prop_id[1]);
$sla_table[$id][$property] = trim($value);
}
// Update timestamps
foreach ($sla_table as &$sla) {
$sla['UnixTime'] = intval(($sla['Time'] / 100 + $time_offset));
$sla['TimeStr'] = strftime('%Y-%m-%d %H:%M:%S', $sla['UnixTime']);
}
unset($sla);
foreach (dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0 AND `status` = 1', array($device['device_id'])) as $sla) {
$sla_nr = $sla['sla_nr'];
echo 'SLA '. $sla_nr .': '.$sla['rtt_type'].' '.$sla['owner'].' '.$sla['tag'].'... ';
if (isset($sla_table[$sla_nr])) {
$slaval = $sla_table[$sla_nr];
echo $slaval['CompletionTime'].'ms at '.$slaval['TimeStr'];
$val = $slaval['CompletionTime'];
}
else {
echo 'NaN';
$val = 'U';
}
$rrd_name = array('sla', $sla_nr);
$rrd_def = 'DS:rtt:GAUGE:600:0:300000';
$fields = array(
'rtt' => $val,
);
$tags = compact('sla_nr', 'rrd_name', 'rrd_def');
data_update($device,'sla',$tags,$fields);
2015-08-19 20:58:02 +00:00
echo "\n";
}//end foreach