add ability to chose only one module in discovery.php. give module name for cemp mempools. use sensor name for cisco-entity-sensors.

git-svn-id: http://www.observium.org/svn/observer/trunk@2015 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-04-04 09:52:09 +00:00
parent 136ba2d1ff
commit 317333f47d
3 changed files with 48 additions and 33 deletions
+36 -25
View File
@@ -24,7 +24,7 @@ $runtime_stats = array();
echo("Observium v".$config['version']." Discovery\n\n"); echo("Observium v".$config['version']." Discovery\n\n");
$options = getopt("h:t:i:n:d::a::"); $options = getopt("h:m:i:n:d::a::");
if (isset($options['h'])) if (isset($options['h']))
{ {
@@ -79,9 +79,12 @@ if (!$where)
echo("-h new Poll all devices that have not had a discovery run before\n\n"); echo("-h new Poll all devices that have not had a discovery run before\n\n");
echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n"); echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n");
echo(" Instances start at 0. 0-3 for -n 4\n\n"); echo(" Instances start at 0. 0-3 for -n 4\n\n");
echo("-d Enable debugging output\n");
echo("\n"); echo("\n");
echo("No polling type specified!\n"); echo("Debugging and testing options:\n");
echo("-d Enable debugging output\n");
echo("-m Specify single module to be run\n");
echo("\n");
echo("Invalid arguments!\n");
exit; exit;
} }
@@ -164,29 +167,37 @@ while ($device = mysql_fetch_array($device_query))
#include("includes/discovery/os.inc.php"); #include("includes/discovery/os.inc.php");
include("includes/discovery/ports.inc.php"); if($options['m'])
include("includes/discovery/entity-physical.inc.php"); {
include("includes/discovery/processors.inc.php"); if(is_file("includes/discovery/".$options['m'].".inc.php"))
include("includes/discovery/mempools.inc.php"); {
include("includes/discovery/ipv4-addresses.inc.php"); include("includes/discovery/".$options['m'].".inc.php");
include("includes/discovery/ipv6-addresses.inc.php"); }
include("includes/discovery/sensors.inc.php");
include("includes/discovery/storage.inc.php");
include("includes/discovery/hr-device.inc.php");
include("includes/discovery/discovery-protocols.inc.php");
include("includes/discovery/arp-table.inc.php");
include("includes/discovery/junose-atm-vp.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");
include("includes/discovery/vmware-vminfo.inc.php");
include("includes/discovery/toner.inc.php");
include("includes/discovery/ucd-diskio.inc.php");
include("includes/discovery/services.inc.php");
} else {
include("includes/discovery/ports.inc.php");
include("includes/discovery/entity-physical.inc.php");
include("includes/discovery/processors.inc.php");
include("includes/discovery/mempools.inc.php");
include("includes/discovery/ipv4-addresses.inc.php");
include("includes/discovery/ipv6-addresses.inc.php");
include("includes/discovery/sensors.inc.php");
include("includes/discovery/storage.inc.php");
include("includes/discovery/hr-device.inc.php");
include("includes/discovery/discovery-protocols.inc.php");
include("includes/discovery/arp-table.inc.php");
include("includes/discovery/junose-atm-vp.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");
include("includes/discovery/vmware-vminfo.inc.php");
include("includes/discovery/toner.inc.php");
include("includes/discovery/ucd-diskio.inc.php");
include("includes/discovery/services.inc.php");
}
if ($device['type'] == "unknown" || $device['type'] == "") if ($device['type'] == "unknown" || $device['type'] == "")
{ {
if ($config['os'][$device['os']]['type']) if ($config['os'][$device['os']]['type'])
@@ -60,10 +60,10 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
if ($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index)) if ($entitysensor[$entry['entSensorType']] && is_numeric($entry['entSensorValue']) && is_numeric($index))
{ {
$entPhysicalIndex = $index; $entPhysicalIndex = $index;
$descr = $entity_array[$index]['entPhysicalName']; if ($entity_array[$index]['entPhysicalName'] || $device['os'] == "iosxr")
if ($descr || $device['os'] == "iosxr")
{ {
$descr = rewrite_entity_descr($descr); $descr = rewrite_entity_descr($entity_array[$index]['entPhysicalName']) . " - " . rewrite_entity_descr($entity_array[$index]['entPhysicalDescr']);
} else { } else {
$descr = $entity_array[$index]['entPhysicalDescr']; $descr = $entity_array[$index]['entPhysicalDescr'];
$descr = rewrite_entity_descr($descr); $descr = rewrite_entity_descr($descr);
@@ -73,10 +73,13 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity'])
{ {
$measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName']; $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName'];
if (!measured_descr) if (!$measured_descr)
{ {
$measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr']; $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr'];
} }
echo("descr: $descr | measured: $measured_descr\n");
$descr = $measured_descr . " - " . $descr; $descr = $measured_descr . " - " . $descr;
} }
@@ -152,4 +155,4 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
} }
} }
?> ?>
+4 -3
View File
@@ -15,8 +15,9 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
if (is_numeric($entry['cempMemPoolUsed']) && $entry['cempMemPoolValid'] == "true") if (is_numeric($entry['cempMemPoolUsed']) && $entry['cempMemPoolValid'] == "true")
{ {
list($entPhysicalIndex) = explode(".", $index); list($entPhysicalIndex) = explode(".", $index);
$entPhysicalName = snmp_get($device, "entPhysicalDescr.".$entPhysicalIndex, "-Oqv", "ENTITY-MIB"); $entPhysicalName = snmp_get($device, "entPhysicalName.".$entPhysicalIndex, "-Oqv", "ENTITY-MIB");
$descr = $entPhysicalDescr." - ".$entry['cempMemPoolName'];
$descr = $entPhysicalName." - ".$entry['cempMemPoolName'];
$descr = str_replace("Cisco ", "", $descr); $descr = str_replace("Cisco ", "", $descr);
$descr = str_replace("Network Processing Engine", "", $descr); $descr = str_replace("Network Processing Engine", "", $descr);
@@ -27,4 +28,4 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios")
} }
} }
?> ?>