git-svn-id: http://www.observium.org/svn/observer/trunk@426 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-05-06 16:50:51 +00:00
parent e34d66c02d
commit 586de53358
10 changed files with 128 additions and 48 deletions

View File

@@ -67,10 +67,12 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/discovery/cisco-vlans.php"); include("includes/discovery/cisco-vlans.php");
include("includes/discovery/cisco-physical.php"); include("includes/discovery/cisco-physical.php");
include("includes/discovery/bgp-peers.php"); include("includes/discovery/bgp-peers.php");
include("includes/discovery/cisco-mac-accounting.php");
include("includes/discovery/cisco-pw.php"); include("includes/discovery/cisco-pw.php");
include("includes/discovery/cisco-vrf.php"); include("includes/discovery/cisco-vrf.php");
include("includes/discovery/cisco-processors.php"); include("includes/discovery/cisco-processors.php");
include("includes/discovery/cisco-mempool.php"); include("includes/discovery/cisco-mempool.php");
} }
echo("\n"); $devices_discovered++; echo("\n"); $devices_discovered++;

View File

@@ -16,8 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#error_reporting(E_ALL | E_NOTICE | E_WARNING);
if($_GET['debug']) { if($_GET['debug']) {
ini_set('display_errors', 1); ini_set('display_errors', 1);
ini_set('display_startup_errors', 0); ini_set('display_startup_errors', 0);
@@ -26,10 +24,10 @@ if($_GET['debug']) {
ini_set('error_reporting', E_ALL); ini_set('error_reporting', E_ALL);
} }
include("../config.php"); include("../config.php");
include("../includes/functions.php"); include("../includes/functions.php");
include("includes/authenticate.inc"); include("includes/authenticate.inc");
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; } if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
function makeTextBlock($text, $fontfile, $fontsize, $width) { function makeTextBlock($text, $fontfile, $fontsize, $width) {
// TODO: handle explicit line-break! // TODO: handle explicit line-break!

View File

@@ -45,6 +45,9 @@ if($_GET['debug']) {
$os = gethostosbyid($device_id); $os = gethostosbyid($device_id);
switch ($type) { switch ($type) {
case 'cisco_entity_sensor':
$graph = graph_entity_sensor ($_GET['a'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'fortigate_sessions': case 'fortigate_sessions':
$graph = graph_fortigate_sessions ($hostname . "/fortigate-sessions.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); $graph = graph_fortigate_sessions ($hostname . "/fortigate-sessions.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break; break;

View File

@@ -51,6 +51,18 @@ if($health) {
"); ");
} }
$cisco_sensors = mysql_result(mysql_query("SELECT count(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%'"),0);
if($cisco_sensors) {
echo("
<li class=" . $select['ciscosensors'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ciscosensors/'>
<img src='images/16/contrast.png' align=absmiddle border=0> Sensors
</a>
</li>
");
}
if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
echo(" echo("
<li class=" . $select['collectd'] . "> <li class=" . $select['collectd'] . ">
@@ -61,7 +73,6 @@ if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
"); ");
} }
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo(" echo("
<li class=" . $select['ports'] . "> <li class=" . $select['ports'] . ">

View File

@@ -83,8 +83,6 @@ if($_POST['ifSpeed']) { $where .= " AND I.ifSpeed = '".$_POST['ifSpeed']."'"; }
if($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".$_POST['ifAlias']."%'"; } if($_POST['ifAlias']) { $where .= " AND I.ifAlias LIKE '%".$_POST['ifAlias']."%'"; }
if($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; } if($_POST['deleted'] || $_GET['type'] == "deleted") { $where .= " AND I.deleted = '1'"; }
print_r($_GET);
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifIndex"; $sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifIndex";
$query = mysql_query($sql); $query = mysql_query($sql);

View File

@@ -22,12 +22,12 @@
if(!strstr($descr, "No") && !strstr($usage, "No") && $cempMemPoolName != "" ) { if(!strstr($descr, "No") && !strstr($usage, "No") && $cempMemPoolName != "" ) {
$descr = str_replace("\"", "", $descr); $descr = str_replace("\"", "", $descr);
$descr = trim($descr); $descr = trim($descr);
# echo("[$cempMemPoolName ($oid)] "); #echo("[$cempMemPoolName ($oid)] ");
if(mysql_result(mysql_query("SELECT count(cempMemPool_id) FROM `cempMemPool` WHERE `Index` = '$Index' AND `entPhysicalIndex` = '$entPhysicalIndex' AND `device_id` = '$id'"),0) == '0') { if(mysql_result(mysql_query("SELECT count(cempMemPool_id) FROM `cempMemPool` WHERE `Index` = '$Index' AND `entPhysicalIndex` = '$entPhysicalIndex' AND `device_id` = '$id'"),0) == '0') {
$query = "INSERT INTO cempMemPool (`Index`, `entPhysicalIndex`, `cempMemPoolType`, `cempMemPoolName`, `cempMemPoolValid`, `device_id`) $query = "INSERT INTO cempMemPool (`Index`, `entPhysicalIndex`, `cempMemPoolType`, `cempMemPoolName`, `cempMemPoolValid`, `device_id`)
values ('$Index', '$entPhysicalIndex', '$cempMemPoolType', '$cempMemPoolName', '$cempMemPoolValid', '$id')"; values ('$Index', '$entPhysicalIndex', '$cempMemPoolType', '$cempMemPoolName', '$cempMemPoolValid', '$id')";
mysql_query($query); mysql_query($query);
# echo("$query\n"); #echo("$query\n");
echo("+"); echo("+");
} else { echo("."); } } else { echo("."); }
$valid_cpm[$id][$oid] = 1; $valid_cpm[$id][$oid] = 1;
@@ -36,10 +36,10 @@
} }
} ## End Cisco Enhanced Mempool } ## End Cisco Enhanced Mempool
##### ************FIX ME*********** ##### ************FIX ME***********
##### WRITE CODE TO REMOVE OLD RAMS ##### WRITE CODE TO REMOVE OLD RAMS
##### SOMETIMES THEY CAN GET STOLED ##### SOMETIMES THEY CAN GET STOLED
##### ***************************** ##### *****************************
echo("\n"); echo("\n");

View File

@@ -2,14 +2,16 @@
echo("Physical Inventory : "); echo("Physical Inventory : ");
unset($valid);
if($config['enable_inventory']) { if($config['enable_inventory']) {
$ents_cmd = $config['snmpbulkwalk'] . " -m ENTITY-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " "; $ents_cmd = $config['snmpbulkwalk'] . " -m ENTITY-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " ";
$ents_cmd .= "1.3.6.1.2.1.47.1.1.1.1.2 | sed s/.1.3.6.1.2.1.47.1.1.1.1.2.//g | cut -f 1 -d\" \""; $ents_cmd .= "1.3.6.1.2.1.47.1.1.1.1.2 | sed s/.1.3.6.1.2.1.47.1.1.1.1.2.//g | grep -v OID | cut -f 1 -d\" \"";
$ents = trim(`$ents_cmd | grep -v o`); $ents = trim(`$ents_cmd | grep -v o`);
foreach(explode("\n", $ents) as $entPhysicalIndex) { foreach(explode("\n", $ents) as $entPhysicalIndex) {
$ent_data = $config['snmpget'] . " -m ENTITY-MIB -Ovqs -"; $ent_data = $config['snmpget'] . " -m ENTITY-MIB -Ovqs -";
$ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port']; $ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port'];
@@ -24,7 +26,6 @@
$ent_data .= " entPhysicalParentRelPos." . $entPhysicalIndex; $ent_data .= " entPhysicalParentRelPos." . $entPhysicalIndex;
$ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0"; $ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0";
list($entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalClass,$entPhysicalName,$entPhysicalSerialNum,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos, $ifIndex) = explode("\n", `$ent_data`); list($entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalClass,$entPhysicalName,$entPhysicalSerialNum,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos, $ifIndex) = explode("\n", `$ent_data`);
if(strpos($ifIndex, "o") || $ifIndex == "") { unset($ifIndex); } if(strpos($ifIndex, "o") || $ifIndex == "") { unset($ifIndex); }
@@ -38,15 +39,11 @@
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType]; $entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
} }
#echo("$entPhysicalIndex,$entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalSerialNum,");
#echo("$entPhysicalClass,$entPhysicalName,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos\n");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0)) { if(mysql_result(mysql_query("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0)) {
### TO DO : WRITE CODE FOR UPDATES! ### TO DO : WRITE CODE FOR UPDATES!
echo("."); echo(".");
} else { } else {
$sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `ifIndex` ) "; $sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `ifIndex` ) ";
@@ -55,10 +52,39 @@
echo("+"); echo("+");
} }
if($entPhysicalClass == "sensor") {
$sensor_cmd = $config['snmpget'] . " -m CISCO-ENTITY-SENSOR-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$sensor_cmd .= " entSensorType.$entPhysicalIndex entSensorScale.$entPhysicalIndex entSensorPrecision.$entPhysicalIndex";
$sensor_cmd .= " entSensorMeasuredEntity.$entPhysicalIndex";
$sensor_data = shell_exec($sensor_cmd);
list($entSensorType,$entSensorScale,$entSensorPrecision,$entSensorValueUpdateRate,$entSensorMeasuredEntity) = explode("\n", $sensor_data);
$sql = "UPDATE `entPhysical` SET entSensorType = '$entSensorType', entSensorScale = '$entSensorScale', entSensorPrecision = '$entSensorPrecision', ";
$sql .= " entSensorMeasuredEntity = '$entSensorMeasuredEntity'";
$sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
mysql_query($sql);
}
$valid[$entPhysicalIndex] = 1;
} }
} else { echo("Disabled!"); } } else { echo("Disabled!"); }
$sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($test = mysql_fetch_array($query)) {
$id = $test['entPhysical_id'];
if(!$valid[$id]) {
echo("-");
# mysql_query("DELETE FROM `entPhysical` WHERE entPhysical_id = '".$test['entPhysical_id']."'");
}
}
unset($valid);
echo("\n"); echo("\n");
?> ?>

