diff --git a/discovery.php b/discovery.php
index 0d8e57f93..591862401 100755
--- a/discovery.php
+++ b/discovery.php
@@ -67,10 +67,12 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/discovery/cisco-vlans.php");
include("includes/discovery/cisco-physical.php");
include("includes/discovery/bgp-peers.php");
+ include("includes/discovery/cisco-mac-accounting.php");
include("includes/discovery/cisco-pw.php");
include("includes/discovery/cisco-vrf.php");
include("includes/discovery/cisco-processors.php");
include("includes/discovery/cisco-mempool.php");
+
}
echo("\n"); $devices_discovered++;
diff --git a/html/collectd-graph.php b/html/collectd-graph.php
index f6ac3cbfc..022d3d935 100755
--- a/html/collectd-graph.php
+++ b/html/collectd-graph.php
@@ -16,8 +16,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#error_reporting(E_ALL | E_NOTICE | E_WARNING);
-
if($_GET['debug']) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
@@ -26,10 +24,10 @@ if($_GET['debug']) {
ini_set('error_reporting', E_ALL);
}
- include("../config.php");
- include("../includes/functions.php");
- include("includes/authenticate.inc");
- if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
+include("../config.php");
+include("../includes/functions.php");
+include("includes/authenticate.inc");
+if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
function makeTextBlock($text, $fontfile, $fontsize, $width) {
// TODO: handle explicit line-break!
diff --git a/html/graph.php b/html/graph.php
index 650a19afa..947159e0c 100644
--- a/html/graph.php
+++ b/html/graph.php
@@ -45,6 +45,9 @@ if($_GET['debug']) {
$os = gethostosbyid($device_id);
switch ($type) {
+ case 'cisco_entity_sensor':
+ $graph = graph_entity_sensor ($_GET['a'], $graphfile, $from, $to, $width, $height, $title, $vertical);
+ break;
case 'fortigate_sessions':
$graph = graph_fortigate_sessions ($hostname . "/fortigate-sessions.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
diff --git a/html/pages/device.php b/html/pages/device.php
index 66d5719cb..cdacfe172 100644
--- a/html/pages/device.php
+++ b/html/pages/device.php
@@ -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("
+
+
+
Sensors
+
+
+");
+}
+
if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
echo("
@@ -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') {
echo("
diff --git a/html/pages/interfaces.php b/html/pages/interfaces.php
index 734f92fd8..95fa68f94 100644
--- a/html/pages/interfaces.php
+++ b/html/pages/interfaces.php
@@ -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['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";
$query = mysql_query($sql);
diff --git a/includes/discovery/cisco-mempool.php b/includes/discovery/cisco-mempool.php
index f52673eaa..d793fa1c3 100755
--- a/includes/discovery/cisco-mempool.php
+++ b/includes/discovery/cisco-mempool.php
@@ -22,12 +22,12 @@
if(!strstr($descr, "No") && !strstr($usage, "No") && $cempMemPoolName != "" ) {
$descr = str_replace("\"", "", $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') {
$query = "INSERT INTO cempMemPool (`Index`, `entPhysicalIndex`, `cempMemPoolType`, `cempMemPoolName`, `cempMemPoolValid`, `device_id`)
values ('$Index', '$entPhysicalIndex', '$cempMemPoolType', '$cempMemPoolName', '$cempMemPoolValid', '$id')";
mysql_query($query);
-# echo("$query\n");
+ #echo("$query\n");
echo("+");
} else { echo("."); }
$valid_cpm[$id][$oid] = 1;
@@ -36,10 +36,10 @@
}
} ## End Cisco Enhanced Mempool
-##### ************FIX ME***********
-##### WRITE CODE TO REMOVE OLD RAMS
-##### SOMETIMES THEY CAN GET STOLED
-##### *****************************
+ ##### ************FIX ME***********
+ ##### WRITE CODE TO REMOVE OLD RAMS
+ ##### SOMETIMES THEY CAN GET STOLED
+ ##### *****************************
echo("\n");
diff --git a/includes/discovery/cisco-physical.php b/includes/discovery/cisco-physical.php
index 65ecf40d9..e492c99f5 100755
--- a/includes/discovery/cisco-physical.php
+++ b/includes/discovery/cisco-physical.php
@@ -2,14 +2,16 @@
echo("Physical Inventory : ");
+ unset($valid);
+
if($config['enable_inventory']) {
$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`);
- foreach(explode("\n", $ents) as $entPhysicalIndex) {
+ foreach(explode("\n", $ents) as $entPhysicalIndex) {
$ent_data = $config['snmpget'] . " -m ENTITY-MIB -Ovqs -";
$ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port'];
@@ -24,7 +26,6 @@
$ent_data .= " entPhysicalParentRelPos." . $entPhysicalIndex;
$ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0";
-
list($entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalClass,$entPhysicalName,$entPhysicalSerialNum,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos, $ifIndex) = explode("\n", `$ent_data`);
if(strpos($ifIndex, "o") || $ifIndex == "") { unset($ifIndex); }
@@ -38,15 +39,11 @@
$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)) {
- ### TO DO : WRITE CODE FOR UPDATES!
+ ### TO DO : WRITE CODE FOR UPDATES!
- echo(".");
+ echo(".");
} else {
$sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `ifIndex` ) ";
@@ -55,10 +52,39 @@
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!"); }
+ $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");
?>
diff --git a/includes/functions.php b/includes/functions.php
index 9802d1ac1..32d9095dc 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -22,6 +22,35 @@ require('collectd/config.php');
require('collectd/functions.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){
diff --git a/includes/graphing.php b/includes/graphing.php
index 408b256c1..13a6e855f 100644
--- a/includes/graphing.php
+++ b/includes/graphing.php
@@ -547,6 +547,37 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
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) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php
index 8048cfd07..05514c4b9 100755
--- a/includes/polling/device-ios.inc.php
+++ b/includes/polling/device-ios.inc.php
@@ -10,35 +10,16 @@
$cpurrd = $config['rrd_dir'] . "/" . $hostname . "/cpu.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, " ") && strlen($ciscomodel) >= '3') {
$hardware = $ciscomodel;
}
- if($device['os'] == "IOS XE") {
- list(,$features,$version) = explode(",", $sysDescr);
- $version = str_replace(" Version ", "", $version);
- $features = str_replace(" IOS-XE Software (", "", $features);
- $features = str_replace("-M", "", $features);
- $features = str_replace(")", "", $features);
- $features = str_replace("PPC_LINUX_IOSD-", "", $features);
- #$features = rewrite_ios_features($features);
- }
-
+ $sysDescr = str_replace("IOS (tm)", "IOS (tm),", $sysDescr);
+ list(,$features,$version) = explode(",", $sysDescr);
+ $version = str_replace(" Version ", "", $version);
+ list(,$features) = explode("(", $features);
+ list(,$features) = explode("-", $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"));
$cpu5m = $cpu5m + 0;
@@ -65,5 +46,6 @@
include("includes/polling/bgpPeer.inc.php");
include("includes/polling/cisco-processors.inc.php");
include("includes/polling/cisco-mempool.inc.php");
+ include("includes/polling/cisco-entity-sensors.inc.php");
?>