diff --git a/includes/polling/altiga-ssl.inc.php b/includes/polling/altiga-ssl.inc.php index ccf4e610c..e4a0f526f 100755 --- a/includes/polling/altiga-ssl.inc.php +++ b/includes/polling/altiga-ssl.inc.php @@ -1,7 +1,7 @@ +?> \ No newline at end of file diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index fd33155cd..e3fbdc603 100644 --- a/includes/polling/applications.inc.php +++ b/includes/polling/applications.inc.php @@ -1,18 +1,19 @@ +?> \ No newline at end of file diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index d145f4ff0..4b5e42c85 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -7,11 +7,12 @@ $apache_cmd = $config['snmpget'] ." -m NET-SNMP-EXTEND-MIB -O qv -" . $device[' $apache_cmd .= " nsExtendOutputFull.6.97.112.97.99.104.101"; $apache = shell_exec($apache_cmd); echo(" apache"); -list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, +list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache); -if (!is_file($apache_rrd)) { - rrdtool_create ($apache_rrd, "--step 300 \ +if (!is_file($apache_rrd)) +{ + rrdtool_create($apache_rrd, "--step 300 \ DS:access:DERIVE:600:0:125000000000 \ DS:kbyte:DERIVE:600:0:125000000000 \ DS:cpu:GAUGE:600:0:125000000000 \ @@ -48,5 +49,4 @@ if (!is_file($apache_rrd)) { rrdtool_update($apache_rrd, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open"); - -?> +?> \ No newline at end of file diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 00e3993e3..e2eb659d3 100755 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -2,235 +2,242 @@ echo("Polling BGP peers\n"); -if(!$config['enable_bgp']) { echo("BGP Support Disabled\n"); } else { - -$query = "SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'"; -$peers = mysql_query($query); -while($peer = mysql_fetch_array($peers)) { - - ### Poll BGP Peer - - echo("Checking ".$peer['bgpPeerIdentifier']." "); - -if (!strstr($peer['bgpPeerIdentifier'],':')) +if (!$config['enable_bgp']) { - # 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']); - - 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); - } + echo("BGP Support Disabled\n"); } - - if ($bgpPeerFsmEstablishedTime) +else +{ + $peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'"); + while ($peer = mysql_fetch_array($peers)) { - if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState']) + ### Poll BGP Peer + + echo("Checking ".$peer['bgpPeerIdentifier']." "); + + if (!strstr($peer['bgpPeerIdentifier'],':')) { - if ($peer['bgpPeerState'] == $bgpPeerState) + # 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']); + + if (!isset($junos_v6)) { - 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); + 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)); + } } - else if ($bgpPeerState == "established") + + ## 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") { - 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); + $bgpLocalAddr = ''; # Unknown? } - else if ($peer['bgpPeerState'] == "established") + else { - 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); + $bgpLocalAddr = strtolower($bgpLocalAddr); + for ($i = 0;$i < 32;$i+=4) + { + $bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4); + } + $bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6); } } - } - $peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd"); - if(!is_file($peerrrd)) { + 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"; + 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'] . "'"; + rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime"); - mysql_query($update); + $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)) + if ($device['os_group'] == "ios" || $device['os'] == "junos") { - $afi = $peer_afi['afi']; - $safi = $peer_afi['safi']; - if($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); } - - if ($device['os_group'] == "ios") + ## 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)) { - ## 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); - } + $afi = $peer_afi['afi']; + $safi = $peer_afi['safi']; + if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); } - if ($device['os'] == "junos") - { - # Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes - - $safis['unicast'] = 1; - $safis['multicast'] = 2; - - if (!isset($peerIndexes)) + if ($device['os_group'] == "ios") { - $j_bgp = snmpwalk_cache_multi_oid($device, "jnxBgpM2PeerTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos"); - foreach($j_bgp as $index => $entry) + ## 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)) { - switch ($entry['jnxBgpM2PeerRemoteAddrType']) + $j_bgp = snmpwalk_cache_multi_oid($device, "jnxBgpM2PeerTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos"); + foreach ($j_bgp as $index => $entry) { - 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; + 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); } - - $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); - # 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 + $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 -?> + +?> \ No newline at end of file diff --git a/includes/polling/cisco-enhanced-mempool.inc.php b/includes/polling/cisco-enhanced-mempool.inc.php deleted file mode 100755 index a51c8ac17..000000000 --- a/includes/polling/cisco-enhanced-mempool.inc.php +++ /dev/null @@ -1,60 +0,0 @@ - diff --git a/includes/polling/cisco-entity-sensors.inc.php b/includes/polling/cisco-entity-sensors.inc.php index 9795e2923..cc4a2ebbf 100755 --- a/includes/polling/cisco-entity-sensors.inc.php +++ b/includes/polling/cisco-entity-sensors.inc.php @@ -2,8 +2,8 @@ $query = "SELECT * FROM entPhysical WHERE device_id = '" . $device['device_id'] . "' AND entPhysicalClass = 'sensor'"; $sensors = mysql_query($query); -while($sensor = mysql_fetch_array($sensors)) { - +while ($sensor = mysql_fetch_array($sensors)) +{ echo("Checking Entity Sensor " . $sensor['entPhysicalName'] . " - " . $sensor['cempsensorName']); $oid = $sensor['entPhysicalIndex']; @@ -19,9 +19,9 @@ while($sensor = mysql_fetch_array($sensors)) { $rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ces-" . $oid . ".rrd"); - if (!is_file($rrd)) { - `rrdtool create $rrd \ - --step 300 \ + if (!is_file($rrd)) + { + rrdtool_create($rrd,"--step 300 \ DS:value:GAUGE:600:-1000:U \ RRA:AVERAGE:0.5:1:2304 \ RRA:AVERAGE:0.5:6:1536 \ @@ -34,7 +34,7 @@ while($sensor = mysql_fetch_array($sensors)) { RRA:MIN:0.5:1:2304 \ RRA:MIN:0.5:6:1536 \ RRA:MIN:0.5:24:2268 \ - RRA:MIN:0.5:288:1890`; + RRA:MIN:0.5:288:1890"); } $entSensorValue = entPhysical_scale($entSensorValue, $sensor['entSensorScale']); @@ -46,7 +46,6 @@ while($sensor = mysql_fetch_array($sensors)) { mysql_query($update_query); echo($entSensorValue . " - " . $entSensorStatus . "\n"); - } -?> +?> \ No newline at end of file diff --git a/includes/polling/cisco-ipsec-flow-monitor.inc.php b/includes/polling/cisco-ipsec-flow-monitor.inc.php index 496eea8c9..06f7b02bc 100755 --- a/includes/polling/cisco-ipsec-flow-monitor.inc.php +++ b/includes/polling/cisco-ipsec-flow-monitor.inc.php @@ -32,17 +32,16 @@ #CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalNoSaFails.0 = Counter32: 5 Failures #CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalSysCapFails.0 = Counter32: 0 Failures -if($device['os_group'] == "ios") { - +if ($device['os_group'] == "ios") +{ $data = snmpwalk_cache_oid($device, "cipSecGlobalStats", NULL, "CISCO-IPSEC-FLOW-MONITOR-MIB"); $data = $data[0]; ## Use HC Counters if they exist - if(is_numeric($data['cipSecGlobalHcInOctets'])) { $data['cipSecGlobalInOctets']= $data['cipSecGlobalHcInOctets']; } - if(is_numeric($data['cipSecGlobalHcOutOctets'])) { $data['cipSecGlobalOutOctets'] = $data['cipSecGlobalHcOutOctets']; } - if(is_numeric($data['cipSecGlobalHcInDecompOctets'])) { $data['cipSecGlobalInDecompOctets'] = $data['cipSecGlobalHcInDecompOctets']; } - if(is_numeric($data['cipSecGlobalHcOutUncompOctets'])) { $data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets']; } - + if (is_numeric($data['cipSecGlobalHcInOctets'])) { $data['cipSecGlobalInOctets']= $data['cipSecGlobalHcInOctets']; } + if (is_numeric($data['cipSecGlobalHcOutOctets'])) { $data['cipSecGlobalOutOctets'] = $data['cipSecGlobalHcOutOctets']; } + if (is_numeric($data['cipSecGlobalHcInDecompOctets'])) { $data['cipSecGlobalInDecompOctets'] = $data['cipSecGlobalHcInDecompOctets']; } + if (is_numeric($data['cipSecGlobalHcOutUncompOctets'])) { $data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets']; } $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cipsec_flow.rrd"); $rrd_create = " DS:Tunnels:GAUGE:600:0:U"; @@ -80,9 +79,9 @@ if($device['os_group'] == "ios") { $rrd_create .= " RRA:MIN:0.5:24:2000"; $rrd_create .= " RRA:MIN:0.5:288:2000"; - if(is_file($rrd_filename) || $data['cipSecGlobalActiveTunnels']) + if (is_file($rrd_filename) || $data['cipSecGlobalActiveTunnels']) { - if(!file_exists($rrd_filename)) + if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, $rrd_create); } @@ -118,9 +117,9 @@ if($device['os_group'] == "ios") { $graphs['cipsec_flow_stats'] = TRUE; echo(" cipsec_flow"); - } + unset($data, $$rrd_filename, $rrd_create, $rrd_update); } -?> +?> \ No newline at end of file diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index b5d3a6597..82ca0a8d7 100755 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -15,16 +15,17 @@ $polled = time(); $mac_entries = 0; $mac_accounting_query = mysql_query("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'"); -while ($acc = mysql_fetch_assoc($mac_accounting_query)) { - + +while ($acc = mysql_fetch_assoc($mac_accounting_query)) +{ $device_id = $acc['device_id']; $ifIndex = $acc['ifIndex']; $mac = $acc['mac']; $polled_period = $polled - $acc['poll_time']; - if($cip_array[$ifIndex][$mac]) { - + if ($cip_array[$ifIndex][$mac]) + { $update .= "`poll_time` = '".$polled."'"; $update .= ", `poll_prev` = '".$acc['poll_time']."'"; $update .= ", `poll_period` = '".$polled_period."'"; @@ -39,26 +40,29 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) { $this_ma = &$cip_array[$ifIndex][$mac]; /// Update metrics - foreach ($cip_oids as $oid) { - foreach(array('input','output') as $dir) { + foreach ($cip_oids as $oid) + { + foreach (array('input','output') as $dir) + { $oid_dir = $oid . "_" . $dir; $update .= ", `".$oid_dir."` = '".$this_ma[$oid][$dir]."'"; $update .= ", `".$oid_dir."_prev` = '".$acc[$oid_dir]."'"; $oid_prev = $oid_dir . "_prev"; - if($this_ma[$oid][$dir]) { + if ($this_ma[$oid][$dir]) + { $oid_diff = $this_ma[$oid][$dir] - $acc[$oid_dir]; $oid_rate = $oid_diff / $polled_period; $update .= ", `".$oid_dir."_rate` = '".$oid_rate."'"; $update .= ", `".$oid_dir."_delta` = '".$oid_diff."'"; - if($debug) {echo("\n $oid_dir ($oid_diff B) $oid_rate Bps $polled_period secs\n");} + if ($debug) { echo("\n $oid_dir ($oid_diff B) $oid_rate Bps $polled_period secs\n"); } } } } - if($debug) {echo("\n" . $acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out ");} + if ($debug) { echo("\n" . $acc['hostname']." ".$acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); } $rrdfile = $host_rrd . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"); - if(!is_file($rrdfile)) + if (!is_file($rrdfile)) { rrdtool_create($rrdfile,"DS:IN:COUNTER:600:0:12500000000 \ DS:OUT:COUNTER:600:0:12500000000 \ @@ -76,21 +80,21 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) { $woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0); $ret = rrdtool_update("$rrdfile", $woo); - if ($update) - { /// Do Updates - $update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'"; - @mysql_query($update_query); - if($debug) {echo("\nMYSQL : [ $update_query ]");} - } /// End Updates - unset($update_query); unset($update); + if ($update) + { /// Do Updates + $update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'"; + @mysql_query($update_query); + if ($debug) { echo("\nMYSQL : [ $update_query ]"); } + } /// End Updates + unset($update_query); unset($update); } } unset($cip_array); -if($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); } +if ($mac_entries) { echo(" $mac_entries MAC accounting entries\n"); } echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/polling/cisco-mempool.inc.php b/includes/polling/cisco-mempool.inc.php deleted file mode 100755 index 8ef4a3ebd..000000000 --- a/includes/polling/cisco-mempool.inc.php +++ /dev/null @@ -1,54 +0,0 @@ - diff --git a/includes/polling/cisco-processors.inc.php b/includes/polling/cisco-processors.inc.php deleted file mode 100755 index 5c7ed9885..000000000 --- a/includes/polling/cisco-processors.inc.php +++ /dev/null @@ -1,36 +0,0 @@ - diff --git a/includes/polling/cisco-remote-access-monitor.inc.php b/includes/polling/cisco-remote-access-monitor.inc.php index 8aa9867ec..dc2cdc781 100755 --- a/includes/polling/cisco-remote-access-monitor.inc.php +++ b/includes/polling/cisco-remote-access-monitor.inc.php @@ -31,10 +31,10 @@ #CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnCumulateSessions.0 = Counter32: 29 Sessions #CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnPeakConcurrentSessions.0 = Gauge32: 9 Sessions -if($device['os_group'] == "ios") { - +if ($device['os_group'] == "ios") +{ $oid_list = "crasEmailNumSessions.0 crasIPSecNumSessions.0 crasL2LNumSessions.0 crasLBNumSessions.0 crasSVCNumSessions.0 crasWebvpnNumSessions.0"; - $data = snmp_get_multi ($device, $oid_list, "-OUQs", "CISCO-REMOTE-ACCESS-MONITOR-MIB"); + $data = snmp_get_multi($device, $oid_list, "-OUQs", "CISCO-REMOTE-ACCESS-MONITOR-MIB"); $data = $data[0]; $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cras_sessions.rrd"); @@ -61,9 +61,9 @@ if($device['os_group'] == "ios") { $rrd_create .= " RRA:MIN:0.5:24:2000"; $rrd_create .= " RRA:MIN:0.5:288:2000"; - if(is_file($rrd_filename) || $data['crasEmailNumSessions'] || $data['crasIPSecNumSessions'] || $data['crasL2LNumSessions'] || $data['crasLBNumSessions'] || $data['crasSVCNumSessions'] || $data['crasWebvpnSessions']) + if (is_file($rrd_filename) || $data['crasEmailNumSessions'] || $data['crasIPSecNumSessions'] || $data['crasL2LNumSessions'] || $data['crasLBNumSessions'] || $data['crasSVCNumSessions'] || $data['crasWebvpnSessions']) { - if(!file_exists($rrd_filename)) + if (!file_exists($rrd_filename)) { rrdtool_create($rrd_filename, $rrd_create); } @@ -80,9 +80,9 @@ if($device['os_group'] == "ios") { $graphs['cras_sessions'] = TRUE; echo(" CRAS Sessions"); - } + unset($data, $$rrd_filename, $rrd_create, $rrd_update); } -?> +?> \ No newline at end of file diff --git a/includes/polling/current.inc.php b/includes/polling/current.inc.php index 66c79f051..bbc8c9ee6 100644 --- a/includes/polling/current.inc.php +++ b/includes/polling/current.inc.php @@ -2,8 +2,8 @@ $query = "SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $current_data = mysql_query($query); -while($dbcurrent = mysql_fetch_array($current_data)) { - +while ($dbcurrent = mysql_fetch_array($current_data)) +{ echo("Checking current " . $dbcurrent['sensor_descr'] . "... "); $current = snmp_get($device, $dbcurrent['sensor_oid'], "-OUqnv", "SNMPv2-MIB"); @@ -13,22 +13,22 @@ while($dbcurrent = mysql_fetch_array($current_data)) { $currentrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("current-" . $dbcurrent['sensor_descr'] . ".rrd"); - if (!is_file($currentrrd)) { - `rrdtool create $currentrrd \ - --step 300 \ + if (!is_file($currentrrd)) + { + rrdtool_create($currentrrd,"--step 300 \ DS:sensor:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($current . " A\n"); rrdtool_update($currentrrd,"N:$current"); - + # FIXME also warn when crossing WARN level!! - if($dbcurrent['sensor_current'] > $dbcurrent['sensor_limit_low'] && $current <= $dbcurrent['sensor_limit_low']) + if ($dbcurrent['sensor_current'] > $dbcurrent['sensor_limit_low'] && $current <= $dbcurrent['sensor_limit_low']) { $msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit']; $msg .= "A) at " . date($config['timestamp_format']); @@ -36,7 +36,7 @@ while($dbcurrent = mysql_fetch_array($current_data)) { echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n"); log_event('Current ' . $dbcurrent['sensor_descr'] . " under threshold: " . $current . " A (< " . $dbcurrent['sensor_limit_low'] . " A)", $device['device_id'], 'current', $current['sensor_id']); } - else if($dbcurrent['sensor_current'] < $dbcurrent['sensor_limit'] && $current >= $dbcurrent['sensor_limit']) + else if ($dbcurrent['sensor_current'] < $dbcurrent['sensor_limit'] && $current >= $dbcurrent['sensor_limit']) { $msg = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit']; $msg .= "A) at " . date($config['timestamp_format']); @@ -48,4 +48,4 @@ while($dbcurrent = mysql_fetch_array($current_data)) { mysql_query("UPDATE sensors SET sensor_current = '$current' WHERE sensor_class='current' AND sensor_id = '" . $dbcurrent['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/fanspeeds.inc.php b/includes/polling/fanspeeds.inc.php index 38cb96fb6..1ce94f12a 100755 --- a/includes/polling/fanspeeds.inc.php +++ b/includes/polling/fanspeeds.inc.php @@ -15,32 +15,31 @@ while ($fanspeed = mysql_fetch_array($fan_data)) $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fanspeed-" . $fanspeed['sensor_descr'] . ".rrd"); $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/fanspeed-" . safename($fanspeed['sensor_type']."-".$fanspeed['sensor_index']) . ".rrd"; - if(is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } + if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } if (!is_file($rrd_file)) { - `rrdtool create $rrd_file \ - --step 300 \ + rrdtool_create($rrd_file,"--step 300 \ DS:sensor:GAUGE:600:0:20000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($fan . " rpm\n"); rrdtool_update($rrd_file,"N:$fan"); - if ($fanspeed['sensor_current'] > $fanspeed['sensor_limit_low'] && $fan <= $fanspeed['sensor_limit_low']) + if ($fanspeed['sensor_current'] > $fanspeed['sensor_limit_low'] && $fan <= $fanspeed['sensor_limit_low']) { $msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['sensor_limit_low']; $msg .= "rpm) at " . date($config['timestamp_format']); notify($device, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg); echo("Alerting for " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . "\n"); log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (<= " . $fanspeed['sensor_limit_low'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']); - } - else if ($fanspeed['sensor_current'] > $fanspeed['sensor_limit_warn'] && $fan <= $fanspeed['sensor_limit_low_warn']) + } + else if ($fanspeed['sensor_current'] > $fanspeed['sensor_limit_warn'] && $fan <= $fanspeed['sensor_limit_low_warn']) { $msg = "Fan Warning: " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . " is " . $fan . "rpm (Warning limit " . $fanspeed['sensor_limit_low_warn']; $msg .= "rpm) at " . date($config['timestamp_format']); @@ -52,4 +51,4 @@ while ($fanspeed = mysql_fetch_array($fan_data)) mysql_query("UPDATE sensors SET sensor_current = '$fan' WHERE sensor_class='fanspeed' AND sensor_id = '" . $fanspeed['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/frequencies.inc.php b/includes/polling/frequencies.inc.php index e266b7efd..14f58862d 100644 --- a/includes/polling/frequencies.inc.php +++ b/includes/polling/frequencies.inc.php @@ -2,32 +2,33 @@ $query = "SELECT * FROM `sensors` WHERE device_id = '" . $device['device_id'] . "' AND `sensor_class` = 'freq' AND poller_type='snmp'"; $sensor_data = mysql_query($query); -while($sensor = mysql_fetch_array($sensor_data)) { +while ($sensor = mysql_fetch_array($sensor_data)) +{ echo("Checking frequency " . $sensor['sensor_descr'] . "... "); $freq = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB"); if ($sensor['sensor_divisor']) { $freq = $freq / $sensor['sensor_divisor']; } if ($sensor['sensor_multiplier']) { $freq = $freq * $sensor['sensor_multiplier']; } - - $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("frequency-" . $sensor['sensor_descr'] . ".rrd"); - if (!is_file($rrd_file)) { - `rrdtool create $rrd_file \ - --step 300 \ + $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("frequency-" . $sensor['sensor_descr'] . ".rrd"); + + if (!is_file($rrd_file)) + { + rrdtool_create($rrd_file,"--step 300 \ DS:sensor:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($freq . " Hz\n"); rrdtool_update($rrd_file,"N:$freq"); - if($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $freq <= $sensor['sensor_limit_low']) + if ($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $freq <= $sensor['sensor_limit_low']) { $msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit']; $msg .= "Hz) at " . date($config['timestamp_format']); @@ -35,7 +36,7 @@ while($sensor = mysql_fetch_array($sensor_data)) { echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); log_event('Frequency ' . $sensor['sensor_descr'] . " under threshold: " . $freq . " Hz (< " . $sensor['sensor_limit_low'] . " Hz)", $device['device_id'] , 'frequency', $sensor['sensor_id']); } - else if($sensor['sensor_current'] < $sensor['sensor_limit'] && $freq >= $sensor['sensor_limit']) + else if ($sensor['sensor_current'] < $sensor['sensor_limit'] && $freq >= $sensor['sensor_limit']) { $msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit']; $msg .= "Hz) at " . date($config['timestamp_format']); @@ -47,4 +48,4 @@ while($sensor = mysql_fetch_array($sensor_data)) { mysql_query("UPDATE frequency SET sensor_current = '$freq' WHERE sensor_id = '" . $sensor['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/hr-mib.inc.php b/includes/polling/hr-mib.inc.php index 9984d7b87..43c30c179 100755 --- a/includes/polling/hr-mib.inc.php +++ b/includes/polling/hr-mib.inc.php @@ -8,10 +8,11 @@ $hrSystem = snmp_get_multi ($device, $oid_list, "-OUQs", "HOST-RESOURCES-MIB"); echo("HR Stats:"); -if(is_numeric($hrSystem[0]['hrSystemProcesses'])) +if (is_numeric($hrSystem[0]['hrSystemProcesses'])) { $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd"; - if (!is_file($rrd_file)) { + if (!is_file($rrd_file)) + { rrdtool_create($rrd_file,"--step 300 \ DS:procs:GAUGE:600:0:U \ RRA:AVERAGE:0.5:1:800 \ @@ -23,15 +24,17 @@ if(is_numeric($hrSystem[0]['hrSystemProcesses'])) RRA:MAX:0.5:24:800 \ RRA:MAX:0.5:288:800"); } + rrdtool_update($rrd_file, "N:".$hrSystem[0]['hrSystemProcesses']); $graphs['hr_processes'] = TRUE; echo(" Processes"); } -if(is_numeric($hrSystem[0]['hrSystemNumUsers'])) +if (is_numeric($hrSystem[0]['hrSystemNumUsers'])) { $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd"; - if (!is_file($rrd_file)) { + if (!is_file($rrd_file)) + { rrdtool_create($rrd_file, "--step 300 \ DS:users:GAUGE:600:0:U \ RRA:AVERAGE:0.5:1:800 \ @@ -43,6 +46,7 @@ if(is_numeric($hrSystem[0]['hrSystemNumUsers'])) RRA:MAX:0.5:24:800 \ RRA:MAX:0.5:288:800"); } + rrdtool_update($rrd_file, "N:".$hrSystem[0]['hrSystemNumUsers']); $graphs['hr_users'] = TRUE; echo(" Users"); @@ -50,4 +54,4 @@ if(is_numeric($hrSystem[0]['hrSystemNumUsers'])) echo("\n"); -?> +?> \ No newline at end of file diff --git a/includes/polling/humidity.inc.php b/includes/polling/humidity.inc.php index f5d497dda..a67c751e7 100644 --- a/includes/polling/humidity.inc.php +++ b/includes/polling/humidity.inc.php @@ -2,8 +2,8 @@ $query = "SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $hum_data = mysql_query($query); -while($humidity = mysql_fetch_array($hum_data)) { - +while ($humidity = mysql_fetch_array($hum_data)) +{ echo("Checking humidity " . $humidity['sensor_descr'] . "... "); $hum = snmp_get($device, $humidity['sensor_oid'], "-OUqnv", "SNMPv2-MIB"); @@ -13,21 +13,21 @@ while($humidity = mysql_fetch_array($hum_data)) { $humrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd"); - if (!is_file($humrrd)) { - `rrdtool create $humrrd \ - --step 300 \ + if (!is_file($humrrd)) + { + rrdtool_create($humrrd,"--step 300 \ DS:sensor:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($hum . " %\n"); rrdtool_update($humrrd,"N:$hum"); - if($humidity['sensor_current'] > $humidity['sensor_limit_low'] && $hum <= $humidity['sensor_limit_low']) + if ($humidity['sensor_current'] > $humidity['sensor_limit_low'] && $hum <= $humidity['sensor_limit_low']) { $msg = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit']; $msg .= "%) at " . date($config['timestamp_format']); @@ -35,7 +35,7 @@ while($humidity = mysql_fetch_array($hum_data)) { echo("Alerting for " . $device['hostname'] . " " . $humidity['sensor_descr'] . "\n"); log_event('Frequency ' . $humidity['sensor_descr'] . " under threshold: " . $hum . " % (< " . $humidity['sensor_limit_low'] . " %)", $device['device_id'] , 'humidity', $humidity['sensor_id']); } - else if($humidity['sensor_current'] < $humidity['sensor_limit'] && $hum >= $humidity['sensor_limit']) + else if ($humidity['sensor_current'] < $humidity['sensor_limit'] && $hum >= $humidity['sensor_limit']) { $msg = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit']; $msg .= "%) at " . date($config['timestamp_format']); @@ -47,4 +47,4 @@ while($humidity = mysql_fetch_array($hum_data)) { mysql_query("UPDATE sensors SET sensor_current = '$hum' WHERE sensor_class='humidity' AND sensor_id = '" . $humidity['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index b2c67fa06..f32145e83 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -2,30 +2,30 @@ /* FIXME: dead file */ -if($device['os_group'] == "ios") { +if ($device['os_group'] == "ios") { $portifIndex = array(); $cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -M ".$config['mibdir']. " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portIfIndex"; #echo("$cmd"); $portifIndex_output = trim(shell_exec($cmd)); - foreach(explode("\n", $portifIndex_output) as $entry){ + foreach (explode("\n", $portifIndex_output) as $entry){ $entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry); list($slotport, $ifIndex) = explode(" ", $entry); $portifIndex[$ifIndex] = $slotport; } - if($debug) { print_r($portifIndex); } + if ($debug) { print_r($portifIndex); } } $interface_query = mysql_query("SELECT * FROM `ports` $where"); while ($interface = mysql_fetch_array($interface_query)) { - if(!$device) { $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'")); } + if (!$device) { $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'")); } unset($ifAdminStatus, $ifOperStatus, $ifAlias, $ifDescr); $interface['hostname'] = $device['hostname']; $interface['device_id'] = $device['device_id']; - if($device['status'] == '1') { + if ($device['status'] == '1') { unset($update); unset($update_query); @@ -54,18 +54,18 @@ while ($interface = mysql_fetch_array($interface_query)) { $ifDescr = trim($ifDescr); $ifIndex = $interface['ifIndex']; - if($portifIndex[$ifIndex]) { - if($device['os'] == "CatOS") { + if ($portifIndex[$ifIndex]) { + if ($device['os'] == "CatOS") { $cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-STACK-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portName." . $portifIndex[$ifIndex]; $ifAlias = trim(shell_exec($cmd)); } } - if($config['os'][$device[os]]['ifname']) { $ifDescr = $ifName; } + if ($config['os'][$device[os]]['ifname']) { $ifDescr = $ifName; } $rrdfile = $host_rrd . "/" . safename($interface['ifIndex'] . ".rrd"); - if(!is_file($rrdfile)) { + if (!is_file($rrdfile)) { rrdtool_create($rrdfile,"DS:INOCTETS:COUNTER:600:0:12500000000 \ DS:OUTOCTETS:COUNTER:600:0:12500000000 \ DS:INERRORS:COUNTER:600:0:12500000000 \ @@ -84,34 +84,34 @@ while ($interface = mysql_fetch_array($interface_query)) { RRA:MAX:0.5:288:797"); } - if( file_exists("includes/polling/interface-" . $device['os'] . ".php") ) { include("includes/polling/interface-" . $device['os'] . ".php"); } + if (file_exists("includes/polling/interface-" . $device['os'] . ".php") ) { include("includes/polling/interface-" . $device['os'] . ".php"); } - if ( $interface['ifDescr'] != $ifDescr && $ifDescr != "" ) { + if ($interface['ifDescr'] != $ifDescr && $ifDescr != "" ) { $update .= $seperator . "`ifDescr` = '$ifDescr'"; $seperator = ", "; eventlog("ifDescr -> $ifDescr", $interface['device_id'], $interface['interface_id']); } - if ( $interface['ifName'] != $ifName && $ifName != "" ) { + if ($interface['ifName'] != $ifName && $ifName != "" ) { $update .= $seperator . "`ifName` = '$ifName'"; $seperator = ", "; eventlog("ifName -> $ifName", $interface['device_id'], $interface['interface_id']); } - if ( $interface['ifAlias'] != $ifAlias && $ifAlias != "" ) { + if ($interface['ifAlias'] != $ifAlias && $ifAlias != "" ) { $update .= $seperator . "`ifAlias` = '".mres($ifAlias)."'"; $seperator = ", "; eventlog("ifAlias -> $ifAlias", $interface['device_id'], $interface['interface_id']); } - if ( $interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) { + if ($interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) { $update .= $seperator . "`ifOperStatus` = '$ifOperStatus'"; $seperator = ", "; eventlog("Interface went $ifOperStatus", $interface['device_id'], $interface['interface_id']); } - if ( $interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) { + if ($interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) { $update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'"; $seperator = ", "; - if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; } + if ($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; } eventlog("Interface $admin", $interface['device_id'], $interface['interface_id']); } @@ -125,7 +125,7 @@ while ($interface = mysql_fetch_array($interface_query)) { # echo("Not Updating : " . $device['hostname'] ." $ifDescr ( " . $interface['ifDescr'] . " )\n\n"); } - if($ifOperStatus == "up") { + if ($ifOperStatus == "up") { $snmp_data_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex']; @@ -137,7 +137,7 @@ while ($interface = mysql_fetch_array($interface_query)) { $snmp_data = str_replace("Wrong Type (should be Counter32): ","", $snmp_data); $snmp_data = str_replace("No Such Instance currently exists at this OID","", $snmp_data); list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data); - if($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) { + if ($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) { $octets_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $octets_cmd .= " ifInOctets." . $interface['ifIndex'] . " ifOutOctets." . $interface['ifIndex']; diff --git a/includes/polling/ipSystemStats.inc.php b/includes/polling/ipSystemStats.inc.php index 4b419edd8..c0e9e4f35 100755 --- a/includes/polling/ipSystemStats.inc.php +++ b/includes/polling/ipSystemStats.inc.php @@ -47,54 +47,55 @@ #IP-MIB::ipSystemStatsRefreshRate.ipv4 = Gauge32: 30000 milli-seconds #IP-MIB::ipSystemStatsRefreshRate.ipv6 = Gauge32: 30000 milli-seconds - echo("Polling IP-MIB ipSystemStats "); +echo("Polling IP-MIB ipSystemStats "); - $ipSystemStats = snmpwalk_cache_oid($device, "ipSystemStats", NULL, "IP-MIB"); +$ipSystemStats = snmpwalk_cache_oid($device, "ipSystemStats", NULL, "IP-MIB"); - if($ipSystemStats) { - - foreach($ipSystemStats as $af => $stats) { - - echo("$af "); +if ($ipSystemStats) +{ + foreach ($ipSystemStats as $af => $stats) + { + echo("$af "); $oids = array('ipSystemStatsInReceives','ipSystemStatsInHdrErrors','ipSystemStatsInAddrErrors','ipSystemStatsInUnknownProtos','ipSystemStatsInForwDatagrams','ipSystemStatsReasmReqds', 'ipSystemStatsReasmOKs','ipSystemStatsReasmFails','ipSystemStatsInDiscards','ipSystemStatsInDelivers','ipSystemStatsOutRequests','ipSystemStatsOutNoRoutes','ipSystemStatsOutDiscards', 'ipSystemStatsOutFragFails','ipSystemStatsOutFragCreates','ipSystemStatsOutForwDatagrams'); ### Use HC counters instead if they're available. - if(isset($stats['ipSystemStatsHCInReceives'])) { $stats['ipSystemStatsInReceives'] = $stats['ipSystemStatsHCInReceives']; } - if(isset($stats['ipSystemStatsHCInForwDatagrams'])) { $stats['ipSystemStatsInForwDatagrams'] = $stats['ipSystemStatsHCInForwDatagrams']; } - if(isset($stats['ipSystemStatsHCInDelivers'])) { $stats['ipSystemStatsInDelivers'] = $stats['ipSystemStatsHCInDelivers']; } - if(isset($stats['ipSystemStatsHCOutRequests'])) { $stats['ipSystemStatsOutRequests'] = $stats['ipSystemStatsHCOutRequests']; } - if(isset($stats['ipSystemStatsHCOutForwDatagrams'])) { $stats['ipSystemStatsOutForwDatagrams'] = $stats['ipSystemStatsHCOutForwDatagrams']; } + if (isset($stats['ipSystemStatsHCInReceives'])) { $stats['ipSystemStatsInReceives'] = $stats['ipSystemStatsHCInReceives']; } + if (isset($stats['ipSystemStatsHCInForwDatagrams'])) { $stats['ipSystemStatsInForwDatagrams'] = $stats['ipSystemStatsHCInForwDatagrams']; } + if (isset($stats['ipSystemStatsHCInDelivers'])) { $stats['ipSystemStatsInDelivers'] = $stats['ipSystemStatsHCInDelivers']; } + if (isset($stats['ipSystemStatsHCOutRequests'])) { $stats['ipSystemStatsOutRequests'] = $stats['ipSystemStatsHCOutRequests']; } + if (isset($stats['ipSystemStatsHCOutForwDatagrams'])) { $stats['ipSystemStatsOutForwDatagrams'] = $stats['ipSystemStatsHCOutForwDatagrams']; } unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create); $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ipSystemStats-".$af.".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"; - $rrdupdate = "N"; - foreach($oids as $oid){ + foreach ($oids as $oid) + { $oid_ds = str_replace("ipSystemStats", "", $oid); $oid_ds = truncate($oid_ds, 19, ''); $rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000"; - if(strstr($stats[$oid], "No") || strstr($stats[$oid], "d") || strstr($stats[$oid], "s")) { $stats[$oid] = "0"; } - $rrdupdate .= ":".$stats[$oid]; + if (strstr($stats[$oid], "No") || strstr($stats[$oid], "d") || strstr($stats[$oid], "s")) { $stats[$oid] = "0"; } + $rrdupdate .= ":".$stats[$oid]; } - if(!file_exists($rrdfile)) { rrdtool_create($rrdfile,$rrd_create); } + + if (!file_exists($rrdfile)) { rrdtool_create($rrdfile,$rrd_create); } rrdtool_update($rrdfile, $rrdupdate); + unset($rrdupdate, $rrd_create); ## FIXME per-AF? - + $graphs['ipsystemstats_'.$af] = TRUE; $graphs['ipsystemstats_'.$af.'_frag'] = TRUE; } - } +} echo("\n"); - -?> +?> \ No newline at end of file diff --git a/includes/polling/ipmi.inc.php b/includes/polling/ipmi.inc.php index 1afff0e15..285f924d5 100644 --- a/includes/polling/ipmi.inc.php +++ b/includes/polling/ipmi.inc.php @@ -7,7 +7,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) { $ipmi['user'] = get_dev_attrib($device,'ipmi_username'); $ipmi['password'] = get_dev_attrib($device,'ipmi_password'); - + echo("Fetching IPMI sensor data..."); $results = shell_exec($config['ipmitool'] . " -c -H " . $ipmi['host'] . " -U " . $ipmi['user'] . " -P " . $ipmi['password'] . " sdr"); echo(" done.\n"); @@ -19,7 +19,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) $ipmi_sensor[$desc][$ipmi_unit[$type]]['unit'] = $type; } - while ($ipmisensors = mysql_fetch_array($ipmi_data)) + while ($ipmisensors = mysql_fetch_array($ipmi_data)) { echo("Updating IPMI sensor " . $ipmisensors['sensor_descr'] . "... "); @@ -30,8 +30,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) if (!is_file($sensorrrd)) { - `rrdtool create $sensorrrd \ - --step 300 \ + rrdtool_create($sensorrrd,"--step 300 \ DS:sensor:GAUGE:600:-20000:20000 \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -44,7 +43,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) RRA:MIN:0.5:1:600 \ RRA:MIN:0.5:6:700 \ RRA:MIN:0.5:24:775 \ - RRA:MIN:0.5:288:797`; + RRA:MIN:0.5:288:797"); } echo($sensor . " $unit\n"); @@ -59,4 +58,4 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname')) unset($ipmi_sensor); } -?> +?> \ No newline at end of file diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index 8c3b21571..10ba1678f 100755 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -3,9 +3,8 @@ $sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id"; $vp_data = mysql_query($sql); -if(mysql_affected_rows()) { - - +if (mysql_affected_rows()) +{ $vp_cache = array(); $vp_cache = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vp_cache, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose"); $vp_cache = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInPackets", $vp_cache, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose"); @@ -18,13 +17,13 @@ if(mysql_affected_rows()) { echo("Checking JunOSe ATM vps: "); - while($vp=mysql_fetch_array($vp_data)) { - + while ($vp=mysql_fetch_array($vp_data)) + { echo("."); $oid = $vp['ifIndex'].".".$vp['vp_id']; - if($debug) { echo("$oid "); } + if ($debug) { echo("$oid "); } $t_vp = $vp_cache[$oid]; @@ -35,11 +34,11 @@ if(mysql_affected_rows()) { $rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("vp-" . $vp['ifIndex'] . "-".$vp['vp_id'].".rrd"); - if($debug) { echo("$rrd "); } + if ($debug) { echo("$rrd "); } - if (!is_file($rrd)) { - - rrdtool_create ($rrd, "--step 300 \ + if (!is_file($rrd)) + { + rrdtool_create ($rrd, "--step 300 \ DS:incells:DERIVE:600:0:125000000000 \ DS:outcells:DERIVE:600:0:125000000000 \ DS:inpackets:DERIVE:600:0:125000000000 \ @@ -63,13 +62,11 @@ if(mysql_affected_rows()) { } rrdtool_update($rrd,"N:$vp_update"); - } echo("\n"); unset($vp_cache); - } -?> +?> \ No newline at end of file diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 553468283..131d2f426 100755 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -1,15 +1,15 @@ +?> \ No newline at end of file diff --git a/includes/polling/mempools/cemp.inc.php b/includes/polling/mempools/cemp.inc.php index 226657861..0b5b8175b 100755 --- a/includes/polling/mempools/cemp.inc.php +++ b/includes/polling/mempools/cemp.inc.php @@ -7,7 +7,7 @@ $pool_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m CISCO-ENHANCED- $pool_cmd .= " cempMemPoolUsed.$oid cempMemPoolFree.$oid cempMemPoolLargestFree.$oid"; $pool_cmd .= " | cut -f 1 -d ' '"; -if ($debug) {echo("SNMP [ $pool_cmd ]\n");} +if ($debug) { echo("SNMP [ $pool_cmd ]\n"); } $pool = shell_exec($pool_cmd); diff --git a/includes/polling/mempools/junos.inc.php b/includes/polling/mempools/junos.inc.php index 7091320bf..d4276858f 100755 --- a/includes/polling/mempools/junos.inc.php +++ b/includes/polling/mempools/junos.inc.php @@ -2,11 +2,11 @@ $oid = $mempool['mempool_index']; -if ($debug) {echo("JunOS Mempool");} +if ($debug) { echo("JunOS Mempool"); } if (!is_array($mempool_cache['junos'])) { - if ($debug) {echo("caching");} + if ($debug) { echo("caching"); } $mempool_cache['junos'] = array(); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, "jnxOperatingBuffer", $mempool_cache['junos'], "JUNIPER-MIB" , $config['install_dir']."/mibs/junos"); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, "jnxOperatingDRAMSize", $mempool_cache['junos'], "JUNIPER-MIB" , $config['install_dir']."/mibs/junos"); diff --git a/includes/polling/netstats-icmp.inc.php b/includes/polling/netstats-icmp.inc.php index 1c8258ef5..e57efe023 100755 --- a/includes/polling/netstats-icmp.inc.php +++ b/includes/polling/netstats-icmp.inc.php @@ -1,7 +1,7 @@ +?> \ No newline at end of file diff --git a/includes/polling/netstats-ip.inc.php b/includes/polling/netstats-ip.inc.php index 3ea852aaf..7ce35949e 100755 --- a/includes/polling/netstats-ip.inc.php +++ b/includes/polling/netstats-ip.inc.php @@ -1,7 +1,7 @@ + $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); + +?> \ No newline at end of file diff --git a/includes/polling/netstats-snmp.inc.php b/includes/polling/netstats-snmp.inc.php index 91df5d9fa..c41f2387e 100755 --- a/includes/polling/netstats-snmp.inc.php +++ b/includes/polling/netstats-snmp.inc.php @@ -1,7 +1,7 @@ +?> \ No newline at end of file diff --git a/includes/polling/netstats-tcp.inc.php b/includes/polling/netstats-tcp.inc.php index 7f38d6c46..622032981 100755 --- a/includes/polling/netstats-tcp.inc.php +++ b/includes/polling/netstats-tcp.inc.php @@ -1,7 +1,7 @@ +?> \ No newline at end of file diff --git a/includes/polling/netstats-udp.inc.php b/includes/polling/netstats-udp.inc.php index 43972861e..382dc5ff4 100755 --- a/includes/polling/netstats-udp.inc.php +++ b/includes/polling/netstats-udp.inc.php @@ -1,6 +1,7 @@ +?> \ No newline at end of file diff --git a/includes/polling/port-adsl.inc.php b/includes/polling/port-adsl.inc.php index c0a444886..44145af94 100755 --- a/includes/polling/port-adsl.inc.php +++ b/includes/polling/port-adsl.inc.php @@ -40,77 +40,84 @@ # adslAturPerfValidIntervals.1 = 0 # adslAturPerfInvalidIntervals.1 = 0 - if(isset($port_stats[$port['ifIndex']]['adslLineCoding'])) { // Check to make sure Port data is cached. +if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) +{ // Check to make sure Port data is cached. - $this_port = &$port_stats[$port['ifIndex']]; + $this_port = &$port_stats[$port['ifIndex']]; - $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-".$port['ifIndex']."-adsl.rrd"); + $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-".$port['ifIndex']."-adsl.rrd"); - $rrd_create = " --step 300"; - $rrd_create .= " DS:AtucCurrSnrMgn:GAUGE:600:0:U"; - $rrd_create .= " DS:AtucCurrAtn:GAUGE:600:0:U"; - $rrd_create .= " DS:AtucCurrOutputPwr:GAUGE:600:0:U"; - $rrd_create .= " DS:AtucCurrAttainableR:GAUGE:600:0:U"; - $rrd_create .= " DS:AtucChanCurrTxRate:GAUGE:600:0:U"; - $rrd_create .= " DS:AturCurrSnrMgn:GAUGE:600:0:U"; - $rrd_create .= " DS:AturCurrAtn:GAUGE:600:0:U"; - $rrd_create .= " DS:AturCurrOutputPwr:GAUGE:600:0:U"; - $rrd_create .= " DS:AturCurrAttainableR:GAUGE:600:0:U"; - $rrd_create .= " DS:AturChanCurrTxRate:GAUGE:600:0:U"; - $rrd_create .= " DS:AtucPerfLofs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucPerfLoss:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucPerfLprs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucPerfESs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucPerfInits:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturPerfLofs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturPerfLoss:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturPerfLprs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturPerfESs:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucChanCorrectedBl:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AtucChanUncorrectBl:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturChanCorrectedBl:COUNTER:600:U:100000000000"; - $rrd_create .= " DS:AturChanUncorrectBl:COUNTER:600:U:100000000000"; - $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"; - $rrd_create .= " RRA:MIN:0.5:1:600 RRA:MIN:0.5:6:700 RRA:MIN:0.5:24:775 RRA:MIN:0.5:288:797 "; - $rrd_create .= " 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 = " --step 300"; + $rrd_create .= " DS:AtucCurrSnrMgn:GAUGE:600:0:U"; + $rrd_create .= " DS:AtucCurrAtn:GAUGE:600:0:U"; + $rrd_create .= " DS:AtucCurrOutputPwr:GAUGE:600:0:U"; + $rrd_create .= " DS:AtucCurrAttainableR:GAUGE:600:0:U"; + $rrd_create .= " DS:AtucChanCurrTxRate:GAUGE:600:0:U"; + $rrd_create .= " DS:AturCurrSnrMgn:GAUGE:600:0:U"; + $rrd_create .= " DS:AturCurrAtn:GAUGE:600:0:U"; + $rrd_create .= " DS:AturCurrOutputPwr:GAUGE:600:0:U"; + $rrd_create .= " DS:AturCurrAttainableR:GAUGE:600:0:U"; + $rrd_create .= " DS:AturChanCurrTxRate:GAUGE:600:0:U"; + $rrd_create .= " DS:AtucPerfLofs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucPerfLoss:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucPerfLprs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucPerfESs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucPerfInits:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturPerfLofs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturPerfLoss:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturPerfLprs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturPerfESs:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucChanCorrectedBl:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AtucChanUncorrectBl:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturChanCorrectedBl:COUNTER:600:U:100000000000"; + $rrd_create .= " DS:AturChanUncorrectBl:COUNTER:600:U:100000000000"; + $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"; + $rrd_create .= " RRA:MIN:0.5:1:600 RRA:MIN:0.5:6:700 RRA:MIN:0.5:24:775 RRA:MIN:0.5:288:797 "; + $rrd_create .= " RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797 "; - $adsl_oids = array('AtucCurrSnrMgn','AtucCurrAtn','AtucCurrOutputPwr','AtucCurrAttainableRate','AtucChanCurrTxRate','AturCurrSnrMgn','AturCurrAtn','AturCurrOutputPwr','AturCurrAttainableRate','AturChanCurrTxRate','AtucPerfLofs','AtucPerfLoss','AtucPerfLprs','AtucPerfESs','AtucPerfInits','AturPerfLofs','AturPerfLoss','AturPerfLprs','AturPerfESs','AtucChanCorrectedBlks','AtucChanUncorrectBlks','AturChanCorrectedBlks','AturChanUncorrectBlks'); + $adsl_oids = array('AtucCurrSnrMgn','AtucCurrAtn','AtucCurrOutputPwr','AtucCurrAttainableRate','AtucChanCurrTxRate','AturCurrSnrMgn','AturCurrAtn','AturCurrOutputPwr','AturCurrAttainableRate','AturChanCurrTxRate','AtucPerfLofs','AtucPerfLoss','AtucPerfLprs','AtucPerfESs','AtucPerfInits','AturPerfLofs','AturPerfLoss','AturPerfLprs','AturPerfESs','AtucChanCorrectedBlks','AtucChanUncorrectBlks','AturChanCorrectedBlks','AturChanUncorrectBlks'); - $adsl_db_oids = array('adslLineCoding','adslLineType','adslAtucInvVendorID','adslAtucInvVersionNumber','adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr', - 'adslAtucCurrAttainableRate','adslAturInvSerialNumber','adslAturInvVendorID','adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', - 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate'); + $adsl_db_oids = array('adslLineCoding','adslLineType','adslAtucInvVendorID','adslAtucInvVersionNumber','adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr', + 'adslAtucCurrAttainableRate','adslAturInvSerialNumber','adslAturInvVendorID','adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', + 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate'); - $adsl_tenth_oids = array('adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr','adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr'); + $adsl_tenth_oids = array('adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr','adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr'); - foreach($adsl_tenth_oids as $oid) { - $this_port[$oid] = $this_port[$oid] / 10; - } - - if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'"),0) == "0") { mysql_query("INSERT INTO `ports_adsl` (`interface_id`) VALUES ('".$port['interface_id']."')"); } - $mysql_update = "UPDATE `ports_adsl` SET `port_adsl_updated` = NOW()"; - foreach($adsl_db_oids as $oid) { - $data = str_replace("\"", "", $this_port[$oid]); - $mysql_update .= ",`".$oid."` = '".$data."'"; - } - $mysql_update .= "WHERE `interface_id` = '".$port['interface_id']."'"; - mysql_query($mysql_update); + foreach ($adsl_tenth_oids as $oid) + { + $this_port[$oid] = $this_port[$oid] / 10; + } - if($debug) { echo($mysql_update); echo(mysql_affected_rows()); echo(mysql_error()); } + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'"),0) == "0") + { + mysql_query("INSERT INTO `ports_adsl` (`interface_id`) VALUES ('".$port['interface_id']."')"); + } + $mysql_update = "UPDATE `ports_adsl` SET `port_adsl_updated` = NOW()"; + foreach ($adsl_db_oids as $oid) + { + $data = str_replace("\"", "", $this_port[$oid]); + $mysql_update .= ",`".$oid."` = '".$data."'"; + } + $mysql_update .= "WHERE `interface_id` = '".$port['interface_id']."'"; + mysql_query($mysql_update); - $rrdupdate = "N"; - foreach($adsl_oids as $oid) { - $oid = "adsl".$oid; - $data = str_replace("\"", "", $this_port[$oid]); - ## Set data to be "unknown" if it's garbled, unexistant or zero - if(!is_numeric($data)) { $data = "0"; } - $rrdupdate .= ":$data"; - } + if ($debug) { echo($mysql_update); echo(mysql_affected_rows()); echo(mysql_error()); } - if (!is_file($rrdfile)) { rrdtool_create ($rrdfile, $rrd_create); } - rrdtool_update ($rrdfile, $rrdupdate); + $rrdupdate = "N"; + foreach ($adsl_oids as $oid) + { + $oid = "adsl".$oid; + $data = str_replace("\"", "", $this_port[$oid]); + ## Set data to be "unknown" if it's garbled, unexistant or zero + if (!is_numeric($data)) { $data = "0"; } + $rrdupdate .= ":$data"; + } - echo("ADSL "); + if (!is_file($rrdfile)) { rrdtool_create ($rrdfile, $rrd_create); } + rrdtool_update ($rrdfile, $rrdupdate); - } -?> + echo("ADSL "); +} + +?> \ No newline at end of file diff --git a/includes/polling/port-etherlike.inc.php b/includes/polling/port-etherlike.inc.php index c8d9f5b88..33e14ecf9 100755 --- a/includes/polling/port-etherlike.inc.php +++ b/includes/polling/port-etherlike.inc.php @@ -1,38 +1,43 @@ + $rrdupdate = "N"; + foreach ($etherlike_oids as $oid) + { + $data = $this_port[$oid] + 0; + $rrdupdate .= ":$data"; + } + rrdtool_update($rrdfile, $rrdupdate); + + echo("EtherLike "); +} + +?> \ No newline at end of file diff --git a/includes/polling/port-poe.inc.php b/includes/polling/port-poe.inc.php index 18c94e77b..84d690974 100755 --- a/includes/polling/port-poe.inc.php +++ b/includes/polling/port-poe.inc.php @@ -12,7 +12,7 @@ $peth_oids = array('pethPsePortAdminEnable', 'pethPsePortPowerPairsControlAbilit $port_stats = snmpwalk_cache_oid($device, "pethPsePortEntry", $port_stats, "POWER-ETHERNET-MIB"); $port_stats = snmpwalk_cache_oid($device, "cpeExtPsePortEntry", $port_stats, "CISCO-POWER-ETHERNET-EXT-MIB"); -if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" +if ($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" && isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) { // Check to make sure Port data is cached. @@ -20,9 +20,8 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-".$port['ifIndex']."-poe.rrd"); - if(!file_exists($rrdfile)) + if (!file_exists($rrdfile)) { - $rrd_create = $config['rrdtool'] . " create $rrdfile "; $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"; @@ -32,7 +31,7 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" $rrd_create .= " DS:PortConsumption:DERIVE:600:0:U"; $rrd_create .= " DS:PortMaxPwrDrawn:GAUGE:600:0:U "; - shell_exec($rrd_create);*/ + rrd_create($rrdfile, $rrd_create); } $upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].":".$port['cpeExtPsePortPwrAvailable'].":".$port['cpeExtPsePortPwrConsumption'].":".$port['cpeExtPsePortMaxPwrDrawn']; @@ -40,4 +39,5 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" echo("PoE "); } -?> + +?> \ No newline at end of file diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 5399fcf35..07f08dfe4 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -1,242 +1,242 @@ "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"); - } +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); +} - echo("\n"); +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"); +} - #foreach ($etherlike_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "EtherLike-MIB"); } - #foreach ($cisco_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "OLD-CISCO-INTERFACES-MIB"); } - #foreach ($pagp_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "CISCO-PAGP-MIB"); } +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"); - } +#foreach ($etherlike_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "EtherLike-MIB"); } +#foreach ($cisco_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "OLD-CISCO-INTERFACES-MIB"); } +#foreach ($pagp_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, "CISCO-PAGP-MIB"); } - $polled = time(); +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"); +} - /// End Building SNMP Cache Array +$polled = time(); - if ($debug) { print_r($port_stats); } +/// End Building SNMP Cache Array - /// New interface detection - ///// TO DO - /// End New interface detection +if ($debug) { print_r($port_stats); } - /// Loop ports in the DB and update where necessary - $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['ignore'] == "0") - { // Check to make sure Port data is cached. - $this_port = &$port_stats[$port['ifIndex']]; +/// New interface detection +///// TO DO +/// End New interface detection - $polled_period = $polled - $port['poll_time']; +/// Loop ports in the DB and update where necessary +$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['ignore'] == "0") + { // Check to make sure Port data is cached. + $this_port = &$port_stats[$port['ifIndex']]; - $update .= "`poll_time` = '".$polled."'"; - $update .= ", `poll_prev` = '".$port['poll_time']."'"; - $update .= ", `poll_period` = '".$polled_period."'"; + $polled_period = $polled - $port['poll_time']; - #echo("\n32bit - In: ".$this_port['ifInOctets']." Out: ".$this_port['ifOutOctets']); - #echo("\n64bit - In: ".$this_port['ifHCInOctets']." Out: ".$this_port['ifHCOutOctets']."\n"); + $update .= "`poll_time` = '".$polled."'"; + $update .= ", `poll_prev` = '".$port['poll_time']."'"; + $update .= ", `poll_period` = '".$polled_period."'"; - ### 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']; + #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 . " "); } } + } - 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']; - } + /// Parse description (usually ifAlias) if config option set - ### 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; - } + 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']); - ### Overwrite ifDuplex with dot3StatsDuplexStatus if it exists - if (isset($this_port['dot3StatsDuplexStatus'])) + foreach ($port_attribs as $attrib) { - 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])) + $attrib_key = "port_descr_".$attrib; + if ($port_ifAlias[$attrib] != $port[$attrib_key]) { - $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 . " "); } + $update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'"; + log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']); } } + } - /// Parse description (usually ifAlias) if config option set + /// Ende parse ifAlias - 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 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)) + $update .= ", `".$oid."_prev` = '".$port[$oid]."'"; + $oid_prev = $oid . "_prev"; + if ($port[$oid]) { - 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"); + $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"); } } + } - 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"; } - } + /// 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"); + } - $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); + 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); } @@ -244,75 +244,79 @@ # $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update); # } - /// End Update IF-MIB + /// 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'])) - { - 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['ignore'] == "0") + /// Update PAgP + if ($this_port['pagpOperationMode']) { - 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 Ignored."); + 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 - echo("\n"); + /// Do EtherLike-MIB + if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); } - #### Clear Per-Port Variables Here - unset($this_port); + /// 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'])) + { + 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['ignore'] == "0") + { + 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 Ignored."); } - #### Clear Variables Here - unset($port_stats); + echo("\n"); -?> + #### Clear Per-Port Variables Here + unset($this_port); + +} + +#### Clear Variables Here +unset($port_stats); + +?> \ No newline at end of file diff --git a/includes/polling/processors.inc.php b/includes/polling/processors.inc.php index 612a41a12..bb47dd139 100755 --- a/includes/polling/processors.inc.php +++ b/includes/polling/processors.inc.php @@ -2,12 +2,13 @@ $query = "SELECT * FROM processors WHERE device_id = '" . $device['device_id'] . "'"; $proc_data = mysql_query($query); -while($processor = mysql_fetch_array($proc_data)) { - +while ($processor = mysql_fetch_array($proc_data)) +{ echo("Processor " . $processor['processor_descr'] . "... "); $file = $config['install_dir']."/includes/polling/processors-".$processor['processor_type'].".inc.php"; - if(is_file($file)) { + if (is_file($file)) + { include($file); } else { $proc = snmp_get ($device, $processor['processor_oid'], "-O Uqnv"); @@ -15,8 +16,9 @@ while($processor = mysql_fetch_array($proc_data)) { $procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd"); - if (!is_file($procrrd)) { - rrdtool_create($procrrd, "--step 300 \ + if (!is_file($procrrd)) + { + rrdtool_create($procrrd, "--step 300 \ DS:usage:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ @@ -25,9 +27,9 @@ while($processor = mysql_fetch_array($proc_data)) { } $proc = trim(str_replace("\"", "", $proc)); - list($proc) = preg_split("@\ @", $proc); + list($proc) = preg_split("@\ @", $proc); - if(!$processor['processor_precision']) {$processor['processor_precision'] = "1";}; + if (!$processor['processor_precision']) { $processor['processor_precision'] = "1"; }; $proc = round($proc / $processor['processor_precision'],2); echo($proc . "%\n"); @@ -35,7 +37,6 @@ while($processor = mysql_fetch_array($proc_data)) { rrdtool_update($procrrd,"N:$proc"); mysql_query("UPDATE `processors` SET `processor_usage` = '$proc' WHERE `processor_id` = '".$processor['processor_id']."'"); - } -?> +?> \ No newline at end of file diff --git a/includes/polling/storage-hrstorage.inc.php b/includes/polling/storage-hrstorage.inc.php index f55219de8..9ee9abf5e 100755 --- a/includes/polling/storage-hrstorage.inc.php +++ b/includes/polling/storage-hrstorage.inc.php @@ -2,7 +2,8 @@ ### HOST-RESOURCES-MIB - Storage Objects -if(!is_array($storage_cache['hrstorage'])) { +if (!is_array($storage_cache['hrstorage'])) +{ $storage_cache['hrstorage'] = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); if ($debug) { print_r($storage_cache); } } @@ -14,4 +15,4 @@ $storage['used'] = $entry['hrStorageUsed'] * $storage['units']; $storage['size'] = $entry['hrStorageSize'] * $storage['units']; $storage['free'] = $storage['size'] - $storage['used']; -?> +?> \ No newline at end of file diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 30ce5318e..260801774 100755 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -6,13 +6,14 @@ $storage_cache = array(); $query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'"; $storage_data = mysql_query($query); -while($storage = mysql_fetch_array($storage_data)) { - +while ($storage = mysql_fetch_array($storage_data)) +{ echo("Storage ".$storage['storage_descr'] . ": "); $storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-" . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".rrd"); - if (!is_file($storage_rrd)) { + if (!is_file($storage_rrd)) + { rrdtool_create($storage_rrd, "--step 300 \ DS:used:GAUGE:600:0:U \ DS:free:GAUGE:600:0:U \ @@ -31,13 +32,14 @@ while($storage = mysql_fetch_array($storage_data)) { } $file = $config['install_dir']."/includes/polling/storage-".$storage['storage_mib'].".inc.php"; - if(is_file($file)) { + if (is_file($file)) + { include($file); } else { ### Generic poller goes here if we ever have a discovery module which uses it. } - if($debug) {print_r($storage);} + if ($debug) {print_r($storage); } if ($storage['size']) { @@ -56,13 +58,12 @@ while($storage = mysql_fetch_array($storage_data)) { $update_query .= ", `storage_free` = '".$storage['free']."', `storage_size` = '".$storage['size']."'"; $update_query .= ", `storage_units` = '".$storage['units']."', `storage_perc` = '".$percent."'"; $update_query .= " WHERE `storage_id` = '".$storage['storage_id']."'"; - if($debug) { echo("$update_query\n"); } + if ($debug) { echo("$update_query\n"); } mysql_query($update_query); echo("\n"); - } unset($storage); -?> +?> \ No newline at end of file diff --git a/includes/polling/temperatures.inc.php b/includes/polling/temperatures.inc.php index 7fe1fc4b4..089f73218 100755 --- a/includes/polling/temperatures.inc.php +++ b/includes/polling/temperatures.inc.php @@ -2,8 +2,8 @@ $query = "SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $temp_data = mysql_query($query); -while($temperature = mysql_fetch_array($temp_data)) { - +while ($temperature = mysql_fetch_array($temp_data)) +{ echo("Checking temp " . $temperature['sensor_descr'] . "... "); for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading @@ -22,11 +22,11 @@ while($temperature = mysql_fetch_array($temp_data)) { $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temperature-" . $temperature['sensor_descr'] . ".rrd"); $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd"; - if(is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } + if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } - if (!is_file($rrd_file)) { - `rrdtool create $rrd_file \ - --step 300 \ + if (!is_file($rrd_file)) + { + rrdtool_create($rrd_file,"--step 300 \ DS:sensor:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -39,14 +39,14 @@ while($temperature = mysql_fetch_array($temp_data)) { RRA:MIN:0.5:1:600 \ RRA:MIN:0.5:6:700 \ RRA:MIN:0.5:24:775 \ - RRA:MIN:0.5:288:797`; + RRA:MIN:0.5:288:797"); } echo($temp . "C\n"); rrdtool_update($rrd_file,"N:$temp"); - if($temperature['sensor_current'] < $temperature['sensor_limit'] && $temp >= $temperature['sensor_limit']) + if ($temperature['sensor_current'] < $temperature['sensor_limit'] && $temp >= $temperature['sensor_limit']) { $msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'] . " is " . $temp . " (Limit " . $temperature['sensor_limit']; $msg .= ") at " . date($config['timestamp_format']); @@ -58,4 +58,4 @@ while($temperature = mysql_fetch_array($temp_data)) { mysql_query("UPDATE sensors SET sensor_current = '$temp' WHERE sensor_class='temperature' AND sensor_id = '" . $temperature['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php index 8a5b01595..8e6124659 100755 --- a/includes/polling/toner.inc.php +++ b/includes/polling/toner.inc.php @@ -4,8 +4,8 @@ if ($config['enable_printers']) { $query = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'"; $toner_data = mysql_query($query); - - while($toner = mysql_fetch_array($toner_data)) + + while ($toner = mysql_fetch_array($toner_data)) { echo("Checking toner " . $toner['toner_descr'] . "... "); @@ -16,15 +16,14 @@ if ($config['enable_printers']) $tonerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("toner-" . $toner['toner_descr'] . ".rrd"); - if (!is_file($tonerrrd)) + if (!is_file($tonerrrd)) { - `rrdtool create $tonerrrd \ - --step 300 \ + rrdtool_create($tonerrrd,"--step 300 \ DS:toner:GAUGE:600:0:20000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($tonerperc . " %\n"); @@ -37,4 +36,4 @@ if ($config['enable_printers']) } } -?> +?> \ No newline at end of file diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index 25dce837d..4b2b40f3d 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -1,35 +1,35 @@ +?> \ No newline at end of file diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index ccbb38bb3..b968f72c5 100755 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -1,45 +1,119 @@ +?> \ No newline at end of file diff --git a/includes/polling/voltages.inc.php b/includes/polling/voltages.inc.php index 257774f35..81f719528 100755 --- a/includes/polling/voltages.inc.php +++ b/includes/polling/voltages.inc.php @@ -2,8 +2,9 @@ $query = "SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'"; $volt_data = mysql_query($query); -while($sensor = mysql_fetch_array($volt_data)) { +while ($sensor = mysql_fetch_array($volt_data)) +{ echo("Checking voltage " . $sensor['sensor_descr'] . "... "); $volt = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB"); @@ -14,23 +15,23 @@ while($sensor = mysql_fetch_array($volt_data)) { $old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("voltage-" . $sensor['sensor_descr'] . ".rrd"); $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/voltage-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd"; - if(is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } + if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); } - if (!is_file($rrd_file)) { - `rrdtool create $rrd_file \ - --step 300 \ + if (!is_file($rrd_file)) + { + rrdtool_create($rrd_file,"--step 300 \ DS:sensor:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } echo($volt . " V\n"); rrdtool_update($rrd_file,"N:$volt"); - if($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low']) + if ($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low']) { $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit']; $msg .= "V) at " . date($config['timestamp_format']); @@ -38,7 +39,7 @@ while($sensor = mysql_fetch_array($volt_data)) { echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n"); log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $volt . " V (< " . $sensor['sensor_limit_low'] . " V)", $device['device_id'], 'voltage', $sensor['sensor_id']); } - else if($sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit']) + else if ($sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit']) { $msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit']; $msg .= "V) at " . date($config['timestamp_format']); @@ -49,4 +50,4 @@ while($sensor = mysql_fetch_array($volt_data)) { mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $sensor['sensor_id'] . "'"); } -?> +?> \ No newline at end of file diff --git a/includes/polling/wifi.inc.php b/includes/polling/wifi.inc.php index 2491816d6..23363b2bf 100644 --- a/includes/polling/wifi.inc.php +++ b/includes/polling/wifi.inc.php @@ -4,11 +4,9 @@ echo("Wireless: "); if ($device['type'] == 'network') { - ##### GENERIC FRAMEWORK, FILLING VARIABLES if ($device['os'] == 'airport') { - echo("Checking Airport Wireless clients... "); $wificlients1 = snmp_get($device, "wirelessNumber.0", "-OUqnv", "AIRPORT-BASESTATION-3-MIB") +0; @@ -17,65 +15,60 @@ if ($device['type'] == 'network') # FIXME Also interesting to poll? dhcpNumber.0 for number of active dhcp leases } - + if ($device['os'] == 'ios' and substr($device['hardware'],0,4) == 'AIR-') { - echo("Checking Aironet Wireless clients... "); $wificlients1 = snmp_get($device, "cDot11ActiveWirelessClients.1", "-OUqnv", "CISCO-DOT11-ASSOCIATION-MIB"); $wificlients2 = snmp_get($device, "cDot11ActiveWirelessClients.2", "-OUqnv", "CISCO-DOT11-ASSOCIATION-MIB"); - + echo(($wificlients1 +0) . " clients on dot11Radio0, " . ($wificlients2 +0) . " clients on dot11Radio1\n"); } - - + ##### RRD Filling Code if (isset($wificlients1) && $wificlients1 != "") { $wificlientsrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("wificlients-radio1.rrd"); - if (!is_file($wificlientsrrd)) { - `rrdtool create $wificlientsrrd \ - --step 300 \ + if (!is_file($wificlientsrrd)) + { + rrdtool_create($wificlientsrrd,"--step 300 \ DS:wificlients:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } rrdtool_update($wificlientsrrd,"N:".$wificlients1); $graphs['wifi_clients'] = TRUE; - } if (isset($wificlients2) && $wificlients2 != "") { $wificlientsrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("wificlients-radio2.rrd"); - if (!is_file($wificlientsrrd)) { - `rrdtool create $wificlientsrrd \ - --step 300 \ + if (!is_file($wificlientsrrd)) + { + rrdtool_create($wificlientsrrd,"--step 300 \ DS:wificlients:GAUGE:600:-273:1000 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400`; + RRA:AVERAGE:0.5:12:2400"); } rrdtool_update($wificlientsrrd,"N:".$wificlients2); $graphs['wifi_clients'] = TRUE; - } unset($wificlients2, $wificlients1); - } echo("\n"); -?> +?> \ No newline at end of file