bit of restructuring and tiding. all hail bunny.

git-svn-id: http://www.observium.org/svn/observer/trunk@977 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-02-28 22:04:15 +00:00
parent a15e74725b
commit 1e7860e930
18 changed files with 108 additions and 56 deletions

View File

@@ -93,7 +93,7 @@ $config['enable_billing'] = 0; # Enable Billing
$config['enable_inventory'] = 1; # Enable Inventory
$config['enable_etherlike'] = 1; # Enable Etherlike
$config['enable_pseudowires'] = 1; # Enable Pseudowires
$config['enable_ports_junoseatmvc'] = 0; # Enable JunOSe ATM VC Discovery/Poller
$config['enable_ports_etherlike'] = 0; # Enable Polling EtherLike-MIB (doubles interface processing time)
#$config['rancid_configs'] = '/var/lib/rancid/network/configs/';

View File

@@ -4,7 +4,6 @@
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
include("includes/functions-poller.inc.php");
include("includes/discovery/functions.inc.php");
$start = utime();
@@ -56,7 +55,7 @@ if (file_exists('.svn'))
if ($dbu_rev+0 > $db_rev)
{
echo("Applying database updates to from r$db_rev to r" . trim($dbu_rev) . "...\n");
echo("SVN revision changed.\nRunning development SQL update script from r$db_rev to r" . trim($dbu_rev) . "...\n");
shell_exec("scripts/update-sql.php database-update.sql");
if ($db_rev == 0)
{
@@ -86,48 +85,31 @@ while ($device = mysql_fetch_array($device_query))
echo("\n");
## Discover OS Changes
#include("includes/discovery/os.inc.php");
## Discover Interfaces
include("includes/discovery/ports.inc.php");
## Discovery ENTITY-MIB
#include("includes/discovery/entity-physical.inc.php");
include("includes/discovery/entity-physical.inc.php");
include("includes/discovery/processors.inc.php");
include("includes/discovery/mempools.inc.php");
## Discover IPv4 Addresses
include("includes/discovery/ipv4-addresses.inc.php");
## Discovery IPv6 Addresses
include("includes/discovery/ipv6-addresses.inc.php");
## Discover Temperatures/Voltages/Fanspeeds
include("includes/discovery/temperatures.inc.php");
include("includes/discovery/voltages.inc.php");
include("includes/discovery/fanspeeds.inc.php");
## Discover Storage
include("includes/discovery/storage.inc.php");
## hr-device.inc.php
include("includes/discovery/hr-device.inc.php");
## Discovery Protocols (FDP, CDP & LLDP)
include("includes/discovery/discovery-protocols.inc.php");
## ARP Table
include("includes/discovery/arp-table.inc.php");
## BGP Peers (Quagga, Cisco, Juniper, Foundry)
include("includes/discovery/junose-atm-vc.inc.php");
include("includes/discovery/bgp-peers.inc.php");
include("includes/discovery/q-bridge-mib.inc.php");
include("includes/discovery/cisco-vlans.inc.php");
include("includes/discovery/cisco-mac-accounting.inc.php");
include("includes/discovery/cisco-pw.inc.php");
include("includes/discovery/cisco-vrf.inc.php");
if($device['os'] == "ironware") {
if ($device['type'] == "unknown") { $device['type'] = 'network'; }
}
if($device['os'] == "screenos") {
if ($device['type'] == "unknown") { $device['type'] = 'firewall'; }
@@ -137,29 +119,16 @@ while ($device = mysql_fetch_array($device_query))
if ($device['type'] == "unknown") { $device['type'] = 'network'; } # FIXME: could also be a Netscreen...
}
if($device['os'] == "junose") {
include("includes/discovery/processors-junose.inc.php");
}
if($device['os'] == "linux") {
if (($device['type'] == "unknown") && preg_match("/-server$/", $device['version'])) { $device['type'] = 'server'; }
}
if($device['os'] == "ios" || $device['os'] == "iosxe" || $device['os'] == "catos" || $device['os'] == "asa" || $device['os'] == "pix") {
include("includes/discovery/cisco-vlans.inc.php");
include("includes/discovery/cisco-mac-accounting.inc.php");
include("includes/discovery/cisco-pw.inc.php");
include("includes/discovery/cisco-vrf.inc.php");
#include("includes/discovery/cisco-processors.php");
include("includes/discovery/cemp-mib.inc.php");
include("includes/discovery/cmp-mib.inc.php");
if ($device['type'] == "unknown") { $device['type'] = 'network'; };
}
if ($device['os'] == "procurve" || $device['os'] == "powerconnect")
{
include("includes/discovery/q-bridge-mib.inc.php");
if ($device['type'] == "unknown") { $device['type'] = 'network'; };
}
@@ -173,6 +142,11 @@ while ($device = mysql_fetch_array($device_query))
if ($device['type'] == "unknown") { $device['type'] = 'printer'; }
}
if($device['os'] == "ironware")
{
if ($device['type'] == "unknown") { $device['type'] = 'network'; }
}
$update_query = "UPDATE `devices` SET ";
$update_query .= " `last_discovered` = NOW(), `type` = '" . $device['type'] . "'";
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";

View File

@@ -101,8 +101,10 @@ $config['ignore_mount_network'] = 1; # Ignore network mounted storage
$config['ignore_junos_os_drives'] = array("/on: \/packages/", "/on: \/dev/", "/on: \/proc/", "/on: \/junos^/", "/on: \/junos\/dev/", "/on: \/jail\/dev/", "/^(dev|proc)fs/", "/^\/dev\/md0/"); # Ignore JunOS partitions who are always 100%
$config['ignore_bsd_os_drives'] = array("/^\/dev,/", "/^\/var\/dhcpd\/dev,/", "/UMA/"); # Ignore BSD partitions who are always 100%
# Ports
# Poller/Discovery
$config['enable_ports_etherlike'] = 0; # Enable EtherLike-MIB
$config['enable_ports_junoseatmvc'] = 0; # Enable JunOSe ATM VC Discovery/Poller
?>

View File

@@ -63,7 +63,6 @@
}
echo("\n");
unset($mac);
?>

