mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
bah
git-svn-id: http://www.observium.org/svn/observer/trunk@195 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$sql = "SELECT * FROM devices WHERE hostname LIKE '%$argv[1]%' order by id ASC";
|
||||
$q = mysql_query($sql);
|
||||
while ($device = mysql_fetch_array($q)) {
|
||||
$hostname = $device['hostname'];
|
||||
$hostid = $device['id'];
|
||||
# echo("$hostname\n");
|
||||
$oids = `snmpwalk -v2c -Osq -c $community $hostname ipAdEntIfIndex | sed s/ipAdEntIfIndex.//g`;
|
||||
$oids = trim($oids);
|
||||
foreach(explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
list($oid,$snmpid) = explode(" ", $data);
|
||||
$temp = `snmpget -O qv -v2c -c $community $hostname ipAdEntNetMask.$oid`;
|
||||
$mask = trim($temp);
|
||||
$address = $oid;
|
||||
$cidr = netmask2cidr($netmask);
|
||||
$network = trim(`$ipcalc $address/$mask | grep Network | cut -d" " -f 4`);
|
||||
if (match_network($config['nets'], $address) && $network != "") {
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `networks` WHERE `cidr` = '$network'"), 0) < '1') {
|
||||
$woo = mysql_query("INSERT INTO `networks` (`id`, `cidr`) VALUES ('', '$network')");
|
||||
echo("Create Subnet $network\n");
|
||||
} else {
|
||||
$interface_id = @mysql_result(mysql_query("SELECT I.id FROM `interfaces` AS I, `devices` AS D WHERE I.host = D.id AND `snmpid` = '$snmpid' AND D.hostname = '$hostname'"), 0);
|
||||
$network_id = @mysql_result(mysql_query("SELECT id from `networks` WHERE `cidr` = '$network'"), 0);
|
||||
if (mysql_result(mysql_query("SELECT count(id) FROM `interfaces` WHERE snmpid = '$snmpid' AND host = '$hostid'"),0) == '1') {
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `adjacencies` WHERE `network_id` = '$network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
|
||||
echo("Create Adjacency : $hostname $network '$network_id', '$interface_id'\n");
|
||||
}
|
||||
} else { echo("$hostname snmpid $snmpid doesn't exist to link to $network/$cidr\n"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,11 +0,0 @@
|
||||
./interface-ips.php 1 &
|
||||
./interface-ips.php 2 &
|
||||
./interface-ips.php 3 &
|
||||
./interface-ips.php 4 &
|
||||
./interface-ips.php 5 &
|
||||
./interface-ips.php 6 &
|
||||
./interface-ips.php 7 &
|
||||
./interface-ips.php 8 &
|
||||
./interface-ips.php 9 &
|
||||
./interface-ips.php 0 &
|
||||
|
Reference in New Issue
Block a user