mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
Use standard sensor type names
This commit is contained in:
parent
fcbafbf577
commit
9eee7fad58
@ -55,33 +55,7 @@ class Sensor extends DeviceRelatedModel
|
||||
|
||||
public static function getTypes()
|
||||
{
|
||||
return ['Airflow',
|
||||
'ber',
|
||||
'Battery Charge',
|
||||
'chromatic_dispersion',
|
||||
'Cooling',
|
||||
'count',
|
||||
'Current',
|
||||
'dBm',
|
||||
'delay',
|
||||
'Energy Efficiency Ratio',
|
||||
'Fanspeed',
|
||||
'Frequency',
|
||||
'Humidity',
|
||||
'Load',
|
||||
'power_consumed',
|
||||
'power_factor',
|
||||
'Power',
|
||||
'Pressure',
|
||||
'quality_factor',
|
||||
'Runtime',
|
||||
'Wireless',
|
||||
'snr',
|
||||
'State',
|
||||
'Temperature',
|
||||
'Voltage',
|
||||
'Water Flow Rate',
|
||||
];
|
||||
return array_keys(self::$icons);
|
||||
}
|
||||
|
||||
// for the legacy menu
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class EventlogSensorReferenceCleanup extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach (\App\Models\Sensor::getTypes() as $type) {
|
||||
DB::table('eventlog')->where('type', ucfirst($type))->update(['type' => $type]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach (\App\Models\Sensor::getTypes() as $type) {
|
||||
DB::table('eventlog')->where('type', $type)->update(['type' => ucfirst($type)]);
|
||||
}
|
||||
}
|
||||
}
|
@ -199,10 +199,10 @@ function record_sensor_data($device, $all_sensors)
|
||||
// FIXME also warn when crossing WARN level!
|
||||
if ($sensor['sensor_limit_low'] != '' && $prev_sensor_value > $sensor['sensor_limit_low'] && $sensor_value < $sensor['sensor_limit_low'] && $sensor['sensor_alert'] == 1) {
|
||||
echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n";
|
||||
log_event("$class under threshold: $sensor_value $unit (< {$sensor['sensor_limit_low']} $unit)", $device, $class, 4, $sensor['sensor_id']);
|
||||
log_event("$class under threshold: $sensor_value $unit (< {$sensor['sensor_limit_low']} $unit)", $device, $sensor['sensor_class'], 4, $sensor['sensor_id']);
|
||||
} elseif ($sensor['sensor_limit'] != '' && $prev_sensor_value < $sensor['sensor_limit'] && $sensor_value > $sensor['sensor_limit'] && $sensor['sensor_alert'] == 1) {
|
||||
echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n";
|
||||
log_event("$class above threshold: $sensor_value $unit (> {$sensor['sensor_limit']} $unit)", $device, $class, 4, $sensor['sensor_id']);
|
||||
log_event("$class above threshold: $sensor_value $unit (> {$sensor['sensor_limit']} $unit)", $device, $sensor['sensor_class'], 4, $sensor['sensor_id']);
|
||||
}
|
||||
if ($sensor['sensor_class'] == 'state' && $prev_sensor_value != $sensor_value) {
|
||||
$trans = array_column(
|
||||
|
Loading…
Reference in New Issue
Block a user