Issues (2963)

includes/discovery/sensors/state/asa.inc.php (1 issue)

1
<?php
2
/*
3
 * LibreNMS
4
 *
5
 * Copyright (c) 2016 Søren Friis Rosiak <[email protected]>
6
 * This program is free software: you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License as published by the
8
 * Free Software Foundation, either version 3 of the License, or (at your
9
 * option) any later version.  Please see LICENSE.txt at the top level of
10
 * the source code distribution for details.
11
 */
12
13
$temp = snmpwalk_cache_multi_oid($device, 'cfwHardwareStatusTable', [], 'CISCO-FIREWALL-MIB');
14
$cur_oid = '.1.3.6.1.4.1.9.9.147.1.2.1.1.1.3.';
15
16
if (is_array($temp)) {
17
    //Create State Index
18
    if (strstr($temp['netInterface']['cfwHardwareStatusDetail'], 'not Configured') == false) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing strstr($temp['netInterfa...il'], 'not Configured') of type string to the boolean false. If you are specifically checking for an empty string, consider using the more explicit === '' instead.
Loading history...
19
        $state_name = 'cfwHardwareStatus';
20
        $states = [
21
            ['value' => 1, 'generic' => 2, 'graph' => 0, 'descr' => 'other'],
22
            ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'up'],
23
            ['value' => 3, 'generic' => 2, 'graph' => 0, 'descr' => 'down'],
24
            ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'error'],
25
            ['value' => 5, 'generic' => 2, 'graph' => 0, 'descr' => 'overTemp'],
26
            ['value' => 6, 'generic' => 2, 'graph' => 0, 'descr' => 'busy'],
27
            ['value' => 7, 'generic' => 2, 'graph' => 0, 'descr' => 'noMedia'],
28
            ['value' => 8, 'generic' => 2, 'graph' => 0, 'descr' => 'backup'],
29
            ['value' => 9, 'generic' => 0, 'graph' => 0, 'descr' => 'active'],
30
            ['value' => 10, 'generic' => 0, 'graph' => 0, 'descr' => 'standby'],
31
        ];
32
        create_state_index($state_name, $states);
33
34
        foreach ($temp as $index => $entry) {
35
            $descr = ucwords(trim(preg_replace('/\s*\([^\s)]*\)/', '', $temp[$index]['cfwHardwareInformation'])));
36
            if ($index == 'netInterface') {
37
                $index = 4;
38
            } elseif ($index == 'primaryUnit') {
39
                $index = 6;
40
            } elseif ($index == 'secondaryUnit') {
41
                $index = 7;
42
            }
43
            //Discover Sensors
44
            discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][' cfwHardwareStatusValue'], 'snmp', $index);
45
46
            //Create Sensor To State Index
47
            create_sensor_to_state_index($device, $state_name, $index);
48
        }
49
    }
50
}
51