mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
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:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
unset ($mac_table);
|
||||
|
||||
echo("ARP Table : ");
|
||||
@@ -6,37 +7,31 @@
|
||||
$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) {
|
||||
|
||||
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);
|
||||
|
||||
$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"); }
|
||||
@@ -53,6 +48,7 @@
|
||||
}
|
||||
$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))
|
||||
@@ -62,7 +58,7 @@
|
||||
if (!$mac_table[$entry_if][$entry_mac])
|
||||
{
|
||||
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']);
|
||||
if ($debug) { echo("Removing MAC $entry_mac from interface ".$interface['ifName']); }
|
||||
echo("-");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -206,4 +207,3 @@ if ($config['enable_bgp'])
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -39,7 +39,6 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
|
||||
echo("\nSensors: ");
|
||||
|
||||
|
||||
if ($debug) { print_r($oids); }
|
||||
|
||||
$entitysensor['voltsDC'] = "voltage";
|
||||
@@ -71,7 +70,8 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
}
|
||||
|
||||
## 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)
|
||||
{
|
||||
@@ -89,6 +89,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
$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"; }
|
||||
@@ -118,6 +119,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
|
||||
{
|
||||
$limit_low = $entry['entSensorThresholdValue'] * $multiplier / $divisor;
|
||||
}
|
||||
|
||||
### Warning Limit
|
||||
if ($entry['entSensorThresholdSeverity'] == "minor" && $entry['entSensorThresholdRelation'] == "greaterOrEqual")
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios")
|
||||
|
||||
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);
|
||||
@@ -17,12 +18,14 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios")
|
||||
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);
|
||||
|
||||
@@ -8,8 +8,8 @@ if($device['os_group'] == "ios")
|
||||
$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') {
|
||||
|
||||
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,15 +21,16 @@ if($device['os_group'] == "ios")
|
||||
|
||||
$vlans = trim(`$vlans_cmd | grep -v o`);
|
||||
|
||||
foreach(explode("\n", $vlans) as $vlan) {
|
||||
|
||||
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 {
|
||||
@@ -38,16 +39,19 @@ if($device['os_group'] == "ios")
|
||||
}
|
||||
|
||||
$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) {
|
||||
foreach ($this_vlans as $test_vlan)
|
||||
{
|
||||
if ($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; }
|
||||
}
|
||||
if(!$vlan_exists) {
|
||||
|
||||
if (!$vlan_exists)
|
||||
{
|
||||
mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'");
|
||||
echo("-");
|
||||
#echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n");
|
||||
@@ -58,6 +62,6 @@ if($device['os_group'] == "ios")
|
||||
unset($this_vlans);
|
||||
|
||||
echo("\n");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
if ($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os'] == "ironware")
|
||||
{
|
||||
|
||||
unset( $vrf_count );
|
||||
|
||||
echo("VRFs : ");
|
||||
@@ -89,14 +88,17 @@ if($device['os_group'] == "ios" || $device['os_group'] == "junos" || $device['os
|
||||
{
|
||||
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
|
||||
|
||||
?>
|
||||
@@ -4,10 +4,12 @@ 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)
|
||||
{
|
||||
@@ -18,13 +20,13 @@ if($device['os'] == "ironware") {
|
||||
$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']);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +35,8 @@ if($device['os'] == "ironware") {
|
||||
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)
|
||||
{
|
||||
@@ -58,19 +61,17 @@ if($cdp_array) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
foreach (array_keys($lldp_array) as $key)
|
||||
{
|
||||
$lldp_if_array = $lldp_array[$key];
|
||||
foreach (array_keys($lldp_if_array) as $entry_key)
|
||||
{
|
||||
@@ -93,7 +94,8 @@ if($lldp_array) {
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +114,8 @@ if ($query = mysql_query($sql))
|
||||
$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 (!$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 "); }
|
||||
|
||||
@@ -15,7 +15,6 @@ echo(" ENTITY-SENSOR ");
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, "entPhysicalName", $entity_array, "CISCO-ENTITY-SENSOR-MIB");
|
||||
}
|
||||
|
||||
|
||||
$oids = array();
|
||||
echo(" entPhySensorType");
|
||||
$oids = snmpwalk_cache_multi_oid($device, "entPhySensorType", $oids, "ENTITY-SENSOR-MIB");
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
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); }
|
||||
|
||||
@@ -75,7 +75,6 @@ function discover_sensor (&$valid, $class, $device, $oid, $index, $type, $descr,
|
||||
}
|
||||
}
|
||||
$valid[$class][$type][$index] = 1;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function sensor_low_limit($class, $current)
|
||||
@@ -321,7 +320,6 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity
|
||||
}
|
||||
|
||||
$valid[$type][$index] = 1;
|
||||
return $return;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
echo("IP Addresses : ");
|
||||
echo("IPv4 Addresses : ");
|
||||
|
||||
$oids = trim(snmp_walk($device,"ipAdEntIfIndex","-Osq","IP-MIB"));
|
||||
$oids = str_replace("ipAdEntIfIndex.", "", $oids);
|
||||
@@ -12,6 +12,7 @@ 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'";
|
||||
@@ -59,4 +60,5 @@ while($row = mysql_fetch_array($data))
|
||||
echo("\n");
|
||||
|
||||
unset($valid_v4);
|
||||
|
||||
?>
|
||||
@@ -27,6 +27,7 @@ foreach(explode("\n", $oids) as $data)
|
||||
$do++;
|
||||
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));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?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
|
||||
@@ -12,14 +11,16 @@ if($device['os'] == "junose" && $config['enable_ports_junoseatmvp'])
|
||||
$valid_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);
|
||||
|
||||
$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)) {
|
||||
if (is_numeric($interface_id) && is_numeric($vp_id))
|
||||
{
|
||||
discover_juniAtmvp($valid_vp, $interface_id, $vp_id, NULL);
|
||||
}
|
||||
} ## End Foreach
|
||||
@@ -27,27 +28,29 @@ if($device['os'] == "junose" && $config['enable_ports_junoseatmvp'])
|
||||
|
||||
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); }
|
||||
|
||||
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 (!$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");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user