View File

@@ -141,4 +141,3 @@ unset($peerlist);
echo("\n");
?>

View File

@@ -1,6 +1,9 @@
<?php
echo("MAC Accounting : ");
if($device['os_group'] == "ios") {
echo("Cisco MAC Accounting : ");
$datas = shell_exec($config['snmpbulkwalk'] . " -m CISCO-IP-STAT-MIB -Oqn -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." cipMacSwitchedBytes");
#echo("$datas\n");
@@ -42,5 +45,9 @@
}
echo("\n");
}
// FIXME - NEEDS TO REMOVE STALE ENTRIES?? :O
?>

View File

@@ -1,11 +1,11 @@
<?php
if($config['enable_pseudowires']) {
if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
unset( $cpw_count );
unset($cpw_exists);
echo("PW : ");
echo("Cisco Pseudowires : ");
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-IETF-PW-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpwVcID");

View File

@@ -1,5 +1,7 @@
<?php
if($device['os_group'] == "ios") {
echo("Cisco VLANs : ");
$vtpversion_cmd = $config['snmpget'] . " -m CISCO-VTP-MIB -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " ";
@@ -56,3 +58,5 @@
unset($this_vlans);
echo("\n");
}

View File

@@ -1,8 +1,11 @@
<?php
#if($device['os_group'] == "ios")
#{
unset( $vrf_count );
echo("VRF : ");
echo("VRFs : ");
$oid_cmd = $config['snmpwalk'] . " -m MPLS-VPN-MIB -CI -Ln -Osqn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " mplsVpnVrfRouteDistinguisher";
$oids = shell_exec($oid_cmd);
@@ -78,4 +81,6 @@
echo("\n");
#}
?>

View File

@@ -1,9 +1,24 @@
<?php
function discover_juniAtmVp(&$exists, $interface_id, $vp_id, $vp_descr) {
global $config; global $debug;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `juniAtmVp` WHERE `interface_id` = '".$interface_id."' AND `vp_id` = '".$vp_id."'"),0) == "0")
{
echo(".");
} else {
$sql = "INSERT INTO `juniAtmVP` (`interface_id`,`vp_id`,`vp_descr`) VALUES ('".$interface_id."','".$vp_id."','".$vp_descr."')";
mysql_query($sql); echo("+"); if($debug) { echo($sql . " - " . mysql_affected_rows() . "inserted "); }
}
$exists[$interface_id][$vp_id] = 1;
}
function discover_link($local_interface_id, $protocol, $remote_interface_id, $remote_hostname, $remote_port, $remote_platform, $remote_version) {
global $config; global $debug; global $link_exists;
if (mysql_result(@mysql_query("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = '$remote_hostname' AND `local_interface_id` = '$local_interface_id'
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `links` WHERE `remote_hostname` = '$remote_hostname' AND `local_interface_id` = '$local_interface_id'
AND `protocol` = '$protocol' AND `remote_port` = '$remote_port'"),0) == "0")
{
$sql = "INSERT INTO `links` (`local_interface_id`,`protocol`,`remote_interface_id`,`remote_hostname`,`remote_port`,`remote_platform`,`remote_version`)

View File

@@ -0,0 +1,50 @@
<?php
### We're discovering this MIB
# snmpwalk -v2c -c <community> <hostname> -M mibs/junose/ -m Juniper-UNI-ATM-MIB juniAtmVpStatsEntry
## JunOSe ATM VCs
if($device['os'] == "junose" && $config['enable_ports_junoseatmvc'])
{
echo("JunOSe ATM VCs : ");
$vc_array = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vc_array, "Juniper-UNI-ATM-MIB" , "+".$config['install_dir']."/mibs/junose");
$valid_vc = array();
if($debug) { print_r($vc_array); }
if(is_array($vc_array[$device['device_id']])) {
foreach($vc_array[$device['device_id']] as $index => $entry) {
list($interface_id,$vp_id)= explode('.', $index);
if(is_numeric($interface_id) && is_numeric($vp_id)) {
discover_juniAtmVp($valid_vc, $interface_id, $vp_id, NULL);
}
} ## End Foreach
} ## End if array
} ## End JUNOS vc
unset ($vc_array);
### Remove ATM VCs 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_vc); }
while ($test = mysql_fetch_array($query)) {
$interface_id = $test['interface_id'];
$vc_id = $test['vc_id'];
if($debug) { echo($interface_id . " -> " . $vc_id . "\n"); }
if(!$valid_vc[$interface_id][$vc_id]) {
echo("-");
mysql_query("DELETE FROM `juniAtmVp` WHERE `juniAtmVp` = '" . $test['juniAtmVp'] . "'");
}
unset($interface_id); unset($vc_id);
}
unset($valid_vc);
echo("\n");
?>

View File

@@ -17,6 +17,7 @@ include_once($config['install_dir'] . "/includes/billing.php");
include_once($config['install_dir'] . "/includes/cisco-entities.php");
include_once($config['install_dir'] . "/includes/syslog.php");
include_once($config['install_dir'] . "/includes/rewrites.php");
include_once($config['install_dir'] . "/includes/snmp.inc.php");
## CollectD

View File

@@ -56,8 +56,8 @@ $os_text['solaris'] = "Sun Solaris";
$os_text['opensolaris'] = "OpenSolaris";
$os_text['powerconnect'] = "Dell PowerConnect";
$os_text['windows'] = "Microsoft Windows";
$os_text['junos'] = "Juniper JUNOS";
$os_text['junose'] = "Juniper JUNOSe";
$os_text['junos'] = "Juniper JunOS";
$os_text['junose'] = "Juniper JunOSe";
$os_text['procurve'] = "HP ProCurve";
$os_text['speedtouch'] = "Thomson Speedtouch";
$os_text['dell-laser'] = "Dell Laser Printer";

View File

@@ -4,7 +4,6 @@
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
include("includes/functions-poller.inc.php");
$poller_start = utime();
echo("Observer Poller v".$config['version']."\n\n");

View File

@@ -7,7 +7,6 @@ include("config.php");
echo("Observer Poller v".$config['version']."\n\n");
include("includes/functions.php");
include("includes/functions-poller.inc.php");
$poller_start = utime();

View File

@@ -5,7 +5,6 @@
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
include("includes/functions-poller.inc.php");
include("includes/discovery/functions.inc.php");
$start = utime();

View File

@@ -4,7 +4,6 @@
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
include("includes/functions-poller.inc.php");
$poller_start = utime();