1 | <?php |
||
2 | |||
3 | $divisor = '1000'; |
||
4 | $multiplier = '1'; |
||
5 | |||
6 | // Check Inlets PDU2 MIB |
||
7 | $inlet_oids = snmp_walk($device, 'inletLabel', '-Osqn', 'PDU2-MIB'); |
||
8 | $inlet_oids = trim($inlet_oids); |
||
9 | if ($inlet_oids) { |
||
10 | d_echo('PDU2 MIB Inlet'); |
||
11 | foreach (explode("\n", $inlet_oids) as $inlet_data) { |
||
12 | $inlet_data = trim($inlet_data); |
||
13 | if ($inlet_data) { |
||
14 | [$inlet_oid,$inlet_descr] = explode(' ', $inlet_data, 2); |
||
15 | $inlet_split_oid = explode('.', $inlet_oid); |
||
16 | $inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)] . '.' . $inlet_split_oid[(count($inlet_split_oid) - 1)]; |
||
17 | $inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.1"; |
||
18 | $inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB')); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
19 | $inlet_current = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.1", '-Ovq', 'PDU2-MIB') / $inlet_divisor); |
||
20 | if ($inlet_current >= 0) { |
||
21 | discover_sensor($valid['sensor'], 'current', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, $multiplier, null, null, null, null, $inlet_current); |
||
22 | } |
||
23 | } |
||
24 | } |
||
25 | } |
||
26 | |||
27 | // Check for per-outlet polling PDU-MIB |
||
28 | $outlet_oids = snmp_walk($device, 'outletIndex', '-Osqn', 'PDU-MIB'); |
||
29 | $outlet_oids = trim($outlet_oids); |
||
30 | if ($outlet_oids) { |
||
31 | d_echo('PDU MIB Outlets'); |
||
32 | foreach (explode("\n", $outlet_oids) as $outlet_data) { |
||
33 | $outlet_data = trim($outlet_data); |
||
34 | if ($outlet_data) { |
||
35 | [$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2); |
||
36 | $outlet_split_oid = explode('.', $outlet_oid); |
||
37 | $outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)]; |
||
38 | $outletsuffix = "$outlet_index"; |
||
39 | $outlet_insert_index = $outlet_index; |
||
40 | // outletLoadValue: "A non-negative value indicates the measured load in milli Amps" |
||
41 | $outlet_oid = ".1.3.6.1.4.1.13742.4.1.2.2.1.4.$outletsuffix"; |
||
42 | $outlet_descr = snmp_get($device, "outletLabel.$outletsuffix", '-Ovq', 'PDU-MIB'); |
||
43 | $outlet_low_warn_limit = snmp_get($device, "outletCurrentLowerWarning.$outletsuffix", '-Ovq', 'PDU-MIB') / $divisor; |
||
44 | $outlet_low_limit = snmp_get($device, "outletCurrentLowerCritical.$outletsuffix", '-Ovq', 'PDU-MIB') / $divisor; |
||
45 | $outlet_high_warn_limit = snmp_get($device, "outletCurrentUpperWarning.$outletsuffix", '-Ovq', 'PDU-MIB') / $divisor; |
||
46 | $outlet_high_limit = snmp_get($device, "outletCurrentUpperCritical.$outletsuffix", '-Ovq', 'PDU-MIB') / $divisor; |
||
47 | $outlet_current = snmp_get($device, "outletCurrent.$outletsuffix", '-Ovq', 'PDU-MIB') / $divisor; |
||
48 | if ($outlet_current >= 0) { |
||
49 | discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_current); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | // Check for per-outlet polling PDU2-MIB |
||
56 | $outlet_oids = snmp_walk($device, '.1.3.6.1.4.1.13742.6.3.5.3.1.2.1', '-Osqn', 'PDU2-MIB'); |
||
57 | $outlet_oids = trim($outlet_oids); |
||
58 | if ($outlet_oids) { |
||
59 | d_echo('PDU2 MIB Outlets'); |
||
60 | foreach (explode("\n", $outlet_oids) as $outlet_data) { |
||
61 | $outlet_data = trim($outlet_data); |
||
62 | if ($outlet_data) { |
||
63 | [$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2); |
||
64 | $outlet_split_oid = explode('.', $outlet_oid); |
||
65 | $outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)]; |
||
66 | $outletsuffix = "$outlet_index"; |
||
67 | $outlet_insert_index = $outlet_index; |
||
68 | $outlet_oid = ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.$outletsuffix.1"; |
||
69 | $outlet_descr = snmp_get($device, "outletName.1.$outletsuffix", '-Ovq', 'PDU2-MIB'); |
||
70 | if (! $outlet_descr) { |
||
71 | $outlet_descr = 'Outlet ' . $outletsuffix; |
||
72 | } |
||
73 | $outlet_low_warn_limit = snmp_get($device, "outletSensorSignedLowerWarningThreshold.1.$outlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'); |
||
74 | $outlet_low_limit = snmp_get($device, "outletSensorSignedLowerCriticalThreshold.1.$outlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'); |
||
75 | $outlet_high_warn_limit = snmp_get($device, "outletSensorSignedUpperWarningThreshold.1.$outlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'); |
||
76 | $outlet_high_limit = snmp_get($device, "outletSensorSignedUpperCriticalThreshold.1.$outlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'); |
||
77 | $outlet_divisor = pow(10, snmp_get($device, "outletSensorDecimalDigits.1.$outlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB')); |
||
78 | $outlet_power = (snmp_get($device, "measurementsOutletSensorValue.1.$outlet_index.1", '-Ovq', 'PDU2-MIB') / $outlet_divisor); |
||
79 | if ($outlet_power >= 0) { |
||
80 | discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $outlet_divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_power); |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * raritan.inc.php |
||
88 | * |
||
89 | * LibreNMS current sensor discovery module for Raritan |
||
90 | * |
||
91 | * This program is free software: you can redistribute it and/or modify |
||
92 | * it under the terms of the GNU General Public License as published by |
||
93 | * the Free Software Foundation, either version 3 of the License, or |
||
94 | * (at your option) any later version. |
||
95 | * |
||
96 | * This program is distributed in the hope that it will be useful, |
||
97 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
98 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
99 | * GNU General Public License for more details. |
||
100 | * |
||
101 | * You should have received a copy of the GNU General Public License |
||
102 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
103 | * |
||
104 | * @link https://www.librenms.org |
||
105 | * |
||
106 | * @copyright 2017 Neil Lathwood |
||
107 | * @author Neil Lathwood <[email protected]> |
||
108 | */ |
||
109 | foreach ($pre_cache['raritan_inletTable'] as $index => $raritan_data) { |
||
110 | for ($x = 1; $x <= $raritan_data['inletPoleCount']; $x++) { |
||
111 | $tmp_index = "$index.$x"; |
||
112 | $new_index = "inletPoleCurrent.$tmp_index"; |
||
113 | $oid = '.1.3.6.1.4.1.13742.4.1.21.2.1.3.' . $tmp_index; |
||
114 | $descr = 'Inlet ' . $pre_cache['raritan_inletPoleTable'][$index][$x]['inletPoleLabel']; |
||
115 | $divisor = 1000; |
||
116 | $low_limit = $raritan_data['inletCurrentUpperCritical'] / $divisor; |
||
117 | $low_warn_limit = $raritan_data['inletCurrentUpperWarning'] / $divisor; |
||
118 | $warn_limit = $raritan_data['inletCurrentLowerWarning'] / $divisor; |
||
119 | $high_limit = $raritan_data['inletCurrentLowerCritical'] / $divisor; |
||
120 | $current = $pre_cache['raritan_inletPoleTable'][$index][$x]['inletPoleCurrent'] / $divisor; |
||
121 | discover_sensor($valid['sensor'], 'current', $device, $oid, $tmp_index, 'raritan', $descr, $divisor, 1, $low_limit, $low_limit, $warn_limit, $high_limit, $current); |
||
122 | } |
||
123 | } |
||
124 |