potentially break all cisco versioning :P

git-svn-id: http://www.observium.org/svn/observer/trunk@2912 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-03-20 16:50:16 +00:00
parent 8b2901cfea
commit bd243db6dc
14 changed files with 105 additions and 55 deletions

View File

@@ -41,7 +41,15 @@ $config['sfdp'] = "/usr/bin/sfdp";
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"])) if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"]))
{ {
if (strpos($_SERVER["SERVER_NAME"] , ":"))
{
# Litteral IPv6
$config['base_url'] = "http://[" . $_SERVER["SERVER_NAME"] ."]:".$_SERVER["SERVER_PORT"]."/";
}
else
{
$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"]."/"; $config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"]."/";
}
} }
$config['title_image'] = "images/observium-logo.png"; $config['title_image'] = "images/observium-logo.png";
@@ -194,6 +202,7 @@ $config['nfsen_enable'] = 0;
#$config['nfsen_suffix'] = "_yourdomain_com"; #$config['nfsen_suffix'] = "_yourdomain_com";
### Ignores & Allows ### Ignores & Allows
# Has to be lowercase
$config['bad_if'][] = "voip-null"; $config['bad_if'][] = "voip-null";
$config['bad_if'][] = "virtual-"; $config['bad_if'][] = "virtual-";

View File

@@ -1,6 +1,6 @@
<?php <?php
if (!$os) if (empty($os))
{ {
if (strstr($sysDescr, "Cisco Internetwork Operating System Software")) { $os = "ios"; } if (strstr($sysDescr, "Cisco Internetwork Operating System Software")) { $os = "ios"; }
else if (strstr($sysDescr, "IOS (tm)")) { $os = "ios"; } else if (strstr($sysDescr, "IOS (tm)")) { $os = "ios"; }
@@ -10,4 +10,8 @@ if (!$os)
if (strstr($sysDescr, "IOS XR")) { $os = "iosxr"; } if (strstr($sysDescr, "IOS XR")) { $os = "iosxr"; }
} }
?> # Fallback case
# If we don't have an OS yet and if the object is in Cisco tree it's most likely an IOS device
#if (empty($os) and substr($sysObjectId, 0, 17) == ".1.3.6.1.4.1.9.1.") { $os = "ios"; }
?>

View File

@@ -321,30 +321,6 @@ function is_odd($number)
return $number & 1; // 0 = even, 1 = odd return $number & 1; // 0 = even, 1 = odd
} }
function isValidInterface($if)
{
global $config;
$if = strtolower($if);
$nullintf = 0;
foreach ($config['bad_if'] as $bi)
{
$pos = strpos($if, $bi);
if ($pos !== FALSE)
{
$nullintf = 1;
echo("$if matched $bi \n");
}
}
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = '1'; }
if ($nullintf != '1')
{
return 1;
} else {
return 0;
}
}
function utime() function utime()
{ {
$time = explode(" ", microtime()); $time = explode(" ", microtime());

View File

@@ -3,7 +3,7 @@
echo("Cisco CEF Switching Path: "); echo("Cisco CEF Switching Path: ");
$cefs = array(); $cefs = array();
$cefs = snmpwalk_cache_threepart_oid($device, "CISCO-CEF-MIB::cefSwitchingStatsEntry", $cefs); $cefs = snmpwalk_cache_threepart_oid($device, "CISCO-CEF-MIB::cefSwitchingStatsEntry", $cefs, "CISCO-CEF-MIB");
$polled = time(); $polled = time();
$cefs_query = dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ?", array($device['device_id'])); $cefs_query = dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ?", array($device['device_id']));

View File

@@ -23,7 +23,7 @@ if ($device['os'] != "Snom")
$snmpstring .= " IP-MIB::".$oid.".0"; $snmpstring .= " IP-MIB::".$oid.".0";
} }
$data = snmp_get_multi($device, $snmpstring); $data = snmp_get_multi($device, $snmpstring, NULL, "IP-MIB");
$rrdupdate = "N"; $rrdupdate = "N";

View File

@@ -27,7 +27,7 @@ if ($device['os'] != "Snom")
$snmpstring .= " tcpHCInSegs.0"; $snmpstring .= " tcpHCInSegs.0";
$snmpstring .= " tcpHCOutSegs.0"; $snmpstring .= " tcpHCOutSegs.0";
$data = snmp_get_multi($device, $snmpstring); $data = snmp_get_multi($device, $snmpstring, NULL, "TCP-MIB");
$rrdupdate = "N"; $rrdupdate = "N";

View File

@@ -22,7 +22,7 @@ if ($device['os'] != "Snom")
$snmpstring .= " UDP-MIB::".$oid.".0"; $snmpstring .= " UDP-MIB::".$oid.".0";
} }
$data = snmp_get_multi($device, $snmpstring); $data = snmp_get_multi($device, $snmpstring, NULL, "UDP-MIB");
$rrdupdate = "N"; $rrdupdate = "N";