View File

@@ -22,6 +22,35 @@ require('collectd/config.php');
require('collectd/functions.php'); require('collectd/functions.php');
require('collectd/definitions.php'); require('collectd/definitions.php');
function entPhysical_scale($value, $scale) {
switch ($scale) {
case "nano":
$value = $value / 1000000000;
break;
case "micro":
$value = $value / 1000000;
break;
case "milli":
$value = $value / 1000;
break;
case "units":
break;
case "kilo":
$value = $value * 1000;
break;
case "mega":
$value = $value * 1000000;
break;
case "giga":
$value = $value * 1000000000;
break;
}
return $value;
}
function mac_clean_to_readable($mac){ function mac_clean_to_readable($mac){

View File

@@ -547,6 +547,37 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
return $imgfile; return $imgfile;
} }
function graph_entity_sensor ($sensor, $graph , $from, $to, $width, $height, $title, $vertical) {
global $config;
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$sensor = mysql_fetch_array(mysql_query("SELECT * FROM entPhysical as E, devices as D WHERE entPhysical_id = '$sensor' and D.device_id = E.device_id"));
$database = $config['rrd_dir'] . "/" . $sensor['hostname'] . "/ces-" . $sensor['entPhysicalIndex'] . ".rrd";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$type = str_pad($sensor['entSensorType'], 8);
$type = substr($type,0,8);
$options .= " DEF:avg=$database:value:AVERAGE";
$options .= " DEF:min=$database:value:MIN";
$options .= " DEF:max=$database:value:MAX";
$options .= " COMMENT:' Last Min Max Ave\\n'";
$options .= " AREA:max#a5a5a5";
$options .= " AREA:min#ffffff";
$options .= " LINE1.25:avg#aa2200:'".$type."'";
$options .= " GPRINT:avg:AVERAGE:%5.2lf%s";
$options .= " GPRINT:max:MAX:%5.2lf%s";
$options .= " GPRINT:max:MAX:%5.2lf%s";
$options .= " GPRINT:avg:LAST:%5.2lf%s";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
#echo($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) { function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) {
global $config; global $config;
$database = $config['rrd_dir'] . "/" . $rrd; $database = $config['rrd_dir'] . "/" . $rrd;

View File

@@ -10,35 +10,16 @@
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd"; $cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.rrd";
$memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd"; $memrrd = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd";
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
$version = str_replace("IOS (tm) ", "", $version);
$version = str_replace(",RELEASE SOFTWARE", "", $version);
$version = str_replace(",MAINTENANCE INTERIM SOFTWARE", "", $version);
$version = str_replace("Version ","", $version);
$version = str_replace("Cisco Internetwork Operating System Software", "", $version);
$version = trim($version);
list($version) = explode("\n", $version);
$version = preg_replace("/^[A-Za-z0-9\ \_]*\(([A-Za-z0-9\-\_]*)\), (.+), .*/", "\\1|\\2", $version);
$version = str_replace("-M|", "|", $version);
$version = str_replace("-", "|", $version);
list($hardware, $features, $version) = explode("|", $version);
#$features = rewrite_ios_features($features);
#$hardware = fixIOSHardware($hardware);
if(strstr($ciscomodel, "OID")){ unset($ciscomodel); } if(strstr($ciscomodel, "OID")){ unset($ciscomodel); }
if(!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') { if(!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') {
$hardware = $ciscomodel; $hardware = $ciscomodel;
} }
if($device['os'] == "IOS XE") { $sysDescr = str_replace("IOS (tm)", "IOS (tm),", $sysDescr);
list(,$features,$version) = explode(",", $sysDescr); list(,$features,$version) = explode(",", $sysDescr);
$version = str_replace(" Version ", "", $version); $version = str_replace(" Version ", "", $version);
$features = str_replace(" IOS-XE Software (", "", $features); list(,$features) = explode("(", $features);
$features = str_replace("-M", "", $features); list(,$features) = explode("-", $features);
$features = str_replace(")", "", $features);
$features = str_replace("PPC_LINUX_IOSD-", "", $features);
#$features = rewrite_ios_features($features);
}
list ($cpu5m, $cpu5s) = explode("\n", shell_exec($config['snmpget'] . " -m OLD-CISCO-CPU-MIB -O qv -$snmpver -c $community $hostname:$port 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0")); list ($cpu5m, $cpu5s) = explode("\n", shell_exec($config['snmpget'] . " -m OLD-CISCO-CPU-MIB -O qv -$snmpver -c $community $hostname:$port 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0"));
$cpu5m = $cpu5m + 0; $cpu5m = $cpu5m + 0;
@@ -65,5 +46,6 @@
include("includes/polling/bgpPeer.inc.php"); include("includes/polling/bgpPeer.inc.php");
include("includes/polling/cisco-processors.inc.php"); include("includes/polling/cisco-processors.inc.php");
include("includes/polling/cisco-mempool.inc.php"); include("includes/polling/cisco-mempool.inc.php");
include("includes/polling/cisco-entity-sensors.inc.php");
?> ?>