Fix misc Cisco polling errors (#16307)

* Fix misc Cisco polling errors

* Apply fixes from StyleCI

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
This commit is contained in:
Tony Murray
2024-08-21 05:22:37 -05:00
committed by GitHub
parent 46396a9393
commit 3c67de2311
8 changed files with 22 additions and 19 deletions

View File

@@ -23,7 +23,7 @@ if ($device['os_group'] == 'cisco') {
$components = $component->getComponents($device['device_id'], $options);
// We only care about our device id.
$components = $components[$device['device_id']];
$components = $components[$device['device_id']] ?? null;
// Only collect SNMP data if we have enabled components
if (is_array($components) && count($components) > 0) {

View File

@@ -15,7 +15,7 @@ if ($device['os_group'] == 'cisco') {
d_echo($cefs);
if (is_array($cefs)) {
if (! is_array($entity_array)) {
if (! isset($entity_array) || ! is_array($entity_array)) {
echo 'Caching OIDs: ';
$entity_array = [];
echo ' entPhysicalDescr';
@@ -93,11 +93,13 @@ if ($device['os_group'] == 'cisco') {
}//end if
// FIXME - need to delete old ones. FIXME REALLY.
print_r($cefs_db);
if (! empty($cefs_db)) {
print_r($cefs_db);
foreach ((array) $cefs_db as $cef_switching_id) {
dbDelete('cef_switching', '`cef_switching_id` = ?', [$cef_switching_id]);
echo '-';
foreach ((array) $cefs_db as $cef_switching_id) {
dbDelete('cef_switching', '`cef_switching_id` = ?', [$cef_switching_id]);
echo '-';
}
}
echo "\n";

View File

@@ -66,7 +66,7 @@ if ($device['os_group'] == 'cisco') {
$components = $component->getComponents($device['device_id'], $options);
// We only care about our device id.
$components = $components[$device['device_id']];
$components = $components[$device['device_id']] ?? null;
// Only collect SNMP data if we have enabled components
if (is_array($components) && count($components) > 0) {

View File

@@ -35,6 +35,11 @@ use LibreNMS\RRD\RrdDefinition;
if ($device['os_group'] == 'cisco') {
$oid_list = ['crasEmailNumSessions.0', 'crasIPSecNumSessions.0', 'crasL2LNumSessions.0', 'crasLBNumSessions.0', 'crasSVCNumSessions.0', 'crasWebvpnNumSessions.0'];
$data = snmp_get_multi($device, $oid_list, '-OUQs', 'CISCO-REMOTE-ACCESS-MONITOR-MIB');
if (empty($data[0])) {
return;
}
$data = $data[0];
// Some ASAs return 'No Such Object available on this agent at this OID'

View File

@@ -16,7 +16,7 @@ use LibreNMS\RRD\RrdDefinition;
if ($device['os_group'] == 'cisco') {
// Total
$total = 0;
$output = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.2.1.1.6', null);
$output = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.2.1.1.6');
if (is_array($output)) {
foreach ($output as $key => $value) {
$total += $value[''];
@@ -25,7 +25,7 @@ if ($device['os_group'] == 'cisco') {
if (isset($total) && $total > 0) {
// Active
$active = 0;
foreach (snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.2.1.1.7', null) as $key => $value) {
foreach (snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.2.1.1.7') as $key => $value) {
$active += $value[''];
}

View File

@@ -15,13 +15,11 @@ use LibreNMS\RRD\RrdDefinition;
if ($device['os_group'] == 'cisco') {
// Total
$total = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.6.4.1.3', null);
$total = $total['1.3.6.1.4.1.9.9.86.1.6.4.1.3'][''];
$total = SnmpQuery::get('1.3.6.1.4.1.9.9.86.1.6.4.1.3')->value();
if (isset($total) && $total > 0) {
// Available
$available = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.6.4.1.4', null);
$available = $available['1.3.6.1.4.1.9.9.86.1.6.4.1.4'][''];
$available = SnmpQuery::get('1.3.6.1.4.1.9.9.86.1.6.4.1.4')->value();
// Active
$active = $total - $available;

View File

@@ -15,13 +15,11 @@ use LibreNMS\RRD\RrdDefinition;
if ($device['os_group'] == 'cisco') {
// Total
$total = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.7.1.0', null);
$total = $total['1.3.6.1.4.1.9.9.86.1.7.1.0'][''];
$total = SnmpQuery::get('1.3.6.1.4.1.9.9.86.1.7.1.0')->value();
if (isset($total) && $total > 0) {
if (is_numeric($total) && $total > 0) {
// Available
$available = snmpwalk_cache_oid_num($device, '1.3.6.1.4.1.9.9.86.1.7.2.0', null);
$available = $available['1.3.6.1.4.1.9.9.86.1.7.2.0'][''];
$available = SnmpQuery::get('1.3.6.1.4.1.9.9.86.1.7.2.0')->value();
// Active
$active = $total - $available;

View File

@@ -16,7 +16,7 @@ use LibreNMS\RRD\RrdDefinition;
if ($device['os_group'] == 'cisco') {
$output = snmpwalk_cache_oid($device, 'cvCallVolConnActiveConnection', [], 'CISCO-VOICE-DIAL-CONTROL-MIB');
d_echo($output);
if (is_array($output)) {
if (is_array($output) && ! empty($output)) {
$rrd_def = RrdDefinition::make()
->addDataset('h323', 'GAUGE', 0)
->addDataset('sip', 'GAUGE', 0)