mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
many fixes to ip address polling and displaying
git-svn-id: http://www.observium.org/svn/observer/trunk@403 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
2
cron.sh
2
cron.sh
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
./discovery.php --forced >> /var/log/observer.log
|
||||
#./discovery.php --forced >> /var/log/observer.log
|
||||
./poll-mac_accounting.php >> /var/log/observer.log &
|
||||
./discover-bgp_peers.php >> /var/log/observer.log &
|
||||
./poll-device.php --odd >> /var/log/observer.log &
|
||||
|
@@ -15,7 +15,7 @@ if($argv[1] == "--device" && $argv[2]) {
|
||||
}
|
||||
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE `status` = '1' AND (`os` = 'IOS' OR `os` = 'IOS XE') AND hostname NOT LIKE '%bar%' $where ORDER BY `device_id` DESC");
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE `status` = '1' AND (`os` = 'IOS' OR `os` = 'IOS XE') AND hostname NOT LIKE '%esr%' $where ORDER BY `device_id` DESC");
|
||||
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
@@ -77,7 +77,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
{
|
||||
$sql = "INSERT INTO `links` (`src_if`, `dst_if`, `cdp`) VALUES ('$src_if_id', '$dst_if_id', '1')";
|
||||
mysql_query($sql);
|
||||
echo("++($src_host $src_if -> $dst_host $dst_if)");
|
||||
echo("\n++($src_host $src_if -> $dst_host $dst_if)");
|
||||
} else {
|
||||
echo("..");
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ if($argv[1] == "--device" && $argv[2]) {
|
||||
}
|
||||
|
||||
|
||||
$devices_polled = 0;
|
||||
$devices_discovered = 0;
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id DESC");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
@@ -47,7 +47,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
include("includes/discovery/interfaces.php");
|
||||
|
||||
## Discover IPv4 Addresses
|
||||
include("includes/discovery/ipaddresses.php");
|
||||
include("includes/discovery/ipv4-addresses.php");
|
||||
|
||||
## Discovery IPv6 Addresses
|
||||
include("includes/discovery/ipv6-addresses.php");
|
||||
@@ -72,14 +72,14 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
include("includes/discovery/cisco-processors.php");
|
||||
}
|
||||
|
||||
echo("\n"); $devices_polled++;
|
||||
echo("\n"); $devices_discovered++;
|
||||
mysql_query("DELETE FROM `devices_attribs` WHERE `device_id` = '".$device['device_id']."' AND `attrib_type` = 'discover'");
|
||||
}
|
||||
|
||||
$end = utime(); $run = $end - $start;
|
||||
$proctime = substr($run, 0, 5);
|
||||
|
||||
echo("$devices_polled devices polled in $proctime secs\n");
|
||||
echo("$devices_discovered devices discovered in $proctime secs\n");
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
@@ -133,7 +133,8 @@
|
||||
if($os == "Linux" || $os == "NetBSD" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "Windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfSense" || $os == "DragonFly" || $os == "OpenBSD") {
|
||||
$graph = cpugraphUnix ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
} elseif($os == "IOS" || $os == "IOS XE") {
|
||||
$graph = cpugraph ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
$graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
#$graph = cpugraph ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
} elseif($os == "Windows") {
|
||||
$graph = cpugraphwin ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
} elseif($os == "ProCurve") {
|
||||
@@ -148,7 +149,9 @@
|
||||
$graph = graph_cpu_generic_single($hostname . "/junos-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'dev_cpmCPU':
|
||||
$graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
case 'temp':
|
||||
$graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
|
@@ -40,14 +40,14 @@
|
||||
|
||||
unset ($break);
|
||||
if(!$dographs) {
|
||||
$ipdata = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
$ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
while($ip = mysql_fetch_Array($ipdata)) {
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip[addr]')\">$ip[addr]/$ip[cidr]</a>");
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
|
||||
$break = "<br />";
|
||||
}
|
||||
$ip6data = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
$ip6data = mysql_query("SELECT * FROM `ipv6_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
while($ip6 = mysql_fetch_Array($ip6data)) {
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=".$ip6['ip6_addr']."')\">".Net_IPv6::compress($ip6['ip6_addr'])."/".$ip6['ip6_prefixlen']."</a>");
|
||||
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
|
||||
$break = "<br />";
|
||||
}
|
||||
|
||||
@@ -111,64 +111,45 @@ echo("</td>");
|
||||
}
|
||||
|
||||
unset($br);
|
||||
$adj_sql = "SELECT * FROM networks AS N, interfaces AS I, adjacencies AS A ";
|
||||
$adj_sql = $adj_sql . "WHERE I.interface_id = A.interface_id AND A.network_id = N.id ";
|
||||
$adj_sql = $adj_sql . "AND I.interface_id = '$if_id'";
|
||||
$adj_query = mysql_query("$adj_sql");
|
||||
while($adjs = mysql_fetch_array($adj_query)) {
|
||||
$network_id = $adjs['network_id'];
|
||||
$newsql = "SELECT * FROM adjacencies AS A, networks as N, interfaces as I, devices as D ";
|
||||
$newsql = $newsql . "WHERE N.id = '$network_id' AND A.network_id = N.id AND I.interface_id = A.interface_id AND D.device_id = I.device_id ";
|
||||
$newsql = $newsql . "AND D.device_id != '".$device['device_id']."' AND I.ifDescr NOT LIKE '%loopback%' GROUP BY D.device_id ORDER BY D.hostname";
|
||||
$new_query = mysql_query($newsql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
|
||||
$this_ifid = $new['interface_id'];
|
||||
$this_hostid = $new['device_id'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['ifDescr']);
|
||||
$wq = mysql_query("select count(*) FROM links WHERE dst_if = '$this_ifid' AND src_if = $if_id;");
|
||||
|
||||
$int_links[$this_ifid] = $this_ifid;
|
||||
$int_links_v4[$this_ifid] = 1;
|
||||
|
||||
|
||||
# if (@mysql_result($wq, 0) == '0' && $this_hostname != $hostname) {
|
||||
# $graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits'";
|
||||
# echo("$br <img src='images/16/bullet_go.png' alt='Same Subnet' align=absmiddle />" . generateiflink($new, makeshortif($new['ifDescr'])) . " on " . generatedevicelink($new));
|
||||
# $br = "<br />";
|
||||
# }
|
||||
}
|
||||
}
|
||||
unset($br);
|
||||
# }
|
||||
|
||||
$sql = "SELECT ip6_network_id FROM ip6addr WHERE interface_id = '".$interface['interface_id']."'";
|
||||
|
||||
$nets_query = mysql_query($sql);
|
||||
|
||||
$sql = "SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = '".$interface['interface_id']."' AND `ipv4_address` NOT LIKE '127.%'";
|
||||
$nets_query = mysql_query($sql);
|
||||
while($net = mysql_fetch_array($nets_query)) {
|
||||
echo($net['ip6_network']);
|
||||
$ip6_network_id = $net['ip6_network_id'];
|
||||
|
||||
$sql = "SELECT I.interface_id FROM ip6addr AS A, ip6networks AS N, interfaces AS I, devices AS D
|
||||
WHERE A.interface_id = I.interface_id
|
||||
AND A.ip6_network = N.ip6_network AND N.ip6_network_id = '".$net['ip6_network_id']."' AND D.device_id = I.device_id
|
||||
AND D.device_id != '".$device['device_id']."' AND A.ip6_origin != 'linklayer' AND A.ip6_origin != 'wellknown'";
|
||||
|
||||
$ipv4_network_id = $net['ipv4_network_id'];
|
||||
$sql = "SELECT I.interface_id FROM ipv4_addresses AS A, interfaces AS I, devices AS D
|
||||
WHERE A.interface_id = I.interface_id
|
||||
AND A.ipv4_network_id = '".$net['ipv4_network_id']."' AND D.device_id = I.device_id
|
||||
AND D.device_id != '".$device['device_id']."'";
|
||||
$new_query = mysql_query($sql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
|
||||
echo($new['ip6_network_id']);
|
||||
|
||||
echo($new['ipv4_network_id']);
|
||||
$this_ifid = $new['interface_id'];
|
||||
$this_hostid = $new['device_id'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['ifDescr']);
|
||||
$int_links[$this_ifid] = $this_ifid;
|
||||
$int_links_v4[$this_ifid] = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT ipv6_network_id FROM ipv6_addresses WHERE interface_id = '".$interface['interface_id']."'";
|
||||
$nets_query = mysql_query($sql);
|
||||
while($net = mysql_fetch_array($nets_query)) {
|
||||
$ipv6_network_id = $net['ipv6_network_id'];
|
||||
$sql = "SELECT I.interface_id FROM ipv6_addresses AS A, interfaces AS I, devices AS D
|
||||
WHERE A.interface_id = I.interface_id
|
||||
AND A.ipv6_network_id = '".$net['ipv6_network_id']."' AND D.device_id = I.device_id
|
||||
AND D.device_id != '".$device['device_id']."' AND A.ipv6_origin != 'linklayer' AND A.ipv6_origin != 'wellknown'";
|
||||
$new_query = mysql_query($sql);
|
||||
while($new = mysql_fetch_array($new_query)) {
|
||||
echo($new['ipv6_network_id']);
|
||||
$this_ifid = $new['interface_id'];
|
||||
$this_hostid = $new['device_id'];
|
||||
$this_hostname = $new['hostname'];
|
||||
$this_ifname = fixifName($new['ifDescr']);
|
||||
$int_links[$this_ifid] = $this_ifid;
|
||||
$int_links_v6[$this_ifid] = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,11 +43,8 @@ if(mysql_result(mysql_query("SELECT count(*) from cpmCPU WHERE device_id = '" .
|
||||
echo("<tr><td class=tablehead><a href='' $proc_popup>" . $proc['entPhysicalDescr'] . "</a></td>
|
||||
<td><a href='#' $fs_popup><img src='percentage.php?per=" . $proc['cpmCPUTotal5minRev'] . "'></a></td>
|
||||
<td style='font-weight: bold; color: $drv_colour'>" . $proc['cpmCPUTotal5minRev'] . "%</td>
|
||||
<td>" . $total . "</td>
|
||||
<td>" . $used . "</td>
|
||||
</tr>");
|
||||
$i++;
|
||||
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
|
@@ -82,6 +82,7 @@ while ($entry = mysql_fetch_array($query)) {
|
||||
}
|
||||
if(!$exists) {
|
||||
mysql_query("DELETE FROM bgpPeers WHERE bgpPeer_id = '" . $entry['bgpPeer_id'] . "'");
|
||||
mysql_query("DELETE FROM bgpPeers_cbgp WHERE bgpPeer_id = '" . $entry['bgpPeer_id'] . "'");
|
||||
echo("-");
|
||||
}
|
||||
}
|
||||
|
42
includes/discovery/ipv4-addresses.php
Executable file
42
includes/discovery/ipv4-addresses.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
echo("IP Addresses : ");
|
||||
|
||||
$oids = shell_exec($config['snmpwalk'] . " -".$device['snmpver']." -Osq -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntIfIndex");
|
||||
$oids = trim($oids);
|
||||
$oids = str_replace("ipAdEntIfIndex.", "", $oids);
|
||||
foreach(explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
list($oid,$ifIndex) = explode(" ", $data);
|
||||
$mask = shell_exec($config['snmpget']." -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname'].":".$device['port']." ipAdEntNetMask.$oid");
|
||||
$mask = trim($mask);
|
||||
$network = trim(shell_exec ($config['ipcalc'] . " $oid/$mask | grep Network | cut -d\" \" -f 4"));
|
||||
list($net,$cidr) = explode("/", $network);
|
||||
$cidr = trim($cidr);
|
||||
if($mask == "255.255.255.255") { $cidr = "32"; $network = "$oid/$cidr"; }
|
||||
|
||||
if (mysql_result(mysql_query("SELECT count(*) FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
|
||||
$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 `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') {
|
||||
mysql_query("INSERT INTO `ipv4_addresses` (`ipv4_address`, `ipv4_prefixlen`, `ipv4_network_id`, `interface_id`) VALUES ('$oid', '$cidr', '$ipv4_network_id', '$interface_id')");
|
||||
#echo("Added $oid/$cidr to $interface_id ( $hostname $ifIndex )\n $i_query\n");
|
||||
echo("+");
|
||||
} else { echo("."); }
|
||||
|
||||
} else { echo("!"); }
|
||||
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
?>
|
@@ -14,60 +14,58 @@ if($ipv6interfaces){
|
||||
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
||||
$oid = "";
|
||||
$sep = ''; $adsep = '';
|
||||
unset($ip6_addr);
|
||||
unset($ipv6_address);
|
||||
$do = '0';
|
||||
foreach(explode(":", $ipv6addr) as $part) {
|
||||
$n = hexdec($part);
|
||||
$oid = "$oid" . "$sep" . "$n";
|
||||
$sep = ".";
|
||||
$ip6_addr = $ip6_addr . "$adsep" . $part;
|
||||
$ipv6_address = $ipv6_address . "$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"));
|
||||
$ipv6_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/.*\.//'"));
|
||||
$ipv6_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 '-'"));
|
||||
$ipv6_network = trim(shell_exec($config['sipcalc']." $ipv6_address/$ipv6_prefixlen | grep Subnet | cut -f 2 -d '-'"));
|
||||
$ipv6_compressed = trim(shell_exec($config['sipcalc']." $ipv6_address/$ipv6_prefixlen | 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' && $ip6_prefixlen > '0' && $ip6_prefixlen < '129' && $ip6_comp_addr != '::1') {
|
||||
if (mysql_result(mysql_query("SELECT count(*) FROM `interfaces`
|
||||
WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $ipv6_prefixlen > '0' && $ipv6_prefixlen < '129' && $ipv6_compressed != '::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 `ip6networks` WHERE `ip6_network` = '$ip6_network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ip6networks` (`ip6_network`) VALUES ('$ip6_network')");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = '$ipv6_network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ipv6_networks` (`ipv6_network`) VALUES ('$ipv6_network')");
|
||||
echo("N");
|
||||
}
|
||||
|
||||
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')");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_networks` WHERE `ipv6_network` = '$ipv6_network'"), 0) < '1') {
|
||||
mysql_query("INSERT INTO `ipv6_networks` (`ipv6_network`) VALUES ('$ipv6_network')");
|
||||
echo("N");
|
||||
}
|
||||
$ip6_network_id = @mysql_result(mysql_query("SELECT `ip6_network_id` from `ip6networks` WHERE `ip6_network` = '$ip6_network'"), 0);
|
||||
$ipv6_network_id = @mysql_result(mysql_query("SELECT `ipv6_network_id` from `ipv6_networks` WHERE `ipv6_network` = '$ipv6_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')");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ipv6_addresses` WHERE `ipv6_address` = '$ipv6_address' AND `ipv6_prefixlen` = '$ipv6_prefixlen' AND `interface_id` = '$interface_id'"), 0) == '0') {
|
||||
mysql_query("INSERT INTO `ipv6_addresses` (`ipv6_address`, `ipv6_compressed`, `ipv6_prefixlen`, `ipv6_origin`, `ipv6_network_id`, `interface_id`)
|
||||
VALUES ('$ipv6_address', '$ipv6_compressed', '$ipv6_prefixlen', '$ipv6_origin', '$ipv6_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";
|
||||
$full_address = "$ipv6_address/$ipv6_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";
|
||||
$sql = "SELECT * FROM ipv6_addresses 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'];
|
||||
$full_address = $row['ipv6_address'] . "/" . $row['ipv6_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']."'");
|
||||
$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)) {
|
||||
$query = @mysql_query("DELETE FROM `ipv6_networks` WHERE `ipv6_network_id` = '".$row['ipv6_network_id']."'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -94,6 +94,34 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config, $installdir;
|
||||
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
|
||||
$options .= " -l 0 -E -b 1024 --title '$title' ";
|
||||
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
|
||||
$hostname = gethostbyid($device);
|
||||
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM `cpmCPU` where `device_id` = '$device'");
|
||||
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
|
||||
while($proc = mysql_fetch_array($sql)) {
|
||||
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
|
||||
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
|
||||
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
|
||||
$proc['descr_fixed'] = str_pad($proc['entPhysicalDescr'], 28);
|
||||
$proc['descr_fixed'] = substr($proc['descr_fixed'],0,28);
|
||||
$rrd = $config['rrd_dir'] . "/$hostname/cpmCPU-" . $proc['cpmCPU_oid'] . ".rrd";
|
||||
$options .= " DEF:proc" . $proc['cpmCPU_oid'] . "=$rrd:usage:AVERAGE ";
|
||||
$options .= " LINE1:proc" . $proc['cpmCPU_oid'] . "#" . $colour . ":'" . $proc['descr_fixed'] . "' ";
|
||||
$options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":LAST:%3.0lf";
|
||||
$options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":MAX:%3.0lf\\\l ";
|
||||
$iter++;
|
||||
}
|
||||
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
|
||||
function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config, $installdir;
|
||||
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
|
||||
|
@@ -9,9 +9,7 @@ while($processor = mysql_fetch_array($proc_data)) {
|
||||
|
||||
echo("Checking CPU " . $processor['entPhysicalDescr'] . "... ");
|
||||
|
||||
$procrrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/cpmCPU-" . str_replace("/", "_", str_replace(" ", "_",$processor['entPhysicalDescr'])) . ".rrd");
|
||||
$procrrd = str_replace(")", "_", $procrrd);
|
||||
$procrrd = str_replace("(", "_", $procrrd);
|
||||
$procrrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/cpmCPU-" . $processor['cpmCPU_oid'] . ".rrd");
|
||||
|
||||
if (!is_file($procrrd)) {
|
||||
`rrdtool create $procrrd \
|
||||
@@ -29,7 +27,7 @@ while($processor = mysql_fetch_array($proc_data)) {
|
||||
echo($proc . "%\n");
|
||||
|
||||
$updatecmd = $config['rrdtool'] ." update $procrrd N:$proc";
|
||||
|
||||
echo("$updatecmd");
|
||||
shell_exec($updatecmd);
|
||||
|
||||
mysql_query("UPDATE `cpmCPU` SET `cpmCPUTotal5minRev` = '$proc' WHERE `cpmCPU_id` = '".$processor['cpmCPU_id']."'");
|
||||
|
318
mibs/CISCO-MEMORY-POOL-MIB.my
Normal file
318
mibs/CISCO-MEMORY-POOL-MIB.my
Normal file
@@ -0,0 +1,318 @@
|
||||
-- *****************************************************************
|
||||
-- CISCO-MEMORY-POOL-MIB
|
||||
--
|
||||
-- February 1996, Jeffrey T. Johnson
|
||||
--
|
||||
-- July 2001, Seth Wang
|
||||
--
|
||||
-- Copyright (c) 2001 by cisco Systems, Inc.
|
||||
-- All rights reserved.
|
||||
-- *****************************************************************
|
||||
|
||||
CISCO-MEMORY-POOL-MIB DEFINITIONS ::= BEGIN
|
||||
|
||||
IMPORTS
|
||||
MODULE-IDENTITY,
|
||||
OBJECT-TYPE,
|
||||
Integer32,
|
||||
Gauge32
|
||||
FROM SNMPv2-SMI
|
||||
TEXTUAL-CONVENTION,
|
||||
DisplayString,
|
||||
TruthValue
|
||||
FROM SNMPv2-TC
|
||||
MODULE-COMPLIANCE,
|
||||
OBJECT-GROUP
|
||||
FROM SNMPv2-CONF
|
||||
ciscoMgmt
|
||||
FROM CISCO-SMI
|
||||
Percent
|
||||
FROM CISCO-QOS-PIB-MIB;
|
||||
|
||||
ciscoMemoryPoolMIB MODULE-IDENTITY
|
||||
LAST-UPDATED "200107310000Z"
|
||||
ORGANIZATION "Cisco Systems, Inc."
|
||||
CONTACT-INFO
|
||||
"Postal: Cisco Systems, Inc.
|
||||
170 West Tasman Drive
|
||||
San Jose, CA 95134-1706
|
||||
USA
|
||||
|
||||
Tel: +1 408 526 4000
|
||||
|
||||
E-mail: cs-snmp@cisco.com"
|
||||
DESCRIPTION
|
||||
"MIB module for monitoring memory pools"
|
||||
REVISION "200107310000Z"
|
||||
DESCRIPTION
|
||||
"Added a new table, ciscoMemoryPoolUtilizationTable, which
|
||||
provides information about memory utilization."
|
||||
REVISION "199602010000Z"
|
||||
DESCRIPTION
|
||||
"Initial version of this MIB module."
|
||||
::= { ciscoMgmt 48 }
|
||||
|
||||
CiscoMemoryPoolTypes ::= TEXTUAL-CONVENTION
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Represents the different types of memory pools that
|
||||
may be present in a managed device. Memory pools can
|
||||
be roughly categorized into two groups, predefined
|
||||
pools and dynamic pools. The following pool types
|
||||
are currently predefined:
|
||||
1: processor memory
|
||||
2: i/o memory
|
||||
3: pci memory
|
||||
4: fast memory
|
||||
5: multibus memory
|
||||
|
||||
Dynamic pools will have a pool type value greater than
|
||||
any of the predefined types listed above.
|
||||
|
||||
Note that only the processor pool is required to be
|
||||
supported by all devices. Support for other pool types
|
||||
is dependent on the device being managed."
|
||||
SYNTAX Integer32 (1..65535)
|
||||
|
||||
ciscoMemoryPoolObjects
|
||||
OBJECT IDENTIFIER ::= { ciscoMemoryPoolMIB 1 }
|
||||
|
||||
ciscoMemoryPoolTable OBJECT-TYPE
|
||||
SYNTAX SEQUENCE OF CiscoMemoryPoolEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A table of memory pool monitoring entries."
|
||||
::= { ciscoMemoryPoolObjects 1 }
|
||||
|
||||
ciscoMemoryPoolEntry OBJECT-TYPE
|
||||
SYNTAX CiscoMemoryPoolEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"An entry in the memory pool monitoring table."
|
||||
INDEX { ciscoMemoryPoolType }
|
||||
::= { ciscoMemoryPoolTable 1 }
|
||||
|
||||
CiscoMemoryPoolEntry ::=
|
||||
SEQUENCE {
|
||||
ciscoMemoryPoolType CiscoMemoryPoolTypes,
|
||||
ciscoMemoryPoolName DisplayString,
|
||||
ciscoMemoryPoolAlternate Integer32,
|
||||
ciscoMemoryPoolValid TruthValue,
|
||||
ciscoMemoryPoolUsed Gauge32,
|
||||
ciscoMemoryPoolFree Gauge32,
|
||||
ciscoMemoryPoolLargestFree Gauge32
|
||||
}
|
||||
|
||||
ciscoMemoryPoolType OBJECT-TYPE
|
||||
SYNTAX CiscoMemoryPoolTypes
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The type of memory pool for which this entry
|
||||
contains information."
|
||||
::= { ciscoMemoryPoolEntry 1 }
|
||||
|
||||
ciscoMemoryPoolName OBJECT-TYPE
|
||||
SYNTAX DisplayString
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A textual name assigned to the memory pool. This
|
||||
object is suitable for output to a human operator,
|
||||
and may also be used to distinguish among the various
|
||||
pool types, especially among dynamic pools."
|
||||
::= { ciscoMemoryPoolEntry 2 }
|
||||
|
||||
ciscoMemoryPoolAlternate OBJECT-TYPE
|
||||
SYNTAX Integer32 (0..65535)
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Indicates whether or not this memory pool has an
|
||||
alternate pool configured. Alternate pools are
|
||||
used for fallback when the current pool runs out
|
||||
of memory.
|
||||
|
||||
If an instance of this object has a value of zero,
|
||||
then this pool does not have an alternate. Otherwise
|
||||
the value of this object is the same as the value of
|
||||
ciscoMemoryPoolType of the alternate pool."
|
||||
::= { ciscoMemoryPoolEntry 3 }
|
||||
|
||||
ciscoMemoryPoolValid OBJECT-TYPE
|
||||
SYNTAX TruthValue
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Indicates whether or not the remaining objects in
|
||||
this entry contain accurate data. If an instance
|
||||
of this object has the value false (which in and of
|
||||
itself indicates an internal error condition), the
|
||||
values of the remaining objects in the conceptual row
|
||||
may contain inaccurate information (specifically, the
|
||||
reported values may be less than the actual values)."
|
||||
::= { ciscoMemoryPoolEntry 4 }
|
||||
|
||||
ciscoMemoryPoolUsed OBJECT-TYPE
|
||||
SYNTAX Gauge32
|
||||
UNITS "bytes"
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Indicates the number of bytes from the memory pool
|
||||
that are currently in use by applications on the
|
||||
managed device."
|
||||
::= { ciscoMemoryPoolEntry 5 }
|
||||
|
||||
ciscoMemoryPoolFree OBJECT-TYPE
|
||||
SYNTAX Gauge32
|
||||
UNITS "bytes"
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Indicates the number of bytes from the memory pool
|
||||
that are currently unused on the managed device.
|
||||
|
||||
Note that the sum of ciscoMemoryPoolUsed and
|
||||
ciscoMemoryPoolFree is the total amount of memory
|
||||
in the pool"
|
||||
::= { ciscoMemoryPoolEntry 6 }
|
||||
|
||||
ciscoMemoryPoolLargestFree OBJECT-TYPE
|
||||
SYNTAX Gauge32
|
||||
UNITS "bytes"
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"Indicates the largest number of contiguous bytes
|
||||
from the memory pool that are currently unused on
|
||||
the managed device."
|
||||
::= { ciscoMemoryPoolEntry 7 }
|
||||
|
||||
ciscoMemoryPoolUtilizationTable OBJECT-TYPE
|
||||
SYNTAX SEQUENCE OF CiscoMemoryPoolUtilizationEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A table of memory pool utilization entries. Each of the
|
||||
objects provides a general idea of how much of the memory
|
||||
pool has been used over a given period of time. It is
|
||||
determined as a weighted decaying average."
|
||||
::= { ciscoMemoryPoolObjects 2 }
|
||||
|
||||
ciscoMemoryPoolUtilizationEntry OBJECT-TYPE
|
||||
SYNTAX CiscoMemoryPoolUtilizationEntry
|
||||
MAX-ACCESS not-accessible
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"An entry in the memory pool utilization table."
|
||||
AUGMENTS { ciscoMemoryPoolEntry }
|
||||
::= { ciscoMemoryPoolUtilizationTable 1 }
|
||||
|
||||
CiscoMemoryPoolUtilizationEntry ::=
|
||||
SEQUENCE {
|
||||
ciscoMemoryPoolUtilization1Min Percent,
|
||||
ciscoMemoryPoolUtilization5Min Percent,
|
||||
ciscoMemoryPoolUtilization10Min Percent
|
||||
}
|
||||
|
||||
ciscoMemoryPoolUtilization1Min OBJECT-TYPE
|
||||
SYNTAX Percent
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"This is the memory pool utilization for 1 minute."
|
||||
::= { ciscoMemoryPoolUtilizationEntry 1 }
|
||||
|
||||
ciscoMemoryPoolUtilization5Min OBJECT-TYPE
|
||||
SYNTAX Percent
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"This is the memory pool utilization for 5 minutes."
|
||||
::= { ciscoMemoryPoolUtilizationEntry 2 }
|
||||
|
||||
ciscoMemoryPoolUtilization10Min OBJECT-TYPE
|
||||
SYNTAX Percent
|
||||
MAX-ACCESS read-only
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"This is the memory pool utilization for 10 minutes."
|
||||
::= { ciscoMemoryPoolUtilizationEntry 3 }
|
||||
|
||||
-- notifications
|
||||
|
||||
ciscoMemoryPoolNotifications
|
||||
OBJECT IDENTIFIER ::= { ciscoMemoryPoolMIB 2 }
|
||||
|
||||
-- (no notifications are currently defined)
|
||||
|
||||
|
||||
-- conformance information
|
||||
|
||||
ciscoMemoryPoolConformance
|
||||
OBJECT IDENTIFIER ::= { ciscoMemoryPoolMIB 3 }
|
||||
ciscoMemoryPoolCompliances
|
||||
OBJECT IDENTIFIER ::= { ciscoMemoryPoolConformance 1 }
|
||||
ciscoMemoryPoolGroups
|
||||
OBJECT IDENTIFIER ::= { ciscoMemoryPoolConformance 2 }
|
||||
|
||||
|
||||
-- compliance statements
|
||||
|
||||
ciscoMemoryPoolCompliance MODULE-COMPLIANCE
|
||||
STATUS deprecated -- superceded by ciscoMemoryPoolComplianceRev1
|
||||
DESCRIPTION
|
||||
"The compliance statement for entities which implement
|
||||
the Cisco Memory Pool MIB"
|
||||
MODULE -- this module
|
||||
MANDATORY-GROUPS { ciscoMemoryPoolGroup }
|
||||
::= { ciscoMemoryPoolCompliances 1 }
|
||||
|
||||
ciscoMemoryPoolComplianceRev1 MODULE-COMPLIANCE
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"The compliance statement for entities which implement
|
||||
the Cisco Memory Pool MIB"
|
||||
MODULE -- this module
|
||||
MANDATORY-GROUPS { ciscoMemoryPoolGroup }
|
||||
|
||||
GROUP ciscoMemoryPoolUtilizationGroup
|
||||
DESCRIPTION
|
||||
"Per memory pool utilization statistics is mandatory for
|
||||
the managed system that supports memory pool utilization."
|
||||
::= { ciscoMemoryPoolCompliances 2 }
|
||||
|
||||
|
||||
-- units of conformance
|
||||
|
||||
ciscoMemoryPoolGroup OBJECT-GROUP
|
||||
OBJECTS {
|
||||
ciscoMemoryPoolName,
|
||||
ciscoMemoryPoolAlternate,
|
||||
ciscoMemoryPoolValid,
|
||||
ciscoMemoryPoolUsed,
|
||||
ciscoMemoryPoolFree,
|
||||
ciscoMemoryPoolLargestFree
|
||||
}
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"A collection of objects providing memory pool monitoring."
|
||||
::= { ciscoMemoryPoolGroups 1 }
|
||||
|
||||
ciscoMemoryPoolUtilizationGroup OBJECT-GROUP
|
||||
OBJECTS {
|
||||
ciscoMemoryPoolUtilization1Min,
|
||||
ciscoMemoryPoolUtilization5Min,
|
||||
ciscoMemoryPoolUtilization10Min
|
||||
}
|
||||
STATUS current
|
||||
DESCRIPTION
|
||||
"An optional group providing a collection of memory pool
|
||||
utilization objects."
|
||||
::= { ciscoMemoryPoolGroups 2 }
|
||||
|
||||
|
||||
END
|
2022
mibs/CISCO-QOS-PIB-MIB.my
Normal file
2022
mibs/CISCO-QOS-PIB-MIB.my
Normal file
File diff suppressed because it is too large
Load Diff
@@ -246,6 +246,8 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$insert_uptime_attrib = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'uptime', '$uptime')");
|
||||
}
|
||||
|
||||
mysql_query("UPDATE `devices` SET `last_polled` = NOW() WHERE `device_id` = '". $device['device_id'] ."'");
|
||||
|
||||
} ## End if snmpable
|
||||
|
||||
|
||||
|
@@ -39,7 +39,7 @@ if ($argv[2] == "--type" && $argv[3]) {
|
||||
|
||||
$devices_polled = 0;
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id DESC");
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id ASC");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
echo("\n" . $device['hostname'] ."\n");
|
||||
|
@@ -32,7 +32,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
|
||||
if($device['os'] == "IOS") {
|
||||
|
||||
$snmp_cmdb = $config['snmpget'] . " -m +CISCO-VLAN-MEMBERSHIP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_cmdb = $config['snmpget'] . " -m +CISCO-VLAN-MEMBERSHIP-MIB:CISCO-VTP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.68.1.2.2.1.2." . $interface['ifIndex'];
|
||||
$snmp_cmdb .= " .1.3.6.1.4.1.9.9.46.1.6.1.1.16." . $interface['ifIndex'];
|
||||
@@ -43,7 +43,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
$snmp_outputb = str_replace("\"", "", $snmp_outputb);
|
||||
|
||||
list($this['ifHardType'], $this['ifVlan'], $this['ifTrunk']) = explode("\n", $snmp_outputb);
|
||||
if($this['ifTrunk'] == "notApplicable") { unset($this['ifTrunk']); }
|
||||
if($this['ifTrunk'] == "notApplicable" || $this['ifTrunk'] == "6") { unset($this['ifTrunk']); }
|
||||
if($this['ifVlan'] == "") { unset($this['ifVlan']); }
|
||||
|
||||
if ( $interface['ifTrunk'] != $this['ifTrunk'] ) {
|
||||
|
Reference in New Issue
Block a user