Issues (2963)

includes/discovery/sensors/count/cisco.inc.php (1 issue)

1
<?php
2
/*
3
 * LibreNMS - Cisco count sensors
4
 *
5
 * This program is free software: you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License as published by the
7
 * Free Software Foundation, either version 3 of the License, or (at your
8
 * option) any later version.  Please see LICENSE.txt at the top level of
9
 * the source code distribution for details.
10
 *
11
 * @package    LibreNMS
12
 * @subpackage webui
13
 * @link       http://librenms.org
14
 * @copyright  2021 LibreNMS
15
 * @author     LibreNMS Contributors
16
*/
17
18
$tables = [
19
    ['num_oid' => '.1.3.6.1.4.1.9.9.661.1.3.2.1.6.',    'oid' => 'c3gGsmNumberOfNearbyCell',   'state_name' => 'c3gGsmNumberOfNearbyCell',   'mib' => 'CISCO-WAN-3G-MIB',       'descr' => 'Nearby cells'],
20
    ['num_oid' => '.1.3.6.1.4.1.9.9.817.1.1.1.1.1.6.',    'oid' => 'cwceLteCurrOperatingBand', 'state_name' => 'cwceLteCurrOperatingBand',   'mib' => 'CISCO-WAN-CELL-EXT-MIB', 'descr' => 'Cellular operating band'],
21
];
22
23
foreach ($tables as $tablevalue) {
24
    $temp = snmpwalk_cache_multi_oid($device, $tablevalue['oid'], [], $tablevalue['mib']);
25
    $cur_oid = $tablevalue['num_oid'];
26
    $state_name = $tablevalue['state_name'];
27
    foreach ($temp as $index => $entry) {
28
        //Discover Sensors
29
        $descr = ucwords($temp[$index][$tablevalue['descr']]);
30
        if ($state_name == 'c3gGsmNumberOfNearbyCell' || $state_name == 'cwceLteCurrOperatingBand') {
31
            $descr = snmp_get($device, 'entPhysicalName.' . $index, '-Oqv', 'ENTITY-MIB') . ' - ' . $tablevalue['descr'];
0 ignored issues
show
Are you sure snmp_get($device, 'entPh..., '-Oqv', 'ENTITY-MIB') of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
            $descr = /** @scrutinizer ignore-type */ snmp_get($device, 'entPhysicalName.' . $index, '-Oqv', 'ENTITY-MIB') . ' - ' . $tablevalue['descr'];
Loading history...
32
        }
33
        discover_sensor($valid['sensor'], 'count', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][$tablevalue['state_name']], 'snmp', $index);
34
    }
35
}
36