some code formatting improvements from sovern

git-svn-id: http://www.observium.org/svn/observer/trunk@1300 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-07-05 19:21:36 +00:00
parent 96c74a23bb
commit c5f851a00f
4 changed files with 194 additions and 194 deletions

View File

@@ -3,7 +3,7 @@
if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
unset( $cpw_count );
unset($cpw_exists);
unset( $cpw_exists );
echo("Cisco Pseudowires : ");
@@ -13,53 +13,53 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
$oids = trim($oids);
foreach ( explode("\n", $oids) as $oid ) {
if($oid) {
list($cpwOid, $cpwVcID) = explode(" ", $oid);
if($cpwOid) {
list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid));
$interface_descr = trim(shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid));
$cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0);
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0);
if($cpw_remote_device && $if_id) {
$hostname = gethostbyid($cpw_remote_device);
#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
AND `cpwVcID`='".$cpwVcID."'"),0)) {
echo(".");
} else {
$insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) ";
$insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')";
mysql_query($insert_query);
echo("+");
#echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n");
}
if($oid) {
list($cpwOid, $cpwVcID) = explode(" ", $oid);
if($cpwOid) {
list($cpw_remote_id) = split(":", shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MPLS-MIB -Ln -Osqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcMplsPeerLdpID." . $cpwOid));
$interface_descr = trim(shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -Oqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcName." . $cpwOid));
$cpw_remote_device = @mysql_result(mysql_query("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '".$cpw_remote_id."' AND A.interface_id = I.interface_id"),0);
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0);
if($cpw_remote_device && $if_id) {
$hostname = gethostbyid($cpw_remote_device);
#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
AND `cpwVcID`='".$cpwVcID."'"),0)) {
echo(".");
} else {
$insert_query = "INSERT INTO `pseudowires` (`interface_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`) ";
$insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')";
mysql_query($insert_query);
echo("+");
#echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n");
}
$cpw_exists[] = $device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID";
}
}
}
}
}
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($cpw = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($cpw_exists) && !$exists) {
$this_cpw = $cpw['device_id'] . " " . $cpw['cpwOid'] . " " . $cpw['peer_device_id'] . " " . $cpw['interface_id'] . " " . $cpw['cpwVcID'];
if ($cpw_exists[$i] == $this_cpw) { $exists = 1;
while ($cpw = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($cpw_exists) && !$exists) {
$this_cpw = $cpw['device_id'] . " " . $cpw['cpwOid'] . " " . $cpw['peer_device_id'] . " " . $cpw['interface_id'] . " " . $cpw['cpwVcID'];
if ($cpw_exists[$i] == $this_cpw) { $exists = 1;
# echo($cpw_exists[$i]. " || $this_cpw \n");
}
$i++;
}
$i++;
}
if(!$exists) {
echo("-");
if(!$exists) {
echo("-");
# echo($this_cpw . "\n");
mysql_query("DELETE FROM pseudowires WHERE pseudowire_id = '" . $cpw['pseudowire_id'] . "'");
mysql_query("DELETE FROM pseudowires WHERE pseudowire_id = '" . $cpw['pseudowire_id'] . "'");
}
}
}
echo("\n");
echo("\n");
}

View File

