more cleanup/reindent, yay

git-svn-id: http://www.observium.org/svn/observer/trunk@1839 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-15 11:24:35 +00:00
parent e43eaf7461
commit 12fbf7430c
13 changed files with 391 additions and 378 deletions

View File

@@ -1,73 +1,69 @@
<?php
unset ($mac_table);
echo("ARP Table : ");
unset ($mac_table);
$ipNetToMedia_data = snmp_walk($device, 'ipNetToMediaPhysAddress', '-Oq', 'IP-MIB');
$ipNetToMedia_data = str_replace("ipNetToMediaPhysAddress.", "", trim($ipNetToMedia_data));
$ipNetToMedia_data = str_replace("IP-MIB::", "", trim($ipNetToMedia_data));
#echo("$ipNetToMedia_data\n");
#echo("done\n");
foreach(explode("\n", $ipNetToMedia_data) as $data) {
list($oid, $mac) = explode(" ", $data);
list($if, $first, $second, $third, $fourth) = explode(".", $oid);
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac);
$interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'"));
$ip = $first .".". $second .".". $third .".". $fourth;
$m_a = zeropad($m_a);
$m_b = zeropad($m_b);
$m_c = zeropad($m_c);
$m_d = zeropad($m_d);
$m_e = zeropad($m_e);
$m_f = zeropad($m_f);
$md_a = hexdec($m_a);
$md_b = hexdec($m_b);
$md_c = hexdec($m_c);
$md_d = hexdec($m_d);
$md_e = hexdec($m_e);
$md_f = hexdec($m_f);
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f";
$mac_table[$if][$mac]['ip'] = $ip;
$mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f";
$clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f;
$mac_table[$if][$mac]['cleanmac'] = $clean_mac;
$interface_id = $interface['interface_id'];
$mac_table[$interface_id][$clean_mac] = 1;
if(mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0))
{
$sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
$old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'"));
if($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '')
{
if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); }
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']);
}
mysql_query($sql);
echo(".");
}
else
{
echo("+");
#echo("Add MAC $mac\n");
mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
}
$interface_id = $interface['interface_id'];
}
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while($entry = mysql_fetch_array($query))
echo("ARP Table : ");
$ipNetToMedia_data = snmp_walk($device, 'ipNetToMediaPhysAddress', '-Oq', 'IP-MIB');
$ipNetToMedia_data = str_replace("ipNetToMediaPhysAddress.", "", trim($ipNetToMedia_data));
$ipNetToMedia_data = str_replace("IP-MIB::", "", trim($ipNetToMedia_data));
foreach (explode("\n", $ipNetToMedia_data) as $data)
{
list($oid, $mac) = explode(" ", $data);
list($if, $first, $second, $third, $fourth) = explode(".", $oid);
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac);
$interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'"));
$ip = $first .".". $second .".". $third .".". $fourth;
$m_a = zeropad($m_a);$m_b = zeropad($m_b);$m_c = zeropad($m_c);$m_d = zeropad($m_d);$m_e = zeropad($m_e);$m_f = zeropad($m_f);
$md_a = hexdec($m_a);$md_b = hexdec($m_b);$md_c = hexdec($m_c);$md_d = hexdec($m_d);$md_e = hexdec($m_e);$md_f = hexdec($m_f);
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f";
$mac_table[$if][$mac]['ip'] = $ip;
$mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f";
$clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f;
$mac_table[$if][$mac]['cleanmac'] = $clean_mac;
$interface_id = $interface['interface_id'];
$mac_table[$interface_id][$clean_mac] = 1;
if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0))
{
$entry_mac = $entry['mac_address'];
$entry_if = $entry['interface_id'];
if(!$mac_table[$entry_if][$entry_mac])
$sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
$old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'"));
if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '')
{
mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'");
#echo("Removing MAC $entry_mac from interface ".$interface['ifName']);
echo("-");
}
if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); }
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']);
}
mysql_query($sql);
echo(".");
}
else
{
echo("+");
#echo("Add MAC $mac\n");
mysql_query("INSERT INTO `ipv4_mac` (interface_id, mac_address, ipv4_address) VALUES ('".$interface['interface_id']."','$clean_mac','$ip')");
}
$interface_id = $interface['interface_id'];
}
echo("\n");
unset($mac);
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($entry = mysql_fetch_array($query))
{
$entry_mac = $entry['mac_address'];
$entry_if = $entry['interface_id'];
if (!$mac_table[$entry_if][$entry_mac])
{
mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'");
if ($debug) { echo("Removing MAC $entry_mac from interface ".$interface['ifName']); }
echo("-");
}
}
?>
echo("\n");
unset($mac);
?>

View File

