mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 00:24:21 +02:00
Fix coding style part 2
This commit is contained in:
@@ -12,22 +12,21 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if ($device['os'] == "dsm") {
|
||||
if ($device['os'] == 'dsm') {
|
||||
echo 'DSM UPS Power';
|
||||
|
||||
echo "DSM UPS Power";
|
||||
|
||||
// UPS Device Manufacturer, example return : SNMPv2-SMI::enterprises.6574.4.1.2.0 = STRING: "American Power Conversion"
|
||||
$ups_device_manufacturer_oid = '.1.3.6.1.4.1.6574.4.1.2.0';
|
||||
$ups_device_manufacturer = str_replace('"', '', snmp_get($device, $ups_device_manufacturer_oid, "-Oqv"));
|
||||
// UPS Device Model, example return : SNMPv2-SMI::enterprises.6574.4.1.1.0 = STRING: "Back-UPS RS 900G"
|
||||
$ups_device_model_oid = '.1.3.6.1.4.1.6574.4.1.1.0';
|
||||
$ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model_oid, "-Oqv"));
|
||||
// UPS Device Manufacturer, example return : SNMPv2-SMI::enterprises.6574.4.1.2.0 = STRING: "American Power Conversion"
|
||||
$ups_device_manufacturer_oid = '.1.3.6.1.4.1.6574.4.1.2.0';
|
||||
$ups_device_manufacturer = str_replace('"', '', snmp_get($device, $ups_device_manufacturer_oid, '-Oqv'));
|
||||
// UPS Device Model, example return : SNMPv2-SMI::enterprises.6574.4.1.1.0 = STRING: "Back-UPS RS 900G"
|
||||
$ups_device_model_oid = '.1.3.6.1.4.1.6574.4.1.1.0';
|
||||
$ups_device_model = str_replace('"', '', snmp_get($device, $ups_device_model_oid, '-Oqv'));
|
||||
|
||||
|
||||
// UPS Info Real Power Nominal, example return : SNMPv2-SMI::enterprises.6574.4.2.21.2.0 = Opaque: Float: 540.000000
|
||||
$ups_real_power_nominal_oid = '.1.3.6.1.4.1.6574.4.2.21.2.0';
|
||||
$ups_real_power_nominal = snmp_get($device, $ups_real_power_nominal_oid, "-Oqv");
|
||||
if (is_numeric($ups_real_power_nominal)) {
|
||||
discover_sensor($valid['sensor'], 'power', $device, $ups_real_power_nominal_oid, 'UPSRealPowerNominal', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Real Power Nominal', '1', '1', NULL, NULL, NULL, NULL, $ups_real_power_nominal);
|
||||
}
|
||||
// UPS Info Real Power Nominal, example return : SNMPv2-SMI::enterprises.6574.4.2.21.2.0 = Opaque: Float: 540.000000
|
||||
$ups_real_power_nominal_oid = '.1.3.6.1.4.1.6574.4.2.21.2.0';
|
||||
$ups_real_power_nominal = snmp_get($device, $ups_real_power_nominal_oid, '-Oqv');
|
||||
if (is_numeric($ups_real_power_nominal)) {
|
||||
discover_sensor($valid['sensor'], 'power', $device, $ups_real_power_nominal_oid, 'UPSRealPowerNominal', $ups_device_manufacturer.' '.$ups_device_model, 'UPS Real Power Nominal', '1', '1', null, null, null, null, $ups_real_power_nominal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ if ($device['os'] == 'ipoman') {
|
||||
// }
|
||||
// }
|
||||
if (is_array($oids_out)) {
|
||||
foreach ($oids_out as $index => $entry)
|
||||
{
|
||||
foreach ($oids_out as $index => $entry) {
|
||||
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.5.'.$index;
|
||||
$divisor = 10;
|
||||
$descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
<?php
|
||||
|
||||
if ($device['os'] == 'raritan')
|
||||
{
|
||||
// Check Inlets
|
||||
$inlet_oids = snmp_walk($device,"inletLabel","-Osqn","PDU2-MIB");
|
||||
$inlet_oids = trim($inlet_oids);
|
||||
if ($inlet_oids) echo("PDU Inlet ");
|
||||
foreach (explode("\n", $inlet_oids) as $inlet_data)
|
||||
{
|
||||
$inlet_data = trim($inlet_data);
|
||||
if ($inlet_data)
|
||||
{
|
||||
list($inlet_oid,$inlet_descr) = explode(" ", $inlet_data,2);
|
||||
$inlet_split_oid = explode('.', $inlet_oid);
|
||||
$inlet_index = $inlet_split_oid[count($inlet_split_oid)-2].".".$inlet_split_oid[count($inlet_split_oid)-1];
|
||||
if ($device['os'] == 'raritan') {
|
||||
// Check Inlets
|
||||
$inlet_oids = snmp_walk($device, 'inletLabel', '-Osqn', 'PDU2-MIB');
|
||||
$inlet_oids = trim($inlet_oids);
|
||||
if ($inlet_oids) {
|
||||
echo 'PDU Inlet ';
|
||||
}
|
||||
|
||||
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.5";
|
||||
$inlet_divisor = pow(10,snmp_get($device, "inletSensorDecimalDigits.$inlet_index.activePower", "-Ovq","PDU2-MIB"));
|
||||
$inlet_power = snmp_get($device, "measurementsInletSensorValue.$inlet_index.activePower", "-Ovq", "PDU2-MIB") / $inlet_divisor;
|
||||
foreach (explode("\n", $inlet_oids) as $inlet_data) {
|
||||
$inlet_data = trim($inlet_data);
|
||||
if ($inlet_data) {
|
||||
list($inlet_oid,$inlet_descr) = explode(' ', $inlet_data, 2);
|
||||
$inlet_split_oid = explode('.', $inlet_oid);
|
||||
$inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)].'.'.$inlet_split_oid[(count($inlet_split_oid) - 1)];
|
||||
|
||||
if ($inlet_power >= 0) {
|
||||
discover_sensor($valid['sensor'], 'power', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, 1, NULL, NULL, NULL, NULL, $inlet_power);
|
||||
}
|
||||
}
|
||||
}
|
||||
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.5";
|
||||
$inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.activePower", '-Ovq', 'PDU2-MIB'));
|
||||
$inlet_power = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.activePower", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
|
||||
|
||||
if ($inlet_power >= 0) {
|
||||
discover_sensor($valid['sensor'], 'power', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, 1, null, null, null, null, $inlet_power);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,54 +1,59 @@
|
||||
<?php
|
||||
|
||||
// RFC1628 UPS
|
||||
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']])
|
||||
{
|
||||
echo("RFC1628 ");
|
||||
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) {
|
||||
echo("RFC1628 ");
|
||||
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.4.3.0", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++)
|
||||
{
|
||||
$current_oid = ".1.3.6.1.2.1.33.1.4.4.1.4.$i";
|
||||
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 300+$i;
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.4.3.0", "-OsqnU"));
|
||||
if ($debug) {
|
||||
echo($oids."\n");
|
||||
}
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++) {
|
||||
$current_oid = ".1.3.6.1.2.1.33.1.4.4.1.4.$i";
|
||||
$descr = "Output";
|
||||
if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 300+$i;
|
||||
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++)
|
||||
{
|
||||
$current_oid = "1.3.6.1.2.1.33.1.3.3.1.5.$i";
|
||||
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 100+$i;
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU"));
|
||||
if ($debug) {
|
||||
echo($oids."\n");
|
||||
}
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++) {
|
||||
$current_oid = "1.3.6.1.2.1.33.1.3.3.1.5.$i";
|
||||
$descr = "Input";
|
||||
if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 100+$i;
|
||||
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++)
|
||||
{
|
||||
$current_oid = ".1.3.6.1.2.1.33.1.5.3.1.4.$i";
|
||||
$descr = "Bypass"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 200+$i;
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU"));
|
||||
if ($debug) {
|
||||
echo($oids."\n");
|
||||
}
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++) {
|
||||
$current_oid = ".1.3.6.1.2.1.33.1.5.3.1.4.$i";
|
||||
$descr = "Bypass";
|
||||
if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $current_oid, "-Oqv");
|
||||
$type = "rfc1628";
|
||||
$precision = 1;
|
||||
$index = 200+$i;
|
||||
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
discover_sensor($valid['sensor'], 'power', $device, $current_oid, $index, $type, $descr, '1', '1', NULL, NULL, NULL, NULL, $current);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user