Issues (2963)

includes/discovery/sensors/fanspeed/nos.inc.php (1 issue)

1
<?php
2
/*
3
 * LibreNMS module for Brocade NOS fanspeed sensor
4
 *
5
 * Copyright (c) 2016 Maxence POULAIN <[email protected]>
6
 *
7
 * This program is free software: you can redistribute it and/or modify it
8
 * under the terms of the GNU General Public License as published by the
9
 * Free Software Foundation, either version 3 of the License, or (at your
10
 * option) any later version.  Please see LICENSE.txt at the top level of
11
 * the source code distribution for details.
12
 */
13
14
$oids = snmp_walk($device, '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.2', '-Osqn');
15
$oids = trim($oids);
16
foreach (explode("\n", $oids) as $data) {
17
    $data = trim($data);
18
    [$dataoid,$dataval] = explode(' ', $data);
19
    $oidparts = explode('.', $dataoid);
20
    $oididx = $oidparts[count($oidparts) - 1];
21
    if ($data and $dataval == '2') {
22
        $value_oid = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.4.' . $oididx;
23
        $descr_oid = '.1.3.6.1.4.1.1588.2.1.1.1.1.22.1.5.' . $oididx;
24
        $value = snmp_get($device, $value_oid, '-Oqv');
25
        $descr = snmp_get($device, $descr_oid, '-Oqv');
26
        if (! strstr($descr, 'No') and ! strstr($value, 'No')) {
0 ignored issues
show
It seems like $descr can also be of type false; however, parameter $haystack of strstr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

26
        if (! strstr(/** @scrutinizer ignore-type */ $descr, 'No') and ! strstr($value, 'No')) {
Loading history...
27
            $descr = str_replace('"', '', $descr);
28
            $descr = trim($descr);
29
            discover_sensor($valid['sensor'], 'fanspeed', $device, $value_oid, $oididx, 'nos', $descr, '1', '1', null, null, '80', '100', $value);
30
        }
31
    }
32
}
33