@@ -1,59 +1,58 @@
<?php
echo "Discovery protocols:";
$community = $device['community'];
if($device['os'] == "ironware") {
echo(" Brocade FDP: ");
$fdp_array = snmpwalk_cache_twopart_oid("snFdpCacheEntry", $device, array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
$fdp_array = $fdp_array[$device['device_id']];
if($fdp_array) {
unset($fdp_links);
foreach( array_keys($fdp_array) as $key)
{
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
$fdp_if_array = $fdp_array[$key];
foreach( array_keys($fdp_if_array) as $entry_key)
{
$fdp = $fdp_if_array[$entry_key];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$fdp['snFdpCacheDeviceId']."' OR `hostname`='".$fdp['snFdpCacheDeviceId']."'"), 0);
if($remote_device_id) {
$if = $fdp['snFdpCacheDevicePort'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
discover_link($interface['interface_id'], $fdp['snFdpCacheVendorId'], $remote_interface_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']);
echo(" Brocade FDP: ");
$fdp_array = snmpwalk_cache_twopart_oid("snFdpCacheEntry", $device, array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
$fdp_array = $fdp_array[$device['device_id']];
if($fdp_array) {
unset($fdp_links);
foreach( array_keys($fdp_array) as $key) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
$fdp_if_array = $fdp_array[$key];
foreach( array_keys($fdp_if_array) as $entry_key)
{
$fdp = $fdp_if_array[$entry_key];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$fdp['snFdpCacheDeviceId']."' OR `hostname`='".$fdp['snFdpCacheDeviceId']."'"), 0);
if($remote_device_id) {
$if = $fdp['snFdpCacheDevicePort'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
discover_link($interface['interface_id'], $fdp['snFdpCacheVendorId'], $remote_interface_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']);
}
}
}
}
}
if($device['os_group'] == "ios") {
echo(" CISCO-CDP-MIB: ");
unset($cdp_array);
$cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, array(), "CISCO-CDP-MIB");
$cdp_array = $cdp_array[$device['device_id']];
if($cdp_array) {
unset($cdp_links);
foreach( array_keys($cdp_array) as $key) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
$cdp_if_array = $cdp_array[$key];
foreach( array_keys($cdp_if_array) as $entry_key) {
$cdp = $cdp_if_array[$entry_key];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$cdp['cdpCacheDeviceId']."' OR `hostname`='".$cdp['cdpCacheDeviceId']."'"), 0);
if($remote_device_id) {
$if = $cdp['cdpCacheDevicePort'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
if($interface['interface_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) {
discover_link($interface['interface_id'], 'cdp', $remote_interface_id, $cdp['cdpCacheDeviceId'], $cdp['cdpCacheDevicePort'], $cdp['cdpCachePlatform'], $cdp['cdpCacheVersion']);
}
}
echo(" CISCO-CDP-MIB: ");
unset($cdp_array);
$cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, array(), "CISCO-CDP-MIB");
$cdp_array = $cdp_array[$device['device_id']];
if($cdp_array) {
unset($cdp_links);
foreach( array_keys($cdp_array) as $key) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
$cdp_if_array = $cdp_array[$key];
foreach( array_keys($cdp_if_array) as $entry_key) {
$cdp = $cdp_if_array[$entry_key];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$cdp['cdpCacheDeviceId']."' OR `hostname`='".$cdp['cdpCacheDeviceId']."'"), 0);
if($remote_device_id) {
$if = $cdp['cdpCacheDevicePort'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
if($interface['interface_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) {
discover_link($interface['interface_id'], 'cdp', $remote_interface_id, $cdp['cdpCacheDeviceId'], $cdp['cdpCacheDevicePort'], $cdp['cdpCachePlatform'], $cdp['cdpCacheVersion']);
}
}
}
}
}
}
echo(" LLDP-MIB: ");
@@ -69,16 +68,16 @@ if($lldp_array) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$entry_key."'"));
$lldp_instance = $lldp_if_array[$entry_key];
foreach ( array_keys($lldp_instance) as $entry_instance) {
$lldp = $lldp_instance[$entry_instance];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$lldp['lldpRemSysName']."' OR `hostname`='".$lldp['lldpRemSysName']."'"), 0);
if($remote_device_id) {
$if = $lldp['lldpRemPortDesc'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
$lldp = $lldp_instance[$entry_instance];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$lldp['lldpRemSysName']."' OR `hostname`='".$lldp['lldpRemSysName']."'"), 0);
if($remote_device_id) {
$if = $lldp['lldpRemPortDesc'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
if($interface['interface_id'] && $lldp['lldpRemSysDesc'] && $lldp['lldpRemPortDesc']) {
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortDesc'], NULL, $lldp['lldpRemSysDesc']);
}
if($interface['interface_id'] && $lldp['lldpRemSysDesc'] && $lldp['lldpRemPortDesc']) {
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortDesc'], NULL, $lldp['lldpRemSysDesc']);
}
}
}
}
@@ -104,6 +103,7 @@ if ($query = mysql_query($sql))
}
}
unset($link_exists); echo("\n");
unset($link_exists);
echo("\n");
?>

View File

