mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Merge branch 'master' into avtech
This commit is contained in:
@@ -31,7 +31,6 @@ include_once($config['install_dir'].'/html/includes/authentication/'.$config['au
|
||||
* @return string|boolean
|
||||
*/
|
||||
function GenSQL($rule) {
|
||||
$rule = htmlspecialchars_decode($rule);
|
||||
$rule = RunMacros($rule);
|
||||
if( empty($rule) ) {
|
||||
//Cannot resolve Macros due to recursion. Rule is invalid.
|
||||
|
||||
@@ -1265,16 +1265,3 @@ function get_port_id ($ports_mapped, $port, $port_association_mode) {
|
||||
|
||||
return $port_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize
|
||||
* @param mixed $item Reference to Item
|
||||
* @param mixed $key Key
|
||||
* @return void
|
||||
*/
|
||||
function sanitize_array(&$item, $key) {
|
||||
$tmp = htmlspecialchars($item);
|
||||
if( !empty($tmp) ){
|
||||
$item = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,8 +266,6 @@ function dbFetchRows($sql, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($rows,'sanitize_array');
|
||||
reset($rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@@ -335,8 +333,6 @@ function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($row,'sanitize_array');
|
||||
reset($row);
|
||||
return $row;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -267,8 +267,6 @@ function dbFetchRows($sql, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($rows,'sanitize_array');
|
||||
reset($rows);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@@ -336,8 +334,6 @@ function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($row,'sanitize_array');
|
||||
reset($row);
|
||||
return $row;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -568,7 +568,7 @@ $config['irc_alert'] = false;
|
||||
$config['irc_alert_utf8'] = false;
|
||||
|
||||
// Authentication
|
||||
$config['allow_unauth_graphs'] = 0;
|
||||
$config['allow_unauth_graphs'] = false;
|
||||
// Allow graphs to be viewed by anyone
|
||||
$config['allow_unauth_graphs_cidr'] = array();
|
||||
// Allow graphs to be viewed without authorisation from certain IP ranges
|
||||
|
||||
@@ -4,244 +4,231 @@ if ($config['enable_bgp']) {
|
||||
// Discover BGP peers
|
||||
echo 'BGP Sessions : ';
|
||||
|
||||
if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco']) != 0)) {
|
||||
$vrfs_lite_cisco = $device['vrf_lite_cisco'];
|
||||
} else {
|
||||
$vrfs_lite_cisco = array(array('context_name' => null));
|
||||
}
|
||||
|
||||
$bgpLocalAs = trim(snmp_walk($device, '.1.3.6.1.2.1.15.2', '-Oqvn', 'BGP4-MIB', $config['mibdir']));
|
||||
|
||||
foreach ($vrfs_lite_cisco as $vrf) {
|
||||
$device['context_name'] = $vrf['context_name'];
|
||||
if (is_numeric($bgpLocalAs)) {
|
||||
echo "AS$bgpLocalAs ";
|
||||
|
||||
if (is_numeric($bgpLocalAs)) {
|
||||
echo "AS$bgpLocalAs ";
|
||||
if ($bgpLocalAs != $device['bgpLocalAs']) {
|
||||
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo 'Updated AS ';
|
||||
}
|
||||
|
||||
if ($bgpLocalAs != $device['bgpLocalAs']) {
|
||||
dbUpdate(array('bgpLocalAs' => $bgpLocalAs), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo 'Updated AS ';
|
||||
$peer2 = false;
|
||||
$peers_data = snmp_walk($device, 'cbgpPeer2RemoteAs', '-Oq', 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
if (empty($peers_data)) {
|
||||
$peers_data = snmp_walk($device, 'BGP4-MIB::bgpPeerRemoteAs', '-Oq', 'BGP4-MIB', $config['mibdir']);
|
||||
}
|
||||
else {
|
||||
$peer2 = true;
|
||||
}
|
||||
|
||||
d_echo("Peers : $peers_data \n");
|
||||
|
||||
$peers = trim(str_replace('CISCO-BGP4-MIB::cbgpPeer2RemoteAs.', '', $peers_data));
|
||||
$peers = trim(str_replace('BGP4-MIB::bgpPeerRemoteAs.', '', $peers));
|
||||
|
||||
foreach (explode("\n", $peers) as $peer) {
|
||||
if ($peer2 === true) {
|
||||
list($ver, $peer) = explode('.', $peer, 2);
|
||||
}
|
||||
|
||||
$peer2 = false;
|
||||
$peers_data = snmp_walk($device, 'cbgpPeer2RemoteAs', '-Oq', 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
if (empty($peers_data)) {
|
||||
$peers_data = snmp_walk($device, 'BGP4-MIB::bgpPeerRemoteAs', '-Oq', 'BGP4-MIB', $config['mibdir']);
|
||||
} else {
|
||||
$peer2 = true;
|
||||
list($peer_ip, $peer_as) = explode(' ', $peer);
|
||||
if (strstr($peer_ip, ':')) {
|
||||
$peer_ip_snmp = preg_replace('/:/', ' ', $peer_ip);
|
||||
$peer_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $peer_ip_snmp);
|
||||
$peer_ip = str_replace('"', '', str_replace(' ', '', $peer_ip));
|
||||
}
|
||||
|
||||
d_echo("Peers : $peers_data \n");
|
||||
if ($peer && $peer_ip != '0.0.0.0') {
|
||||
d_echo("Found peer $peer_ip (AS$peer_as)\n");
|
||||
|
||||
$peers = trim(str_replace('CISCO-BGP4-MIB::cbgpPeer2RemoteAs.', '', $peers_data));
|
||||
$peers = trim(str_replace('BGP4-MIB::bgpPeerRemoteAs.', '', $peers));
|
||||
$peerlist[] = array(
|
||||
'ip' => $peer_ip,
|
||||
'as' => $peer_as,
|
||||
'ver' => $ver,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
// Juniper BGP4-V2 MIB
|
||||
// FIXME: needs a big cleanup! also see below.
|
||||
// FIXME: is .0.ipv6 the only possible value here?
|
||||
$result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
$peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result));
|
||||
foreach (explode("\n", $peers) as $peer) {
|
||||
if ($peer2 === true) {
|
||||
list($ver, $peer) = explode('.', $peer, 2);
|
||||
}
|
||||
list($peer_ip_snmp, $peer_as) = explode(' ', $peer);
|
||||
|
||||
list($peer_ip, $peer_as) = explode(' ', $peer);
|
||||
if (strstr($peer_ip, ':')) {
|
||||
$peer_ip_snmp = preg_replace('/:/', ' ', $peer_ip);
|
||||
$peer_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $peer_ip_snmp);
|
||||
$peer_ip = str_replace('"', '', str_replace(' ', '', $peer_ip));
|
||||
}
|
||||
// Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs.
|
||||
$peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16)))));
|
||||
|
||||
if ($peer && $peer_ip != '0.0.0.0') {
|
||||
if ($peer) {
|
||||
d_echo("Found peer $peer_ip (AS$peer_as)\n");
|
||||
|
||||
$peerlist[] = array(
|
||||
'ip' => $peer_ip,
|
||||
'as' => $peer_as,
|
||||
'ver' => $ver,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
// Juniper BGP4-V2 MIB
|
||||
// FIXME: needs a big cleanup! also see below.
|
||||
// FIXME: is .0.ipv6 the only possible value here?
|
||||
$result = snmp_walk($device, 'jnxBgpM2PeerRemoteAs.0.ipv6', '-Onq', 'BGP4-V2-MIB-JUNIPER', $config['install_dir'] . '/mibs/junos');
|
||||
$peers = trim(str_replace('.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.', '', $result));
|
||||
foreach (explode("\n", $peers) as $peer) {
|
||||
list($peer_ip_snmp, $peer_as) = explode(' ', $peer);
|
||||
|
||||
// Magic! Basically, takes SNMP form and finds peer IPs from the walk OIDs.
|
||||
$peer_ip = Net_IPv6::compress(snmp2ipv6(implode('.', array_slice(explode('.', $peer_ip_snmp), (count(explode('.', $peer_ip_snmp)) - 16)))));
|
||||
|
||||
if ($peer) {
|
||||
d_echo("Found peer $peer_ip (AS$peer_as)\n");
|
||||
|
||||
$peerlist[] = array(
|
||||
'ip' => $peer_ip,
|
||||
'as' => $peer_as,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo 'No BGP on host';
|
||||
if ($device['bgpLocalAs']) {
|
||||
dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo ' (Removed ASN) ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo 'No BGP on host';
|
||||
if ($device['bgpLocalAs']) {
|
||||
dbUpdate(array('bgpLocalAs' => 'NULL'), 'devices', 'device_id=?', array($device['device_id']));
|
||||
echo ' (Removed ASN) ';
|
||||
}
|
||||
}
|
||||
|
||||
// Process disovered peers
|
||||
if (isset($peerlist)) {
|
||||
foreach ($peerlist as $peer) {
|
||||
$astext = get_astext($peer['as']);
|
||||
// Process disovered peers
|
||||
if (isset($peerlist)) {
|
||||
foreach ($peerlist as $peer) {
|
||||
$astext = get_astext($peer['as']);
|
||||
|
||||
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers` WHERE device_id = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['ip'])) < '1') {
|
||||
|
||||
$add = dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'bgpPeerRemoteAs' => $peer['as'], 'context_name' => $device['context_name']), 'bgpPeers');
|
||||
if ($config['autodiscovery']['bgp'] === true) {
|
||||
$name = gethostbyaddr($peer['ip']);
|
||||
$remote_device_id = discover_new_device($name, $device, 'BGP');
|
||||
}
|
||||
|
||||
echo '+';
|
||||
} else {
|
||||
$update = dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext), 'context_name' => $device['context_name']), 'bgpPeers', 'device_id=? AND bgpPeerIdentifier=?', array($device['device_id'], $peer['ip']));
|
||||
echo '.';
|
||||
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers` WHERE device_id = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['ip'])) < '1') {
|
||||
$add = dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'bgpPeerRemoteAs' => $peer['as']), 'bgpPeers');
|
||||
if ($config['autodiscovery']['bgp'] === true) {
|
||||
$name = gethostbyaddr($peer['ip']);
|
||||
$remote_device_id = discover_new_device($name, $device, 'BGP');
|
||||
}
|
||||
|
||||
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
|
||||
if ($device['os_group'] == 'cisco') {
|
||||
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
|
||||
unset($af_list);
|
||||
echo '+';
|
||||
}
|
||||
else {
|
||||
$update = dbUpdate(array('bgpPeerRemoteAs' => $peer['as'], 'astext' => mres($astext)), 'bgpPeers', 'device_id=? AND bgpPeerIdentifier=?', array($device['device_id'], $peer['ip']));
|
||||
echo '.';
|
||||
}
|
||||
|
||||
if ($peer2 === true) {
|
||||
$af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
} else {
|
||||
$af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
}
|
||||
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
|
||||
if ($device['os_group'] == 'cisco') {
|
||||
// Get afi/safi and populate cbgp on cisco ios (xe/xr)
|
||||
unset($af_list);
|
||||
|
||||
d_echo('afi data :: ');
|
||||
d_echo($af_data);
|
||||
|
||||
foreach ($af_data as $k => $v) {
|
||||
if ($peer2 === true) {
|
||||
list(, $k) = explode('.', $k, 2);
|
||||
}
|
||||
|
||||
d_echo("AFISAFI = $k\n");
|
||||
|
||||
$afisafi_tmp = explode('.', $k);
|
||||
$safi = array_pop($afisafi_tmp);
|
||||
$afi = array_pop($afisafi_tmp);
|
||||
$bgp_ip = str_replace(".$afi.$safi", '', $k);
|
||||
$bgp_ip = preg_replace('/:/', ' ', $bgp_ip);
|
||||
$bgp_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $bgp_ip);
|
||||
$bgp_ip = str_replace('"', '', str_replace(' ', '', $bgp_ip));
|
||||
if ($afi && $safi && $bgp_ip == $peer['ip']) {
|
||||
$af_list[$bgp_ip][$afi][$safi] = 1;
|
||||
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ? AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi, 'context_name' => $device['context_name']), 'bgpPeers_cbgp');
|
||||
}
|
||||
else {
|
||||
//Update Context
|
||||
dbUpdate(array('context_name' => $device['context_name']), 'bgpPeers_cbgp', 'device_id = ? AND bgpPeerIdentifier = ? AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($peer2 === true) {
|
||||
$af_data = snmpwalk_cache_oid($device, 'cbgpPeer2AddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
}
|
||||
else {
|
||||
$af_data = snmpwalk_cache_oid($device, 'cbgpPeerAddrFamilyEntry', $cbgp, 'CISCO-BGP4-MIB', $config['mibdir']);
|
||||
}
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
$safis[1] = 'unicast';
|
||||
$safis[2] = 'multicast';
|
||||
d_echo('afi data :: ');
|
||||
d_echo($af_data);
|
||||
|
||||
if (!isset($j_peerIndexes)) {
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'] . '/mibs/junos');
|
||||
|
||||
foreach ($j_bgp as $index => $entry) {
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
d_echo("peerindex for ipv4 $ip is " . $entry['jnxBgpM2PeerIndex'] . "\n");
|
||||
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
|
||||
$ip6 = substr($ip6, 0, 4) . ':' . substr($ip6, 4, 4) . ':' . substr($ip6, 8, 4) . ':' . substr($ip6, 12, 4) . ':' . substr($ip6, 16, 4) . ':' . substr($ip6, 20, 4) . ':' . substr($ip6, 24, 4) . ':' . substr($ip6, 28, 4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
d_echo("peerindex for ipv6 $ip6 is " . $entry['jnxBgpM2PeerIndex'] . "\n");
|
||||
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "HALP? Don't know RemoteAddrType " . $entry['jnxBgpM2PeerRemoteAddrType'] . "!\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ($af_data as $k => $v) {
|
||||
if ($peer2 === true) {
|
||||
list(,$k) = explode('.', $k, 2);
|
||||
}
|
||||
|
||||
if (!isset($j_afisafi)) {
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'] . '/mibs/junos');
|
||||
foreach (array_keys($j_prefixes) as $key) {
|
||||
list($index, $afisafi) = explode('.', $key, 2);
|
||||
$j_afisafi[$index][] = $afisafi;
|
||||
}
|
||||
}
|
||||
d_echo("AFISAFI = $k\n");
|
||||
|
||||
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) {
|
||||
list ($afi, $safi) = explode('.', $afisafi);
|
||||
$safi = $safis[$safi];
|
||||
$af_list[$afi][$safi] = 1;
|
||||
$afisafi_tmp = explode('.', $k);
|
||||
$safi = array_pop($afisafi_tmp);
|
||||
$afi = array_pop($afisafi_tmp);
|
||||
$bgp_ip = str_replace(".$afi.$safi", '', $k);
|
||||
$bgp_ip = preg_replace('/:/', ' ', $bgp_ip);
|
||||
$bgp_ip = preg_replace('/(\S+\s+\S+)\s/', '$1:', $bgp_ip);
|
||||
$bgp_ip = str_replace('"', '', str_replace(' ', '', $bgp_ip));
|
||||
if ($afi && $safi && $bgp_ip == $peer['ip']) {
|
||||
$af_list[$bgp_ip][$afi][$safi] = 1;
|
||||
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi), 'bgpPeers_cbgp');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$af_query = "SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '" . $device['device_id'] . "' AND bgpPeerIdentifier = '" . $peer['ip'] . "'";
|
||||
foreach (dbFetchRows($af_query) as $entry) {
|
||||
$afi = $entry['afi'];
|
||||
$safi = $entry['safi'];
|
||||
if (!$af_list[$afi][$safi] || !$af_list[$entry['bgpPeerIdentifier']][$afi][$safi]) {
|
||||
dbDelete('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeerIdentifier` = ?, afi=?, safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
|
||||
if ($device['os'] == 'junos') {
|
||||
$safis[1] = 'unicast';
|
||||
$safis[2] = 'multicast';
|
||||
|
||||
if (!isset($j_peerIndexes)) {
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
|
||||
foreach ($j_bgp as $index => $entry) {
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
d_echo("peerindex for ipv4 $ip is ".$entry['jnxBgpM2PeerIndex']."\n");
|
||||
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
|
||||
$ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
d_echo("peerindex for ipv6 $ip6 is ".$entry['jnxBgpM2PeerIndex']."\n");
|
||||
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "HALP? Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($j_afisafi)) {
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
foreach (array_keys($j_prefixes) as $key) {
|
||||
list($index,$afisafi) = explode('.', $key, 2);
|
||||
$j_afisafi[$index][] = $afisafi;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) {
|
||||
list ($afi,$safi) = explode('.', $afisafi);
|
||||
$safi = $safis[$safi];
|
||||
$af_list[$afi][$safi] = 1;
|
||||
if (dbFetchCell('SELECT COUNT(*) from `bgpPeers_cbgp` WHERE device_id = ? AND bgpPeerIdentifier = ?, AND afi=? AND safi=?', array($device['device_id'], $peer['ip'], $afi, $safi)) == 0) {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'bgpPeerIdentifier' => $peer['ip'], 'afi' => $afi, 'safi' => $safi), 'bgpPeers_cbgp');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($j_afisafi);
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}
|
||||
|
||||
// Delete removed peers
|
||||
$sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '" . $device['device_id'] . "' AND `context_name` = '" . $device['context_name'] . "'";
|
||||
|
||||
foreach (dbFetchRows($sql) as $entry) {
|
||||
unset($exists);
|
||||
$i = 0;
|
||||
|
||||
while ($i < count($peerlist) && !isset($exists)) {
|
||||
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
|
||||
$exists = 1;
|
||||
$af_query = "SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '".$peer['ip']."'";
|
||||
foreach (dbFetchRows($af_query) as $entry) {
|
||||
$afi = $entry['afi'];
|
||||
$safi = $entry['safi'];
|
||||
if (!$af_list[$afi][$safi] || !$af_list[$entry['bgpPeerIdentifier']][$afi][$safi]) {
|
||||
dbDelete('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeerIdentifier` = ?, afi=?, safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!isset($exists)) {
|
||||
dbDelete('bgpPeers', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
|
||||
dbDelete('bgpPeers_cbgp', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
|
||||
echo '-';
|
||||
}
|
||||
}
|
||||
unset($peerlist);
|
||||
|
||||
echo "\n";
|
||||
unset($device['context_name']);
|
||||
unset($j_afisafi);
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}
|
||||
unset($device['context_name']);
|
||||
unset($vrfs_c);
|
||||
|
||||
// Delete removed peers
|
||||
$sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
|
||||
|
||||
foreach (dbFetchRows($sql) as $entry) {
|
||||
unset($exists);
|
||||
$i = 0;
|
||||
|
||||
while ($i < count($peerlist) && !isset($exists)) {
|
||||
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
|
||||
$exists = 1;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!isset($exists)) {
|
||||
dbDelete('bgpPeers', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
|
||||
dbDelete('bgpPeers_cbgp', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
|
||||
echo '-';
|
||||
}
|
||||
}
|
||||
|
||||
unset($peerlist);
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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'] == 'netonix') {
|
||||
echo 'NETONIX : ';
|
||||
|
||||
$free = str_replace('"', "", snmp_get($device, 'UCD-SNMP-MIB::memTotalFree.0', '-OvQU'));
|
||||
|
||||
if (is_numeric($free)) {
|
||||
discover_mempool($valid_mempool, $device, 0, 'netonix', 'Memory', '1024');
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
if (!$os) {
|
||||
// Canon Multifunction Printer/Scanner
|
||||
if (strstr($sysDescr, 'Canon MF')) {
|
||||
if (strstr($sysDescr, 'Canon MF') || strstr($sysDescr, 'Canon iR')) {
|
||||
$os = 'canonprinter';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
if (!$os) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.80')) {
|
||||
$os = 'ciscosb';
|
||||
}
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.81')) {
|
||||
$os = 'ciscosb';
|
||||
}
|
||||
@@ -22,4 +25,4 @@ if (!$os) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.9.6.1.89')) {
|
||||
$os = 'ciscosb';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if (!$os) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.4413') && (!stristr($sysDescr, 'vxworks') && !stristr($sysDescr, 'Quanta'))) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.4413') && (!stristr($sysDescr, 'vxworks') && !stristr($sysDescr, 'Quanta') && !stristr($sysDescr, 'FASTPATH Switching'))) {
|
||||
$os = 'edgeswitch';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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 (!$os) {
|
||||
if (strstr($sysObjectId, '.1.3.6.1.4.1.46242')) {
|
||||
$os = 'netonix';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
if ($device['os'] == 'netonix') {
|
||||
echo 'NETONIX : ';
|
||||
|
||||
// $system = snmp_get($device, 'ssCpuSystem.0', '-OvQ', 'UCD-SNMP-MIB');
|
||||
// $user = snmp_get($device, 'ssCpuUser.0', '-OvQ', 'UCD-SNMP-MIB');
|
||||
$idle = snmp_get($device, 'ssCpuIdle.0', '-OvQ', 'UCD-SNMP-MIB');
|
||||
|
||||
if (is_numeric($idle)) {
|
||||
discover_processor($valid['processor'], $device, 0, 0, 'ucd-old', 'CPU', '1', (100 - $idle));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Netonix Fan Speeds
|
||||
if ($device['os'] == 'netonix') {
|
||||
@@ -7,7 +18,7 @@ if ($device['os'] == 'netonix') {
|
||||
if (is_array($oids)) {
|
||||
foreach ($oids as $index => $entry) {
|
||||
if (is_numeric($entry['fanSpeed']) && is_numeric($index)) {
|
||||
$descr = $index;
|
||||
$descr = "Fan ".$index;
|
||||
$oid = '.1.3.6.1.4.1.46242.2.1.2.'.$index;
|
||||
$current = $entry['fanSpeed'];
|
||||
discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $device['os'], $descr, '1', '1', '0', '0', null, null, $current);
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Netonix Temperatures
|
||||
if ($device['os'] == 'netonix') {
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Netonix Voltages
|
||||
if ($device['os'] == 'netonix') {
|
||||
|
||||
@@ -97,7 +97,6 @@ class ObjCache implements ArrayAccess {
|
||||
else {
|
||||
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = dbFetchRows($this->data[$obj]['query'], $this->data[$obj]['params']);
|
||||
if (sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value']) == 1 && sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]) == 1) {
|
||||
reset($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]);
|
||||
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = current($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]);
|
||||
}
|
||||
return $GLOBALS['_ObjCache'][$this->obj][$obj]['value'];
|
||||
|
||||
@@ -72,28 +72,15 @@ if ($config['enable_bgp']) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// $peer_cmd = $config['snmpget'].' -M '.$config['mibdir'].' -m BGP4-MIB -OUvq '.snmp_gen_auth($device).' '.$device['hostname'].':'.$device['port'].' ';
|
||||
$oids = "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$oids .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$oids .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
|
||||
$peer_data=snmp_get_multi($device,$oids,'-OUQs','BGP4-MIB');
|
||||
$peer_data= array_pop($peer_data);
|
||||
if($debug){
|
||||
var_dump($peer_data);
|
||||
}
|
||||
$peer_cmd = $config['snmpget'].' -M '.$config['mibdir'].' -m BGP4-MIB -OUvq '.snmp_gen_auth($device).' '.$device['hostname'].':'.$device['port'].' ';
|
||||
$peer_cmd .= 'bgpPeerState.'.$peer['bgpPeerIdentifier'].' bgpPeerAdminStatus.'.$peer['bgpPeerIdentifier'].' bgpPeerInUpdates.'.$peer['bgpPeerIdentifier'].' bgpPeerOutUpdates.'.$peer['bgpPeerIdentifier'].' bgpPeerInTotalMessages.'.$peer['bgpPeerIdentifier'].' ';
|
||||
$peer_cmd .= 'bgpPeerOutTotalMessages.'.$peer['bgpPeerIdentifier'].' bgpPeerFsmEstablishedTime.'.$peer['bgpPeerIdentifier'].' bgpPeerInUpdateElapsedTime.'.$peer['bgpPeerIdentifier'].' ';
|
||||
$peer_cmd .= 'bgpPeerLocalAddr.'.$peer['bgpPeerIdentifier'].'';
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
}//end if
|
||||
$bgpPeerState= !empty($peer_data['bgpPeerState'])?$peer_data['bgpPeerState']:'';
|
||||
$bgpPeerAdminStatus= !empty($peer_data['bgpPeerAdminStatus'])?$peer_data['bgpPeerAdminStatus']:'';
|
||||
$bgpPeerInUpdates= !empty($peer_data['bgpPeerInUpdates'])?$peer_data['bgpPeerInUpdates']:'';
|
||||
$bgpPeerOutUpdates= !empty($peer_data['bgpPeerOutUpdates'])?$peer_data['bgpPeerOutUpdates']:'';
|
||||
$bgpPeerInTotalMessages= !empty($peer_data['bgpPeerInTotalMessages'])?$peer_data['bgpPeerInTotalMessages']:'';
|
||||
$bgpPeerOutTotalMessages= !empty($peer_data['bgpPeerOutTotalMessages'])?$peer_data['bgpPeerOutTotalMessages']:'';
|
||||
$bgpPeerFsmEstablishedTime= !empty($peer_data['bgpPeerFsmEstablishedTime'])?$peer_data['bgpPeerFsmEstablishedTime']:'';
|
||||
$bgpPeerInUpdateElapsedTime= !empty($peer_data['bgpPeerInUpdateElapsedTime'])?$peer_data['bgpPeerInUpdateElapsedTime']:'';
|
||||
$bgpLocalAddr= !empty($peer_data['bgpPeerLocalAddr'])?$peer_data['bgpPeerLocalAddr']:'';
|
||||
//list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
d_echo($peer_data);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
$bgpLocalAddr = str_replace('"', '', str_replace(' ', '', $bgpLocalAddr));
|
||||
unset($peer_data);
|
||||
}
|
||||
else if ($device['os'] == 'junos') {
|
||||
// v6 for JunOS via Juniper MIB
|
||||
@@ -199,6 +186,7 @@ if ($config['enable_bgp']) {
|
||||
if ($device['os_group'] == 'cisco' || $device['os'] == 'junos') {
|
||||
// Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier']));
|
||||
print_r($peer_afis);
|
||||
foreach ($peer_afis as $peer_afi) {
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
@@ -285,6 +273,45 @@ if ($config['enable_bgp']) {
|
||||
unset($cbgp_data);
|
||||
}//end if
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
// Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes
|
||||
$safis['unicast'] = 1;
|
||||
$safis['multicast'] = 2;
|
||||
|
||||
if (!isset($peerIndexes)) {
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PeerTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
foreach ($j_bgp as $index => $entry) {
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType']) {
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ', '', $entry['jnxBgpM2PeerRemoteAddr']), '"');
|
||||
$ip6 = substr($ip6, 0, 4).':'.substr($ip6, 4, 4).':'.substr($ip6, 8, 4).':'.substr($ip6, 12, 4).':'.substr($ip6, 16, 4).':'.substr($ip6, 20, 4).':'.substr($ip6, 24, 4).':'.substr($ip6, 28, 4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "PANIC: Don't know RemoteAddrType ".$entry['jnxBgpM2PeerRemoteAddrType']."!\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixCountersTable', $jbgp, 'BGP4-V2-MIB-JUNIPER', $config['install_dir'].'/mibs/junos');
|
||||
|
||||
$cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted'];
|
||||
$cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected'];
|
||||
$cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi.".$safis[$safi]]['jnxBgpM2PrefixOutPrefixes'];
|
||||
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}//end if
|
||||
|
||||
// FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = 'UPDATE bgpPeers_cbgp SET';
|
||||
$peer['c_update']['AcceptedPrefixes'] = $cbgpPeerAcceptedPrefixes;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
unset($poll_device);
|
||||
|
||||
$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0 sysDescr.0 sysObjectID.0', '-OQnUs', 'SNMPv2-MIB:HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
|
||||
$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0 sysDescr.0 sysObjectID.0', '-OQnUst', 'SNMPv2-MIB:HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
|
||||
$poll_device = $snmpdata[0];
|
||||
$poll_device['sysName'] = strtolower($poll_device['sysName']);
|
||||
|
||||
@@ -25,35 +25,20 @@ if (!empty($agent_data['uptime'])) {
|
||||
}
|
||||
|
||||
if (empty($uptime)) {
|
||||
$snmp_data = snmp_get_multi($device, 'snmpEngineTime.0 hrSystemUptime.0', '-OQnUs', 'HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
|
||||
$snmp_data = snmp_get_multi($device, 'snmpEngineTime.0 hrSystemUptime.0', '-OQnUst', 'HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB');
|
||||
$uptime_data = $snmp_data[0];
|
||||
$snmp_uptime = (integer) $uptime_data['snmpEngineTime'];
|
||||
$hrSystemUptime = $uptime_data['hrSystemUptime'];
|
||||
if (!empty($hrSystemUptime) && !strpos($hrSystemUptime, 'No') && ($device['os'] != 'windows')) {
|
||||
echo 'Using hrSystemUptime ('.$hrSystemUptime.")\n";
|
||||
$agent_uptime = $uptime;
|
||||
// Move uptime into agent_uptime
|
||||
// HOST-RESOURCES-MIB::hrSystemUptime.0 = Timeticks: (63050465) 7 days, 7:08:24.65
|
||||
$hrSystemUptime = str_replace('(', '', $hrSystemUptime);
|
||||
$hrSystemUptime = str_replace(')', '', $hrSystemUptime);
|
||||
list($days,$hours, $mins, $secs) = explode(':', $hrSystemUptime);
|
||||
list($secs, $microsecs) = explode('.', $secs);
|
||||
$hours = ($hours + ($days * 24));
|
||||
$mins = ($mins + ($hours * 60));
|
||||
$secs = ($secs + ($mins * 60));
|
||||
$uptime = $secs;
|
||||
$agent_uptime = $uptime;
|
||||
|
||||
$uptime = floor($hrSystemUptime / 100);
|
||||
echo 'Using hrSystemUptime ('.$uptime."s)\n";
|
||||
}
|
||||
else {
|
||||
echo 'Using SNMP Agent Uptime ('.$poll_device['sysUpTime'].")\n";
|
||||
// SNMPv2-MIB::sysUpTime.0 = Timeticks: (2542831) 7:03:48.31
|
||||
$poll_device['sysUpTime'] = str_replace('(', '', $poll_device['sysUpTime']);
|
||||
$poll_device['sysUpTime'] = str_replace(')', '', $poll_device['sysUpTime']);
|
||||
list($days, $hours, $mins, $secs) = explode(':', $poll_device['sysUpTime']);
|
||||
list($secs, $microsecs) = explode('.', $secs);
|
||||
$hours = ($hours + ($days * 24));
|
||||
$mins = ($mins + ($hours * 60));
|
||||
$secs = ($secs + ($mins * 60));
|
||||
$uptime = $secs;
|
||||
$uptime = floor($poll_device['sysUpTime'] / 100);
|
||||
echo 'Using SNMP Agent Uptime ('.$uptime."s)\n";
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ function poll_device($device, $options) {
|
||||
|
||||
dbUpdate(array('status' => $status, 'status_reason' => $response['status_reason']), 'devices', 'device_id=?', array($device['device_id']));
|
||||
|
||||
log_event('Device status changed to '.($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down'));
|
||||
log_event('Device status changed to '.($status == '1' ? 'Up' : 'Down'). ' from ' . $response['status_reason'] . ' check.', $device, ($status == '1' ? 'up' : 'down'));
|
||||
}
|
||||
|
||||
if ($status == '1') {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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'] == 'netonix') {
|
||||
$total = snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", "-OvQU") * 1024;
|
||||
$free = snmp_get($device, "UCD-SNMP-MIB::memAvailReal.0", "-OvQU") * 1024;
|
||||
|
||||
$mempool['total'] = $total;
|
||||
$mempool['free'] = $free;
|
||||
$mempool['used'] = $total - $free;
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
//SNMPv2-MIB::sysDescr.0 = STRING: EdgeSwitch 48-Port 750W, 1.1.2.4767216, Linux 3.6.5-f4a26ed5
|
||||
if( preg_match('/^(EdgeSwitch .*), (.*), Linux .*$/', $poll_device['sysDescr'], $regexp_result)) {
|
||||
//SNMPv2-MIB::sysDescr.0 = STRING: USW-24P-250, 3.3.15.3976, Linux 3.6.5
|
||||
if( preg_match('/^(EdgeSwitch .*|USW-.*), (.*), Linux .*$/', $poll_device['sysDescr'], $regexp_result)) {
|
||||
$hardware = $regexp_result[1];
|
||||
$version = $regexp_result[2];
|
||||
$serial = trim(snmp_get($device, ".1.3.6.1.2.1.47.1.1.1.1.11.1", "-Ovq") , '" ');
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module for Netonix
|
||||
*
|
||||
* Copyright (c) 2016 Tony Murray <murraytony@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$version = snmp_get($device, 'firmwareVersion.0', '-OQv', 'NETONIX-SWITCH-MIB', $config['mibdir'].':'.$config['mibdir'].'/netonix');
|
||||
$version = str_replace('.n.........', '', $version); // version display bug in 1.3.9
|
||||
$hardware = $poll_device['sysDescr'];
|
||||
|
||||
Reference in New Issue
Block a user