Skip to content

Commit

Permalink
Sensor: Only post to eventlog when specific columns change (librenms#…
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant authored Sep 7, 2024
1 parent f54e38f commit 3da6912
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/Observers/SensorObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public function updated(Sensor $sensor): void
echo 'U';
}

EventLog::log('Sensor Updated: ' . $sensor->sensor_class . ' ' . $sensor->sensor_type . ' ' . $sensor->sensor_index . ' ' . $sensor->sensor_descr, $sensor->device_id, 'sensor', Severity::Notice, $sensor->sensor_id);
// only post eventlog when relevant columns change
if ($sensor->isDirty(['sensor_class', 'sensor_oid', 'sensor_index', 'sensor_type', 'sensor_descr', 'group', 'sensor_divisor', 'sensor_multiplier', 'entPhysicalIndex', 'entPhysicalIndex_measured', 'user_func'])) {
EventLog::log('Sensor Updated: ' . $sensor->sensor_class . ' ' . $sensor->sensor_type . ' ' . $sensor->sensor_index . ' ' . $sensor->sensor_descr, $sensor->device_id, 'sensor', Severity::Notice, $sensor->sensor_id);
}
}

public function deleted(): void
Expand Down

0 comments on commit 3da6912

Please sign in to comment.