mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
add IPSLA support
git-svn-id: http://www.observium.org/svn/observer/trunk@3002 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -368,6 +368,29 @@ $config['auth_ldap_groups']['support']['level'] = 1;
|
||||
$config['astext'][65332] = "Cymru FullBogon Feed";
|
||||
$config['astext'][65333] = "Cymru Bogon Feed";
|
||||
|
||||
### Nicer labels for the SLA types
|
||||
$config['sla_type_labels']['echo'] = 'ICMP ping';
|
||||
$config['sla_type_labels']['pathEcho'] = 'Path ICMP ping';
|
||||
$config['sla_type_labels']['fileIO'] = 'File I/O';
|
||||
$config['sla_type_labels']['script'] = 'Script';
|
||||
$config['sla_type_labels']['udpEcho'] = 'UDP ping';
|
||||
$config['sla_type_labels']['tcpConnect'] = 'TCP connect';
|
||||
$config['sla_type_labels']['http'] = 'HTTP';
|
||||
$config['sla_type_labels']['dns'] = 'DNS';
|
||||
$config['sla_type_labels']['jitter'] = 'Jitter';
|
||||
$config['sla_type_labels']['dlsw'] = 'DLSW';
|
||||
$config['sla_type_labels']['dhcp'] = 'DHCP';
|
||||
$config['sla_type_labels']['ftp'] = 'FTP';
|
||||
$config['sla_type_labels']['voip'] = 'VoIP';
|
||||
$config['sla_type_labels']['rtp'] = 'RTP';
|
||||
$config['sla_type_labels']['lspGroup'] = 'LSP group';
|
||||
$config['sla_type_labels']['icmpjitter'] = 'ICMP jitter';
|
||||
$config['sla_type_labels']['lspPing'] = 'LSP ping';
|
||||
$config['sla_type_labels']['lspTrace'] = 'LSP trace';
|
||||
$config['sla_type_labels']['ethernetPing'] = 'Ethernet ping';
|
||||
$config['sla_type_labels']['ethernetJitter'] = 'Ethernet jitter';
|
||||
$config['sla_type_labels']['lspPingPseudowire'] = 'LSP Pseudowire ping';
|
||||
|
||||
### Warnings on front page
|
||||
$config['warn']['ifdown'] = TRUE; ## Show down interfaces
|
||||
|
||||
@@ -396,6 +419,7 @@ $config['poller_modules']['ospf'] = 1;
|
||||
$config['poller_modules']['cisco-ipsec-flow-monitor'] = 1;
|
||||
$config['poller_modules']['cisco-remote-access-monitor'] = 1;
|
||||
$config['poller_modules']['cisco-cef'] = 1;
|
||||
$config['poller_modules']['cisco-sla'] = 1;
|
||||
$config['poller_modules']['cisco-mac-accounting'] = 1;
|
||||
$config['poller_modules']['cipsec-tunnels'] = 1;
|
||||
$config['poller_modules']['cisco-ace-loadbalancer'] = 1;
|
||||
@@ -426,6 +450,7 @@ $config['discovery_modules']['cisco-mac-accounting'] = 1;
|
||||
$config['discovery_modules']['cisco-pw'] = 1;
|
||||
$config['discovery_modules']['cisco-vrf'] = 1;
|
||||
#$config['discovery_modules']['cisco-cef'] = 1;
|
||||
$config['discovery_modules']['cisco-sla'] = 1;
|
||||
$config['discovery_modules']['vmware-vminfo'] = 1;
|
||||
$config['discovery_modules']['libvirt-vminfo'] = 1;
|
||||
$config['discovery_modules']['toner'] = 1;
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
if ($config['enable_sla'] && $device['os_group'] == "cisco")
|
||||
{
|
||||
echo("SLAs : ");
|
||||
|
||||
$slas = snmp_walk($device, "ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl", "-Osq", "+CISCO-RTTMON-MIB");
|
||||
|
||||
$sla_table = array();
|
||||
foreach (explode("\n", $slas) 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 = $prop_id[0];
|
||||
$id = intval($prop_id[1]);
|
||||
|
||||
$sla_table[$id][$property] = trim($value);
|
||||
}
|
||||
|
||||
#var_dump($sla_table);
|
||||
|
||||
// Get existing SLAs
|
||||
$existing_slas = dbFetchColumn("SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `deleted` = 0", array('device_id' => $device['device_id']));
|
||||
|
||||
foreach ($sla_table as $sla_nr => $sla_config)
|
||||
{
|
||||
$query_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'sla_nr' => $sla_nr,
|
||||
);
|
||||
$sla_id = dbFetchCell("SELECT `sla_id` FROM `slas` WHERE `device_id` = :device_id AND `sla_nr` = :sla_nr", $query_data);
|
||||
|
||||
$data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'sla_nr' => $sla_nr,
|
||||
'owner' => $sla_config['rttMonCtrlAdminOwner'],
|
||||
'tag' => $sla_config['rttMonCtrlAdminTag'],
|
||||
'rtt_type' => $sla_config['rttMonCtrlAdminRttType'],
|
||||
'status' => ($sla_config['rttMonCtrlAdminStatus'] == 'active') ? 1 : 0,
|
||||
'deleted' => 0,
|
||||
);
|
||||
|
||||
// Some fallbacks for when the tag is empty
|
||||
if (!$data['tag'])
|
||||
{
|
||||
switch ($data['rtt_type'])
|
||||
{
|
||||
case 'http':
|
||||
$data['tag'] = $sla_config['rttMonEchoAdminURL'];
|
||||
break;
|
||||
|
||||
case 'dns':
|
||||
$data['tag'] = $sla_config['rttMonEchoAdminTargetAddressString'];
|
||||
break;
|
||||
|
||||
case 'echo':
|
||||
$parts = explode(" ", $sla_config['rttMonEchoAdminTargetAddress']);
|
||||
if (count($parts) == 4)
|
||||
{
|
||||
// IPv4
|
||||
$data['tag'] = implode(".", array_map('hexdec', $parts));
|
||||
}
|
||||
elseif (count($parts) == 16)
|
||||
{
|
||||
// IPv6
|
||||
$data['tag'] = $parts[0].$parts[1].':'.$parts[2].$parts[3].':'.$parts[4].$parts[5].':'.$parts[6].$parts[7].':'.$parts[8].$parts[9].':'.$parts[10].$parts[11].':'.$parts[12].$parts[13].':'.$parts[14].$parts[15];
|
||||
$data['tag'] = preg_replace('/:0*([0-9])/', ':$1', $data['tag']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !$sla_id )
|
||||
{
|
||||
$sla_id = dbInsert($data, 'slas');
|
||||
echo "+";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove from the list
|
||||
$existing_slas = array_diff($existing_slas, array($sla_id));
|
||||
|
||||
dbUpdate($data, 'slas', "`sla_id` = :sla_id", array('sla_id' => $sla_id));
|
||||
echo ".";
|
||||
}
|
||||
}
|
||||
|
||||
// Mark all remaining SLAs as deleted
|
||||
foreach ($existing_slas as $existing_sla)
|
||||
{
|
||||
dbUpdate(array('deleted' => 1), 'slas', "`sla_id` = :sla_id", array('sla_id' => $existing_sla));
|
||||
echo "-";
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
} # enable_sla && cisco
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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:%I:%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)
|
||||
{
|
||||
echo("SLA " . $sla['sla_nr'] . ": " . $sla['rtt_type'] . " " . $sla['owner'] . " " . $sla['tag']. "... ");
|
||||
|
||||
$slarrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sla-" . $sla['sla_nr'] . ".rrd");
|
||||
|
||||
if (!is_file($slarrd))
|
||||
{
|
||||
rrdtool_create($slarrd, "--step 300 \
|
||||
DS:rtt:GAUGE:600:0:300000 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:MIN:0.5:12:2400 \
|
||||
RRA:MAX:0.5:12:2400 \
|
||||
RRA:AVERAGE:0.5:12:2400");
|
||||
}
|
||||
|
||||
if (isset($sla_table[$sla['sla_nr']]))
|
||||
{
|
||||
$slaval = $sla_table[$sla['sla_nr']];
|
||||
echo($slaval['CompletionTime'] . "ms at " . $slaval['TimeStr']);
|
||||
|
||||
$ts = $slaval['UnixTime'];
|
||||
$val = $slaval['CompletionTime'];
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("NaN");
|
||||
|
||||
$ts = 'N';
|
||||
$val = 'U';
|
||||
}
|
||||
|
||||
rrdtool_update($slarrd,$ts.":".$val);
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user