@@ -2,83 +2,83 @@
# Discover ports
echo("Ports : ");
echo("Ports : ");
$ports = snmp_walk($device, "ifDescr", "-Onsq", "IF-MIB");
$ports = snmp_walk($device, "ifDescr", "-Onsq", "IF-MIB");
$ports = str_replace("\"", "", $ports);
$ports = str_replace("ifDescr.", "", $ports);
$ports = str_replace(" ", "||", $ports);
$ports = str_replace("\"", "", $ports);
$ports = str_replace("ifDescr.", "", $ports);
$ports = str_replace(" ", "||", $ports);
$interface_ignored = 0;
$interface_added = 0;
$interface_ignored = 0;
$interface_added = 0;
foreach(explode("\n", $ports) as $entry){
foreach(explode("\n", $ports) as $entry){
$entry = trim($entry);
list($ifIndex, $ifDescr) = explode("||", $entry);
$entry = trim($entry);
list($ifIndex, $ifDescr) = explode("||", $entry);
if(!strstr($entry, "irtual")) {
$if = trim(strtolower($ifDescr));
$nullintf = 0;
foreach($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
if(is_array($config['bad_if_regexp'])) {
foreach($config['bad_if_regexp'] as $bi) {
if (preg_match($bi ."i", $if)) {
$nullintf = 1;
}
}
if(!strstr($entry, "irtual")) {
$if = trim(strtolower($ifDescr));
$nullintf = 0;
foreach($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
if(is_array($config['bad_if_regexp'])) {
foreach($config['bad_if_regexp'] as $bi) {
if (preg_match($bi ."i", $if)) {
$nullintf = 1;
}
}
}
if($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; }
$ifDescr = fixifName($ifDescr);
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
if(isset($config['allow_ng']) && !$config['allow_ng']) {
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; }
if($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; }
$ifDescr = fixifName($ifDescr);
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
if(isset($config['allow_ng']) && !$config['allow_ng']) {
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; }
}
if ($debug) echo("\n $if ");
if ($nullintf == 0) {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','$ifDescr')");
# Add Interface
echo("+");
} else {
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
echo(".");
}
if ($debug) echo("\n $if ");
if ($nullintf == 0) {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','$ifDescr')");
# Add Interface
echo("+");
} else {
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
echo(".");
}
$int_exists[] = "$ifIndex";
} else {
# Ignored Interface
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
# Delete Interface
echo("-"); ## Deleted Interface
} else {
echo("X"); ## Ignored Interface
}
$int_exists[] = "$ifIndex";
} else {
# Ignored Interface
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
# Delete Interface
echo("-"); ## Deleted Interface
} else {
echo("X"); ## Ignored Interface
}
}
}
}
}
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
while ($test_if = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($int_exists) && !isset($exists)) {
$this_if = $test_if['ifIndex'];
if ($int_exists[$i] == $this_if) { $exists = 1; }
$i++;
}
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
while ($test_if = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($int_exists) && !isset($exists)) {
$this_if = $test_if['ifIndex'];
if ($int_exists[$i] == $this_if) { $exists = 1; }
$i++;
}
if(!$exists) {
echo("-");
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
}
if(!$exists) {
echo("-");
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
}
}
unset($temp_exists);
echo("\n");
unset($temp_exists);
echo("\n");
?>

View File

@@ -1,52 +1,52 @@
<?php
if($device['os'] == "ios" || $device['os_group'] == "ios")
if($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid("cpmCPU", $device, $processors_array, "CISCO-PROCESS-MIB");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry)
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid("cpmCPU", $device, $processors_array, "CISCO-PROCESS-MIB");
if($debug) { print_r($processors_array); }
foreach($processors_array[$device['device_id']] as $index => $entry)
if ($entry['cpmCPUTotal5minRev'] || $entry['cpmCPUTotal5min'])
{
if ($entry['cpmCPUTotal5minRev'] || $entry['cpmCPUTotal5min'])
$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if($entry['cpmCPUTotal5minRev']) {
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.8." . $index;
$usage = $entry['cpmCPUTotal5minRev'];
} elseif($entry['cpmCPUTotal5min']) {
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5." . $index;
$usage = $entry['cpmCPUTotal5min'];
}
$descr_oid = "entPhysicalName." . $entPhysicalIndex;
$descr = snmp_get($device, $descr_oid, "-Oqv", "ENTITY-MIB");
if(!$descr) { $descr = "Processor $index"; }
$old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("cpmCPU-" . $index . ".rrd");
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-cpm-" . $index . ".rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd)) {
shell_exec("mv -f $old_rrd $new_rrd");
echo("Moved RRD ");
}
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
if($entry['cpmCPUTotal5minRev']) {
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.8." . $index;
$usage = $entry['cpmCPUTotal5minRev'];
} elseif($entry['cpmCPUTotal5min']) {
$usage_oid = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5." . $index;
$usage = $entry['cpmCPUTotal5min'];
}
$descr_oid = "entPhysicalName." . $entPhysicalIndex;
$descr = snmp_get($device, $descr_oid, "-Oqv", "ENTITY-MIB");
if(!$descr) { $descr = "Processor $index"; }
$old_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("cpmCPU-" . $index . ".rrd");
$new_rrd = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("processor-cpm-" . $index . ".rrd");
if($debug) { echo("$old_rrd $new_rrd"); }
if (is_file($old_rrd)) {
shell_exec("mv -f $old_rrd $new_rrd");
echo("Moved RRD ");
}
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
{
discover_processor($valid_processor, $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
}
discover_processor($valid_processor, $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL);
}
}
if(!is_array($valid_processor['cpm'])) {
$avgBusy5 = snmp_get($device, ".1.3.6.1.4.1.9.2.1.58.0", "-Oqv");
if(is_numeric($avgBusy5)) {
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", "1", $avgBusy5, NULL, NULL);
}
}
if(!is_array($valid_processor['cpm'])) {
$avgBusy5 = snmp_get($device, ".1.3.6.1.4.1.9.2.1.58.0", "-Oqv");
if(is_numeric($avgBusy5)) {
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", "1", $avgBusy5, NULL, NULL);
}
}
## End Cisco Processors
}
}
## End Cisco Processors
unset ($processors_array);
unset ($processors_array);
?>