new files

git-svn-id: http://www.observium.org/svn/observer/trunk@410 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-04-28 11:02:13 +00:00
parent 1df7127d28
commit 8fc09e963f
3 changed files with 126 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
$snmpver = $device['snmpver'];
$port = $device['port'];
echo("Cisco Enh Mempool : ");
## Cisco Enhanced Mempool
if($device['os'] == "IOS" || $device['os'] == "IOS XE") {
echo("Cisco ");
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-ENHANCED-MEMPOOL-MIB -v2c -CI -Osq -c ".$community." ".$hostname.":".$port." cempMemPoolName | sed s/cempMemPoolName.//g");
$oids = trim($oids);
foreach(explode("\n", $oids) as $data) {
$data = trim($data);
if($data) {
list($oid, $cempMemPoolName) = explode(" ", $data);
list($entPhysicalIndex, $Index) = explode(".", $oid);
$cempMemPoolType = trim(shell_exec($config['snmpget'] . " -m CISCO-ENHANCED-MEMPOOL-MIB -O qv -v2c -c $community $hostname:$port cempMemPoolType.$oid"));
$cempMemPoolValid = trim(shell_exec($config['snmpget'] . " -m CISCO-ENHANCED-MEMPOOL-MIB -O qv -v2c -c $community $hostname:$port cempMemPoolValid.$oid"));
if(!strstr($descr, "No") && !strstr($usage, "No") && $cempMemPoolName != "" ) {
$descr = str_replace("\"", "", $descr);
$descr = trim($descr);
# 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("+");
} else { echo("."); }
$valid_cpm[$id][$oid] = 1;
}
}
}
} ## End Cisco Enhanced Mempool
##### ************FIX ME***********
##### WRITE CODE TO REMOVE OLD RAMS
##### SOMETIMES THEY CAN GET STOLED
##### *****************************
echo("\n");
?>

View File

@@ -0,0 +1,25 @@
<?php
echo("Physical Inventory : ");
# if($config['enable_inventory']) {
$ents_cmd = $config['snmpwalk'] . " -m HOST-RESOURCES-MIB -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['$port'] . " ";
$ents_cmd .= "hrDeviceIndex | sed s/.1.3.6.1.2.1.25.3.2.1.1.//g | cut -f 1 -d\" \"";
$ents = trim(`$ents_cmd | grep -v o`);
foreach(explode("\n", $ents) as $hrDeviceIndex) {
$ent_data = $config['snmpget'] ". -m HOST-RESOURCES-MIB:ENTITY-MIB -Ovqs -";
$ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port'];
$ent_data .= " hrDeviceType." . $entPhysicalIndex;
$ent_data .= " hrDeviceDescr." . $entPhysicalIndex;
$ent_data .= " entPhysicalParentRelPos." . $entPhysicalIndex;
$ent_data .= " entAliasMappingIdentifier." . $entPhysicalIndex. ".0";
}
#}
?>

View File

@@ -0,0 +1,55 @@
<?
$query = "SELECT * FROM cempMemPool WHERE device_id = '" . $device['device_id'] . "'";
$pool_data = mysql_query($query);
while($mempool = mysql_fetch_array($pool_data)) {
$entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$device['device_id']."'
AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0);
echo("Checking Mempool " . $entPhysicalName . " - " . $mempool['cempMemPoolName']);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$pool_cmd = "snmpget -m CISCO-ENHANCED-MEMPOOL-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$pool_cmd .= " cempMemPoolUsed.$oid cempMemPoolFree.$oid cempMemPoolLargestFree.$oid cempMemPoolLowestFree.$oid";
$pool_cmd .= " | cut -f 1 -d ' '";
$pool = shell_exec($pool_cmd);
list($cempMemPoolUsed, $cempMemPoolFree, $cempMemPoolLargestFree, $cempMemPoolLowestFree) = explode("\n", $pool);
$poolrrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/cempMemPool-" . $oid . ".rrd");
if (!is_file($poolrrd)) {
`rrdtool create $poolrrd \
--step 300 \
DS:used:GAUGE:600:0:U \
DS:free:GAUGE:600:-1:U \
DS:largestfree:GAUGE:600:0:U \
DS:lowestfree:GAUGE:600:-1:U \
RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`;
}
$pool = trim(str_replace("\"", "", $pool));
list($pool) = split(" ", $pool);
$updatecmd = $config['rrdtool'] ." update $poolrrd N:$cempMemPoolUsed:$cempMemPoolFree:$cempMemPoolLargestFree:$cempMemPoolLowestFree";
shell_exec($updatecmd);
$update_query = "UPDATE `cempMemPool` SET cempMemPoolUsed='$cempMemPoolUsed', cempMemPoolFree='$cempMemPoolFree', cempMemPoolLargestFree='$cempMemPoolLargestFree', cempMemPoolLowestFree='$cempMemPoolLowestFree' WHERE `cempMemPool_id` = '".$mempool['cempMemPool_id']."'";
mysql_query($update_query);
echo("\n");
}
?>