mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
updates and new MIB
git-svn-id: http://www.observium.org/svn/observer/trunk@399 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -7,7 +7,6 @@ $ipv6interfaces = shell_exec($config['snmpget']." -Ovnq -".$device['snmpver']."
|
||||
if($ipv6interfaces){
|
||||
|
||||
$oids = trim(trim(shell_exec($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No")));
|
||||
echo($config['snmpwalk']." -".$device['snmpver']." -Ln -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAddressIfIndex.ipv6 -Osq | grep -v No");
|
||||
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
|
||||
foreach(explode("\n", $oids) as $data) {
|
||||
if($data) {
|
||||
@@ -15,43 +14,64 @@ if($ipv6interfaces){
|
||||
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
||||
$oid = "";
|
||||
$sep = ''; $adsep = '';
|
||||
unset($address);
|
||||
unset($ip6_addr);
|
||||
$do = '0';
|
||||
foreach(explode(":", $ipv6addr) as $part) {
|
||||
$n = hexdec($part);
|
||||
$oid = "$oid" . "$sep" . "$n";
|
||||
$sep = ".";
|
||||
$address = $address . "$adsep" . $part;
|
||||
$ip6_addr = $ip6_addr . "$adsep" . $part;
|
||||
$do++;
|
||||
if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";}
|
||||
}
|
||||
$ip6_prefixlen = trim(shell_exec($config['snmpget']." -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'"));
|
||||
$ip6_origin = trim(shell_exec($config['snmpget']." -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid"));
|
||||
|
||||
$cidr = trim(shell_exec($config['snmpget']." -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'"));
|
||||
$origin = trim(shell_exec($config['snmpget']." -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid"));
|
||||
$ip6_network = trim(shell_exec($config['sipcalc']." $ip6_addr/$ip6_prefixlen | grep Subnet | cut -f 2 -d '-'"));
|
||||
$ip6_comp_addr = trim(shell_exec($config['sipcalc']." $ip6_addr/$ip6_prefixlen | grep Compressed | cut -f 2 -d '-'"));
|
||||
|
||||
$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 '-'"));
|
||||
|
||||
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') {
|
||||
if (mysql_result(mysql_query("SELECT count(*) FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $ip6_prefixlen > '0' && $ip6_prefixlen < '129' && $ip6_comp_addr != '::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);
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6addr` WHERE `addr` = '$address' AND `cidr` = '$cidr' AND `interface_id` = '$interface_id'"), 0) == '0') {
|
||||
mysql_query("INSERT INTO `ip6addr` (`addr`, `comp_addr`, `cidr`, `origin`, `network`, `interface_id`) VALUES ('$address', '$comp', '$cidr', '$origin', '$network', '$interface_id')");
|
||||
echo("+");
|
||||
} else { echo("."); }
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6networks` WHERE `cidr` = '$network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ip6networks` (`id`, `cidr`) VALUES ('', '$network')");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6networks` WHERE `ip6_network` = '$ip6_network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ip6networks` (`ip6_network`) VALUES ('$ip6_network')");
|
||||
echo("N");
|
||||
}
|
||||
$network_id = @mysql_result(mysql_query("SELECT id from `ip6networks` WHERE `cidr` = '$network'"), 0);
|
||||
if (match_network($nets, $address) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6adjacencies` WHERE `network_id` = '$network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ip6adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
|
||||
echo("A");
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6networks` WHERE `ip6_network` = '$ip6_network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ip6networks` (`ip6_network`) VALUES ('$ip6_network')");
|
||||
echo("N");
|
||||
}
|
||||
$ip6_network_id = @mysql_result(mysql_query("SELECT `ip6_network_id` from `ip6networks` WHERE `ip6_network` = '$ip6_network'"), 0);
|
||||
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6addr` WHERE `ip6_addr` = '$ip6_addr' AND `ip6_prefixlen` = '$ip6_prefixlen' AND `interface_id` = '$interface_id'"), 0) == '0') {
|
||||
mysql_query("INSERT INTO `ip6addr` (`ip6_addr`, `ip6_comp_addr`, `ip6_prefixlen`, `ip6_origin`, `ip6_network`, `ip6_network_id`, `interface_id`) VALUES ('$ip6_addr', '$ip6_comp_addr', '$ip6_prefixlen', '$ip6_origin', '$ip6_network', '$ip6_network_id', '$interface_id')");
|
||||
echo("+");
|
||||
} else { echo("."); }
|
||||
# if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6adjacencies` WHERE `ip6_network_id` = '$ip6_network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
|
||||
# mysql_query("INSERT INTO `ip6adjacencies` (`network_id`, `interface_id`) VALUES ('$ip6_network_id', '$interface_id')");
|
||||
# echo("A");
|
||||
# }
|
||||
$full_address = "$ip6_addr/$ip6_prefixlen";
|
||||
$valid_v6[$full_address] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { echo("None configured"); }
|
||||
|
||||
$sql = "SELECT * FROM ip6addr AS A, interfaces 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)) {
|
||||
$full_address = $row['ip6_addr'] . "/" . $row['ip6_prefixlen'];
|
||||
if(!$valid_v6[$full_address]) {
|
||||
echo("-");
|
||||
$query = @mysql_query("DELETE FROM `ip6addr` WHERE `ip6_addr_id` = '".$row['ip6_addr_id']."'");
|
||||
if(!mysql_result(mysql_query("SELECT count(*) FROM ip6addr WHERE ip6_network_id = '".$row['ip6_network_id']."'"),0)) {
|
||||
$query = @mysql_query("DELETE FROM `ip6networks` WHERE `ip6_network_id` = '".$row['ip6_network_id']."'");
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($valid_v6);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user