View File

@@ -2,6 +2,7 @@
if (is_file($config['install_dir'] . "/includes/polling/os/".$device['os'].".inc.php")) if (is_file($config['install_dir'] . "/includes/polling/os/".$device['os'].".inc.php"))
{ {
echo "os = /includes/polling/os/".$device['os'].".inc.php\n";
/// OS Specific /// OS Specific
include($config['install_dir'] . "/includes/polling/os/".$device['os'].".inc.php"); include($config['install_dir'] . "/includes/polling/os/".$device['os'].".inc.php");
} }

View File

@@ -0,0 +1,50 @@
<?php
if (preg_match('/^Cisco IOS Software, .+? Software \([^\-]+-([\w\d]+)-\w\), Version ([^,]+)/', $poll_device['sysDescr'], $regexp_result))
{
$features = $regexp_result[1];
$version = $regexp_result[2];
}
elseif( false )
{
# Placeholder
# Other regexp for other type of string
}
echo("\n".$poll_device['sysDescr']."\n");
$oids = "entPhysicalModelName.1 entPhysicalContainedIn.1 entPhysicalName.1 entPhysicalSoftwareRev.1 entPhysicalModelName.1001 entPhysicalContainedIn.1001 cardDescr.1 cardSlotNumber.1";
$data = snmp_get_multi($device, $oids, "-OQUs", "ENTITY-MIB:OLD-CISCO-CHASSIS-MIB");
if ($data[1]['entPhysicalContainedIn'] == "0")
{
if (!empty($data[1]['entPhysicalSoftwareRev']))
{
$version = $data[1]['entPhysicalSoftwareRev'];
}
if (!empty($data[1]['entPhysicalName']))
{
$hardware = $data[1]['entPhysicalName'];
}
if (!empty($data[1]['entPhysicalModelName']))
{
$hardware = $data[1]['entPhysicalModelName'];
}
}
# if ($slot_1 == "-1" && strpos($descr_1, "No") === FALSE) { $ciscomodel = $descr_1; }
# if (($contained_1 == "0" || $name_1 == "Chassis") && strpos($model_1, "No") === FALSE) { $ciscomodel = $model_1; list($version_1) = explode(",",$ver_1); }
# if ($contained_1001 == "0" && strpos($model_1001, "No") === FALSE) { $ciscomodel = $model_1001; }
# $ciscomodel = str_replace("\"","",$ciscomodel);
# if ($ciscomodel) { $hardware = $ciscomodel; unset($ciscomodel); }
if(empty($hardware)) { $hardware = snmp_get($device, "sysObjectID.0", "-Osqv", "SNMPv2-MIB:CISCO-PRODUCTS-MIB"); }
#if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; }
?>

View File

