mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
- Code cleanup by Bastian Widmer.
git-svn-id: http://www.observium.org/svn/observer/trunk@1957 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -6,20 +6,20 @@ $app_data = mysql_query($sql);
|
||||
|
||||
if (mysql_affected_rows())
|
||||
{
|
||||
echo('Applications: ');
|
||||
while ($app = mysql_fetch_array($app_data))
|
||||
{
|
||||
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
|
||||
if (is_file($app_include))
|
||||
echo('Applications: ');
|
||||
while ($app = mysql_fetch_array($app_data))
|
||||
{
|
||||
include($app_include);
|
||||
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
|
||||
if (is_file($app_include))
|
||||
{
|
||||
include($app_include);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($app['app_type'].' include missing! ');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($app['app_type'].' include missing! ');
|
||||
}
|
||||
}
|
||||
echo("\n");
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
+219
-219
@@ -4,240 +4,240 @@ echo("Polling BGP peers\n");
|
||||
|
||||
if (!$config['enable_bgp'])
|
||||
{
|
||||
echo("BGP Support Disabled\n");
|
||||
echo("BGP Support Disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
|
||||
while ($peer = mysql_fetch_array($peers))
|
||||
{
|
||||
### Poll BGP Peer
|
||||
|
||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||
|
||||
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
|
||||
while ($peer = mysql_fetch_array($peers))
|
||||
{
|
||||
# v4 BGP4 MIB
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $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`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
}
|
||||
else
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
# v6 for JunOS via Juniper MIB
|
||||
$peer_ip = ipv62snmp($peer['bgpPeerIdentifier']);
|
||||
### Poll BGP Peer
|
||||
|
||||
if (!isset($junos_v6))
|
||||
{
|
||||
echo("\nCaching Oids...");
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
|
||||
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
|
||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||
|
||||
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||
{
|
||||
list($peer_oid) = split(' ',$oid);
|
||||
$peer_id = explode('.',$peer_oid);
|
||||
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
|
||||
# v4 BGP4 MIB
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $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`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
}
|
||||
}
|
||||
|
||||
## FIXME - move to function (and clean up, wtf?)
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip]; # Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented?
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerFsmEstablishedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"|grep -v "No Such Instance"';
|
||||
if ($debug) echo("\n$peer_cmd\n");
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
|
||||
if ($debug) { echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); }
|
||||
|
||||
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
|
||||
if ($bgpLocalAddr == "00000000000000000000000000000000")
|
||||
{
|
||||
$bgpLocalAddr = ''; # Unknown?
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgpLocalAddr = strtolower($bgpLocalAddr);
|
||||
for ($i = 0;$i < 32;$i+=4)
|
||||
{
|
||||
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
|
||||
}
|
||||
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
|
||||
}
|
||||
}
|
||||
|
||||
if ($bgpPeerFsmEstablishedTime)
|
||||
{
|
||||
if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])
|
||||
{
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState)
|
||||
{
|
||||
notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($bgpPeerState == "established")
|
||||
{
|
||||
notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($peer['bgpPeerState'] == "established")
|
||||
{
|
||||
notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd");
|
||||
if (!is_file($peerrrd))
|
||||
{
|
||||
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerEstablished:GAUGE:600:0:U \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797";
|
||||
|
||||
rrdtool_create($peerrrd, $create_rrd);
|
||||
}
|
||||
|
||||
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
|
||||
mysql_query($update);
|
||||
|
||||
if ($device['os_group'] == "ios" || $device['os'] == "junos")
|
||||
{
|
||||
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
|
||||
while ($peer_afi = mysql_fetch_assoc($afi_query))
|
||||
{
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); }
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
## FIXME - move to function
|
||||
$cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
|
||||
if ($debug) { echo("$cbgp_cmd\n"); }
|
||||
$cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`));
|
||||
if ($debug) { echo("$cbgp_data\n"); }
|
||||
list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data);
|
||||
}
|
||||
|
||||
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)
|
||||
else
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
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;
|
||||
}
|
||||
# v6 for JunOS via Juniper MIB
|
||||
$peer_ip = ipv62snmp($peer['bgpPeerIdentifier']);
|
||||
|
||||
if (!isset($junos_v6))
|
||||
{
|
||||
echo("\nCaching Oids...");
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
|
||||
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
|
||||
{
|
||||
list($peer_oid) = split(' ',$oid);
|
||||
$peer_id = explode('.',$peer_oid);
|
||||
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
|
||||
}
|
||||
}
|
||||
|
||||
## FIXME - move to function (and clean up, wtf?)
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip]; # Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented?
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerFsmEstablishedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"|grep -v "No Such Instance"';
|
||||
if ($debug) echo("\n$peer_cmd\n");
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
|
||||
if ($debug) { echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); }
|
||||
|
||||
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
|
||||
if ($bgpLocalAddr == "00000000000000000000000000000000")
|
||||
{
|
||||
$bgpLocalAddr = ''; # Unknown?
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgpLocalAddr = strtolower($bgpLocalAddr);
|
||||
for ($i = 0;$i < 32;$i+=4)
|
||||
{
|
||||
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
|
||||
}
|
||||
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
if ($bgpPeerFsmEstablishedTime)
|
||||
{
|
||||
if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])
|
||||
{
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState)
|
||||
{
|
||||
notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($bgpPeerState == "established")
|
||||
{
|
||||
notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($peer['bgpPeerState'] == "established")
|
||||
{
|
||||
notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = "UPDATE bgpPeers_cbgp SET";
|
||||
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
|
||||
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
|
||||
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
|
||||
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
|
||||
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
|
||||
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
|
||||
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
|
||||
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
|
||||
if ($debug) { echo("MYSQL: $update\n"); }
|
||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd");
|
||||
if (!is_file($peerrrd))
|
||||
{
|
||||
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerEstablished:GAUGE:600:0:U \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797";
|
||||
|
||||
rrdtool_create($peerrrd, $create_rrd);
|
||||
}
|
||||
|
||||
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
|
||||
mysql_query($update);
|
||||
|
||||
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd");
|
||||
if (!is_file($cbgp_rrd))
|
||||
if ($device['os_group'] == "ios" || $device['os'] == "junos")
|
||||
{
|
||||
$rrd_create = "DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797";
|
||||
rrdtool_create($cbgp_rrd, $rrd_create);
|
||||
}
|
||||
rrdtool_update("$cbgp_rrd", "N:$cbgpPeerAcceptedPrefixes:$cbgpPeerDeniedPrefixes:$cbgpPeerAdvertisedPrefixes:$cbgpPeerSuppressedPrefixes:$cbgpPeerWithdrawnPrefixes");
|
||||
} # while
|
||||
} # os=ios | junos
|
||||
echo("\n");
|
||||
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
|
||||
while ($peer_afi = mysql_fetch_assoc($afi_query))
|
||||
{
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); }
|
||||
|
||||
} ## End While loop on peers
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
## FIXME - move to function
|
||||
$cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
|
||||
if ($debug) { echo("$cbgp_cmd\n"); }
|
||||
$cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`));
|
||||
if ($debug) { echo("$cbgp_data\n"); }
|
||||
list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
# FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = "UPDATE bgpPeers_cbgp SET";
|
||||
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
|
||||
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
|
||||
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
|
||||
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
|
||||
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
|
||||
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
|
||||
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
|
||||
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
|
||||
if ($debug) { echo("MYSQL: $update\n"); }
|
||||
mysql_query($update);
|
||||
|
||||
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd");
|
||||
if (!is_file($cbgp_rrd))
|
||||
{
|
||||
$rrd_create = "DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797";
|
||||
rrdtool_create($cbgp_rrd, $rrd_create);
|
||||
}
|
||||
rrdtool_update("$cbgp_rrd", "N:$cbgpPeerAcceptedPrefixes:$cbgpPeerDeniedPrefixes:$cbgpPeerAdvertisedPrefixes:$cbgpPeerSuppressedPrefixes:$cbgpPeerWithdrawnPrefixes");
|
||||
} # while
|
||||
} # os=ios | junos
|
||||
echo("\n");
|
||||
|
||||
} ## End While loop on peers
|
||||
} ## End check for BGP support
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -2,55 +2,55 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" ICMP");
|
||||
echo(" ICMP");
|
||||
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
||||
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
||||
'icmpInAddrMaskReps','icmpOutTimeExcds','icmpOutParmProbs','icmpOutSrcQuenchs','icmpOutRedirects',
|
||||
'icmpOutTimestamps','icmpOutTimestampReps','icmpOutAddrMasks','icmpOutAddrMaskReps');
|
||||
$oids = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
||||
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
||||
'icmpInAddrMaskReps','icmpOutTimeExcds','icmpOutParmProbs','icmpOutSrcQuenchs','icmpOutRedirects',
|
||||
'icmpOutTimestamps','icmpOutTimestampReps','icmpOutAddrMasks','icmpOutAddrMaskReps');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";
|
||||
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "icmp", array());
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
$data_array = snmpwalk_cache_oid($device, "icmp", array());
|
||||
|
||||
if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_icmp'] = TRUE;
|
||||
$graphs['netstat_icmp_info'] = TRUE;
|
||||
}
|
||||
$rrdupdate = "N";
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
|
||||
if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_icmp'] = TRUE;
|
||||
$graphs['netstat_icmp_info'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -2,52 +2,52 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" IP");
|
||||
echo(" IP");
|
||||
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
|
||||
|
||||
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
|
||||
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
||||
'ipInHdrErrors', 'ipInAddrErrors');
|
||||
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
|
||||
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
||||
'ipInHdrErrors', 'ipInAddrErrors');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";
|
||||
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip'] = TRUE;
|
||||
$graphs['netstat_ip_frag'] = TRUE;
|
||||
}
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip'] = TRUE;
|
||||
$graphs['netstat_ip_frag'] = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -2,51 +2,51 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" SNMP");
|
||||
echo(" SNMP");
|
||||
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array ('snmpInPkts','snmpOutPkts','snmpInBadVersions','snmpInBadCommunityNames','snmpInBadCommunityUses','snmpInASNParseErrs',
|
||||
'snmpInTooBigs','snmpInNoSuchNames','snmpInBadValues','snmpInReadOnlys','snmpInGenErrs','snmpInTotalReqVars','snmpInTotalSetVars',
|
||||
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
||||
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
||||
$oids = array ('snmpInPkts','snmpOutPkts','snmpInBadVersions','snmpInBadCommunityNames','snmpInBadCommunityUses','snmpInASNParseErrs',
|
||||
'snmpInTooBigs','snmpInNoSuchNames','snmpInBadValues','snmpInReadOnlys','snmpInGenErrs','snmpInTotalReqVars','snmpInTotalSetVars',
|
||||
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
||||
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-snmp.rrd");
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-snmp.rrd");
|
||||
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "snmp", array());
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_snmp'] = TRUE;
|
||||
$graphs['netstat_snmp_pkt'] = TRUE;
|
||||
}
|
||||
$data_array = snmpwalk_cache_oid($device, "snmp", array());
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_snmp'] = TRUE;
|
||||
$graphs['netstat_snmp_pkt'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -2,56 +2,56 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" TCP");
|
||||
echo(" TCP");
|
||||
|
||||
$oids = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
||||
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
||||
$oids = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
||||
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
||||
|
||||
# $oids['tcp_collect'] = $oids['tcp'];
|
||||
# $oids['tcp_collect'][] = 'tcpHCInSegs';
|
||||
# $oids['tcp_collect'][] = 'tcpHCOutSegs';
|
||||
# $oids['tcp_collect'] = $oids['tcp'];
|
||||
# $oids['tcp_collect'][] = 'tcpHCInSegs';
|
||||
# $oids['tcp_collect'][] = 'tcpHCOutSegs';
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd";
|
||||
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; ## Limit to 10MPPS
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$snmpstring .= " tcpHCInSegs.0";
|
||||
$snmpstring .= " tcpHCOutSegs.0";
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; ## Limit to 10MPPS
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
$snmpstring .= " tcpHCInSegs.0";
|
||||
$snmpstring .= " tcpHCOutSegs.0";
|
||||
|
||||
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_tcp'] = TRUE;
|
||||
}
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
|
||||
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_tcp'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -3,48 +3,48 @@
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
|
||||
echo(" UDP");
|
||||
echo(" UDP");
|
||||
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmpget_multi them
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmpget_multi them
|
||||
|
||||
$oids = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
||||
$oids = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd";
|
||||
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; ## Limit to 1MPPS?
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; ## Limit to 1MPPS?
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_udp'] = TRUE;
|
||||
}
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_udp'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
echo("Polling Netstats:");
|
||||
echo("Polling Netstats:");
|
||||
|
||||
include("netstats-ip.inc.php");
|
||||
include("netstats-tcp.inc.php");
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
include("netstats-ip.inc.php");
|
||||
include("netstats-tcp.inc.php");
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
|
||||
echo("\n");
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
|
||||
+238
-238
@@ -7,25 +7,25 @@ $ports = snmp_cache_ifIndex($device); // Cache Port List
|
||||
|
||||
// Build SNMP Cache Array
|
||||
$data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress',
|
||||
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
|
||||
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
|
||||
|
||||
$stat_oids = array('ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInNUcastPkts', 'ifOutNUcastPkts',
|
||||
'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts',
|
||||
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets', 'ifInDiscards', 'ifOutDiscards', 'ifInUnknownProtos',
|
||||
'ifInBroadcastPkts', 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts');
|
||||
'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts',
|
||||
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets', 'ifInDiscards', 'ifOutDiscards', 'ifInUnknownProtos',
|
||||
'ifInBroadcastPkts', 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts');
|
||||
|
||||
$stat_oids_db = array('ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts'); // From above for DB
|
||||
|
||||
$etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames',
|
||||
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
|
||||
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
|
||||
'dot3StatsSymbolErrors');
|
||||
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
|
||||
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
|
||||
'dot3StatsSymbolErrors');
|
||||
|
||||
$cisco_oids = array('locIfHardType', 'locIfInRunts', 'locIfInGiants', 'locIfInCRC', 'locIfInFrame', 'locIfInOverrun', 'locIfInIgnored', 'locIfInAbort',
|
||||
'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops');
|
||||
'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops');
|
||||
|
||||
$pagp_oids = array('pagpOperationMode', 'pagpPortState', 'pagpPartnerDeviceId', 'pagpPartnerLearnMethod', 'pagpPartnerIfIndex', 'pagpPartnerGroupIfIndex',
|
||||
'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex');
|
||||
'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex');
|
||||
|
||||
$ifmib_oids = array_merge($data_oids, $stat_oids);
|
||||
|
||||
@@ -36,39 +36,39 @@ foreach ($ifmib_oids as $oid) { echo("$oid "); $port_stats = snmpwalk_cache_oid(
|
||||
|
||||
if ($config['enable_ports_etherlike'])
|
||||
{
|
||||
echo("dot3Stats "); $port_stats = snmpwalk_cache_oid($device, "dot3StatsEntry", $port_stats, "EtherLike-MIB");
|
||||
echo("dot3Stats "); $port_stats = snmpwalk_cache_oid($device, "dot3StatsEntry", $port_stats, "EtherLike-MIB");
|
||||
} else {
|
||||
echo("dot3StatsDuplexStatus"); $port_stats = snmpwalk_cache_oid($device, "dot3StatsDuplexStatus", $port_stats, "EtherLike-MIB");
|
||||
echo("dot3StatsDuplexStatus"); $port_stats = snmpwalk_cache_oid($device, "dot3StatsDuplexStatus", $port_stats, "EtherLike-MIB");
|
||||
}
|
||||
|
||||
if ($config['enable_ports_adsl'])
|
||||
{
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
}
|
||||
|
||||
if ($device['adsl_count'] > "0")
|
||||
{
|
||||
echo("ADSL ");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.2.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.3.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.4.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.5.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.8", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
echo("ADSL ");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.2.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.3.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.4.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.5.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.8", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
@@ -79,12 +79,12 @@ echo("\n");
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
$port_stats = snmp_cache_portIfIndex ($device, $port_stats);
|
||||
$port_stats = snmp_cache_portName ($device, $port_stats);
|
||||
$data_oids[] = "portName";
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vmVlan", $port_stats, "CISCO-VLAN-MEMBERSHIP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB");
|
||||
$port_stats = snmp_cache_portIfIndex ($device, $port_stats);
|
||||
$port_stats = snmp_cache_portName ($device, $port_stats);
|
||||
$data_oids[] = "portName";
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vmVlan", $port_stats, "CISCO-VLAN-MEMBERSHIP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB");
|
||||
}
|
||||
|
||||
$polled = time();
|
||||
@@ -101,218 +101,218 @@ if ($debug) { print_r($port_stats); }
|
||||
$port_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = 0");
|
||||
while ($port = mysql_fetch_array($port_query))
|
||||
{
|
||||
echo("Port " . $port['ifDescr'] . " ");
|
||||
if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1")
|
||||
{ // Check to make sure Port data is cached.
|
||||
$this_port = &$port_stats[$port['ifIndex']];
|
||||
echo("Port " . $port['ifDescr'] . " ");
|
||||
if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1")
|
||||
{ // Check to make sure Port data is cached.
|
||||
$this_port = &$port_stats[$port['ifIndex']];
|
||||
|
||||
$polled_period = $polled - $port['poll_time'];
|
||||
$polled_period = $polled - $port['poll_time'];
|
||||
|
||||
$update .= "`poll_time` = '".$polled."'";
|
||||
$update .= ", `poll_prev` = '".$port['poll_time']."'";
|
||||
$update .= ", `poll_period` = '".$polled_period."'";
|
||||
$update .= "`poll_time` = '".$polled."'";
|
||||
$update .= ", `poll_prev` = '".$port['poll_time']."'";
|
||||
$update .= ", `poll_period` = '".$polled_period."'";
|
||||
|
||||
#echo("\n32bit - In: ".$this_port['ifInOctets']." Out: ".$this_port['ifOutOctets']);
|
||||
#echo("\n64bit - In: ".$this_port['ifHCInOctets']." Out: ".$this_port['ifHCOutOctets']."\n");
|
||||
#echo("\n32bit - In: ".$this_port['ifInOctets']." Out: ".$this_port['ifOutOctets']);
|
||||
#echo("\n64bit - In: ".$this_port['ifHCInOctets']." Out: ".$this_port['ifHCOutOctets']."\n");
|
||||
|
||||
### Copy ifHC[In|Out]Octets values to non-HC if they exist
|
||||
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
||||
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
||||
}
|
||||
|
||||
if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
|
||||
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
|
||||
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
|
||||
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
|
||||
}
|
||||
|
||||
### Overwrite ifSpeed with ifHighSpeed if it's over 10G
|
||||
if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
|
||||
{
|
||||
echo("HighSpeed ");
|
||||
$this_port['ifSpeed'] = $this_port['ifHighSpeed'] * 1000000;
|
||||
}
|
||||
|
||||
### Overwrite ifDuplex with dot3StatsDuplexStatus if it exists
|
||||
if (isset($this_port['dot3StatsDuplexStatus']))
|
||||
{
|
||||
echo("dot3Duplex ");
|
||||
$this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus'];
|
||||
}
|
||||
|
||||
### Update IF-MIB data
|
||||
foreach ($data_oids as $oid)
|
||||
{
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid]))
|
||||
{
|
||||
$update .= ", `$oid` = NULL";
|
||||
log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); }
|
||||
} elseif ($port[$oid] != $this_port[$oid] ) {
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse description (usually ifAlias) if config option set
|
||||
|
||||
if (isset($config['port_descr_parser']) && is_file($config['install_dir'] . "/" . $config['port_descr_parser']))
|
||||
{
|
||||
$port_attribs = array('type','descr','circuit','speed','notes');
|
||||
include($config['install_dir'] . "/" . $config['port_descr_parser']);
|
||||
|
||||
foreach ($port_attribs as $attrib)
|
||||
{
|
||||
$attrib_key = "port_descr_".$attrib;
|
||||
if ($port_ifAlias[$attrib] != $port[$attrib_key])
|
||||
### Copy ifHC[In|Out]Octets values to non-HC if they exist
|
||||
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets']))
|
||||
{
|
||||
$update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'";
|
||||
log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']);
|
||||
echo("HC ");
|
||||
$this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
||||
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ende parse ifAlias
|
||||
|
||||
/// Update IF-MIB metrics
|
||||
foreach ($stat_oids_db as $oid)
|
||||
{
|
||||
$update .= ", `$oid` = '".$this_port[$oid]."'";
|
||||
$update .= ", `".$oid."_prev` = '".$port[$oid]."'";
|
||||
$oid_prev = $oid . "_prev";
|
||||
if ($port[$oid])
|
||||
{
|
||||
$oid_diff = $this_port[$oid] - $port[$oid];
|
||||
$oid_rate = $oid_diff / $polled_period;
|
||||
if ($oid_rate < 0) { $oid_rate = "0"; }
|
||||
$update .= ", `".$oid."_rate` = '".$oid_rate."'";
|
||||
$update .= ", `".$oid."_delta` = '".$oid_diff."'";
|
||||
if ($debug) {echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Update RRDs
|
||||
$rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (!is_file($rrdfile))
|
||||
{
|
||||
rrdtool_create($rrdfile," --step 300 \
|
||||
DS:INOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:INERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:INUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
|
||||
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
foreach ($stat_oids as $oid)
|
||||
{ /// Copy values from array to global variables and force numeric.
|
||||
$$oid = $this_port[$oid];
|
||||
if (!is_numeric($$oid)) { $$oid = "0"; }
|
||||
}
|
||||
|
||||
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos";
|
||||
$if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts";
|
||||
$ret = rrdtool_update("$rrdfile", $if_rrd_update);
|
||||
|
||||
# if ($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
|
||||
# if (!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
|
||||
# $ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
|
||||
# $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
|
||||
# }
|
||||
|
||||
/// End Update IF-MIB
|
||||
|
||||
/// Update PAgP
|
||||
if ($this_port['pagpOperationMode'])
|
||||
{
|
||||
foreach ($pagp_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($this_port[$oid] != $port[$oid] )
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
echo("PAgP ");
|
||||
log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
|
||||
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
|
||||
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
|
||||
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
|
||||
}
|
||||
}
|
||||
|
||||
### Overwrite ifSpeed with ifHighSpeed if it's over 10G
|
||||
if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
|
||||
{
|
||||
echo("HighSpeed ");
|
||||
$this_port['ifSpeed'] = $this_port['ifHighSpeed'] * 1000000;
|
||||
}
|
||||
|
||||
### Overwrite ifDuplex with dot3StatsDuplexStatus if it exists
|
||||
if (isset($this_port['dot3StatsDuplexStatus']))
|
||||
{
|
||||
echo("dot3Duplex ");
|
||||
$this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus'];
|
||||
}
|
||||
|
||||
### Update IF-MIB data
|
||||
foreach ($data_oids as $oid)
|
||||
{
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid]))
|
||||
{
|
||||
$update .= ", `$oid` = NULL";
|
||||
log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); }
|
||||
} elseif ($port[$oid] != $this_port[$oid] ) {
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse description (usually ifAlias) if config option set
|
||||
|
||||
if (isset($config['port_descr_parser']) && is_file($config['install_dir'] . "/" . $config['port_descr_parser']))
|
||||
{
|
||||
$port_attribs = array('type','descr','circuit','speed','notes');
|
||||
include($config['install_dir'] . "/" . $config['port_descr_parser']);
|
||||
|
||||
foreach ($port_attribs as $attrib)
|
||||
{
|
||||
$attrib_key = "port_descr_".$attrib;
|
||||
if ($port_ifAlias[$attrib] != $port[$attrib_key])
|
||||
{
|
||||
$update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'";
|
||||
log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ende parse ifAlias
|
||||
|
||||
/// Update IF-MIB metrics
|
||||
foreach ($stat_oids_db as $oid)
|
||||
{
|
||||
$update .= ", `$oid` = '".$this_port[$oid]."'";
|
||||
$update .= ", `".$oid."_prev` = '".$port[$oid]."'";
|
||||
$oid_prev = $oid . "_prev";
|
||||
if ($port[$oid])
|
||||
{
|
||||
$oid_diff = $this_port[$oid] - $port[$oid];
|
||||
$oid_rate = $oid_diff / $polled_period;
|
||||
if ($oid_rate < 0) { $oid_rate = "0"; }
|
||||
$update .= ", `".$oid."_rate` = '".$oid_rate."'";
|
||||
$update .= ", `".$oid."_delta` = '".$oid_diff."'";
|
||||
if ($debug) {echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Update RRDs
|
||||
$rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (!is_file($rrdfile))
|
||||
{
|
||||
rrdtool_create($rrdfile," --step 300 \
|
||||
DS:INOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:INERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:INUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
|
||||
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797");
|
||||
}
|
||||
|
||||
foreach ($stat_oids as $oid)
|
||||
{ /// Copy values from array to global variables and force numeric.
|
||||
$$oid = $this_port[$oid];
|
||||
if (!is_numeric($$oid)) { $$oid = "0"; }
|
||||
}
|
||||
|
||||
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos";
|
||||
$if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts";
|
||||
$ret = rrdtool_update("$rrdfile", $if_rrd_update);
|
||||
|
||||
# if ($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
|
||||
# if (!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
|
||||
# $ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
|
||||
# $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
|
||||
# }
|
||||
|
||||
/// End Update IF-MIB
|
||||
|
||||
/// Update PAgP
|
||||
if ($this_port['pagpOperationMode'])
|
||||
{
|
||||
foreach ($pagp_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($this_port[$oid] != $port[$oid] )
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
echo("PAgP ");
|
||||
log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Update PAgP
|
||||
|
||||
/// Do EtherLike-MIB
|
||||
if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); }
|
||||
|
||||
/// Do ADSL MIB
|
||||
if ($config['enable_ports_adsl']) { include("port-adsl.inc.php"); }
|
||||
|
||||
/// Do PoE MIBs
|
||||
if ($config['enable_ports_poe']) { include("port-poe.inc.php"); }
|
||||
|
||||
// Update MySQL
|
||||
if ($update)
|
||||
{
|
||||
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
}
|
||||
// End Update MySQL
|
||||
|
||||
unset($update_query); unset($update);
|
||||
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0)
|
||||
{
|
||||
if ($this_port['ifAlias'])
|
||||
{
|
||||
$falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")";
|
||||
} else {
|
||||
$full = $this_port['ifDescr'];
|
||||
}
|
||||
switch ($this_port['ifOperStatus'])
|
||||
{
|
||||
case "up":
|
||||
notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
case "down":
|
||||
notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Update PAgP
|
||||
|
||||
/// Do EtherLike-MIB
|
||||
if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); }
|
||||
|
||||
/// Do ADSL MIB
|
||||
if ($config['enable_ports_adsl']) { include("port-adsl.inc.php"); }
|
||||
|
||||
/// Do PoE MIBs
|
||||
if ($config['enable_ports_poe']) { include("port-poe.inc.php"); }
|
||||
|
||||
// Update MySQL
|
||||
if ($update)
|
||||
elseif ($port['disabled'] != "1")
|
||||
{
|
||||
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
echo("Port Deleted"); // Port missing from SNMP cache.
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$this_port['ifIndex']."'");
|
||||
} else {
|
||||
echo("Port Disabled.");
|
||||
}
|
||||
// End Update MySQL
|
||||
|
||||
unset($update_query); unset($update);
|
||||
echo("\n");
|
||||
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0)
|
||||
{
|
||||
if ($this_port['ifAlias'])
|
||||
{
|
||||
$falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")";
|
||||
} else {
|
||||
$full = $this_port['ifDescr'];
|
||||
}
|
||||
switch ($this_port['ifOperStatus'])
|
||||
{
|
||||
case "up":
|
||||
notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
case "down":
|
||||
notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($port['disabled'] != "1")
|
||||
{
|
||||
echo("Port Deleted"); // Port missing from SNMP cache.
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$this_port['ifIndex']."'");
|
||||
} else {
|
||||
echo("Port Disabled.");
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
#### Clear Per-Port Variables Here
|
||||
unset($this_port);
|
||||
#### Clear Per-Port Variables Here
|
||||
unset($this_port);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user