mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Added Cisco Integrated Management Console inventory and sensor support #4454
This commit is contained in:
committed by
Neil Lathwood
parent
12c4b8acb2
commit
a2563c5b67
@@ -36,6 +36,11 @@ require 'includes/dev-overview-data.inc.php';
|
||||
LibreNMS\Plugins::call('device_overview_container', array($device));
|
||||
|
||||
require 'overview/ports.inc.php';
|
||||
|
||||
if ($device['os'] == 'cimc') {
|
||||
require 'overview/cimc.inc.php';
|
||||
}
|
||||
|
||||
echo('
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
49
html/pages/device/overview/cimc.inc.php
Normal file
49
html/pages/device/overview/cimc.inc.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
$component = new LibreNMS\Component();
|
||||
$components = $component->getComponents($device['device_id'], array('type'=>'Cisco-CIMC'));
|
||||
|
||||
// We only care about our device id.
|
||||
$components = $components[$device['device_id']];
|
||||
|
||||
if (count($components) > 0) {
|
||||
?>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-default panel-condensed">
|
||||
<div class="panel-heading">
|
||||
<img src='images/16/cog.png'><strong> Hardware Components</strong>
|
||||
</div>
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
<?php
|
||||
foreach ($components as $component => $array) {
|
||||
if ($array['status'] == 2) {
|
||||
$class = "danger";
|
||||
$message = "Alert";
|
||||
} else {
|
||||
$class = "";
|
||||
$message = "Ok";
|
||||
}
|
||||
?>
|
||||
<tr class="<?php echo $class ?>">
|
||||
<td><?php echo $array['string']?></td>
|
||||
</tr>
|
||||
<?php
|
||||
// Display an additional row to show the error
|
||||
if ($array['status'] == 2) {
|
||||
?>
|
||||
<tr class="<?php echo $class ?>">
|
||||
<td>Error: <?php echo nl2br($array['error'])?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
@@ -685,12 +685,13 @@ $os = 'cimc';
|
||||
$config['os'][$os]['text'] = 'Cisco Integrated Management Controller';
|
||||
$config['os'][$os]['type'] = 'server';
|
||||
$config['os'][$os]['icon'] = 'cisco';
|
||||
$config['os'][$os]['over'][0]['graph'] = 'device_bits';
|
||||
$config['os'][$os]['over'][0]['text'] = 'Device Traffic';
|
||||
$config['os'][$os]['over'][1]['graph'] = 'device_processor';
|
||||
$config['os'][$os]['over'][1]['text'] = 'CPU Usage';
|
||||
$config['os'][$os]['over'][2]['graph'] = 'device_mempool';
|
||||
$config['os'][$os]['over'][2]['text'] = 'Memory Usage';
|
||||
$config['os'][$os]['group'] = "cisco";
|
||||
$config['os'][$os]['over'][0]['graph'] = 'device_temperature';
|
||||
$config['os'][$os]['over'][0]['text'] = 'Temperature';
|
||||
$config['os'][$os]['over'][1]['graph'] = 'device_voltage';
|
||||
$config['os'][$os]['over'][1]['text'] = 'Power Voltage';
|
||||
$config['os'][$os]['over'][2]['graph'] = 'device_current';
|
||||
$config['os'][$os]['over'][2]['text'] = 'Power Current';
|
||||
|
||||
$os = 'cucm';
|
||||
$config['os'][$os]['text'] = 'Cisco Unified Communications Manager';
|
||||
|
@@ -1,164 +1,23 @@
|
||||
<?php
|
||||
|
||||
if ($config['enable_inventory']) {
|
||||
echo "\nCaching OIDs:";
|
||||
// Legacy entPhysical - junos/timos/cisco
|
||||
include 'includes/discovery/entity-physical/entity-physical.inc.php';
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
$entity_array = array();
|
||||
echo ' jnxBoxAnatomy';
|
||||
$entity_array = snmpwalk_cache_oid($device, 'jnxBoxAnatomy', $entity_array, 'JUNIPER-MIB');
|
||||
} elseif ($device['os'] == 'timos') {
|
||||
$entity_array = array();
|
||||
echo 'tmnxHwObjs';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'tmnxHwObjs', $entity_array, 'TIMETRA-CHASSIS-MIB', 'aos');
|
||||
} else {
|
||||
$entity_array = array();
|
||||
echo ' entPhysicalEntry';
|
||||
$entity_array = snmpwalk_cache_oid($device, 'entPhysicalEntry', $entity_array, 'ENTITY-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB');
|
||||
echo ' entAliasMappingIdentifier';
|
||||
$entity_array = snmpwalk_cache_twopart_oid($device, 'entAliasMappingIdentifier', $entity_array, 'ENTITY-MIB:IF-MIB');
|
||||
// Cisco CIMC
|
||||
if ($device['os'] == 'cimc') {
|
||||
include 'includes/discovery/entity-physical/cimc.inc.php';
|
||||
}
|
||||
|
||||
foreach ($entity_array as $entPhysicalIndex => $entry) {
|
||||
if ($device['os'] == 'junos') {
|
||||
// Juniper's MIB doesn't have the same objects as the Entity MIB, so some values
|
||||
// are made up here.
|
||||
$entPhysicalDescr = $entry['jnxContentsDescr'];
|
||||
$entPhysicalContainedIn = $entry['jnxContainersWithin'];
|
||||
$entPhysicalClass = $entry['jnxBoxClass'];
|
||||
$entPhysicalName = $entry['jnxOperatingDescr'];
|
||||
$entPhysicalSerialNum = $entry['jnxContentsSerialNo'];
|
||||
$entPhysicalModelName = $entry['jnxContentsPartNo'];
|
||||
$entPhysicalMfgName = 'Juniper';
|
||||
$entPhysicalVendorType = 'Juniper';
|
||||
$entPhysicalParentRelPos = -1;
|
||||
$entPhysicalHardwareRev = $entry['jnxContentsRevision'];
|
||||
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
|
||||
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
|
||||
$entPhysicalIsFRU = $entry['jnxFruType'];
|
||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||
// fix for issue 1865, $entPhysicalIndex, as it contains a quad dotted number on newer Junipers
|
||||
// using str_replace to remove all dots should fix this even if it changes in future
|
||||
$entPhysicalIndex = str_replace('.', '', $entPhysicalIndex);
|
||||
} elseif ($device['os'] == 'timos') {
|
||||
$entPhysicalDescr = $entry['tmnxCardTypeDescription'];
|
||||
$entPhysicalContainedIn = $entry['tmnxHwContainedIn'];
|
||||
$entPhysicalClass = $entry['tmnxHwClass'];
|
||||
$entPhysicalName = $entry['tmnxCardTypeName'];
|
||||
$entPhysicalSerialNum = $entry['tmnxHwSerialNumber'];
|
||||
$entPhysicalModelName = $entry['tmnxHwMfgBoardNumber'];
|
||||
$entPhysicalMfgName = $entry['tmnxHwMfgBoardNumber'];
|
||||
$entPhysicalVendorType = $entry['tmnxCardTypeName'];
|
||||
$entPhysicalParentRelPos = $entry['tmnxHwParentRelPos'];
|
||||
$entPhysicalHardwareRev = '1.0';
|
||||
$entPhysicalFirmwareRev = $entry['tmnxHwBootCodeVersion'];
|
||||
$entPhysicalSoftwareRev = $entry['tmnxHwBootCodeVersion'];
|
||||
$entPhysicalIsFRU = $entry['tmnxHwIsFRU'];
|
||||
$entPhysicalAlias = $entry['tmnxHwAlias'];
|
||||
$entPhysicalAssetID = $entry['tmnxHwAssetID'];
|
||||
$entPhysicalIndex = str_replace('.', '', $entPhysicalIndex);
|
||||
} else {
|
||||
$entPhysicalDescr = $entry['entPhysicalDescr'];
|
||||
$entPhysicalContainedIn = $entry['entPhysicalContainedIn'];
|
||||
$entPhysicalClass = $entry['entPhysicalClass'];
|
||||
$entPhysicalName = $entry['entPhysicalName'];
|
||||
$entPhysicalSerialNum = $entry['entPhysicalSerialNum'];
|
||||
$entPhysicalModelName = $entry['entPhysicalModelName'];
|
||||
$entPhysicalMfgName = $entry['entPhysicalMfgName'];
|
||||
$entPhysicalVendorType = $entry['entPhysicalVendorType'];
|
||||
$entPhysicalParentRelPos = $entry['entPhysicalParentRelPos'];
|
||||
$entPhysicalHardwareRev = $entry['entPhysicalHardwareRev'];
|
||||
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
|
||||
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
|
||||
$entPhysicalIsFRU = $entry['entPhysicalIsFRU'];
|
||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||
}//end if
|
||||
|
||||
if (isset($entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'])) {
|
||||
$ifIndex = $entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'];
|
||||
// Delete any entries that have not bee accounted for.
|
||||
$sql = 'SELECT * FROM `entPhysical` WHERE `device_id` = ?';
|
||||
foreach (dbFetchRows($sql, array($device['device_id'])) as $test) {
|
||||
$id = $test['entPhysicalIndex'];
|
||||
if (!$valid[$id]) {
|
||||
echo '-';
|
||||
dbDelete('entPhysical', 'entPhysical_id = ?', array ($test['entPhysical_id']));
|
||||
}
|
||||
|
||||
if (!strpos($ifIndex, 'fIndex') || $ifIndex == '') {
|
||||
unset($ifIndex);
|
||||
} else {
|
||||
$ifIndex_array = explode('.', $ifIndex);
|
||||
$ifIndex = $ifIndex_array[1];
|
||||
}
|
||||
|
||||
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName) {
|
||||
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
|
||||
}
|
||||
|
||||
// FIXME - dbFacile
|
||||
if ($entPhysicalDescr || $entPhysicalName) {
|
||||
$entPhysical_id = dbFetchCell('SELECT entPhysical_id FROM `entPhysical` WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $entPhysicalIndex));
|
||||
|
||||
if ($entPhysical_id) {
|
||||
$update_data = array(
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID,
|
||||
);
|
||||
dbUpdate($update_data, 'entPhysical', 'device_id=? AND entPhysicalIndex=?', array($device['device_id'], $entPhysicalIndex));
|
||||
echo '.';
|
||||
} else {
|
||||
$insert_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID,
|
||||
);
|
||||
|
||||
if (!empty($ifIndex)) {
|
||||
$insert_data['ifIndex'] = $ifIndex;
|
||||
}
|
||||
|
||||
dbInsert($insert_data, 'entPhysical');
|
||||
echo '+';
|
||||
}//end if
|
||||
|
||||
$valid[$entPhysicalIndex] = 1;
|
||||
}//end if
|
||||
}//end foreach
|
||||
}
|
||||
} else {
|
||||
echo 'Disabled!';
|
||||
}//end if
|
||||
|
||||
$sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'";
|
||||
foreach (dbFetchRows($sql) as $test) {
|
||||
$id = $test['entPhysicalIndex'];
|
||||
if (!$valid[$id]) {
|
||||
echo '-';
|
||||
dbDelete('entPhysical', 'entPhysical_id = ?', array($test['entPhysical_id']));
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
596
includes/discovery/entity-physical/cimc.inc.php
Normal file
596
includes/discovery/entity-physical/cimc.inc.php
Normal file
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to discover hardware components in a Cisco Integrated Management Controller
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$comp_module = 'Cisco-CIMC';
|
||||
$component = new LibreNMS\Component();
|
||||
$components = $component->getComponents($device['device_id'], array('type'=>$comp_module));
|
||||
|
||||
// We only care about our device id.
|
||||
$components = $components[$device['device_id']];
|
||||
|
||||
// Begin our master array, all other values will be processed into this array.
|
||||
$tblCIMC = array();
|
||||
|
||||
// Let's gather some data..
|
||||
$tblUCSObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1', 2);
|
||||
|
||||
/*
|
||||
* False == no object found - this is not an error, there is no QOS configured
|
||||
* null == timeout or something else that caused an error, the OID's may be present but we couldn't get them.
|
||||
*/
|
||||
if (is_null($tblUCSObjects)) {
|
||||
// We have to error here or we will end up deleting all our components.
|
||||
} else {
|
||||
// No Error, lets process things.
|
||||
echo("CIMC Hardware Found: ");
|
||||
|
||||
// Make sure we have an array before we try to iterate over it
|
||||
if (is_array($tblUCSObjects)) {
|
||||
// Gather entPhysical data
|
||||
$entmax = 0;
|
||||
$entphysical = array();
|
||||
$dbentphysical = $entries = dbFetchRows('SELECT * FROM entPhysical WHERE device_id=?', array($device['device_id']));
|
||||
foreach ($dbentphysical as $array) {
|
||||
$entphysical[$array['entPhysicalVendorType']] = $array;
|
||||
if ($array['entPhysicalIndex'] > $entmax) {
|
||||
$entmax = $array['entPhysicalIndex'];
|
||||
}
|
||||
}
|
||||
|
||||
// Let's extract any active faults, we will use them later.
|
||||
$faults = array();
|
||||
foreach ($tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1'][5] as $fid => $fobj) {
|
||||
$fobj = preg_replace('/^\/?sys\//', '', $fobj);
|
||||
$faults[$fobj] = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1'][3][$fid] ." - ". $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1'][11][$fid];
|
||||
}
|
||||
|
||||
// Unset the faults and stats array so it isn't reported as an error later.
|
||||
unset(
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1'],
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.9.14.1'],
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.9.44.1'],
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.30.12.1'],
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.41.2.1'],
|
||||
$tblUCSObjects['1.3.6.1.4.1.9.9.719.1.45.36.1']
|
||||
);
|
||||
|
||||
foreach ($tblUCSObjects as $tbl => $array) {
|
||||
// Remove the leading /sys/
|
||||
foreach ($array[2] as &$label) {
|
||||
$label = preg_replace('/^\/?sys\//', '', $label);
|
||||
}
|
||||
|
||||
// Lets Set some defaults.
|
||||
$entPhysicalData = array(
|
||||
'entPhysicalHardwareRev' => '',
|
||||
'entPhysicalFirmwareRev' => '',
|
||||
'entPhysicalSoftwareRev' => '',
|
||||
'entPhysicalIsFRU' => 'FALSE',
|
||||
);
|
||||
|
||||
switch ($tbl) {
|
||||
// Chassis - rack-unit-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.9.35.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'chassis';
|
||||
$result['id'] = $array[27][$key];
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[47][$key];
|
||||
$result['string'] = $array[32][$key] ." - ". ($array[49][$key]/1024) ."G Mem, ". $array[36][$key] ." CPU, ". $array[35][$key] ." core";
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.9.35.1.43.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[43][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[43][$key]."\n";
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// See if there are any errors on this chassis.
|
||||
foreach ($faults as $id => $value) {
|
||||
if (strpos($id, $result['label']) !== false) {
|
||||
// The fault is on this chassis.
|
||||
$result['status'] = 2;
|
||||
$result['error'] .= $value."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'chassis';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[32][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Chassis';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[47][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("Chassis (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// System Board - rack-unit-1/board
|
||||
case "1.3.6.1.4.1.9.9.719.1.9.6.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'board';
|
||||
$result['id'] = $array[5][$key];
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[14][$key];
|
||||
$result['string'] = $array[6][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.9.6.1.9.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[9][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[9][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'backplane';
|
||||
$entPhysicalData['entPhysicalName'] = 'System Board';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[14][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("System Board (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// Memory Modules - rack-unit-1/board/memarray-1/mem-0
|
||||
case "1.3.6.1.4.1.9.9.719.1.30.11.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
// If there is no memory module present, continue.
|
||||
if ($array[17][$key] != 10) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result['hwtype'] = 'memory';
|
||||
$result['id'] = substr($array[3][$key], 4);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[19][$key];
|
||||
$result['string'] = $array[11][$key] ." - ". ($array[6][$key]/1024) ."G, ". $array[27][$key] ." Bit, ". $array[7][$key] ." Mhz, ". $array[21][$key] ." MT/s";
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.30.11.1.14.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[14][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[14][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[11][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Memory';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[19][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("Memory (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// CPU's - rack-unit-1/board/cpu-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.41.9.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
// If there is no cpu present, continue.
|
||||
if ($array[13][$key] != 10) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result['hwtype'] = 'cpu';
|
||||
$result['id'] = substr($array[3][$key], 4);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[15][$key];
|
||||
$result['string'] = $array[8][$key] ." - ". $array[5][$key] ." Cores, ". $array[20][$key] ." Threads";
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.41.9.1.10.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[10][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[10][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'cpu';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[8][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Processor';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[15][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("CPU (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// SAS Storage Module - rack-unit-1/board/storage-SAS-2
|
||||
case "1.3.6.1.4.1.9.9.719.1.45.1.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'sas-controller';
|
||||
$result['id'] = substr($array[3][$key], 12);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[14][$key];
|
||||
$result['string'] = $array[5][$key] ." - Rev: ". $array[13][$key] .", ". $array[9][$key] .", RAID Types: ". $array[19][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.45.1.1.7.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[7][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[7][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[5][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Storage Module';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[14][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("SAS Module (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// SAS Disks - rack-unit-1/board/storage-SAS-2/disk-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.45.4.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'sas-disk';
|
||||
$result['id'] = substr($array[3][$key], 5);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[12][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.45.4.1.9.'.$key;
|
||||
|
||||
// Old Firmware returns 4294967296 as 1 MB.
|
||||
// The if below assumes we will never have < 1 Gb on old firmware or > 4 Pb on new firmware
|
||||
if (($array[13][$key]) > 4294967296000) {
|
||||
// Old Firmware
|
||||
$result['string'] = $array[14][$key] ." ". $array[7][$key] .", Rev: ". $array[11][$key] .", Size: ". round($array[13][$key]/4294967296000, 2) ." GB";
|
||||
d_echo("Disk: ".$array[2][$key].", Raw Size: ".$array[13][$key].", converted (old FW): ".round($array[13][$key]/4294967296000, 2)."GB\n");
|
||||
} else {
|
||||
// New Firmware
|
||||
$result['string'] = $array[14][$key] ." ". $array[7][$key] .", Rev: ". $array[11][$key] .", Size: ". round($array[13][$key]/1000, 2) ." GB";
|
||||
d_echo("Disk: ".$array[2][$key].", Raw Size: ".$array[13][$key].", converted (New FW): ".round($array[13][$key]/1000, 2)."GB\n");
|
||||
}
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[9][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[9][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[14][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Disk';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[12][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("SAS Disk (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// LUN's - rack-unit-1/board/storage-SAS-2/lun-0
|
||||
case "1.3.6.1.4.1.9.9.719.1.45.8.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'lun';
|
||||
$result['id'] = substr($array[3][$key], 4);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = 'N/A';
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.45.8.1.9.'.$key;
|
||||
|
||||
// Old Firmware returns 4294967296 as 1 MB.
|
||||
// The if below assumes we will never have < 1 Gb on old firmware or > 4 Pb on new firmware
|
||||
if (($array[13][$key]) > 4294967296000) {
|
||||
// Old Firmware
|
||||
$result['string'] = $array[3][$key] .", Size: ". round($array[13][$key]/4294967296000, 2) ." GB";
|
||||
d_echo("LUN: ".$array[2][$key].", Raw Size: ".$array[13][$key].", converted (Old FW): ".round($array[13][$key]/4294967296000, 2)."GB\n");
|
||||
} else {
|
||||
// New Firmware
|
||||
$result['string'] = $array[3][$key] .", Size: ". round($array[13][$key]/1000, 2) ." GB";
|
||||
d_echo("LUN: ".$array[2][$key].", Raw Size: ".$array[13][$key].", converted (New FW): ".round($array[13][$key]/1000, 2)."GB\n");
|
||||
}
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[9][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[9][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[3][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'LUN';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = '';
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("LUN (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// RAID Battery - rack-unit-1/board/storage-SAS-2/raid-battery
|
||||
case "1.3.6.1.4.1.9.9.719.1.45.11.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'raid-battery';
|
||||
$result['id'] = $array[3][$key];
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = 'N/A';
|
||||
$result['string'] = $array[3][$key] ." - ". $array[7][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.45.11.1.9.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[9][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[9][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[3][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'RAID Battery';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = '';
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("RAID Battery (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// Fan's - rack-unit-1/fan-module-1-1/fan-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.15.12.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'fan';
|
||||
$result['id'] = $array[8][$key] ."-". substr($array[3][$key], 4);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = 'N/A';
|
||||
$result['string'] = $array[7][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.15.12.1.10.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[10][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[10][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'fan';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[7][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'FAN';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = '';
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("Fan (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// PSU's - rack-unit-1/psu-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.15.56.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'psu';
|
||||
$result['id'] = substr($array[3][$key], 4);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[13][$key];
|
||||
$result['string'] = $array[6][$key] ." - Rev: ". $array[12][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.15.56.1.8.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[8][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[8][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'powerSupply';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[6][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'PSU';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[13][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("PSU (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// Adaptors - rack-unit-1/adaptor-1
|
||||
case "1.3.6.1.4.1.9.9.719.1.3.85.1":
|
||||
foreach ($array[3] as $key => $item) {
|
||||
$result = array();
|
||||
$result['hwtype'] = 'adaptor';
|
||||
$result['id'] = substr($array[3][$key], 8);
|
||||
$result['label'] = $array[2][$key];
|
||||
$result['serial'] = $array[21][$key];
|
||||
$result['string'] = $array[11][$key] ." - Rev: ". $array[20][$key] ." - Part-No: ". $array[26][$key];
|
||||
$result['statusoid'] = '1.3.6.1.4.1.9.9.719.1.3.85.1.13.'.$key;
|
||||
|
||||
// What is the Operability, 1 is good, everything else is bad.
|
||||
if ($array[13][$key] != 1) {
|
||||
// Yes, report an error
|
||||
$result['status'] = 2;
|
||||
$result['error'] = "Error Operability Code: ".$array[13][$key];
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$result['status'] = 0;
|
||||
$result['error'] = '';
|
||||
}
|
||||
|
||||
// Add the ent Physical entry
|
||||
$entPhysicalData['entPhysicalClass'] = 'module';
|
||||
$entPhysicalData['entPhysicalModelName'] = $array[11][$key];
|
||||
$entPhysicalData['entPhysicalName'] = 'Adaptor';
|
||||
$entPhysicalData['entPhysicalDescr'] = $result['string'];
|
||||
$entPhysicalData['entPhysicalSerialNum'] = $array[21][$key];
|
||||
list($result['entPhysical'],$entPhysicalData['entPhysicalIndex']) = setCIMCentPhysical($result['label'], $entPhysicalData, $entphysical, $entmax);
|
||||
$valid[$entPhysicalData['entPhysicalIndex']] = 1;
|
||||
|
||||
// Add the result to the array.
|
||||
d_echo("Adaptor (".$tbl."): ".print_r($result, true)."\n");
|
||||
$tblCIMC[] = $result;
|
||||
}
|
||||
break;
|
||||
|
||||
// Unknown Table, ask the user to log an issue so this can be identified.
|
||||
default:
|
||||
d_echo("Cisco-CIMC Error...\n");
|
||||
d_echo("Please log an issue on github with the following information:\n");
|
||||
d_echo("-----------------------------------------------\n");
|
||||
d_echo("Subject: CIMC Unknown Table: ".$tbl."\n");
|
||||
d_echo("Description: The entity-physical module discovered an unknown CIMC table.\nA dump of its contents is below:\n");
|
||||
d_echo($array);
|
||||
d_echo("-----------------------------------------------\n\n");
|
||||
break;
|
||||
} // End Switch
|
||||
} // End foreach tblUCSObjects
|
||||
} // End is_array
|
||||
|
||||
/*
|
||||
* Ok, we have our 2 array's (Components and SNMP) now we need
|
||||
* to compare and see what needs to be added/updated.
|
||||
*
|
||||
* Let's loop over the SNMP data to see if we need to ADD or UPDATE any components.
|
||||
*/
|
||||
foreach ($tblCIMC as $key => $array) {
|
||||
$component_key = false;
|
||||
|
||||
// Loop over our components to determine if the component exists, or we need to add it.
|
||||
foreach ($components as $compid => $child) {
|
||||
if ($child['label'] === $array['label']) {
|
||||
$component_key = $compid;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$component_key) {
|
||||
// The component doesn't exist, we need to ADD it - ADD.
|
||||
$new_component = $component->createComponent($device['device_id'], $comp_module);
|
||||
$component_key = key($new_component);
|
||||
$components[$component_key] = array_merge($new_component[$component_key], $array);
|
||||
echo "+";
|
||||
} else {
|
||||
// The component does exist, merge the details in - UPDATE.
|
||||
$components[$component_key] = array_merge($components[$component_key], $array);
|
||||
echo ".";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop over the Component data to see if we need to DELETE any components.
|
||||
*/
|
||||
foreach ($components as $key => $array) {
|
||||
// Guilty until proven innocent
|
||||
$found = false;
|
||||
|
||||
foreach ($tblCIMC as $k => $v) {
|
||||
if ($array['label'] == $v['label']) {
|
||||
// Yay, we found it...
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found === false) {
|
||||
// The component has not been found. we should delete it and it's entPhysical entry
|
||||
echo "-";
|
||||
dbDelete('entPhysical', '`entPhysical_id` = ?', array($array['entPhysical']));
|
||||
$component->deleteComponent($key);
|
||||
}
|
||||
}
|
||||
// Write the Components back to the DB.
|
||||
$component->setComponentPrefs($device['device_id'], $components);
|
||||
echo "\n";
|
||||
} // End if not error
|
149
includes/discovery/entity-physical/entity-physical.inc.php
Normal file
149
includes/discovery/entity-physical/entity-physical.inc.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
echo "\nCaching OIDs:";
|
||||
|
||||
if ($device['os'] == 'junos') {
|
||||
$entity_array = array();
|
||||
echo ' jnxBoxAnatomy';
|
||||
$entity_array = snmpwalk_cache_oid($device, 'jnxBoxAnatomy', $entity_array, 'JUNIPER-MIB');
|
||||
} elseif ($device['os'] == 'timos') {
|
||||
$entity_array = array();
|
||||
echo 'tmnxHwObjs';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'tmnxHwObjs', $entity_array, 'TIMETRA-CHASSIS-MIB', '+'.$config['mib_dir'].'/aos:'.$config['mib_dir']);
|
||||
} else {
|
||||
$entity_array = array();
|
||||
echo ' entPhysicalEntry';
|
||||
$entity_array = snmpwalk_cache_oid($device, 'entPhysicalEntry', $entity_array, 'ENTITY-MIB:CISCO-ENTITY-VENDORTYPE-OID-MIB');
|
||||
echo ' entAliasMappingIdentifier';
|
||||
$entity_array = snmpwalk_cache_twopart_oid($device, 'entAliasMappingIdentifier', $entity_array, 'ENTITY-MIB:IF-MIB');
|
||||
}
|
||||
|
||||
foreach ($entity_array as $entPhysicalIndex => $entry) {
|
||||
if ($device['os'] == 'junos') {
|
||||
// Juniper's MIB doesn't have the same objects as the Entity MIB, so some values
|
||||
// are made up here.
|
||||
$entPhysicalDescr = $entry['jnxContentsDescr'];
|
||||
$entPhysicalContainedIn = $entry['jnxContainersWithin'];
|
||||
$entPhysicalClass = $entry['jnxBoxClass'];
|
||||
$entPhysicalName = $entry['jnxOperatingDescr'];
|
||||
$entPhysicalSerialNum = $entry['jnxContentsSerialNo'];
|
||||
$entPhysicalModelName = $entry['jnxContentsPartNo'];
|
||||
$entPhysicalMfgName = 'Juniper';
|
||||
$entPhysicalVendorType = 'Juniper';
|
||||
$entPhysicalParentRelPos = -1;
|
||||
$entPhysicalHardwareRev = $entry['jnxContentsRevision'];
|
||||
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
|
||||
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
|
||||
$entPhysicalIsFRU = $entry['jnxFruType'];
|
||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||
// fix for issue 1865, $entPhysicalIndex, as it contains a quad dotted number on newer Junipers
|
||||
// using str_replace to remove all dots should fix this even if it changes in future
|
||||
$entPhysicalIndex = str_replace('.', '', $entPhysicalIndex);
|
||||
} elseif ($device['os'] == 'timos') {
|
||||
$entPhysicalDescr = $entry['tmnxCardTypeDescription'];
|
||||
$entPhysicalContainedIn = $entry['tmnxHwContainedIn'];
|
||||
$entPhysicalClass = $entry['tmnxHwClass'];
|
||||
$entPhysicalName = $entry['tmnxCardTypeName'];
|
||||
$entPhysicalSerialNum = $entry['tmnxHwSerialNumber'];
|
||||
$entPhysicalModelName = $entry['tmnxHwMfgBoardNumber'];
|
||||
$entPhysicalMfgName = $entry['tmnxHwMfgBoardNumber'];
|
||||
$entPhysicalVendorType = $entry['tmnxCardTypeName'];
|
||||
$entPhysicalParentRelPos = $entry['tmnxHwParentRelPos'];
|
||||
$entPhysicalHardwareRev = '1.0';
|
||||
$entPhysicalFirmwareRev = $entry['tmnxHwBootCodeVersion'];
|
||||
$entPhysicalSoftwareRev = $entry['tmnxHwBootCodeVersion'];
|
||||
$entPhysicalIsFRU = $entry['tmnxHwIsFRU'];
|
||||
$entPhysicalAlias = $entry['tmnxHwAlias'];
|
||||
$entPhysicalAssetID = $entry['tmnxHwAssetID'];
|
||||
$entPhysicalIndex = str_replace('.', '', $entPhysicalIndex);
|
||||
} else {
|
||||
$entPhysicalDescr = $entry['entPhysicalDescr'];
|
||||
$entPhysicalContainedIn = $entry['entPhysicalContainedIn'];
|
||||
$entPhysicalClass = $entry['entPhysicalClass'];
|
||||
$entPhysicalName = $entry['entPhysicalName'];
|
||||
$entPhysicalSerialNum = $entry['entPhysicalSerialNum'];
|
||||
$entPhysicalModelName = $entry['entPhysicalModelName'];
|
||||
$entPhysicalMfgName = $entry['entPhysicalMfgName'];
|
||||
$entPhysicalVendorType = $entry['entPhysicalVendorType'];
|
||||
$entPhysicalParentRelPos = $entry['entPhysicalParentRelPos'];
|
||||
$entPhysicalHardwareRev = $entry['entPhysicalHardwareRev'];
|
||||
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
|
||||
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
|
||||
$entPhysicalIsFRU = $entry['entPhysicalIsFRU'];
|
||||
$entPhysicalAlias = $entry['entPhysicalAlias'];
|
||||
$entPhysicalAssetID = $entry['entPhysicalAssetID'];
|
||||
}//end if
|
||||
|
||||
if (isset($entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'])) {
|
||||
$ifIndex = $entity_array[$entPhysicalIndex]['0']['entAliasMappingIdentifier'];
|
||||
}
|
||||
|
||||
if (!strpos($ifIndex, 'fIndex') || $ifIndex == '') {
|
||||
unset($ifIndex);
|
||||
} else {
|
||||
$ifIndex_array = explode('.', $ifIndex);
|
||||
$ifIndex = $ifIndex_array[1];
|
||||
}
|
||||
|
||||
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName) {
|
||||
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
|
||||
}
|
||||
|
||||
// FIXME - dbFacile
|
||||
if ($entPhysicalDescr || $entPhysicalName) {
|
||||
$entPhysical_id = dbFetchCell('SELECT entPhysical_id FROM `entPhysical` WHERE device_id = ? AND entPhysicalIndex = ?', array($device['device_id'], $entPhysicalIndex));
|
||||
|
||||
if ($entPhysical_id) {
|
||||
$update_data = array(
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID,
|
||||
);
|
||||
dbUpdate($update_data, 'entPhysical', 'device_id=? AND entPhysicalIndex=?', array($device['device_id'], $entPhysicalIndex));
|
||||
echo '.';
|
||||
} else {
|
||||
$insert_data = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'entPhysicalIndex' => $entPhysicalIndex,
|
||||
'entPhysicalDescr' => $entPhysicalDescr,
|
||||
'entPhysicalClass' => $entPhysicalClass,
|
||||
'entPhysicalName' => $entPhysicalName,
|
||||
'entPhysicalModelName' => $entPhysicalModelName,
|
||||
'entPhysicalSerialNum' => $entPhysicalSerialNum,
|
||||
'entPhysicalContainedIn' => $entPhysicalContainedIn,
|
||||
'entPhysicalMfgName' => $entPhysicalMfgName,
|
||||
'entPhysicalParentRelPos' => $entPhysicalParentRelPos,
|
||||
'entPhysicalVendorType' => $entPhysicalVendorType,
|
||||
'entPhysicalHardwareRev' => $entPhysicalHardwareRev,
|
||||
'entPhysicalFirmwareRev' => $entPhysicalFirmwareRev,
|
||||
'entPhysicalSoftwareRev' => $entPhysicalSoftwareRev,
|
||||
'entPhysicalIsFRU' => $entPhysicalIsFRU,
|
||||
'entPhysicalAlias' => $entPhysicalAlias,
|
||||
'entPhysicalAssetID' => $entPhysicalAssetID,
|
||||
);
|
||||
|
||||
if (!empty($ifIndex)) {
|
||||
$insert_data['ifIndex'] = $ifIndex;
|
||||
}
|
||||
|
||||
dbInsert($insert_data, 'entPhysical');
|
||||
echo '+';
|
||||
}//end if
|
||||
|
||||
$valid[$entPhysicalIndex] = 1;
|
||||
}//end if
|
||||
}//end foreach
|
||||
echo "\n";
|
46
includes/discovery/sensors/power/cimc.inc.php
Normal file
46
includes/discovery/sensors/power/cimc.inc.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to create sensors from Cisco Integrated Management Controllers (CIMC)
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if ($device['os'] == 'cimc') {
|
||||
// Let's add some power sensors.
|
||||
$pwr_board = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.9.14');
|
||||
|
||||
/*
|
||||
* False == OID not found - this is not an error.
|
||||
* null == timeout or something else that caused an error.
|
||||
*/
|
||||
if (is_null($pwr_board)) {
|
||||
echo "Error\n";
|
||||
} else {
|
||||
// No Error, lets process things.
|
||||
$index = 1;
|
||||
|
||||
// Board Input Power
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.14.1.4';
|
||||
$description = "MB Input Power";
|
||||
d_echo($oid." - ".$description." - ".$pwr_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'power', $device, $oid.".".$index, 'mb-input-power', 'cimc', $description, '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
|
||||
// Board Input Current
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.14.1.8';
|
||||
$description = "MB Input Current";
|
||||
d_echo($oid." - ".$description." - ".$pwr_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'current', $device, $oid.".".$index, 'mb-input-current', 'cimc', $description, '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
|
||||
// Board Input Voltage
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.14.1.12';
|
||||
$description = "MB Input Voltage";
|
||||
d_echo($oid." - ".$description." - ".$pwr_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'voltage', $device, $oid.".".$index, 'mb-input-voltage', 'cimc', $description, '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
}
|
||||
}
|
77
includes/discovery/sensors/temperatures/cimc.inc.php
Normal file
77
includes/discovery/sensors/temperatures/cimc.inc.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to create sensors from Cisco Integrated Management Controllers (CIMC)
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if ($device['os'] == 'cimc') {
|
||||
// Let's add some temperature sensors.
|
||||
$temp_board = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.9.44.1');
|
||||
$temp_mem = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.30.12.1');
|
||||
$temp_cpu = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1.41');
|
||||
|
||||
/*
|
||||
* False == OID not found - this is not an error.
|
||||
* null == timeout or something else that caused an error.
|
||||
*/
|
||||
if (is_null($temp_board) || is_null($temp_mem) || is_null($temp_cpu)) {
|
||||
echo "Error\n";
|
||||
} else {
|
||||
// No Error, lets process things.
|
||||
|
||||
// Board Temperatures
|
||||
foreach ($temp_board['1.3.6.1.4.1.9.9.719.1.9.44.1.2'] as $index => $string) {
|
||||
$temp = preg_match('/sys\/(rack-unit-[^,]+)\/board\/temp-stats/', $string, $regexp_result);
|
||||
$description = $regexp_result[1];
|
||||
|
||||
// Ambient Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.44.1.4'.$index;
|
||||
d_echo($oid." - ".$description." - Ambient: ".$temp_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'ambient-'.$index, 'cimc', $description." - Ambient", '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
|
||||
// Front Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.44.1.8'.$index;
|
||||
d_echo($oid." - ".$description." - Front: ".$temp_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'front-'.$index, 'cimc', $description." - Front", '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
|
||||
// Rear Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.44.1.21.'.$index;
|
||||
d_echo($oid." - ".$description." - Rear: ".$temp_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'rear-'.$index, 'cimc', $description." - Rear", '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
|
||||
// IO Hub Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.9.44.1.13.'.$index;
|
||||
d_echo($oid." - ".$description." - IO Hub: ".$temp_board[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'ioh-'.$index, 'cimc', $description." - IO Hub", '1', '1', null, null, null, null, $temp_board[$oid][$index]);
|
||||
}
|
||||
|
||||
// Memory Temperatures
|
||||
foreach ($temp_mem['1.3.6.1.4.1.9.9.719.1.30.12.1.2'] as $index => $string) {
|
||||
$temp = preg_match('/sys\/(rack-unit-[^,]+)\/memarray-1\/(mem-[^,]+)\/dimm-env-stats/', $string, $regexp_result);
|
||||
$description = $regexp_result[1]." - ".$regexp_result[2];
|
||||
|
||||
// DIMM Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.30.12.1.6.'.$index;
|
||||
d_echo($oid." - ".$description." - ".$temp_mem[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'mem-'.$index, 'cimc', $description, '1', '1', null, null, 40, null, $temp_mem[$oid][$index]);
|
||||
}
|
||||
|
||||
// CPU Temperatures
|
||||
foreach ($temp_cpu['1.3.6.1.4.1.9.9.719.1.41.2.1.2'] as $index => $string) {
|
||||
$temp = preg_match('/sys\/(rack-unit-[^,]+)\/board\/(cpu-[^,]+)\/env-stats/', $string, $regexp_result);
|
||||
$description = $regexp_result[1]." - ".$regexp_result[2];
|
||||
|
||||
// CPU Temperature
|
||||
$oid = '.1.3.6.1.4.1.9.9.719.1.41.2.1.10.'.$index;
|
||||
d_echo($oid." - ".$description." - ".$temp_cpu[$oid][$index]."\n");
|
||||
discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'cpu-'.$index, 'cimc', $description, '1', '1', null, null, 40, null, $temp_cpu[$oid][$index]);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1568,3 +1568,82 @@ function hytera_h2f($number, $nd)
|
||||
|
||||
return number_format($floatfinal, $nd, '.', '');
|
||||
}
|
||||
|
||||
/*
|
||||
* Cisco CIMC functions
|
||||
*/
|
||||
// Create an entry in the entPhysical table if it doesnt already exist.
|
||||
function setCIMCentPhysical($location, $data, &$entphysical, &$index)
|
||||
{
|
||||
// Go get the location, this will create it if it doesnt exist.
|
||||
$entPhysicalIndex = getCIMCentPhysical($location, $entphysical, $index);
|
||||
|
||||
// See if we need to update
|
||||
$update = array();
|
||||
foreach ($data as $key => $value) {
|
||||
// Is the Array(DB) value different to the supplied data
|
||||
if ($entphysical[$location][$key] != $value) {
|
||||
$update[$key] = $value;
|
||||
$entphysical[$location][$key] = $value;
|
||||
} // End if
|
||||
} // end foreach
|
||||
|
||||
// Do we need to update
|
||||
if (count($update) > 0) {
|
||||
dbUpdate($update, 'entPhysical', '`entPhysical_id` = ?', array($entphysical[$location]['entPhysical_id']));
|
||||
}
|
||||
$entPhysicalId = $entphysical[$location]['entPhysical_id'];
|
||||
return array($entPhysicalId, $entPhysicalIndex);
|
||||
}
|
||||
|
||||
function getCIMCentPhysical($location, &$entphysical, &$index)
|
||||
{
|
||||
global $device;
|
||||
|
||||
// Level 1 - Does the location exist
|
||||
if (isset($entphysical[$location])) {
|
||||
// Yes, return the entPhysicalIndex.
|
||||
return $entphysical[$location]['entPhysicalIndex'];
|
||||
} else {
|
||||
/*
|
||||
* No, the entry doesnt exist.
|
||||
* Find its parent so we can create it.
|
||||
*/
|
||||
|
||||
// Pull apart the location
|
||||
$parts = explode('/', $location);
|
||||
|
||||
// Level 2 - Are we at the root
|
||||
if (count($parts) == 1) {
|
||||
// Level 2 - Yes. We are the root, there is no parent
|
||||
d_echo("ROOT - ".$location."\n");
|
||||
$shortlocation = $location;
|
||||
$parent = 0;
|
||||
} else {
|
||||
// Level 2 - No. Need to go deeper.
|
||||
d_echo("NON-ROOT - ".$location."\n");
|
||||
$shortlocation = array_pop($parts);
|
||||
$parentlocation = implode('/', $parts);
|
||||
d_echo("Decend - parent location: ".$parentlocation."\n");
|
||||
$parent = getCIMCentPhysical($parentlocation, $entphysical, $index);
|
||||
} // end if - Level 2
|
||||
d_echo("Parent: ".$parent."\n");
|
||||
|
||||
// Now we have an ID, create the entry.
|
||||
$index++;
|
||||
$insert = array(
|
||||
'device_id' => $device['device_id'],
|
||||
'entPhysicalIndex' => $index,
|
||||
'entPhysicalClass' => 'container',
|
||||
'entPhysicalVendorType' => $location,
|
||||
'entPhysicalName' => $shortlocation,
|
||||
'entPhysicalContainedIn' => $parent,
|
||||
'entPhysicalParentRelPos' => '-1',
|
||||
);
|
||||
|
||||
// Add to the DB and Array.
|
||||
$id = dbInsert($insert, 'entPhysical');
|
||||
$entphysical[$location] = dbFetchRow('SELECT * FROM entPhysical WHERE entPhysical_id=?', array($id));
|
||||
return $index;
|
||||
} // end if - Level 1
|
||||
} // end function
|
||||
|
@@ -1,85 +1,18 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == 'ios') {
|
||||
echo "Cisco Cat6xxx/76xx Crossbar : \n";
|
||||
|
||||
$mod_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleModeTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleChannelTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarStatisticsTable', $chan_stats, 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
|
||||
foreach ($mod_stats as $index => $entry) {
|
||||
$group = 'c6kxbar';
|
||||
foreach ($entry as $key => $value) {
|
||||
$subindex = null;
|
||||
$entPhysical_state[$index][$subindex][$group][$key] = $value;
|
||||
}
|
||||
if ($config['enable_inventory']) {
|
||||
// Cisco
|
||||
if ($device['os'] == 'ios') {
|
||||
include 'includes/polling/entity-physical/ios.inc.php';
|
||||
}
|
||||
|
||||
foreach ($chan_stats as $index => $entry) {
|
||||
list($index,$subindex) = explode('.', $index, 2);
|
||||
$group = 'c6kxbar';
|
||||
foreach ($entry as $key => $value) {
|
||||
$entPhysical_state[$index][$subindex][$group][$key] = $value;
|
||||
}
|
||||
// Cisco CIMC
|
||||
if ($device['os'] == 'cimc') {
|
||||
include 'includes/polling/entity-physical/cimc.inc.php';
|
||||
}
|
||||
|
||||
$rrd_name = array('c6kxbar', $index, $subindex);
|
||||
$rrd_def = array(
|
||||
'DS:inutil:GAUGE:600:0:100',
|
||||
'DS:oututil:GAUGE:600:0:100',
|
||||
'DS:outdropped:DERIVE:600:0:125000000000',
|
||||
'DS:outerrors:DERIVE:600:0:125000000000',
|
||||
'DS:inerrors:DERIVE:600:0:125000000000'
|
||||
);
|
||||
|
||||
$fields = array(
|
||||
'inutil' => $entry['cc6kxbarStatisticsInUtil'],
|
||||
'oututil' => $entry['cc6kxbarStatisticsOutUtil'],
|
||||
'outdropped' => $entry['cc6kxbarStatisticsOutDropped'],
|
||||
'outerrors' => $entry['cc6kxbarStatisticsOutErrors'],
|
||||
'inerrors' => $entry['cc6kxbarStatisticsInErrors'],
|
||||
);
|
||||
|
||||
$tags = compact('index', 'subindex', 'rrd_name', 'rrd_def');
|
||||
data_update($device, 'c6kxbar', $tags, $fields);
|
||||
}//end foreach
|
||||
|
||||
// print_r($entPhysical_state);
|
||||
// Update State
|
||||
include 'includes/polling/entity-physical/state.inc.php';
|
||||
} else {
|
||||
echo 'Disabled!';
|
||||
}//end if
|
||||
|
||||
// Set Entity state
|
||||
foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) {
|
||||
if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) {
|
||||
dbDelete(
|
||||
'entPhysical_state',
|
||||
'`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?',
|
||||
array(
|
||||
$device['device_id'],
|
||||
$entity['entPhysicalIndex'],
|
||||
$entity['subindex'],
|
||||
$entity['group'],
|
||||
$entity['key'],
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) {
|
||||
echo 'no match!';
|
||||
}
|
||||
|
||||
unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]);
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
// End Set Entity Attrivs
|
||||
// Delete Entity state
|
||||
foreach ($entPhysical_state as $epi => $entity) {
|
||||
foreach ($entity as $subindex => $si) {
|
||||
foreach ($si as $group => $ti) {
|
||||
foreach ($ti as $key => $value) {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// End Delete Entity state
|
||||
echo "\n";
|
||||
|
80
includes/polling/entity-physical/cimc.inc.php
Normal file
80
includes/polling/entity-physical/cimc.inc.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS module to poll hardware components in a Cisco Integrated Management Controller
|
||||
*
|
||||
* Copyright (c) 2016 Aaron Daniels <aaron@daniels.id.au>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$component = new LibreNMS\Component();
|
||||
$components = $component->getComponents($device['device_id'], array('type'=>'Cisco-CIMC'));
|
||||
|
||||
// We only care about our device id.
|
||||
$components = $components[$device['device_id']];
|
||||
|
||||
// Only collect SNMP data if we have enabled components
|
||||
if (count($components > 0)) {
|
||||
// Let's gather some data..
|
||||
$tblUCSObjects = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.719.1', 0);
|
||||
|
||||
// Make sure we have an array of data before we try to iterate over it
|
||||
if (is_array($tblUCSObjects)) {
|
||||
// First, let's extract any active faults, we will use them later.
|
||||
$faults = array();
|
||||
foreach ($tblUCSObjects as $oid => $data) {
|
||||
if (strstr($oid, '1.3.6.1.4.1.9.9.719.1.1.1.1.5.')) {
|
||||
$id = substr($oid, 30);
|
||||
$fobj = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.5.'.$id];
|
||||
$fobj = preg_replace('/^sys/', '/sys', $fobj);
|
||||
$faults[$fobj] = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.11.'.$id];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($components as &$array) {
|
||||
/*
|
||||
* Because our discovery module was nice and stored the OID we need to
|
||||
* poll for status, this is quite straight forward.
|
||||
*
|
||||
* Was the status oid found in the list?
|
||||
*/
|
||||
if (isset($tblUCSObjects[$array['statusoid']])) {
|
||||
if ($tblUCSObjects[$array['statusoid']] != 1) {
|
||||
// Yes, report an error
|
||||
$array['status'] = 2;
|
||||
$array['error'] = "Error Operability Code: ".$tblUCSObjects[$array['statusoid']]."\n";
|
||||
} else {
|
||||
// No, unset any errors that may exist.
|
||||
$array['status'] = 0;
|
||||
$array['error'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// if the type is chassis, we may have to add generic chassis faults
|
||||
if ($array['hwtype'] == 'chassis') {
|
||||
// See if there are any errors on this chassis.
|
||||
foreach ($faults as $key => $value) {
|
||||
if (strstr($key, $array['label'])) {
|
||||
// The fault is on this chassis.
|
||||
$array['status'] = 2;
|
||||
$array['error'] .= $value."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print some debugging
|
||||
if ($array['status'] == 0) {
|
||||
d_echo($array['label']." - Ok\n");
|
||||
} else {
|
||||
d_echo($array['label']." - ".$array['error']."\n");
|
||||
}
|
||||
} // End foreach components
|
||||
// Write the Components back to the DB.
|
||||
$component->setComponentPrefs($device['device_id'], $components);
|
||||
} // End is_array
|
||||
echo "\n";
|
||||
} // End if not error
|
43
includes/polling/entity-physical/ios.inc.php
Normal file
43
includes/polling/entity-physical/ios.inc.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
echo "Cisco Cat6xxx/76xx Crossbar : \n";
|
||||
|
||||
$mod_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleModeTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleChannelTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarStatisticsTable', $chan_stats, 'CISCO-CAT6K-CROSSBAR-MIB');
|
||||
|
||||
foreach ($mod_stats as $index => $entry) {
|
||||
$group = 'c6kxbar';
|
||||
foreach ($entry as $key => $value) {
|
||||
$subindex = null;
|
||||
$entPhysical_state[$index][$subindex][$group][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($chan_stats as $index => $entry) {
|
||||
list($index,$subindex) = explode('.', $index, 2);
|
||||
$group = 'c6kxbar';
|
||||
foreach ($entry as $key => $value) {
|
||||
$entPhysical_state[$index][$subindex][$group][$key] = $value;
|
||||
}
|
||||
|
||||
$rrd_name = array('c6kxbar', $index, $subindex);
|
||||
$rrd_def = array(
|
||||
'DS:inutil:GAUGE:600:0:100',
|
||||
'DS:oututil:GAUGE:600:0:100',
|
||||
'DS:outdropped:DERIVE:600:0:125000000000',
|
||||
'DS:outerrors:DERIVE:600:0:125000000000',
|
||||
'DS:inerrors:DERIVE:600:0:125000000000'
|
||||
);
|
||||
|
||||
$fields = array(
|
||||
'inutil' => $entry['cc6kxbarStatisticsInUtil'],
|
||||
'oututil' => $entry['cc6kxbarStatisticsOutUtil'],
|
||||
'outdropped' => $entry['cc6kxbarStatisticsOutDropped'],
|
||||
'outerrors' => $entry['cc6kxbarStatisticsOutErrors'],
|
||||
'inerrors' => $entry['cc6kxbarStatisticsInErrors'],
|
||||
);
|
||||
|
||||
$tags = compact('index', 'subindex', 'rrd_name', 'rrd_def');
|
||||
data_update($device, 'c6kxbar', $tags, $fields);
|
||||
}//end foreach
|
36
includes/polling/entity-physical/state.inc.php
Normal file
36
includes/polling/entity-physical/state.inc.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// Set Entity state
|
||||
foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', array($device['device_id'])) as $entity) {
|
||||
if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']])) {
|
||||
dbDelete(
|
||||
'entPhysical_state',
|
||||
'`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?',
|
||||
array(
|
||||
$device['device_id'],
|
||||
$entity['entPhysicalIndex'],
|
||||
$entity['subindex'],
|
||||
$entity['group'],
|
||||
$entity['key'],
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value']) {
|
||||
echo 'no match!';
|
||||
}
|
||||
|
||||
unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]);
|
||||
}
|
||||
}//end foreach
|
||||
|
||||
// End Set Entity Attrivs
|
||||
// Delete Entity state
|
||||
foreach ($entPhysical_state as $epi => $entity) {
|
||||
foreach ($entity as $subindex => $si) {
|
||||
foreach ($si as $group => $ti) {
|
||||
foreach ($ti as $key => $value) {
|
||||
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state');
|
||||
}
|
||||
}
|
||||
}
|
||||
} // End Delete Entity state
|
Reference in New Issue
Block a user