Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Sentry4 sensor discovery #8407

Merged
merged 6 commits into from Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
491 changes: 491 additions & 0 deletions includes/definitions/discovery/sentry4.yaml

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions includes/discovery/sensors/frequency/sentry4.inc.php

This file was deleted.

33 changes: 0 additions & 33 deletions includes/discovery/sensors/power/sentry4.inc.php

This file was deleted.

42 changes: 24 additions & 18 deletions includes/discovery/sensors/temperature/sentry4.inc.php
Expand Up @@ -22,27 +22,33 @@
$divisor = '10';
$multiplier = '1';
if ($oids) {
echo 'ServerTech Sentry4 Temperature ';
}
$sentry_temp_scale = snmp_get($device, 'st4TempSensorScale.0', '-Ovq', 'Sentry4-MIB');
if ($sentry_temp_scale == 'fahrenheit') {
$user_func = 'convert_to_celsius';
} else {
$user_func = null;
}

foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$descr) = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
echo 'ServerTech Sentry4 Temperature ';
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid, $descr) = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];

// Sentry4-MIB::st4TempSensorValue
$temperature_oid = '.1.3.6.1.4.1.1718.4.1.9.3.1.1.1.'.$index;
$descr = 'Removable Sensor '.$index;
$low_warn_limit = (snmp_get($device, "st4TempSensorLowWarning.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$low_limit = (snmp_get($device, "st4TempSensorLowAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$high_warn_limit = (snmp_get($device, "st4TempSensorHighWarning.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$high_limit = (snmp_get($device, "st4TempSensorHighAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$current = (snmp_get($device, "$temperature_oid", '-OvqU', 'Sentry4-MIB') / $divisor);
// Sentry4-MIB::st4TempSensorValue
$temperature_oid = '.1.3.6.1.4.1.1718.4.1.9.3.1.1.1.' . $index;
$descr = 'Removable Sensor ' . $index;
$low_warn_limit = (snmp_get($device, "st4TempSensorLowWarning.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$low_limit = (snmp_get($device, "st4TempSensorLowAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$high_warn_limit = (snmp_get($device, "st4TempSensorHighWarning.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$high_limit = (snmp_get($device, "st4TempSensorHighAlarm.1.$index", '-Ovq', 'Sentry4-MIB') / $divisor);
$current = (snmp_get($device, "$temperature_oid", '-OvqU', 'Sentry4-MIB') / $divisor);

if (is_numeric($current) && $current >= 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $index, 'sentry4', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current);
if (is_numeric($current) && $current >= 0) {
discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $index, 'sentry4', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $high_warn_limit, $high_limit, $current, 'snmp', null, null, $user_func);
}
}
}
}
8 changes: 4 additions & 4 deletions includes/polling/functions.inc.php
Expand Up @@ -66,10 +66,6 @@ function poll_sensor($device, $class)
require 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php';
}

if (isset($sensor['user_func']) && function_exists($sensor['user_func'])) {
$sensor_value = $sensor['user_func']($sensor_value);
}

if ($class == 'temperature') {
preg_match('/[\d\.\-]+/', $sensor_value, $temp_response);
if (!empty($temp_response[0])) {
Expand Down Expand Up @@ -165,6 +161,10 @@ function record_sensor_data($device, $all_sensors)
$sensor_value = ($sensor_value * $sensor['sensor_multiplier']);
}

if (isset($sensor['user_func']) && function_exists($sensor['user_func'])) {
$sensor_value = $sensor['user_func']($sensor_value);
}

$rrd_name = get_sensor_rrd_name($device, $sensor);

$rrd_def = RrdDefinition::make()->addDataset('sensor', 'GAUGE');
Expand Down