Skip to content

Commit

Permalink
Fix Cisco ASA HA state sensors - Issue ID librenms#16544 (librenms#16770
Browse files Browse the repository at this point in the history
)

* Cisco ASA fix for librenms#16544

ASA Fix for librenms#16544

Previous version had an index translation to an integer, but the $temp table doesn't contain integer keys. Removed.

Additionally, the discover_sensor had an erroneous space in the array column key

* Update asa.json

* Update asa.inc.php

* Fix Cisco ASA state sensor discovery

* Update Cisco ASA Test Data

* Update asa.json

* Remove lookup table. use SNMP flags instead

* Migrate to SnmpQuery
  • Loading branch information
rudybroersma authored Nov 26, 2024
1 parent df44d1c commit f783721
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions includes/discovery/sensors/state/asa.inc.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<?php
/*
* LibreNMS
* asa.inc.php
*
* LibreNMS state sensor discovery module for Cisco ASA appliances
*
* Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
* 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.
*
* @link https://www.librenms.org
*
* @copyright 2016 Søren Friis Rosiak <[email protected]>
* @author Søren Friis Rosiak <[email protected]>
* @copyright 2024 CTNET BV
* @author Rudy Broersma <[email protected]>
*/

$temp = snmpwalk_cache_multi_oid($device, 'cfwHardwareStatusTable', [], 'CISCO-FIREWALL-MIB');
$cur_oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.';
$temp = SnmpQuery::cache()->walk('CISCO-FIREWALL-MIB::cfwHardwareStatusTable')->table(1);

if (is_array($temp)) {
//Create State Index
if (strstr($temp['netInterface']['cfwHardwareStatusDetail'], 'not Configured') == false) {
if (strstr($temp['netInterface']['CISCO-FIREWALL-MIB::cfwHardwareStatusDetail'], 'not Configured') == false) {
$state_name = 'cfwHardwareStatus';
$states = [
['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'other'],
Expand All @@ -32,19 +40,23 @@
create_state_index($state_name, $states);

foreach ($temp as $index => $entry) {
$descr = ucwords(trim(preg_replace('/\s*\([^\s)]*\)/', '', $temp[$index]['cfwHardwareInformation'])));
$descr = ucwords(trim(preg_replace('/\s*\([^\s)]*\)/', '', $temp[$index]['CISCO-FIREWALL-MIB::cfwHardwareInformation'])));

if ($index == 'netInterface') {
$index = 4;
$oid_index = 4;
} elseif ($index == 'primaryUnit') {
$index = 6;
$oid_index = 6;
} elseif ($index == 'secondaryUnit') {
$index = 7;
$oid_index = 7;
}

$sensor_value = $temp[$index]['CISCO-FIREWALL-MIB::cfwHardwareStatusValue'];

//Discover Sensors
discover_sensor(null, 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][' cfwHardwareStatusValue'], 'snmp', $index);
discover_sensor(null, 'state', $device, $cur_oid . $oid_index, $oid_index, $state_name, $descr, 1, 1, null, null, null, null, $sensor_value, 'snmp', $oid_index);

//Create Sensor To State Index
create_sensor_to_state_index($device, $state_name, $index);
create_sensor_to_state_index($device, $state_name, $oid_index);
}
}
}

0 comments on commit f783721

Please sign in to comment.