Issues (2963)

discovery/sensors/frequency/eaton-ats.inc.php (1 issue)

Labels
Severity
1
<?php
2
/*
3
 * LibreNMS
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
 * @link       https://www.librenms.org
13
 * @copyright  2017 Thomas GAGNIERE
14
 * @author     Thomas GAGNIERE <[email protected]>
15
 */
16
17
echo 'EATON-ATS ';
18
19
$oids = snmpwalk_cache_oid($device, 'ats2InputFrequency', [], 'EATON-ATS2-MIB');
20
foreach ($oids as $volt_id => $data) {
21
    $source_oid = 'EATON-ATS2-MIB::ats2InputIndex.' . $volt_id;
22
    $num_id = snmp_get($device, $source_oid, '-Oqve');
23
    $volt_oid = '.1.3.6.1.4.1.534.10.2.2.2.1.3.' . $num_id;
0 ignored issues
show
Are you sure $num_id 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

23
    $volt_oid = '.1.3.6.1.4.1.534.10.2.2.2.1.3.' . /** @scrutinizer ignore-type */ $num_id;
Loading history...
24
    $index = '.1.3.6.1.4.1.534.10.2.2.2.1.1.' . $num_id;
25
    $descr = 'Input';
26
    if (count($oids) > 1) {
27
        $source = snmp_get($device, $source_oid, '-Oqv');
28
        $descr .= " $source";
29
    }
30
    $type = 'eaton-ats';
31
    $divisor = 10;
32
    $current = $data['ats2InputFrequency'] / $divisor;
33
34
    discover_sensor($valid['sensor'], 'frequency', $device, $volt_oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current);
35
}
36