mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
adding ironware linecard cpu polling
git-svn-id: http://www.observium.org/svn/observer/trunk@860 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -83,14 +83,15 @@ ALTER TABLE `voltage` ADD `volt_limit_low` int(11) NULL DEFAULT NULL AFTER `volt
|
|||||||
ALTER TABLE `voltage` CHANGE `volt_current` `volt_current` FLOAT(3) NULL DEFAULT NULL;
|
ALTER TABLE `voltage` CHANGE `volt_current` `volt_current` FLOAT(3) NULL DEFAULT NULL;
|
||||||
ALTER TABLE `voltage` CHANGE `volt_limit` `volt_limit` FLOAT(3) NULL DEFAULT NULL;
|
ALTER TABLE `voltage` CHANGE `volt_limit` `volt_limit` FLOAT(3) NULL DEFAULT NULL;
|
||||||
ALTER TABLE `voltage` CHANGE `volt_limit_low` `volt_limit_low` FLOAT(3) NULL DEFAULT NULL;
|
ALTER TABLE `voltage` CHANGE `volt_limit_low` `volt_limit_low` FLOAT(3) NULL DEFAULT NULL;
|
||||||
ALTER TABLE `fanspeed` ADD `fan_index` INT NOT NULL AFTER `fan_host` , ADD `fan_mibtype` VARCHAR( 32 ) NOT NULL AFTER `fan_index`
|
ALTER TABLE `fanspeed` ADD `fan_index` INT NOT NULL AFTER `fan_host` , ADD `fan_mibtype` VARCHAR( 32 ) NOT NULL AFTER `fan_index`;
|
||||||
ALTER TABLE `temperature` CHANGE `temp_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0'
|
ALTER TABLE `temperature` CHANGE `temp_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0';
|
||||||
ALTER TABLE `fanspeed` CHANGE `fan_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0'
|
ALTER TABLE `fanspeed` CHANGE `fan_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0';
|
||||||
ALTER TABLE `voltage` CHANGE `volt_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0'
|
ALTER TABLE `voltage` CHANGE `volt_host` `device_id` INT( 11 ) NOT NULL DEFAULT '0';
|
||||||
CREATE TABLE IF NOT EXISTS `processors` ( `processor_id` int(11) NOT NULL AUTO_INCREMENT, `entPhysicalIndex` int(11) NOT NULL, `device_id` int(11) NOT NULL, `processor_oid` int(11) NOT NULL, `processor_type` int(11) NOT NULL, `processor_usage` int(11) NOT NULL, `processor_description` varchar(64) NOT NULL, PRIMARY KEY (`processor_id`), KEY `cpuCPU_id` (`processor_id`,`device_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
CREATE TABLE IF NOT EXISTS `processors` ( `processor_id` int(11) NOT NULL AUTO_INCREMENT, `entPhysicalIndex` int(11) NOT NULL, `device_id` int(11) NOT NULL, `processor_oid` int(11) NOT NULL, `processor_type` int(11) NOT NULL, `processor_usage` int(11) NOT NULL, `processor_description` varchar(64) NOT NULL, PRIMARY KEY (`processor_id`), KEY `cpuCPU_id` (`processor_id`,`device_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||||
ALTER TABLE `processors` ADD `hrDeviceIndex` int(11) NULL AFTER `entPhysicalIndex`
|
ALTER TABLE `processors` ADD `hrDeviceIndex` int(11) NULL AFTER `entPhysicalIndex`;
|
||||||
ALTER TABLE `temperature` CHANGE `temp_current` `temp_current` FLOAT( 4 ) NOT NULL DEFAULT '0'
|
ALTER TABLE `temperature` CHANGE `temp_current` `temp_current` FLOAT( 4 ) NOT NULL DEFAULT '0';
|
||||||
ALTER TABLE `processors` ADD `processor_index` varchar(32) NOT NULL AFTER `processor_oid`
|
ALTER TABLE `processors` ADD `processor_index` varchar(32) NOT NULL AFTER `processor_oid`;
|
||||||
ALTER TABLE `processors` CHANGE `processor_description` `processor_descr` varchar(64) NOT NULL
|
ALTER TABLE `processors` CHANGE `processor_description` `processor_descr` varchar(64) NOT NULL;
|
||||||
ALTER TABLE `fanspeed` CHANGE `fan_mibtype` `fan_type` varchar(64) NOT NULL
|
ALTER TABLE `fanspeed` CHANGE `fan_mibtype` `fan_type` varchar(64) NOT NULL ;
|
||||||
ALTER TABLE `voltage` ADD `volt_index` VARCHAR( 8 ) NOT NULL AFTER `volt_oid`,ADD `volt_type` VARCHAR( 32 ) NOT NULL AFTER `volt_index`
|
ALTER TABLE `voltage` ADD `volt_index` VARCHAR( 8 ) NOT NULL AFTER `volt_oid`,ADD `volt_type` VARCHAR( 32 ) NOT NULL AFTER `volt_index` ;
|
||||||
|
ALTER TABLE `processors` ADD `processor_precision` INT( 11 ) NOT NULL DEFAULT '1';
|
||||||
|
|||||||
58
includes/discovery/processors-ironware.inc.php
Executable file
58
includes/discovery/processors-ironware.inc.php
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if($device['os'] == "ironware" || $device['os_group'] == "ironware")
|
||||||
|
{
|
||||||
|
echo("IronWare : ");
|
||||||
|
$processors_array = snmpwalk_cache_triple_oid($device, "snAgentCpuUtilEntry", $processors_array, "FOUNDRY-SN-AGENT-MIB");
|
||||||
|
if($debug) { print_r($processors_array); }
|
||||||
|
foreach($processors_array[$device['device_id']] as $index => $entry)
|
||||||
|
{
|
||||||
|
if (($entry['snAgentCpuUtilValue'] || $entry['snAgentCpuUtil100thPercent']) && $entry['snAgentCpuUtilInterval'] == "300")
|
||||||
|
{
|
||||||
|
#$entPhysicalIndex = $entry['cpmCPUTotalPhysicalIndex'];
|
||||||
|
|
||||||
|
if($entry['snAgentCpuUtil100thPercent']) {
|
||||||
|
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.6." . $index;
|
||||||
|
$usage = $entry['snAgentCpuUtil100thPercent'];
|
||||||
|
$precision = 100;
|
||||||
|
} elseif($entry['snAgentCpuUtilValue']) {
|
||||||
|
$usage_oid = ".1.3.6.1.4.1.1991.1.1.2.11.1.1.4." . $index;
|
||||||
|
$usage = $entry['snAgentCpuUtilValue'];
|
||||||
|
$precision = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
list($slot, $instance, $interval) = explode(".", $index);
|
||||||
|
|
||||||
|
$descr_oid = "snAgentConfigModuleDescription." . $entry['snAgentCpuUtilSlotNum'];
|
||||||
|
$descr = snmp_get($device, $descr_oid, "-Oqv", "FOUNDRY-SN-AGENT-MIB");
|
||||||
|
$descr = str_replace("\"", "", $descr);
|
||||||
|
list($descr) = explode(" ", $descr);
|
||||||
|
|
||||||
|
$descr = "Slot " . $entry['snAgentCpuUtilSlotNum'] . " " . $descr;
|
||||||
|
$descr = $descr . " [".$instance."]";
|
||||||
|
|
||||||
|
if(!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" )
|
||||||
|
{
|
||||||
|
if(mysql_result(mysql_query("SELECT count(processor_id) FROM `processors` WHERE `processor_index` = '$index' AND `device_id` = '".$device['device_id']."' AND `processor_type` = 'ironware'"),0) == '0') {
|
||||||
|
$query = "INSERT INTO processors (`entPhysicalIndex`, `device_id`, `processor_descr`, `processor_index`, `processor_oid`, `processor_usage`, `processor_type`, `processor_precision`)
|
||||||
|
values ('$entPhysicalIndex', '".$device['device_id']."', '$descr', '$index', '$usage_oid', '".$usage."', 'ironware', '$precision')";
|
||||||
|
mysql_query($query);
|
||||||
|
if($debug) { print $query . "\n"; }
|
||||||
|
echo("+");
|
||||||
|
} else {
|
||||||
|
echo(".");
|
||||||
|
$query = "UPDATE `processors` SET `processor_descr` = '".$descr."', `processor_oid` = '".$usage_oid."', `processor_usage` = '".$usage."'
|
||||||
|
WHERE `device_id` = '".$device['device_id']."' AND `processor_index` = '".$index."' AND `processor_type` = 'ironware'";
|
||||||
|
mysql_query($query);
|
||||||
|
if($debug) { print $query . "\n"; }
|
||||||
|
}
|
||||||
|
$valid_processor['ironware'][$index] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
## End Cisco Processors
|
||||||
|
|
||||||
|
unset ($processors_array);
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -5,6 +5,7 @@ echo("Processors : ");
|
|||||||
include("processors-ios.inc.php");
|
include("processors-ios.inc.php");
|
||||||
include("processors-junose.inc.php");
|
include("processors-junose.inc.php");
|
||||||
include("processors-hrdevice.inc.php");
|
include("processors-hrdevice.inc.php");
|
||||||
|
include("processors-ironware.inc.php");
|
||||||
|
|
||||||
### Remove processors which weren't redetected here
|
### Remove processors which weren't redetected here
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,22 @@ function snmpwalk_cache_double_oid($device, $oid, $array, $mib = NULL, $mibdir =
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function snmpwalk_cache_triple_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL) {
|
||||||
|
$data = snmp_walk($device, $oid, "-OQUs", $mib, $mibdir);
|
||||||
|
foreach(explode("\n", $data) as $entry) {
|
||||||
|
list($oid,$value) = explode("=", $entry);
|
||||||
|
$oid = trim($oid); $value = trim($value);
|
||||||
|
list($oid, $first, $second, $third) = explode(".", $oid);
|
||||||
|
if (!strstr($value, "at this OID") && isset($oid) && isset($first) && isset($second)) {
|
||||||
|
$index = $first.".".$second.".".$third;
|
||||||
|
$array[$device[device_id]][$index][$oid] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function snmpwalk_cache_twopart_oid($oid, $device, $array, $mib = 0) {
|
function snmpwalk_cache_twopart_oid($oid, $device, $array, $mib = 0) {
|
||||||
global $config;
|
global $config;
|
||||||
$cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -O QUs -" . $device['snmpver'] . " -c " . $device['community'] . " " .
|
$cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -O QUs -" . $device['snmpver'] . " -c " . $device['community'] . " " .
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ while($processor = mysql_fetch_array($proc_data)) {
|
|||||||
|
|
||||||
echo($proc . "%\n");
|
echo($proc . "%\n");
|
||||||
|
|
||||||
$updatecmd = $config['rrdtool'] ." update $procrrd N:$proc";
|
rrdtool_update($procrrd,"N:$proc");
|
||||||
shell_exec($updatecmd);
|
|
||||||
|
|
||||||
mysql_query("UPDATE `processors` SET `processor_usage` = '$proc' WHERE `processor_id` = '".$processor['processor_id']."'");
|
mysql_query("UPDATE `processors` SET `processor_usage` = '$proc' WHERE `processor_id` = '".$processor['processor_id']."'");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user