Remove CIMC custom inventory code (#16305)

No test data and it is too complex and strange to update without data.
If someone wants to update and re-submit it, they are welcome to.
This commit is contained in:
Tony Murray
2024-08-21 05:24:30 -05:00
committed by GitHub
parent 3c67de2311
commit 35967dc98d
4 changed files with 0 additions and 212 deletions
-81
View File
@@ -667,87 +667,6 @@ 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 = [];
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` = ?', [$entphysical[$location]['entPhysical_id']]);
}
$entPhysicalId = $entphysical[$location]['entPhysical_id'];
return [$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 = [
'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=?', [$id]);
return $index;
} // end if - Level 1
} // end function
function q_bridge_bits2indices($hex_data)
{
/* convert hex string to an array of 1-based indices of the nonzero bits
@@ -26,10 +26,6 @@ foreach (PluginManager::call(DeviceOverviewHook::class, ['device' => DeviceCache
require 'overview/ports.inc.php';
if ($device['os'] == 'cimc') {
require 'overview/cimc.inc.php';
}
if ($device['os'] == 'ping') {
require 'overview/ping.inc.php';
}
@@ -1,47 +0,0 @@
<?php
$component = new LibreNMS\Component();
$components = $component->getComponents($device['device_id'], ['type'=>'Cisco-CIMC']);
// We only care about our device id.
$components = $components[$device['device_id']];
if (! empty($components)) {
?>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default panel-condensed">
<div class="panel-heading">
<i class="fa fa-cogs fa-lg icon-theme" aria-hidden="true"></i> <strong>Hardware Components</strong>
</div>
<table class="table table-hover table-condensed table-striped">
<?php
foreach ($components as $component => $array) {
if ($array['disabled'] == 1) {
continue;
} elseif ($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>
<?php
}
@@ -1,80 +0,0 @@
<?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'], ['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 (! empty($components)) {
// 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 = [];
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