Issues (2963)

discovery/sensors/voltage/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, 'ats2InputVoltage', [], 'EATON-ATS2-MIB');
20
foreach ($oids as $volt_id => $data) {
21
    //we need to retrieve the numerical value of oid
22
    $source_oid = 'EATON-ATS2-MIB::ats2InputIndex.' . $volt_id;
23
    $num_id = snmp_get($device, $source_oid, '-Oqve');
24
    $volt_oid = '.1.3.6.1.4.1.534.10.2.2.2.1.2.' . $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

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