@@ -1,15 +1,18 @@
<?php <?php
$poll_device['sysDescr'] = str_replace("IOS (tm)", "IOS (tm),", $poll_device['sysDescr']); # 7200 and IOS-XE (ASR1k)
$poll_device['sysDescr'] = str_replace(") RELEASE", "), RELEASE", $poll_device['sysDescr']); if (preg_match('/^Cisco IOS Software, .+? Software \([^\-]+-([^\-]+)-\w\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result))
{
$features = $regexp_result[1];
$version = $regexp_result[2];
}
echo("\n".$poll_device['sysDescr']."\n"); # 7600
elseif (preg_match('/Cisco Internetwork Operating System Software\s+IOS \(tm\) [^ ]+ Software \([^\-]+-([^\-]+)-\w\),.+?Version ([^, ]+)/', $poll_device['sysDescr'], $regexp_result))
list(,$features,$version) = explode(",", $poll_device['sysDescr']); {
$features = $regexp_result[1];
$version = str_replace(" Version ", "", $version); $version = $regexp_result[2];
list(,$features) = explode("(", $features); }
list(,$features) = explode("-", $features);
$oids = "entPhysicalModelName.1 entPhysicalContainedIn.1 entPhysicalName.1 entPhysicalSoftwareRev.1 entPhysicalModelName.1001 entPhysicalContainedIn.1001 cardDescr.1 cardSlotNumber.1"; $oids = "entPhysicalModelName.1 entPhysicalContainedIn.1 entPhysicalName.1 entPhysicalSoftwareRev.1 entPhysicalModelName.1001 entPhysicalContainedIn.1001 cardDescr.1 cardSlotNumber.1";
@@ -17,21 +20,20 @@ $data = snmp_get_multi($device, $oids, "-OQUs", "ENTITY-MIB:OLD-CISCO-CHASSIS-MI
if ($data[1]['entPhysicalContainedIn'] == "0") if ($data[1]['entPhysicalContainedIn'] == "0")
{ {
if (isset($data[1]['entPhysicalSoftwareRev']) && $data[1]['entPhysicalSoftwareRev'] != "") if (!empty($data[1]['entPhysicalSoftwareRev']))
{ {
$version = $data[1]['entPhysicalSoftwareRev']; $version = $data[1]['entPhysicalSoftwareRev'];
} }
if (isset($data[1]['entPhysicalName']) && $data[1]['entPhysicalName'] != "") if (!empty($data[1]['entPhysicalName']))
{ {
$hardware = $data[1]['entPhysicalName']; $hardware = $data[1]['entPhysicalName'];
} }
if (isset($data[1]['entPhysicalModelName']) && $data[1]['entPhysicalModelName'] != "") if (!empty($data[1]['entPhysicalModelName']))
{ {
$hardware = $data[1]['entPhysicalModelName']; $hardware = $data[1]['entPhysicalModelName'];
} }
} }
list($version) = explode(",", $version);
# if ($slot_1 == "-1" && strpos($descr_1, "No") === FALSE) { $ciscomodel = $descr_1; } # if ($slot_1 == "-1" && strpos($descr_1, "No") === FALSE) { $ciscomodel = $descr_1; }
# if (($contained_1 == "0" || $name_1 == "Chassis") && strpos($model_1, "No") === FALSE) { $ciscomodel = $model_1; list($version_1) = explode(",",$ver_1); } # if (($contained_1 == "0" || $name_1 == "Chassis") && strpos($model_1, "No") === FALSE) { $ciscomodel = $model_1; list($version_1) = explode(",",$ver_1); }
@@ -39,16 +41,8 @@ list($version) = explode(",", $version);
# $ciscomodel = str_replace("\"","",$ciscomodel); # $ciscomodel = str_replace("\"","",$ciscomodel);
# if ($ciscomodel) { $hardware = $ciscomodel; unset($ciscomodel); } # if ($ciscomodel) { $hardware = $ciscomodel; unset($ciscomodel); }
if($hardware == "") { $hardware = snmp_get($device, "sysObjectID.0", "-Osqv", "SNMPv2-MIB:CISCO-PRODUCTS-MIB"); } if(empty($hardware)) { $hardware = snmp_get($device, "sysObjectID.0", "-Osqv", "SNMPv2-MIB:CISCO-PRODUCTS-MIB"); }
#if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; } #if(isset($cisco_hardware_oids[$poll_device['sysObjectID']])) { $hardware = $cisco_hardware_oids[$poll_device['sysObjectID']]; }
if (strpos($poll_device['sysDescr'], "IOS XR")) {
list(,$version) = explode(",", $poll_device['sysDescr']);
$version = trim($version);
list(,$version) = explode(" ", $version);
list($version) = explode("\n", $version);
trim($version);
}
?> ?>

View File

@@ -0,0 +1,16 @@
<?php
if (preg_match('/^Cisco IOS XR Software \(Cisco ([^\)]+)\),\s+Version ([^\[]+)\[([^\]]+)\]/', $poll_device['sysDescr'], $regexp_result))
{
$hardware = $regexp_result[1];
$features = $regexp_result[3];
$version = $regexp_result[2];
}
else
{
# It is not an IOS-XR ... What should we do ?
}
echo("\n".$poll_device['sysDescr']."\n");
?>

View File

@@ -9,7 +9,7 @@ foreach (dbFetchRows("SELECT * FROM processors WHERE device_id = ?", array($devi
{ {
include($file); include($file);
} else { } else {
$proc = snmp_get ($device, $processor['processor_oid'], "-O Uqnv"); $proc = snmp_get ($device, $processor['processor_oid'], "-O Uqnv", "\"\"");
} }
$procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd"); $procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd");

View File

@@ -32,7 +32,7 @@ $mem_rrd = $host_rrd . "/ucd_mem.rrd";
#UCD-SNMP-MIB::ssRawSwapIn.0 = Counter32: 602002 #UCD-SNMP-MIB::ssRawSwapIn.0 = Counter32: 602002
#UCD-SNMP-MIB::ssRawSwapOut.0 = Counter32: 937422 #UCD-SNMP-MIB::ssRawSwapOut.0 = Counter32: 937422
$ss = snmpwalk_cache_oid($device, "systemStats", array()); $ss = snmpwalk_cache_oid($device, "systemStats", array(), "UCD-SNMP-MIB");
$ss = $ss[0]; ### Insert Nazi joke here. $ss = $ss[0]; ### Insert Nazi joke here.
## Create CPU RRD if it doesn't already exist ## Create CPU RRD if it doesn't already exist

View File

@@ -50,7 +50,7 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall')
{ {
echo("Checking Symbol Wireless clients... "); echo("Checking Symbol Wireless clients... ");
$wificlients1 = snmp_get($device, ".1.3.6.1.4.1.388.11.2.4.2.100.10.1.18.1", "-Ovq"); $wificlients1 = snmp_get($device, ".1.3.6.1.4.1.388.11.2.4.2.100.10.1.18.1", "-Ovq", "\"\"");
echo(($wificlients1 +0) . " clients on wireless connector, "); echo(($wificlients1 +0) . " clients on wireless connector, ");
} }