- | $i |
- ".generatedevicelink($peer)." |
- " . $peer['bgpPeerIdentifier'] . " ".$peername." |
- $peer_type |
+ $i |
+ ".generatedevicelink($peer, shorthost($peer['hostname']))." |
+ " . $peer['bgpPeerIdentifier'] . " ".$peername." |
+ $peer_type |
AS" . $peer['bgpPeerRemoteAs'] . " " . $peer['astext'] . " |
" . $peer['bgpPeerAdminStatus'] . " " . $peer['bgpPeerState'] . " |
" .formatUptime($peer['bgpPeerFsmEstablishedTime']). "
diff --git a/includes/functions.php b/includes/functions.php
index 2a9284042..150e87284 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -1,18 +1,24 @@
-include_once("common.php");
-include_once("ipv6-functions.php");
-include_once("generic.php");
-include_once("ios.php");
-include_once("unix.php");
-include_once("windows.php");
-include_once("procurve.php");
-include_once("snom.php");
-include_once("graphing.php");
-include_once("print-functions.php");
-include_once("billing-functions.php");
-include_once("cisco-entities.php");
-include_once("syslog.php");
+## Include from PEAR
+
+include_once("Net/IPv4.php");
+include_once("Net/IPv6.php");
+
+## Observer Includes
+
+include_once($config['install_dir'] . "/includes/common.php");
+include_once($config['install_dir'] . "/includes/generic.php");
+include_once($config['install_dir'] . "/includes/ios.php");
+include_once($config['install_dir'] . "/includes/unix.php");
+include_once($config['install_dir'] . "/includes/windows.php");
+include_once($config['install_dir'] . "/includes/procurve.php");
+include_once($config['install_dir'] . "/includes/snom.php");
+include_once($config['install_dir'] . "/includes/graphing.php");
+include_once($config['install_dir'] . "/includes/print-functions.php");
+include_once($config['install_dir'] . "/includes/billing-functions.php");
+include_once($config['install_dir'] . "/includes/cisco-entities.php");
+include_once($config['install_dir'] . "/includes/syslog.php");
function write_dev_attrib($device_id, $attrib_type, $attrib_value) {
$count_sql = "SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device_id . "' AND `attrib_type` = '$attrib_type'";
@@ -58,10 +64,10 @@ function getHostOS($hostname, $community, $snmpver) {
$sysDescr_cmd = $config['snmpget']." -O qv -" . $snmpver . " -c " . $community . " " . $hostname . " sysDescr.0";
$sysDescr = str_replace("\"", "", trim(shell_exec($sysDescr_cmd)));
- $dir_handle = @opendir("includes/osdiscovery") or die("Unable to open $path");
+ $dir_handle = @opendir($config['install_dir'] . "/includes/osdiscovery") or die("Unable to open $path");
while ($file = readdir($dir_handle)) {
if( preg_match("/^discover-([a-z0-9]*).php/", $file) ) {
- include("includes/osdiscovery/" . $file);
+ include($config['install_dir'] . "includes/osdiscovery/" . $file);
}
}
closedir($dir_handle);
@@ -327,11 +333,12 @@ function delHost($id) {
function addHost($host, $community, $snmpver) {
+ global $config;
list($hostshort) = explode(".", $host);
if ( isDomainResolves($host)){
if ( isPingable($host)) {
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) {
- $snmphost = trim(`snmpwalk -Oqv -$snmpver -c $community $host sysname | sed s/\"//g`);
+ $snmphost = shell_exec($config['snmpget'] ." -Oqv -$snmpver -c $community $host sysName.0");
if ($snmphost == $host || $hostshort = $host) {
createHost ($host, $community, $snmpver);
} else { echo("Given hostname does not match SNMP-read hostname!\n"); }
@@ -443,10 +450,11 @@ function formatUptime($diff, $format="long") {
}
function isSNMPable($hostname, $community, $snmpver) {
- $pos = `snmpget -$snmpver -c $community -t 1 $hostname sysDescr.0`;
+ global $config;
+ $pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname sysDescr.0");
if($pos == '') {
$status='0';
- $posb = `snmpget -$snmpver -c $community -t 1 $hostname 1.3.6.1.2.1.7526.2.4`;
+ $posb = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname 1.3.6.1.2.1.7526.2.4");
if($posb == '') { } else { $status='1'; }
} else {
$status='1';
diff --git a/includes/ipv6-functions.php b/includes/ipv6-functions.php
deleted file mode 100644
index 5671d85ff..000000000
--- a/includes/ipv6-functions.php
+++ /dev/null
@@ -1,286 +0,0 @@
-0) {
- $match = '';
- foreach($zeros[0] as $zero) {
- if (strlen($zero) > strlen($match))
- $match = $zero;
- }
- $cip = preg_replace('/' . $match . '/', ':', $cip, 1);
- }
- $cip = preg_replace('/((^:)|(:$))/', '' ,$cip);
- $cip = preg_replace('/((^:)|(:$))/', '::' ,$cip);
- }
- if('' != $netmask) {
- $cip = $cip.'/'.$netmask;
- }
- return $cip;
- }
-
- function SplitV64($ip) {
- $ip = Net_IPv6::removeNetmaskSpec($ip);
- $ip = Net_IPv6::Uncompress($ip);
- if (strstr($ip, '.')) {
- $pos = strrpos($ip, ':');
- $ip{$pos} = '_';
- $ipPart = explode('_', $ip);
- return $ipPart;
- } else {
- return array($ip, "");
- }
- }
-
- function checkIPv6($ip) {
- $ip = Net_IPv6::removeNetmaskSpec($ip);
- $ipPart = Net_IPv6::SplitV64($ip);
- $count = 0;
- if (!empty($ipPart[0])) {
- $ipv6 =explode(':', $ipPart[0]);
- for ($i = 0; $i < count($ipv6); $i++) {
- $dec = hexdec($ipv6[$i]);
- $hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i]));
- if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) {
- $count++;
- }
- }
- if (8 == $count) {
- return true;
- } elseif (6 == $count and !empty($ipPart[1])) {
- $ipv4 = explode('.',$ipPart[1]);
- $count = 0;
- for ($i = 0; $i < count($ipv4); $i++) {
- if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) {
- $count++;
- }
- }
- if (4 == $count) {
- return true;
- }
- } else {
- return false;
- }
-
- } else {
- return false;
- }
- }
-
- function _ip2Bin($ip) {
- $binstr = '';
- $ip = Net_IPv6::removeNetmaskSpec($ip);
- $ip = Net_IPv6::Uncompress($ip);
- $parts = explode(':', $ip);
- foreach($parts as $v) {
- $str = base_convert($v, 16, 2);
- $binstr .= str_pad($str, 16, '0', STR_PAD_LEFT);
- }
- return $binstr;
- }
-
- function _bin2Ip($bin) {
- $ip = "";
- if(strlen($bin)<128) {
- $bin = str_pad($str, 128, '0', STR_PAD_LEFT);
- }
- $parts = str_split($bin, "16");
- foreach($parts as $v) {
- $str = base_convert($v, 2, 16);
- $ip .= $str.":";
- }
- $ip = substr($ip, 0,-1);
- return $ip;
- }
-
-}
-
-?>
diff --git a/ipv6.php b/ipv6.php
index 352819ea1..86c0bea93 100755
--- a/ipv6.php
+++ b/ipv6.php
@@ -9,11 +9,13 @@ while ($device = mysql_fetch_array($q)) {
echo("\n" . $device['hostname'] . " : ");
- $oids = shell_exec("snmpwalk -v2c -c v05tr0n82 ".$device['hostname']." ipAddressIfIndex.ipv6 -Osq");
+ $oids = shell_exec("snmpwalk -v2c -c ".$device['community']." ".$device['hostname']." ipAddressIfIndex.ipv6 -Osq");
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
+
foreach(explode("\n", $oids) as $data) {
$data = trim($data);
list($ipv6addr,$ifIndex) = explode(" ", $data);
+
$oid = "";
$sep = ''; $adsep = '';
unset($address);
@@ -33,6 +35,8 @@ while ($device = mysql_fetch_array($q)) {
$network = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Subnet | cut -f 2 -d '-'"));
$comp = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Compressed | cut -f 2 -d '-'"));
+ $valid_ips[] = $address . " " . $ifIndex;
+
if (mysql_result(mysql_query("SELECT count(*) FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $cidr > '0' && $cidr < '129' && $comp != '::1') {
$i_query = "SELECT interface_id FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'";
$interface_id = mysql_result(mysql_query($i_query), 0);
@@ -49,7 +53,23 @@ while ($device = mysql_fetch_array($q)) {
mysql_query("INSERT INTO `ip6adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
echo("A");
}
- } else { echo("."); }
+ } else { echo("."); }
+
}
+
+ $sql = "SELECT * FROM ip6addr AS A, interfaces AS I WHERE A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'";
+ $data = mysql_query($sql);
+ while($row = mysql_fetch_array($data)) {
+ unset($valid);
+ foreach($valid_ips as $valid_ip) {
+ if($row['addr'] . " " . $row['ifIndex'] == $valid_ip) { $valid = 1; }
+ }
+ if(!$valid) { echo("-"); mysql_query("DELETE FROM ip6addr WHERE ip6addr_id = '".$row['ip6addr_id']."'");}
+ }
+
+ unset($valid_ips);
+
+ echo("\n");
+
}
?>
diff --git a/poll-device.php b/poll-device.php
index 62bfe0ccc..cf5ef13d1 100755
--- a/poll-device.php
+++ b/poll-device.php
@@ -250,7 +250,7 @@ while ($device = mysql_fetch_array($device_query)) {
if ($uptime) {
- $old_uptime = mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'uptime'"), 0);
+ $old_uptime = @mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'uptime'"), 0);
if( $uptime < $old_uptime ) {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
@@ -284,7 +284,7 @@ while ($device = mysql_fetch_array($device_query)) {
$update_query = "UPDATE `devices` SET ";
$update_query .= $update;
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
- echo("Updating " . $device['hostname'] . "\n" . $update_query . "\n");
+ echo("Updating " . $device['hostname'] . "\n");
$update_result = mysql_query($update_query);
} else {
echo("No Changes to " . $device['hostname'] . "\n");
|