@@ -40,7 +40,7 @@ if ($config['enable_bgp'])
# FIXME: is .0.ipv6 the only possible value here?
$result = snmp_walk($device, "jnxBgpM2PeerRemoteAs.0.ipv6", "-Onq", "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos");
$peers = trim(str_replace(".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.","", $result));
$peers = trim(str_replace(".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.","", $result));
foreach (explode("\n", $peers) as $peer)
{
list($peer_ip_snmp, $peer_as) = split(" ", $peer);
@@ -57,7 +57,8 @@ if ($config['enable_bgp'])
} # OS junos
} else {
echo("No BGP on host");
if ($device['bgpLocalAs']) {
if ($device['bgpLocalAs'])
{
mysql_query("UPDATE devices SET bgpLocalAs = NULL WHERE device_id = '".$device['device_id']."'"); echo(" (Removed ASN) ");
} # End if
} # End if
@@ -86,10 +87,10 @@ if ($config['enable_bgp'])
{
## Get afi/safi and populate cbgp on cisco ios (xe/xr)
unset($af_list);
$af_data = snmp_walk($device, "cbgpPeerAddrFamilyName." . $peer['ip'], "-OsQ", "CISCO-BGP4-MIB", $config['mibdir']);
if ($debug) { echo("afi data :: $af_data \n"); }
$afs = trim(str_replace("cbgpPeerAddrFamilyName.".$peer['ip'].".", "", $af_data));
foreach (explode("\n", $afs) as $af)
{
@@ -205,5 +206,4 @@ if ($config['enable_bgp'])
echo("\n");
}
?>
?>

View File

@@ -2,14 +2,14 @@
global $valid_sensor;
if ($device['os'] == "ios" || $device['os_group'] == "ios")
if ($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("\nCISCO-ENTITY-SENSOR");
$oids = array();
$oids = array();
echo("\nCaching OIDs:");
if(!is_array($entity_array))
if (!is_array($entity_array))
{
$entity_array = array();
echo(" entPhysicalDescr");
@@ -39,8 +39,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
echo("\nSensors: ");
if($debug) { print_r($oids); }
if ($debug) { print_r($oids); }
$entitysensor['voltsDC'] = "voltage";
$entitysensor['voltsAC'] = "voltage";
@@ -52,93 +51,96 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
$entitysensor['celsius'] = "temperature";
$entitysensor['watts'] = "watts";
if(is_array($oids))
if (is_array($oids))
{
foreach($oids as $index => $entry)
foreach ($oids as $index => $entry)
{
#echo("[" . $entry['entSensorType'] . "|" . $entry['entSensorValue']. "|" . $index . "]");
if($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index))
if ($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index))
{
$entPhysicalIndex = $index;
$descr = $entity_array[$index]['entPhysicalName'];
if($descr || $device['os'] == "iosxr")
{
if ($descr || $device['os'] == "iosxr")
{
$descr = rewrite_entity_descr($descr);
} else {
$descr = $entity_array[$index]['entPhysicalDescr'];
} else {
$descr = $entity_array[$index]['entPhysicalDescr'];
$descr = rewrite_entity_descr($descr);
}
## Set description based on measured entity if it exists
if(is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) {
if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity'])
{
$measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName'];
if(!measured_descr)
if (!measured_descr)
{
$measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr'];
}
}
$descr = $measured_descr . " - " . $descr;
}
### Bit dirty also, clean later
$descr = str_replace("Temp: ", "", $descr);
$descr = str_ireplace("temperature ", "", $descr);
$descr = str_ireplace("temperature ", "", $descr);
$oid = ".1.3.6.1.4.1.9.9.91.1.1.1.1.4.".$index;
$current = $entry['entSensorValue'];
$type = $entitysensor[$entry['entSensorType']];
#echo("$index : ".$entry['entSensorScale']."|");
### FIXME this stuff is foul
if($entry['entSensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if($entry['entSensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if($entry['entSensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if($entry['entSensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if($entry['entSensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
if(is_numeric($entry['entSensorPrecision']) && $entry['entSensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entSensorPrecision'], "0"); }
if ($entry['entSensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if ($entry['entSensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if ($entry['entSensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if ($entry['entSensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if ($entry['entSensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if ($entry['entSensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if ($entry['entSensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
if (is_numeric($entry['entSensorPrecision']) && $entry['entSensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entSensorPrecision'], "0"); }
$current = $current * $multiplier / $divisor;
### Set thresholds to null
$limit = NULL; $low_limit = NULL; $warn_limit = NULL; $warn_limit_low = NULL;
### Check thresholds for this entry (bit dirty, but it works!)
if(is_array($t_oids[$index]))
if (is_array($t_oids[$index]))
{
foreach($t_oids[$index] as $t_index => $entry)
{
### Critical Limit
if($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "greaterOrEqual")
foreach ($t_oids[$index] as $t_index => $entry)
{
$limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
### Critical Limit
if ($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "greaterOrEqual")
{
$limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
if($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "lessOrEqual")
{
$limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
### Warning Limit
if($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "greaterOrEqual")
{
$warn_limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
if ($entry['entSensorThresholdSeverity'] == "major" && $entry['entSensorThresholdRelation'] == "lessOrEqual")
{
$limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
if($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "lessOrEqual")
{
$warn_limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
### Warning Limit
if ($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "greaterOrEqual")
{
$warn_limit = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
if ($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "lessOrEqual")
{
$warn_limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
}
}
}
}
### End Threshold code
$ok = TRUE;
if($current == "-127") { $ok = FALSE; } ## False reading
# if($type == "temperature" && $current < 1) { $ok = FALSE; } ## False reading. Temperature <1 :)
if($descr == "") { $ok = FALSE; } ## Invalid description. Lots of these on Nexus
if($ok) {
if ($current == "-127") { $ok = FALSE; } ## False reading
# if ($type == "temperature" && $current < 1) { $ok = FALSE; } ## False reading. Temperature <1 :)
if ($descr == "") { $ok = FALSE; } ## Invalid description. Lots of these on Nexus
if ($ok) {
# echo("\n$valid_sensor, $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $limit, $warn_limit, $current");
discover_sensor($valid_sensor, $type, $device, $oid, $index, 'cisco-entity-sensor', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $limit, $warn_limit, $current);
}
@@ -150,4 +152,4 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
}
}
?>
?>

View File

@@ -1,41 +1,44 @@
<?php
if($config['enable_pseudowires'] && $device['os_group'] == "ios")
if ($config['enable_pseudowires'] && $device['os_group'] == "ios")
{
unset( $cpw_count );
unset( $cpw_exists );
unset( $cpw_exists );
echo("Cisco Pseudowires : ");
# FIXME snmp_walk
$oids = shell_exec($config['snmpwalk'] . " -M " . $config['mibdir'] . " -m CISCO-IETF-PW-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcID");
$oids = str_replace(".1.3.6.1.4.1.9.10.106.1.2.1.10.", "", $oids);
$oids = trim($oids);
foreach ( explode("\n", $oids) as $oid )
foreach (explode("\n", $oids) as $oid)
{
if($oid)
if ($oid)
{
list($cpwOid, $cpwVcID) = explode(" ", $oid);
if($cpwOid)
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)
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))
if (mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
AND `cpwVcID`='".$cpwVcID."'"),0))
{
echo(".");
}
else
}
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')";
$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");
@@ -49,19 +52,19 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios")
$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))
while ($cpw = mysql_fetch_array($query))
{
unset($exists);
$i = 0;
while ($i < count($cpw_exists) && !$exists)
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;
if ($cpw_exists[$i] == $this_cpw) { $exists = 1;
# echo($cpw_exists[$i]. " || $this_cpw \n");
}
$i++;
}
if(!$exists)
if (!$exists)
{
echo("-");
# echo($this_cpw . "\n");

View File

@@ -1,15 +1,15 @@
<?php
if($device['os_group'] == "ios")
if ($device['os_group'] == "ios")
{
echo("Cisco VLANs : ");
$vtpversion_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " ";
$vtpversion_cmd .= $device['hostname'].":".$device['port'] . " .1.3.6.1.4.1.9.9.46.1.1.1.0";
$vtpversion = trim(`$vtpversion_cmd 2>/dev/null`);
if($vtpversion == '1' || $vtpversion == '2' || $vtpversion == 'two' || $vtpversion == 'three') {
$vtpversion = trim(`$vtpversion_cmd 2>/dev/null`);
if ($vtpversion == '1' || $vtpversion == '2' || $vtpversion == 'two' || $vtpversion == 'three')
{
$vtp_domain_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$vtp_domain_cmd .= " .1.3.6.1.4.1.9.9.46.1.2.1.1.2.1";
$vtp_domain = trim(str_replace("\"", "", `$vtp_domain_cmd 2>/dev/null`));
@@ -21,36 +21,40 @@ if($device['os_group'] == "ios")
$vlans = trim(`$vlans_cmd | grep -v o`);
foreach(explode("\n", $vlans) as $vlan) {
$vlan_descr_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-VTP-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
foreach (explode("\n", $vlans) as $vlan)
{
$vlan_descr_cmd = $config['snmpget'] . " -M " . $config['mibdir'] . " -m CISCO-VTP-MIB -O nvq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
$vlan_descr_cmd .= ".1.3.6.1.4.1.9.9.46.1.3.1.1.4.1." . $vlan;
$vlan_descr = shell_exec($vlan_descr_cmd);
$vlan_descr = trim(str_replace("\"", "", $vlan_descr));
if(mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0') {
if (mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0')
{
mysql_query("INSERT INTO `vlans` (`device_id`,`vlan_domain`,`vlan_vlan`, `vlan_descr`) VALUES (" . $device['device_id'] . ",'" . mres($vtp_domain) . "','$vlan', '" . mres($vlan_descr) . "')");
echo("+");
} else {
echo(".");
} else {
echo(".");
mysql_query("UPDATE `vlans` SET `vlan_descr`='" . mres($vlan_descr) . "' WHERE `device_id`='" . $device['device_id'] . "' AND `vlan_vlan`='" . $vlan . "' AND `vlan_domain`='" . $vtp_domain . "'");
}
$this_vlans[] = $vlan;
}
$device_vlans = mysql_query("SELECT * FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "'");
while($dev_vlan = mysql_fetch_array($device_vlans)) {
while ($dev_vlan = mysql_fetch_array($device_vlans))
{
unset($vlan_exists);
foreach($this_vlans as $test_vlan) {
if($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; }
foreach ($this_vlans as $test_vlan)
{
if ($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; }
}
if(!$vlan_exists) {
mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'");
if (!$vlan_exists)
{
mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'");
echo("-");
#echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n");
#echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n");
}
}
}
@@ -58,6 +62,6 @@ if($device['os_group'] == "ios")
unset($this_vlans);
echo("\n");
}
?>

View File

@@ -1,8 +1,7 @@
<?php
if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os'] == "ironware")
if ($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os'] == "ironware")
{
unset( $vrf_count );
echo("VRFs : ");
@@ -10,27 +9,27 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
$oid_cmd = $config['snmpwalk'] . " -M " . $config['mibdir'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher";
$oids = shell_exec($oid_cmd);
if($debug) { echo("$oid_cmd -> $oids \n"); }
if ($debug) { echo("$oid_cmd -> $oids \n"); }
$oids = str_replace(".1.3.6.1.3.118.1.2.2.1.3.", "", $oids);
$oids = str_replace(" \"", "||", $oids);
$oids = str_replace("\"", "", $oids);
$oids = trim($oids);
foreach ( explode("\n", $oids) as $oid )
foreach ( explode("\n", $oids) as $oid )
{
if($oid)
if ($oid)
{
list($vrf['oid'], $vrf['mplsVpnVrfRouteDistinguisher']) = explode("||", $oid);
$vrf['name'] = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m MPLS-VPN-MIB -Ln -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher.".$vrf['oid']));
list(,$vrf['name'],, $vrf['mplsVpnVrfRouteDistinguisher']) = explode("\"", $vrf['name']);
$vrf['mplsVpnVrfDescription'] = trim(shell_exec($config['snmpget'] . " -M " . $config['mibdir'] . " -m MPLS-VPN-MIB -Ln -Osqvn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfDescription.".$vrf['oid']));
if(@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."'
if (@mysql_result(mysql_query("SELECT count(*) FROM vrfs WHERE `device_id` = '".$device['device_id']."'
AND `vrf_oid`='".$vrf['oid']."'"),0))
{
$update_query = "UPDATE `vrfs` SET `mplsVpnVrfDescription` = '".$vrf['mplsVpnVrfDescription']."', `mplsVpnVrfRouteDistinguisher` = '".$vrf['mplsVpnVrfRouteDistinguisher']."' ";
$update_query .= "WHERE device_id = '".$device['device_id']."' AND vrf_oid = '".$vrf['oid']."'";
$update_query .= "WHERE device_id = '".$device['device_id']."' AND vrf_oid = '".$vrf['oid']."'";
mysql_query($update_query);
}
else
@@ -39,7 +38,7 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
$insert_query .= "VALUES ('".$vrf['oid']."','".$vrf['name']."','".$vrf['mplsVpnVrfRouteDistinguisher']."','".$vrf['mplsVpnVrfDescription']."','".$device['device_id']."')";
mysql_query($insert_query);
}
$vrf_id = @mysql_result(mysql_query("SELECT vrf_id FROM vrfs WHERE `device_id` = '".$device['device_id']."' AND `vrf_oid`='".$vrf['oid']."'"),0);
$valid_vrf[$vrf_id] = 1;
echo("\nRD:".$vrf['mplsVpnVrfRouteDistinguisher']." ".$vrf['name']." ".$vrf['mplsVpnVrfDescription']." ");
@@ -62,41 +61,44 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
$sql = "SELECT * FROM ports WHERE device_id = '" . $device['device_id'] . "'";
$data = mysql_query($sql);
while($row = mysql_fetch_array($data))
while ($row = mysql_fetch_array($data))
{
$if = $row['interface_id'];
$vrf_id = $row['ifVrf'];
if($row['ifVrf'])
if ($row['ifVrf'])
{
if(!$valid_vrf_if[$vrf_id][$if])
if (!$valid_vrf_if[$vrf_id][$if])
{
echo("-");
$query = @mysql_query("UPDATE ports SET `ifVrf` = NULL WHERE interface_id = '$if'");
}
}
else
{
echo(".");
}
}
}
}
$sql = "SELECT * FROM vrfs WHERE device_id = '" . $device['device_id'] . "'";
$data = mysql_query($sql);
while($row = mysql_fetch_array($data))
while ($row = mysql_fetch_array($data))
{
$vrf_id = $row['vrf_id'];
if(!$valid_vrf[$vrf_id])
if (!$valid_vrf[$vrf_id])
{
echo("-");
$query = @mysql_query("DELETE FROM vrfs WHERE vrf_id = '$vrf_id'");
} else { echo(".");}
}
else
{
echo(".");
}
}
unset($valid_vrf_if);
unset($valid_vrf);
echo("\n");
} # ios/junos/ironware
?>

View File

@@ -4,104 +4,106 @@ echo("Discovery protocols:");
$community = $device['community'];
if($device['os'] == "ironware") {
if ($device['os'] == "ironware")
{
echo(" Brocade FDP: ");
$fdp_array = snmpwalk_cache_twopart_oid($device, "snFdpCacheEntry", array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
if($fdp_array) {
if ($fdp_array)
{
unset($fdp_links);
foreach( array_keys($fdp_array) as $key)
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)
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 ($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(" CISCO-CDP-MIB: ");
echo(" CISCO-CDP-MIB: ");
unset($cdp_array);
$cdp_array = snmpwalk_cache_twopart_oid($device, "cdpCache", array(), "CISCO-CDP-MIB");
if($cdp_array) {
if ($cdp_array)
{
unset($cdp_links);
foreach( array_keys($cdp_array) as $key)
{
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_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 ($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'])
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: ");
unset($lldp_array);
$lldp_array = snmpwalk_cache_threepart_oid($device, "lldpRemoteSystemsData", array(), "LLDP-MIB");
$dot1d_array = snmpwalk_cache_oid($device, "dot1dBasePortIfIndex", array(), "BRIDGE-MIB");
#print_r($lldp_array);
#print_r($dot1d_array);
if($lldp_array) {
if ($lldp_array)
{
$lldp_links = "";
foreach( array_keys($lldp_array) as $key) {
$lldp_if_array = $lldp_array[$key];
foreach( array_keys($lldp_if_array) as $entry_key)
{
if(is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex']))
foreach (array_keys($lldp_array) as $key)
{
$lldp_if_array = $lldp_array[$key];
foreach (array_keys($lldp_if_array) as $entry_key)
{
if (is_numeric($dot1d_array[$entry_key]['dot1dBasePortIfIndex']))
{
$ifIndex = $dot1d_array[$entry_key]['dot1dBasePortIfIndex'];
} else {
$ifIndex = $entry_key;
}
}
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'"));
$lldp_instance = $lldp_if_array[$entry_key];
foreach ( array_keys($lldp_instance) as $entry_instance)
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 ($remote_device_id)
{
$if = $lldp['lldpRemPortDesc']; $id = $lldp['lldpRemPortId'];
$remote_interface_id = @mysql_result(mysql_query("SELECT interface_id FROM `ports` WHERE (`ifDescr` = '$if' OR `ifName`='$if' OR `ifDescr`= '$id' OR `ifName`='$id') AND `device_id` = '".$remote_device_id."'"),0);
} else { $remote_interface_id = "0"; }
if(is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId'])) {
if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId']))
{
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']);
}
}
}
}
}
}
if($debug) { print_r($link_exists); }
if ($debug) { print_r($link_exists); }
$sql = "SELECT * FROM `links` AS L, `ports` AS I WHERE L.local_interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'";
if ($query = mysql_query($sql))
@@ -111,16 +113,17 @@ if ($query = mysql_query($sql))
$local_interface_id = $test['local_interface_id'];
$remote_hostname = $test['remote_hostname'];
$remote_port = $test['remote_port'];
if($debug) { echo("$local_interface_id -> $remote_hostname -> $remote_port \n"); }
if(!$link_exists[$local_interface_id][$remote_hostname][$remote_port]) {
if ($debug) { echo("$local_interface_id -> $remote_hostname -> $remote_port \n"); }
if (!$link_exists[$local_interface_id][$remote_hostname][$remote_port])
{
echo("-");
mysql_query("DELETE FROM `links` WHERE id = '" . $test['id'] . "'");
if($debug) {echo(mysql_affected_rows()." deleted ");}
if ($debug) { echo(mysql_affected_rows()." deleted "); }
}
}
}
unset($link_exists);
unset($link_exists);
echo("\n");
?>
?>

View File

@@ -4,19 +4,18 @@ global $valid_sensor;
echo(" ENTITY-SENSOR ");
echo("\nCaching OIDs:");
echo("\nCaching OIDs:");
if(!is_array($entity_array))
{
$entity_array = array();
echo(" entPhysicalDescr");
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalDescr", $entity_array, "CISCO-ENTITY-SENSOR-MIB");
echo(" entPhysicalName");
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalName", $entity_array, "CISCO-ENTITY-SENSOR-MIB");
}
if (!is_array($entity_array))
{
$entity_array = array();
echo(" entPhysicalDescr");
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalDescr", $entity_array, "CISCO-ENTITY-SENSOR-MIB");
echo(" entPhysicalName");
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalName", $entity_array, "CISCO-ENTITY-SENSOR-MIB");
}
$oids = array();
$oids = array();
echo(" entPhySensorType");
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorType", $oids, "ENTITY-SENSOR-MIB");
echo(" entPhySensorScale");
@@ -35,13 +34,13 @@ $entitysensor['percentRH'] = "humidity";
$entitysensor['rpm'] = "fanspeed";
$entitysensor['celsius'] = "temperature";
if(is_array($oids))
if (is_array($oids))
{
foreach($oids as $index => $entry)
foreach ($oids as $index => $entry)
{
#echo("[" . $entry['entPhySensorType'] . "|" . $entry['entPhySensorValue']. "|" . $index . "]");
if($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index))
if ($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index))
{
$entPhysicalIndex = $index;
$oid = ".1.3.6.1.2.1.99.1.1.1.4.".$index;
@@ -49,7 +48,7 @@ if(is_array($oids))
#ENTITY-SENSOR-MIB::entPhySensorUnitsDisplay.11 = STRING: "C"
$descr = $entity_array[$index]['entPhysicalName'];
if($descr || $device['os'] == "iosxr")
if ($descr || $device['os'] == "iosxr")
{
$descr = rewrite_entity_descr($descr);
} else {
@@ -60,27 +59,27 @@ if(is_array($oids))
$valid = TRUE;
$type = $entitysensor[$entry['entPhySensorType']];
### FIXME this stuff is foul
if($entry['entPhySensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if($entry['entPhySensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
if ($entry['entPhySensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; }
if ($entry['entPhySensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; }
if ($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; }
if ($entry['entPhySensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; }
if ($entry['entPhySensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; }
if ($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; }
if ($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; }
if(is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); }
if (is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); }
$current = $current * $multiplier / $divisor;
if($type == "temperature") { if($current > "200"){ $valid = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); }
if ($type == "temperature") { if ($current > "200"){ $valid = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); }
#echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n");
if($current == "-127") { $valid = FALSE; }
if ($current == "-127") { $valid = FALSE; }
if($valid && mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."' AND `sensor_class` = '".$type."' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = '".$index."'"),0) == "0")
if ($valid && mysql_result(mysql_query("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = '".$device['device_id']."' AND `sensor_class` = '".$type."' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = '".$index."'"),0) == "0")
## Check to make sure we've not already seen this sensor via cisco's entity sensor mib
{
discover_sensor($valid_sensor, $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, NULL, NULL, NULL, NULL, $current);
@@ -91,4 +90,4 @@ if(is_array($oids))
echo("\n");
?>
?>

View File

@@ -1,21 +1,21 @@
<?php
### Discover sensors
function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = NULL, $low_warn_limit = NULL, $warn_limit = NULL, $high_limit = NULL, $current = NULL, $poller_type = 'snmp')
function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr, $divisor = '1', $multiplier = '1', $low_limit = NULL, $low_warn_limit = NULL, $warn_limit = NULL, $high_limit = NULL, $current = NULL, $poller_type = 'snmp')
{
global $config, $debug;
if($debug) { echo("$oid, $index, $type, $descr, $precision\n"); }
if ($debug) { echo("Discover sensor: $oid, $index, $type, $descr, $precision\n"); }
if (mysql_result(mysql_query("SELECT count(sensor_id) FROM `sensors` WHERE poller_type='" . mres($poller_type) . "' AND sensor_class='" . mres($class) . "' AND device_id = '".$device['device_id']."' AND sensor_type = '$type' AND `sensor_index` = '$index'"),0) == '0')
{
if(!$high_limit) { $high_limit = sensor_limit($class, $current); }
if(!$low_limit) { $low_limit = sensor_low_limit($class, $current); }
if (!$high_limit) { $high_limit = sensor_limit($class, $current); }
if (!$low_limit) { $low_limit = sensor_low_limit($class, $current); }
$query = "INSERT INTO sensors (`poller_type`,`sensor_class`, `device_id`, `sensor_oid`, `sensor_index`, `sensor_type`, `sensor_descr`, `sensor_divisor`, `sensor_multiplier`, `sensor_limit`, `sensor_limit_warn`, `sensor_limit_low`, `sensor_limit_low_warn`, `sensor_current`) ";
$query .= " VALUES ('" . mres($poller_type) . "','" . mres($class) . "', '".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$divisor', '$multiplier', '$high_limit', '$warn_limit', '$low_limit', '$low_warn_limit', '$current')";
mysql_query($query);
if($debug) { echo("$query\n". mysql_affected_rows() . " inserted\n"); }
if ($debug) { echo("$query\n". mysql_affected_rows() . " inserted\n"); }
echo("+");
log_event("Sensor Added: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device['device_id'], 'sensor', mysql_insert_id());
}
@@ -23,9 +23,9 @@ function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr,
{
$sensor_entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `sensors` WHERE sensor_class='" . mres($class) . "' AND device_id = '".$device['device_id']."' AND sensor_type = '$type' AND `sensor_index` = '$index'"));
if(!$high_limit)
{
if(!$sensor_entry['sensor_limit'])
if (!$high_limit)
{
if (!$sensor_entry['sensor_limit'])
{
$high_limit = sensor_limit($class, $current);
} else {
@@ -35,18 +35,18 @@ function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr,
if ($high_limit != $sensor_entry['sensor_limit'])
{
$query = "UPDATE sensors SET `sensor_limit` = '".$high_limit."' WHERE `sensor_id` = '".$sensor_entry['sensor_id']."'";
$query = "UPDATE sensors SET `sensor_limit` = '".$high_limit."' WHERE `sensor_id` = '".$sensor_entry['sensor_id']."'";
mysql_query($query);
if($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
echo("H");
log_event("Sensor High Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$high_limit.")", $device['device_id'], 'sensor', $sensor_id);
}
if(!$low_limit)
{
if(!$sensor_entry['sensor_limit_low'])
if (!$low_limit)
{
if (!$sensor_entry['sensor_limit_low'])
{
$low_limit = sensor_low_limit($class, $current);
$low_limit = sensor_low_limit($class, $current);
} else {
$low_limit = $sensor_entry['sensor_limit_low'];
}
@@ -55,13 +55,13 @@ function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr,
if ($sensor_entry['sensor_limit_low'] != $low_limit)
{
$query = "UPDATE sensors SET `sensor_limit_low` = '".$low_limit."' WHERE `sensor_id` = '".$sensor_entry['sensor_id']."'";
mysql_query($query);
if($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
mysql_query($query);
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
echo("L");
log_event("Sensor Low Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$low_limit.")", $device['device_id'], 'sensor', $sensor_id);
}
if($oid == $sensor_entry['sensor_oid'] && $descr == $sensor_entry['sensor_descr'] && $multiplier == $sensor_entry['sensor_multiplier'] && $divisor == $sensor_entry['sensor_divisor'])
if ($oid == $sensor_entry['sensor_oid'] && $descr == $sensor_entry['sensor_descr'] && $multiplier == $sensor_entry['sensor_multiplier'] && $divisor == $sensor_entry['sensor_divisor'])
{
echo(".");
}
@@ -71,71 +71,70 @@ function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr,
mysql_query($query);
echo("U");
log_event("Sensor Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr), $device['device_id'], 'sensor', $sensor_id);
if($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
if ($debug) { echo("$query\n". mysql_affected_rows() . " updated\n"); }
}
}
$valid[$class][$type][$index] = 1;
return $return;
}
function sensor_low_limit ($class, $current)
{
$limit = NULL;
switch($class)
{
case 'temperature':
$limit = $current * 0.7;
break;
case 'voltage':
$limit = $current * 0.85;
break;
case 'humidity':
$limit = "70";
break;
case 'freq':
$limit = $current * 0.95;
break;
case 'current':
$limit = $current * 0.80;
break;
case 'fanspeed':
$limit = $current * 0.80;
break;
}
return $limit;
}
function sensor_limit ($class, $current)
function sensor_low_limit($class, $current)
{
$limit = NULL;
switch($class)
{
case 'temperature':
$limit = $current * 1.60;
break;
$limit = $current * 0.7;
break;
case 'voltage':
$limit = $current * 1.15;
break;
$limit = $current * 0.85;
break;
case 'humidity':
$limit = "70";
break;
$limit = "70";
break;
case 'freq':
$limit = $current * 1.05;
break;
$limit = $current * 0.95;
break;
case 'current':
$limit = $current * 1.50;
break;
$limit = $current * 0.80;
break;
case 'fanspeed':
$limit = $current * 1.30;
break;
$limit = $current * 0.80;
break;
}
return $limit;
}
function check_valid_sensors($device, $class, $valid)
function sensor_limit($class, $current)
{
$limit = NULL;
switch($class)
{
case 'temperature':
$limit = $current * 1.60;
break;
case 'voltage':
$limit = $current * 1.15;
break;
case 'humidity':
$limit = "70";
break;
case 'freq':
$limit = $current * 1.05;
break;
case 'current':
$limit = $current * 1.50;
break;
case 'fanspeed':
$limit = $current * 1.30;
break;
}
return $limit;
}
function check_valid_sensors($device, $class, $valid)
{
$sql = "SELECT * FROM sensors AS S, devices AS D WHERE S.sensor_class='".$class."' AND S.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
if ($query = mysql_query($sql))
@@ -144,8 +143,8 @@ function check_valid_sensors($device, $class, $valid)
{
$index = $test['sensor_index'];
$type = $test['sensor_type'];
if($debug) { echo($index . " -> " . $type . "\n"); }
if(!$valid[$class][$type][$index])
if ($debug) { echo($index . " -> " . $type . "\n"); }
if (!$valid[$class][$type][$index])
{
echo("-");
mysql_query("DELETE FROM `sensors` WHERE sensor_class='".$class."' AND sensor_id = '" . $test['sensor_id'] . "'");
@@ -161,13 +160,13 @@ function discover_juniAtmVp(&$valid, $interface_id, $vp_id, $vp_descr)
{
global $config, $debug;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = '".$interface_id."' AND `vp_id` = '".$vp_id."'"),0) == "0")
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = '".$interface_id."' AND `vp_id` = '".$vp_id."'"),0) == "0")
{
$sql = "INSERT INTO `juniAtmVp` (`interface_id`,`vp_id`,`vp_descr`) VALUES ('".$interface_id."','".$vp_id."','".$vp_descr."')";
mysql_query($sql); echo("+");
if($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); }
}
else
mysql_query($sql); echo("+");
if ($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); }
}
else
{
echo(".");
}
@@ -184,40 +183,40 @@ function discover_link($local_interface_id, $protocol, $remote_interface_id, $re
$sql = "INSERT INTO `links` (`local_interface_id`,`protocol`,`remote_interface_id`,`remote_hostname`,`remote_port`,`remote_platform`,`remote_version`)
VALUES ('$local_interface_id','$protocol','$remote_interface_id','$remote_hostname','$remote_port','$remote_platform','$remote_version')";
mysql_query($sql);
echo("+"); if($debug) { echo("$sql"); }
echo("+"); if ($debug) { echo("$sql"); }
}
else
{
$data = mysql_fetch_assoc(mysql_query("SELECT * FROM `links` WHERE `remote_hostname` = '$remote_hostname' AND `local_interface_id` = '$local_interface_id'
AND `protocol` = '$protocol' AND `remote_port` = '$remote_port'"));
if($data['remote_interface_id'] == $remote_interface_id && $data['remote_platform'] == $remote_platform && $remote_version == $remote_version)
if ($data['remote_interface_id'] == $remote_interface_id && $data['remote_platform'] == $remote_platform && $remote_version == $remote_version)
{
echo(".");
}
else
{
$sql = "UPDATE `links` SET `remote_interface_id` = $remote_interface_id, `remote_platform` = '$remote_platform', `remote_version` = '$remote_version' WHERE `id` = '".$data['id']."'";
mysql_query($sql);
echo("U"); if($debug) {echo("$sql");}
mysql_query($sql);
echo("U"); if ($debug) {echo("$sql");}
}
}
$link_exists[$local_interface_id][$remote_hostname][$remote_port] = 1;
}
function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size, $units, $used = NULL)
{
global $config, $debug;
if($debug) { echo("$device, $index, $type, $mib, $descr, $units, $used, $size\n"); }
if($descr && $size > "0")
if ($debug) { echo("$device, $index, $type, $mib, $descr, $units, $used, $size\n"); }
if ($descr && $size > "0")
{
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE `storage_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `storage_mib` = '$mib'"),0) == '0')
if (mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE `storage_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `storage_mib` = '$mib'"),0) == '0')
{
$query = "INSERT INTO storage (`device_id`, `storage_descr`, `storage_index`, `storage_mib`, `storage_type`, `storage_units`,`storage_size`,`storage_used`)
values ('".$device['device_id']."', '$descr', '$index', '$mib','$type', '$units', '$size', '$used')";
mysql_query($query);
if($debug) { print $query . "\n"; mysql_error(); }
if ($debug) { print $query . "\n"; mysql_error(); }
echo("+");
}
else
@@ -226,9 +225,9 @@ function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size,
$query = "UPDATE `storage` SET `storage_descr` = '".$descr."', `storage_type` = '".$type."', `storage_units` = '".$units."', `storage_size` = '".$size."'
WHERE `device_id` = '".$device['device_id']."' AND `storage_index` = '".$index."' AND `storage_mib` = '".$mib."'";
mysql_query($query);
if($debug) { print $query . "\n"; }
if ($debug) { print $query . "\n"; }
}
$valid[$mib][$index] = 1;
}
}
@@ -237,17 +236,17 @@ function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size,
function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $precision = "1", $current = NULL, $entPhysicalIndex = NULL, $hrDeviceIndex = NULL)
{
global $config, $debug;
if($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
if($descr)
if ($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
if ($descr)
{
$descr = str_replace("\"", "", $descr);
if(mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = '$type'"),0) == '0')
if (mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = '$type'"),0) == '0')
{
$query = "INSERT INTO processors (`entPhysicalIndex`, `hrDeviceIndex`, `device_id`, `processor_descr`, `processor_index`, `processor_oid`, `processor_usage`, `processor_type`, `processor_precision`)
values ('$entPhysicalIndex', '$hrDeviceIndex', '".$device['device_id']."', '$descr', '$index', '$oid', '$current', '$type','$precision')";
mysql_query($query);
if($debug) { print $query . "\n"; }
if ($debug) { print $query . "\n"; }
echo("+");
}
else
@@ -256,7 +255,7 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec
$query = "UPDATE `processors` SET `processor_descr` = '".$descr."', `processor_oid` = '".$oid."', `processor_precision` = '".$precision."'
WHERE `device_id` = '".$device['device_id']."' AND `processor_index` = '".$index."' AND `processor_type` = '".$type."'";
mysql_query($query);
if($debug) { print $query . "\n"; }
if ($debug) { print $query . "\n"; }
}
$valid[$type][$index] = 1;
@@ -267,16 +266,16 @@ function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $prec
function discover_mempool(&$valid, $device, $index, $type, $descr, $precision = "1", $entPhysicalIndex = NULL, $hrDeviceIndex = NULL)
{
global $config, $debug;
if($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
if($descr)
if ($debug) { echo("$device, $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n"); }
if ($descr)
{
if(mysql_result(mysql_query("SELECT count(mempool_id) FROM `mempools` WHERE `mempool_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `mempool_type` = '$type'"),0) == '0')
if (mysql_result(mysql_query("SELECT count(mempool_id) FROM `mempools` WHERE `mempool_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `mempool_type` = '$type'"),0) == '0')
{
$query = "INSERT INTO mempools (`entPhysicalIndex`, `hrDeviceIndex`, `device_id`, `mempool_descr`, `mempool_index`, `mempool_type`, `mempool_precision`)
values ('$entPhysicalIndex', '$hrDeviceIndex', '".$device['device_id']."', '$descr', '$index', '$type','$precision')";
mysql_query($query);
if($debug) { print $query . "\n"; }
if ($debug) { print $query . "\n"; }
echo("+");
}
else
@@ -286,7 +285,7 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
$query .= ", `hrDeviceIndex` = '$hrDeviceIndex' ";
$query .= "WHERE `device_id` = '".$device['device_id']."' AND `mempool_index` = '".$index."' AND `mempool_type` = '".$type."'";
mysql_query($query);
if($debug) { print $query . "\n"; }
if ($debug) { print $query . "\n"; }
}
$valid[$type][$index] = 1;
@@ -296,8 +295,8 @@ function discover_mempool(&$valid, $device, $index, $type, $descr, $precision =
function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity = NULL, $current = NULL)
{
global $config, $debug;
if($debug) { echo("$oid, $index, $type, $descr, $capacity\n"); }
if ($debug) { echo("$oid, $index, $type, $descr, $capacity\n"); }
if (mysql_result(mysql_query("SELECT count(toner_id) FROM `toner` WHERE device_id = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index'"),0) == '0')
{
@@ -305,23 +304,22 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
$query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$capacity', '$current')";
mysql_query($query);
echo("+");
}
else
}
else
{
$toner_entry = mysql_fetch_assoc(mysql_query("SELECT * FROM `toner` WHERE device_id = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index'"));
if($oid == $toner_entry['toner_oid'] && $descr == $toner_entry['toner_descr'] && $capacity == $toner_entry['toner_capacity'])
if ($oid == $toner_entry['toner_oid'] && $descr == $toner_entry['toner_descr'] && $capacity == $toner_entry['toner_capacity'])
{
echo(".");
}
else
else
{
mysql_query("UPDATE toner SET `toner_descr` = '$descr', `toner_oid` = '$oid', `toner_capacity` = '$capacity' WHERE `device_id` = '".$device['device_id']."' AND toner_type = '$type' AND `toner_index` = '$index' ");
echo("U");
}
}
$valid[$type][$index] = 1;
return $return;
}
?>
?>

View File

@@ -1,10 +1,10 @@
<?php
echo("IP Addresses : ");
echo("IPv4 Addresses : ");
$oids = trim(snmp_walk($device,"ipAdEntIfIndex","-Osq","IP-MIB"));
$oids = str_replace("ipAdEntIfIndex.", "", $oids);
foreach(explode("\n", $oids) as $data)
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
list($oid,$ifIndex) = explode(" ", $data);
@@ -12,18 +12,19 @@ foreach(explode("\n", $oids) as $data)
$addr = Net_IPv4::parseAddress("$oid/$mask");
$network = $addr->network . "/" . $addr->bitmask;
$cidr = $addr->bitmask;
if (mysql_result(mysql_query("SELECT count(*) FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $oid != "0.0.0.0")
{
$i_query = "SELECT interface_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'";
$interface_id = mysql_result(mysql_query($i_query), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv4_networks` WHERE `ipv4_network` = '$network'"), 0) < '1')
{
mysql_query("INSERT INTO `ipv4_networks` (`ipv4_network`) VALUES ('$network')");
#echo("Create Subnet $network\n");
echo("S");
}
$ipv4_network_id = @mysql_result(mysql_query("SELECT `ipv4_network_id` from `ipv4_networks` WHERE `ipv4_network` = '$network'"), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv4_addresses` WHERE `ipv4_address` = '$oid' AND `ipv4_prefixlen` = '$cidr' AND `interface_id` = '$interface_id'"), 0) == '0')
@@ -32,7 +33,7 @@ foreach(explode("\n", $oids) as $data)
#echo("Added $oid/$cidr to $interface_id ( $hostname $ifIndex )\n $i_query\n");
echo("+");
} else { echo("."); }
$full_address = "$oid/$cidr|$ifIndex";
$valid_v4[$full_address] = 1;
} else { echo("!"); }
@@ -41,7 +42,7 @@ foreach(explode("\n", $oids) as $data)
$sql = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id";
$data = mysql_query($sql);
while($row = mysql_fetch_array($data))
while ($row = mysql_fetch_array($data))
{
$full_address = $row['ipv4_address'] . "/" . $row['ipv4_prefixlen'] . "|" . $row['ifIndex'];
@@ -59,4 +60,5 @@ while($row = mysql_fetch_array($data))
echo("\n");
unset($valid_v4);
?>
?>

View File

@@ -8,9 +8,9 @@ $oids = str_replace("\"", "", $oids);
$oids = str_replace("IP-MIB::", "", $oids);
$oids = trim($oids);
foreach(explode("\n", $oids) as $data)
foreach (explode("\n", $oids) as $data)
{
if($data)
if ($data)
{
$data = trim($data);
list($ipv6addr,$ifIndex) = explode(" ", $data);
@@ -18,15 +18,16 @@ foreach(explode("\n", $oids) as $data)
$sep = ''; $adsep = '';
unset($ipv6_address);
$do = '0';
foreach(explode(":", $ipv6addr) as $part)
foreach (explode(":", $ipv6addr) as $part)
{
$n = hexdec($part);
$oid = "$oid" . "$sep" . "$n";
$sep = ".";
$ipv6_address = $ipv6_address . "$adsep" . $part;
$do++;
if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";}
if ($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";}
}
$ipv6_prefixlen = snmp_get($device, ".1.3.6.1.2.1.4.34.1.5.2.16.$oid", "", "IP-MIB");
$ipv6_prefixlen = explode(".", $ipv6_prefixlen);
$ipv6_prefixlen = str_replace("\"", "", end($ipv6_prefixlen));
@@ -43,9 +44,9 @@ if (!$oids)
$oids = str_replace(".1.3.6.1.2.1.55.1.8.1.2.", "", $oids);
$oids = str_replace("\"", "", $oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data)
foreach (explode("\n", $oids) as $data)
{
if($data)
if ($data)
{
$data = trim($data);
list($if_ipv6addr,$ipv6_prefixlen) = explode(" ", $data);
@@ -60,16 +61,16 @@ if (!$oids)
$sql = "SELECT * FROM ipv6_addresses AS A, ports AS I WHERE I.device_id = '".$device['device_id']."' AND A.interface_id = I.interface_id";
$data = mysql_query($sql);
while($row = mysql_fetch_array($data))
while ($row = mysql_fetch_array($data))
{
$full_address = $row['ipv6_address'] . "/" . $row['ipv6_prefixlen'];
$interface_id = $row['interface_id'];
$valid = $full_address . "-" . $interface_id;
if(!$valid_v6[$valid])
if (!$valid_v6[$valid])
{
echo("-");
$query = @mysql_query("DELETE FROM `ipv6_addresses` WHERE `ipv6_address_id` = '".$row['ipv6_address_id']."'");
if(!mysql_result(mysql_query("SELECT count(*) FROM ipv6_addresses WHERE ipv6_network_id = '".$row['ipv6_network_id']."'"),0))
if (!mysql_result(mysql_query("SELECT count(*) FROM ipv6_addresses WHERE ipv6_network_id = '".$row['ipv6_network_id']."'"),0))
{
$query = @mysql_query("DELETE FROM `ipv6_networks` WHERE `ipv6_network_id` = '".$row['ipv6_network_id']."'");
}

View File

@@ -1,53 +1,56 @@
<?php
### We're discovering this MIB
# We're discovering this MIB
# snmpwalk -v2c -c <community> <hostname> -M mibs/junose/ -m Juniper-UNI-ATM-MIB juniAtmVpStatsEntry
## JunOSe ATM vps
if($device['os'] == "junose" && $config['enable_ports_junoseatmvp'])
if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp'])
{
echo("JunOSe ATM vps : ");
$vp_array = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vp_array, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose");
$valid_vp = array();
if($debug) { print_r($vp_array); }
if ($debug) { print_r($vp_array); }
if(is_array($vp_array)) {
foreach($vp_array as $index => $entry) {
if (is_array($vp_array))
{
foreach ($vp_array as $index => $entry)
{
list($ifIndex,$vp_id)= explode('.', $index);
list($ifIndex,$vp_id)= explode('.', $index);
$interface_id = mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'"),0);
$interface_id = mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$ifIndex."'"),0);
if(is_numeric($interface_id) && is_numeric($vp_id)) {
discover_juniAtmvp($valid_vp, $interface_id, $vp_id, NULL);
}
if (is_numeric($interface_id) && is_numeric($vp_id))
{
discover_juniAtmvp($valid_vp, $interface_id, $vp_id, NULL);
}
} ## End Foreach
} ## End if array
unset ($vp_array);
### Remove ATM vps which weren't redetected here
## Remove ATM vps which weren't redetected here
$sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id";
$query = mysql_query($sql);
if($debug) { print_r ($valid_vp); }
if ($debug) { print_r ($valid_vp); }
while ($test = mysql_fetch_array($query)) {
while ($test = mysql_fetch_array($query))
{
$interface_id = $test['interface_id'];
$vp_id = $test['vp_id'];
if($debug) { echo($interface_id . " -> " . $vp_id . "\n"); }
if(!$valid_vp[$interface_id][$vp_id]) {
if ($debug) { echo($interface_id . " -> " . $vp_id . "\n"); }
if (!$valid_vp[$interface_id][$vp_id])
{
echo("-");
mysql_query("DELETE FROM `juniAtmvp` WHERE `juniAtmVp` = '" . $test['juniAtmvp'] . "'");
}
unset($interface_id); unset($vp_id);
}
unset($valid_vp);
echo("\n");
}
?>
?>

View File

@@ -9,20 +9,20 @@ if ($config['discover_services'])
110 => "pop", 143 => "imap");
# Services
if($device['type'] == "server")
if ($device['type'] == "server")
{
$oids = trim(snmp_walk($device, ".1.3.6.1.2.1.6.13.1.1.0.0.0.0", "-Osqn"));
foreach(explode("\n", $oids) as $data)
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if($data)
if ($data)
{
list($oid, $tcpstatus) = explode(" ", $data);
if (trim($tcpstatus) == "listen")
{
$split_oid = explode('.',$oid);
$tcp_port = $split_oid[count($split_oid)-6];
if($known_services[$tcp_port])
if ($known_services[$tcp_port])
{
add_service($known_services[$tcp_port]);
}
@@ -34,4 +34,4 @@ if ($config['discover_services'])
echo("\n");
}
?>
?>