mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Merge branch 'master' into issue-4062
Conflicts: includes/definitions.inc.php
This commit is contained in:
		@@ -4,22 +4,23 @@ $name = 'ceph';
 | 
			
		||||
if (!empty($agent_data['app'][$name])) {
 | 
			
		||||
    $app_id = $app['app_id'];
 | 
			
		||||
 | 
			
		||||
    foreach (explode('<', $agent_raw) as $section) {
 | 
			
		||||
    foreach (explode('<', $agent_data['app'][$name]) as $section) {
 | 
			
		||||
        if (empty($section))
 | 
			
		||||
            continue;
 | 
			
		||||
        list($section, $data) = explode('>', $section);
 | 
			
		||||
 | 
			
		||||
        if ($section == "poolstats") {
 | 
			
		||||
            $rrd_def = array(
 | 
			
		||||
                'DS:ops:GAUGE:600:0:U',
 | 
			
		||||
                'DS:wrbytes:GAUGE:600:0:U',
 | 
			
		||||
                'DS:rbytes:GAUGE:600:0:U'
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach (explode("\n", $data) as $line) {
 | 
			
		||||
                if (empty($line))
 | 
			
		||||
                    continue;
 | 
			
		||||
                list($pool,$ops,$wrbytes,$rbytes) = explode(':', $line);
 | 
			
		||||
                $rrd_name = array('app', $name, $app_id, 'pool'.$pool);
 | 
			
		||||
                $rrd_def = array(
 | 
			
		||||
                    'DS:ops:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:wrbytes:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:rbytes:GAUGE:600:0:U'
 | 
			
		||||
                );
 | 
			
		||||
                $rrd_name = array('app', $name, $app_id, 'pool', $pool);
 | 
			
		||||
 | 
			
		||||
                print "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n";
 | 
			
		||||
                $fields = array(
 | 
			
		||||
@@ -27,42 +28,43 @@ if (!empty($agent_data['app'][$name])) {
 | 
			
		||||
                    'wrbytes' => $wrbytes,
 | 
			
		||||
                    'rbytes' => $rbytes
 | 
			
		||||
                );
 | 
			
		||||
                $tags = compact($name, $app_id, $pool, $rrd_name, $rrd_def);
 | 
			
		||||
                $tags = compact('name', 'app_id', 'pool', 'rrd_name', 'rrd_def');
 | 
			
		||||
                data_update($device, 'app', $tags, $fields);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        elseif ($section == "osdperformance") {
 | 
			
		||||
            $rrd_def = array(
 | 
			
		||||
                'DS:apply_ms:GAUGE:600:0:U',
 | 
			
		||||
                'DS:commit_ms:GAUGE:600:0:U'
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach (explode("\n", $data) as $line) {
 | 
			
		||||
                if (empty($line))
 | 
			
		||||
                    continue;
 | 
			
		||||
                list($osd,$apply,$commit) = explode(':', $line);
 | 
			
		||||
                $rrd_name = array('app', $name, $app_id, 'osd'.$osd);
 | 
			
		||||
                $rrd_def = array(
 | 
			
		||||
                    'DS:apply_ms:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:commit_ms:GAUGE:600:0:U'
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                $rrd_name = array('app', $name, $app_id, 'osd', $osd);
 | 
			
		||||
 | 
			
		||||
                print "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n";
 | 
			
		||||
                $fields = array(
 | 
			
		||||
                    'apply_ms' => $apply,
 | 
			
		||||
                    'commit_ms' => $commit
 | 
			
		||||
                );
 | 
			
		||||
                $tags = compact($name, $app_id, $osd, $rrd_name, $rrd_def);
 | 
			
		||||
                $tags = compact('name', 'app_id', 'osd', 'rrd_name', 'rrd_def');
 | 
			
		||||
                data_update($device, 'app', $tags, $fields);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        elseif ($section == "df") {
 | 
			
		||||
            $rrd_def = array(
 | 
			
		||||
                'DS:avail:GAUGE:600:0:U',
 | 
			
		||||
                'DS:used:GAUGE:600:0:U',
 | 
			
		||||
                'DS:objects:GAUGE:600:0:U'
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach (explode("\n", $data) as $line) {
 | 
			
		||||
                if (empty($line))
 | 
			
		||||
                    continue;
 | 
			
		||||
                list($df,$avail,$used,$objects) = explode(':', $line);
 | 
			
		||||
                $rrd_name = array('app', $name, $app_id, 'df', $df);
 | 
			
		||||
                $rrd_def = array(
 | 
			
		||||
                    'DS:avail:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:used:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:objects:GAUGE:600:0:U'
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                print "Ceph Pool DF: $pool, Avail: $avail, Used: $used, Objects: $objects\n";
 | 
			
		||||
                $fields = array(
 | 
			
		||||
@@ -71,7 +73,7 @@ if (!empty($agent_data['app'][$name])) {
 | 
			
		||||
                    'objects' => $objects
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                $tags = compact($name, $app_id, $df, $rrd_name, $rrd_def);
 | 
			
		||||
                $tags = compact('name', 'app_id', 'df', 'rrd_name', 'rrd_def');
 | 
			
		||||
                data_update($device, 'app', $tags, $fields);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,5 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
$name = 'proxmox';
 | 
			
		||||
$app_id = $app['app_id'];
 | 
			
		||||
if (isset($config['enable_proxmox']) && $config['enable_proxmox'] && !empty($agent_data['app'][$name])) {
 | 
			
		||||
    $proxmox = $agent_data['app'][$name];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Check if a port on a Proxmox VM exists
 | 
			
		||||
 * @param string  $p Port name
 | 
			
		||||
@@ -41,57 +35,72 @@ function proxmox_vm_exists($i, $c, &$pmxcache) {
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$pmxlines = explode("\n", $proxmox);
 | 
			
		||||
$name = 'proxmox';
 | 
			
		||||
$app_id = $app['app_id'];
 | 
			
		||||
 | 
			
		||||
$pmxcluster = array_shift($pmxlines);
 | 
			
		||||
 | 
			
		||||
$pmxcdir = join('/', array($config['rrd_dir'], $name, $pmxcluster));
 | 
			
		||||
if (!is_dir($pmxcdir)) {
 | 
			
		||||
    mkdir($pmxcdir, 0775, true);
 | 
			
		||||
if (isset($config['enable_proxmox']) && $config['enable_proxmox'] && !empty($agent_data['app'][$name])) {
 | 
			
		||||
    $proxmox = $agent_data['app'][$name];
 | 
			
		||||
} elseif (isset($config['enable_proxmox']) && $config['enable_proxmox']) {
 | 
			
		||||
    $options = '-O qv';
 | 
			
		||||
    $oid     = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.112.114.111.120.109.111.120';
 | 
			
		||||
    $proxmox = snmp_get($device, $oid, $options);
 | 
			
		||||
    $proxmox = preg_replace('/^.+\n/', '', $proxmox);
 | 
			
		||||
    $proxmox = str_replace("<<<app-proxmox>>>\n", '', $proxmox);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
dbUpdate(array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $name));
 | 
			
		||||
if ($proxmox) {
 | 
			
		||||
    $pmxlines = explode("\n", $proxmox);
 | 
			
		||||
    $pmxcluster = array_shift($pmxlines);
 | 
			
		||||
    dbUpdate(array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster),
 | 
			
		||||
        'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], $name));
 | 
			
		||||
 | 
			
		||||
if (count($pmxlines) > 0) {
 | 
			
		||||
    $pmxcache = array();
 | 
			
		||||
    if (count($pmxlines) > 0) {
 | 
			
		||||
        $pmxcache = array();
 | 
			
		||||
 | 
			
		||||
    foreach ($pmxlines as $vm) {
 | 
			
		||||
        list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5);
 | 
			
		||||
        print "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n";
 | 
			
		||||
        foreach ($pmxlines as $vm) {
 | 
			
		||||
            list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5);
 | 
			
		||||
            print "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n";
 | 
			
		||||
 | 
			
		||||
        $rrd_name = join('/', array($name, $pmxcluster, $vmid)).'_netif_'.$vmport;
 | 
			
		||||
        $rrd_def = array(
 | 
			
		||||
            'DS:INOCTETS:DERIVE:600:0:12500000000',
 | 
			
		||||
            'DS:OUTOCTETS:DERIVE:600:0:12500000000'
 | 
			
		||||
        );
 | 
			
		||||
        $fields = array(
 | 
			
		||||
            'INOCTETS' => $vmpin,
 | 
			
		||||
            'OUTOCTETS' => $vmpout
 | 
			
		||||
        );
 | 
			
		||||
            $rrd_proxmox_name = array(
 | 
			
		||||
                'pmxcluster' => $pmxcluster,
 | 
			
		||||
                'vmid' => $vmid,
 | 
			
		||||
                'vmport' => $vmport
 | 
			
		||||
            );
 | 
			
		||||
            $rrd_def = array(
 | 
			
		||||
                'DS:INOCTETS:DERIVE:600:0:12500000000',
 | 
			
		||||
                'DS:OUTOCTETS:DERIVE:600:0:12500000000'
 | 
			
		||||
            );
 | 
			
		||||
            $fields = array(
 | 
			
		||||
                'INOCTETS' => $vmpin,
 | 
			
		||||
                'OUTOCTETS' => $vmpout
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
        $tags = compact('name', 'app_id', 'pmxcluster', 'vmid', 'vmport', 'rrd_name', 'rrd_def');
 | 
			
		||||
        data_update($device, 'app', $tags, $fields);
 | 
			
		||||
            $tags = compact('name', 'app_id', 'pmxcluster', 'vmid', 'vmport', 'rrd_proxmox_name', 'rrd_def');
 | 
			
		||||
            data_update($device, 'app', $tags, $fields);
 | 
			
		||||
 | 
			
		||||
        if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) {
 | 
			
		||||
            dbUpdate(array('device_id' => $device['device_id'], 'last_seen' => array('NOW()'), 'description' => $vmdesc), $name, '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster));
 | 
			
		||||
            if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) {
 | 
			
		||||
                dbUpdate(array(
 | 
			
		||||
                    'device_id' => $device['device_id'],
 | 
			
		||||
                    'last_seen' => array('NOW()'),
 | 
			
		||||
                    'description' => $vmdesc
 | 
			
		||||
                ), $name, '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster));
 | 
			
		||||
            } else {
 | 
			
		||||
                $pmxcache[$pmxcluster][$vmid] = dbInsert(array(
 | 
			
		||||
                    'cluster' => $pmxcluster,
 | 
			
		||||
                    'vmid' => $vmid,
 | 
			
		||||
                    'description' => $vmdesc,
 | 
			
		||||
                    'device_id' => $device['device_id']
 | 
			
		||||
                ), $name);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) {
 | 
			
		||||
                dbUpdate(array('last_seen' => array('NOW()')), 'proxmox_ports', '`vm_id` = ? AND `port` = ?',
 | 
			
		||||
                    array($pmxcache[$pmxcluster][$vmid], $vmport));
 | 
			
		||||
            } else {
 | 
			
		||||
                dbInsert(array('vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport), 'proxmox_ports');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            $pmxcache[$pmxcluster][$vmid] = dbInsert(array('cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, 'device_id' => $device['device_id']), $name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) {
 | 
			
		||||
            dbUpdate(array('last_seen' => array('NOW()')), 'proxmox_ports', '`vm_id` = ? AND `port` = ?', array($pmxcache[$pmxcluster][$vmid], $vmport));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            dbInsert(array('vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport), 'proxmox_ports');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
unset($pmxlines);
 | 
			
		||||
unset($pmxcluster);
 | 
			
		||||
unset($pmxcdir);
 | 
			
		||||
unset($proxmox);
 | 
			
		||||
unset($pmxcache);
 | 
			
		||||
unset($pmxlines, $pmxcluster, $pmxcdir, $proxmox, $pmxcache);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								includes/polling/applications/unbound.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								includes/polling/applications/unbound.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
<?php
 | 
			
		||||
$name = 'unbound';
 | 
			
		||||
$app_id = $app['app_id'];
 | 
			
		||||
if (!empty($agent_data['app'][$name])) {
 | 
			
		||||
    $rawdata = $agent_data['app'][$name];
 | 
			
		||||
}else{
 | 
			
		||||
	echo "Unbound Missing";
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
#Format Data
 | 
			
		||||
$lines = explode("\n",$rawdata);
 | 
			
		||||
$unbound = array();
 | 
			
		||||
foreach ($lines as $line) {
 | 
			
		||||
	list($var,$value) = explode('=',$line);
 | 
			
		||||
	$unbound[$var] = $value;
 | 
			
		||||
}
 | 
			
		||||
#Unbound Queries
 | 
			
		||||
$rrd_name =  array('app', $name,'queries',$app_id);
 | 
			
		||||
$rrd_def = array(
 | 
			
		||||
	'DS:type0:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:A:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:NS:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:CNAME:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:SOA:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:NULL:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:WKS:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:PTR:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:MX:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:TXT:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:AAAA:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:SRV:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:NAPTR:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:DS:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:DNSKEY:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:SPF:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:ANY:DERIVE:600:0:125000000000',
 | 
			
		||||
	'DS:other:DERIVE:600:0:125000000000'
 | 
			
		||||
	);
 | 
			
		||||
$fields = array (
 | 
			
		||||
	'type0' => $unbound['num.query.type.TYPE0'],
 | 
			
		||||
	'a' => $unbound['num.query.type.A'],
 | 
			
		||||
	'ns' => $unbound['num.query.type.NS'],
 | 
			
		||||
	'cname' => $unbound['num.query.type.CNAME'],
 | 
			
		||||
	'soa' => $unbound['num.query.type.SOA'],
 | 
			
		||||
	'null' => $unbound['num.query.type.NULL'],
 | 
			
		||||
	'wks' => $unbound['num.query.type.WKS'],
 | 
			
		||||
	'ptr' => $unbound['num.query.type.PTR'],
 | 
			
		||||
	'mx' => $unbound['num.query.type.MX'],
 | 
			
		||||
	'txt' => $unbound['num.query.type.TXT'],
 | 
			
		||||
	'aaaa' => $unbound['num.query.type.AAAA'],
 | 
			
		||||
	'srv' => $unbound['num.query.type.SRV'],
 | 
			
		||||
	'naptr' => $unbound['num.query.type.NAPTR'],
 | 
			
		||||
	'ds' => $unbound['num.query.type.DS'],
 | 
			
		||||
	'dnskey' => $unbound['num.query.type.DNSKEY'],
 | 
			
		||||
	'spf' => $unbound['num.query.type.SPF'],
 | 
			
		||||
	'any' => $unbound['num.query.type.ANY'],
 | 
			
		||||
	'other' => $unbound['num.query.type.other']
 | 
			
		||||
	);
 | 
			
		||||
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
 | 
			
		||||
data_update($device, 'app', $tags, $fields);
 | 
			
		||||
unset($lines , $unbound, $rrd_name, $rrd_def, $fields, $tags);
 | 
			
		||||
@@ -1,61 +1,95 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
$uptime      = snmp_get($device, 'sysUpTime.0', '-Otv');
 | 
			
		||||
$time_offset = (time() - intval($uptime) / 100);
 | 
			
		||||
// Gather our SLA's from the DB.
 | 
			
		||||
$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', array($device['device_id']));
 | 
			
		||||
 | 
			
		||||
$slavals = snmp_walk($device, 'ciscoRttMonMIB.ciscoRttMonObjects.rttMonCtrl.rttMonLatestRttOperTable', '-OUsqt', '+CISCO-RTTMON-MIB');
 | 
			
		||||
if (count($slas > 0)) {
 | 
			
		||||
    // We have SLA's, lets go!!!
 | 
			
		||||
 | 
			
		||||
$sla_table = array();
 | 
			
		||||
foreach (explode("\n", $slavals) as $sla) {
 | 
			
		||||
    $key_val = explode(' ', $sla, 2);
 | 
			
		||||
    if (count($key_val) != 2) {
 | 
			
		||||
        $key_val[] = '';
 | 
			
		||||
    // Go get some data from the device.
 | 
			
		||||
    $rttMonLatestRttOperTable = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.2.10.1', 1);
 | 
			
		||||
    $rttMonLatestOper = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.5', 1);
 | 
			
		||||
 | 
			
		||||
    $uptime      = snmp_get($device, 'sysUpTime.0', '-Otv');
 | 
			
		||||
    $time_offset = (time() - intval($uptime) / 100);
 | 
			
		||||
 | 
			
		||||
    foreach ($slas as $sla) {
 | 
			
		||||
        $sla_nr = $sla['sla_nr'];
 | 
			
		||||
        $rtt_type = $sla['rtt_type'];
 | 
			
		||||
 | 
			
		||||
        // Lets process each SLA
 | 
			
		||||
        $unixtime = intval(($rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.5'][$sla_nr] / 100 + $time_offset));
 | 
			
		||||
        $time  = strftime('%Y-%m-%d %H:%M:%S', $unixtime);
 | 
			
		||||
        $update = array();
 | 
			
		||||
 | 
			
		||||
        // Use Nagios Status codes.
 | 
			
		||||
        $opstatus = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.2'][$sla_nr];
 | 
			
		||||
        if ($opstatus == 1) {
 | 
			
		||||
            $opstatus = 0;        // 0=Good
 | 
			
		||||
        } else {
 | 
			
		||||
            $opstatus = 2;        // 2=Critical
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Populating the update array means we need to update the DB.
 | 
			
		||||
        if ($opstatus != $sla['opstatus']) {
 | 
			
		||||
            $update['opstatus'] = $opstatus;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $rtt = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.1'][$sla_nr];
 | 
			
		||||
        echo 'SLA '.$sla_nr.': '.$rtt_type.' '.$sla['owner'].' '.$sla['tag'].'... '.$rtt.'ms at '.$time.'\n';
 | 
			
		||||
 | 
			
		||||
        $fields = array(
 | 
			
		||||
            'rtt' => $rtt,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // The base RRD
 | 
			
		||||
        $rrd_name = array('sla', $sla_nr);
 | 
			
		||||
        $rrd_def = 'DS:rtt:GAUGE:600:0:300000';
 | 
			
		||||
        $tags = compact('sla_nr', 'rrd_name', 'rrd_def');
 | 
			
		||||
        data_update($device,'sla',$tags,$fields);
 | 
			
		||||
 | 
			
		||||
        // Let's gather some per-type metrics.
 | 
			
		||||
        switch ($rtt_type) {
 | 
			
		||||
            case 'jitter':
 | 
			
		||||
                $jitter = array(
 | 
			
		||||
                    'PacketLossSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.26'][$sla_nr],
 | 
			
		||||
                    'PacketLossDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.27'][$sla_nr],
 | 
			
		||||
                    'PacketOutOfSequence' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.28'][$sla_nr],
 | 
			
		||||
                    'PacketMIA' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.29'][$sla_nr],
 | 
			
		||||
                    'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.30'][$sla_nr],
 | 
			
		||||
                    'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla_nr]/100,
 | 
			
		||||
                    'ICPIF' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.43'][$sla_nr],
 | 
			
		||||
                    'OWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.49'][$sla_nr],
 | 
			
		||||
                    'OWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.50'][$sla_nr],
 | 
			
		||||
                    'AvgSDJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.47'][$sla_nr],
 | 
			
		||||
                    'AvgDSJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.48'][$sla_nr],
 | 
			
		||||
                );
 | 
			
		||||
                $rrd_name = array('sla', $sla_nr, $rtt_type);
 | 
			
		||||
                $rrd_def = array(
 | 
			
		||||
                    'DS:PacketLossSD:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:PacketLossDS:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:PacketOutOfSequence:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:PacketMIA:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:PacketLateArrival:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:MOS:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:ICPIF:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:OWAvgSD:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:OWAvgDS:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:AvgSDJ:GAUGE:600:0:U',
 | 
			
		||||
                    'DS:AvgDSJ:GAUGE:600:0:U',
 | 
			
		||||
                );
 | 
			
		||||
                $tags = compact('rrd_name', 'rrd_def', 'sla_nr', 'rtt_type');
 | 
			
		||||
                data_update($device,'sla',$tags,$jitter);
 | 
			
		||||
                $metrics = array_merge($metrics,$jitter);
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        d_echo("The following metrics were collected for #".$sla['sla_nr'].":\n");
 | 
			
		||||
        d_echo($metrics);
 | 
			
		||||
 | 
			
		||||
        // Update the DB if necessary
 | 
			
		||||
        if (count($update) > 0) {
 | 
			
		||||
            $updated = dbUpdate($update, 'slas', '`sla_id` = ?', array($sla['sla_id']));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $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);
 | 
			
		||||
 | 
			
		||||
    echo "\n";
 | 
			
		||||
}//end foreach
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								includes/polling/ntp.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								includes/polling/ntp.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * LibreNMS module to capture NTP statistics
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2016 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.
 | 
			
		||||
 *
 | 
			
		||||
 * This module will display NTP details from various device types.
 | 
			
		||||
 * To display, modules must create rrd's named: ntp-%PEER%.rrd with the following DS':
 | 
			
		||||
 *      DS:stratum:GAUGE:600:0:U
 | 
			
		||||
 *      DS:offset:GAUGE:600:0:U
 | 
			
		||||
 *      DS:delay:GAUGE:600:0:U
 | 
			
		||||
 *      DS:dispersion:GAUGE:600:0:U
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
if ($device['os_group'] == 'cisco') {
 | 
			
		||||
    require_once 'includes/polling/ntp/cisco.inc.php';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										82
									
								
								includes/polling/ntp/cisco.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								includes/polling/ntp/cisco.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,82 @@
 | 
			
		||||
<?php
 | 
			
		||||
/*
 | 
			
		||||
 * LibreNMS module to capture statistics from the CISCO-NTP-MIB
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2016 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.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$module = 'ntp';
 | 
			
		||||
 | 
			
		||||
require_once 'includes/component.php';
 | 
			
		||||
$component = new component();
 | 
			
		||||
$options = array();
 | 
			
		||||
$options['filter']['type'] = array('=',$module);
 | 
			
		||||
$options['filter']['disabled'] = array('=',0);
 | 
			
		||||
$options['filter']['ignore'] = array('=',0);
 | 
			
		||||
$components = $component->getComponents($device['device_id'],$options);
 | 
			
		||||
 | 
			
		||||
// We only care about our device id.
 | 
			
		||||
$components = $components[$device['device_id']];
 | 
			
		||||
 | 
			
		||||
// Only collect SNMP data if we have enabled components
 | 
			
		||||
if (count($components > 0)) {
 | 
			
		||||
    // Let's gather the stats..
 | 
			
		||||
    $cntpPeersVarEntry = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.168.1.2.1.1', 2);
 | 
			
		||||
 | 
			
		||||
    // Loop through the components and extract the data.
 | 
			
		||||
    foreach ($components as $key => &$array) {
 | 
			
		||||
        $peer = $array['peer'];
 | 
			
		||||
 | 
			
		||||
        // Let's make sure the rrd is setup for this class.
 | 
			
		||||
        $rrd_name = array('ntp', $peer);
 | 
			
		||||
        $rrd_def = array(
 | 
			
		||||
            'DS:stratum:GAUGE:600:0:U',
 | 
			
		||||
            'DS:offset:GAUGE:600:0:U',
 | 
			
		||||
            'DS:delay:GAUGE:600:0:U',
 | 
			
		||||
            'DS:dispersion:GAUGE:600:0:U',
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        $array['stratum'] = $cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][9][$array['UID']];
 | 
			
		||||
        // Set the status, 16 = Bad
 | 
			
		||||
        if ($array['stratum'] == 16) {
 | 
			
		||||
            $array['status'] = 2;
 | 
			
		||||
            $array['error'] = 'NTP Stratum is Insane';
 | 
			
		||||
        } else {
 | 
			
		||||
            $array['status'] = 0;
 | 
			
		||||
            $array['error'] = '';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Extract the statistics and update rrd
 | 
			
		||||
        $rrd['stratum'] = $array['stratum'];
 | 
			
		||||
        $rrd['offset'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][23][$array['UID']]);
 | 
			
		||||
        $rrd['delay'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][24][$array['UID']]);
 | 
			
		||||
        $rrd['dispersion'] = hexdec($cntpPeersVarEntry['1.3.6.1.4.1.9.9.168.1.2.1.1'][25][$array['UID']]);
 | 
			
		||||
        $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer');
 | 
			
		||||
        data_update($device, 'ntp', $tags, $rrd);
 | 
			
		||||
 | 
			
		||||
        // Let's print some debugging info.
 | 
			
		||||
        d_echo("\n\nComponent: ".$key."\n");
 | 
			
		||||
        d_echo("    Index:      ".$array['UID']."\n");
 | 
			
		||||
        d_echo("    Peer:       ".$array['peer'].":".$array['port']."\n");
 | 
			
		||||
        d_echo("    Stratum:    1.3.6.1.4.1.9.9.168.1.2.1.1.9.".$array['UID']."  = ".$rrd['stratum']."\n");
 | 
			
		||||
        d_echo("    Offset:     1.3.6.1.4.1.9.9.168.1.2.1.1.23.".$array['UID']." = ".$rrd['offset']."\n");
 | 
			
		||||
        d_echo("    Delay:      1.3.6.1.4.1.9.9.168.1.2.1.1.24.".$array['UID']." = ".$rrd['delay']."\n");
 | 
			
		||||
        d_echo("    Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25.".$array['UID']." = ".$rrd['dispersion']."\n");
 | 
			
		||||
 | 
			
		||||
        // Clean-up after yourself!
 | 
			
		||||
        unset($filename, $rrd_filename, $rrd);
 | 
			
		||||
    } // End foreach components
 | 
			
		||||
 | 
			
		||||
    // Write the Components back to the DB.
 | 
			
		||||
    $component->setComponentPrefs($device['device_id'],$components);
 | 
			
		||||
 | 
			
		||||
} // end if count components
 | 
			
		||||
 | 
			
		||||
// Clean-up after yourself!
 | 
			
		||||
unset($type, $components, $component, $options, $module);
 | 
			
		||||
							
								
								
									
										7
									
								
								includes/polling/os/acano.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								includes/polling/os/acano.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
if (preg_match('/Acano Server ([^,]+)/', $device['sysDescr'], $regexp_result)) {
 | 
			
		||||
    $version  = $regexp_result[1];
 | 
			
		||||
} else {
 | 
			
		||||
    $version = '';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								includes/polling/os/hpblmos.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								includes/polling/os/hpblmos.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
<?php
 | 
			
		||||
$version = trim(snmp_get($device, 'SNMPv2-SMI::enterprises.232.22.2.3.1.1.1.8.1', '-Ovq'), '"');
 | 
			
		||||
$hardware = trim(snmp_get($device, 'SNMPv2-SMI::enterprises.232.22.2.3.1.1.1.3.1', '-Ovq'), '"');
 | 
			
		||||
							
								
								
									
										9
									
								
								includes/polling/os/ise.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								includes/polling/os/ise.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
if ($device['sysObjectID'] == 'enterprises.9.1.2139') {
 | 
			
		||||
    $hardware = 'SNS-3945';
 | 
			
		||||
} elseif ($device['sysObjectID'] == 'enterprises.9.1.1426') {
 | 
			
		||||
    $hardware = 'Virtual Machine';
 | 
			
		||||
} else {
 | 
			
		||||
    $hardware = 'Unknown';
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								includes/polling/os/nitro.inc.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								includes/polling/os/nitro.inc.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
if ($device['sysObjectID'] == 'enterprises.23128.1000.1.1') {
 | 
			
		||||
    $features = 'Enterprise Security Manager';
 | 
			
		||||
} elseif ($device['sysObjectID'] == 'enterprises.23128.1000.3.1') {
 | 
			
		||||
    $features = 'Event Receiver';
 | 
			
		||||
} elseif ($device['sysObjectID'] == 'enterprises.23128.1000.7.1') {
 | 
			
		||||
    $features = 'Enterprise Log Manager';
 | 
			
		||||
} elseif ($device['sysObjectID'] == 'enterprises.23128.1000.11.1') {
 | 
			
		||||
    $features = 'Advanced Correlation Engine';
 | 
			
		||||
} else {
 | 
			
		||||
    $features = 'Unknown';
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// McAfee ACE 9.5.0
 | 
			
		||||
if (preg_match('/^McAfee [A-Z]{3} ([^,]+)$/', $device['sysDescr'], $regexp_result)) {
 | 
			
		||||
    $version  = $regexp_result[1];
 | 
			
		||||
}
 | 
			
		||||
@@ -59,6 +59,7 @@ if ($device['os_group'] == 'unix') {
 | 
			
		||||
            "mysql",
 | 
			
		||||
            "nginx",
 | 
			
		||||
            "powerdns",
 | 
			
		||||
            "powerdns-recursor",
 | 
			
		||||
            "proxmox",
 | 
			
		||||
            "rrdcached",
 | 
			
		||||
            "tinydns");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user