Reduziere SD-Karten-Schreiblast: leiser Agent + journald volatile
- Agent loggt im Normalfall nichts mehr (kein heartbeat_tick, kein mqtt_heartbeat_sent, kein status_report_sent) - nur noch Fehler und Zustandsaenderungen werden geloggt - Ansible: journald auf Storage=volatile + RuntimeMaxUse=20M (RAM-only, automatisches Verdraengen alter Eintraege bei vollem Puffer) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b111cf8421
commit
d461abc3f5
4 changed files with 28 additions and 6 deletions
|
|
@ -4,6 +4,12 @@
|
|||
daemon_reload: true
|
||||
become: true
|
||||
|
||||
- name: Restart journald
|
||||
ansible.builtin.systemd:
|
||||
name: systemd-journald
|
||||
state: restarted
|
||||
become: true
|
||||
|
||||
- name: Restart morz-agent
|
||||
ansible.builtin.systemd:
|
||||
name: morz-agent
|
||||
|
|
|
|||
|
|
@ -50,6 +50,28 @@
|
|||
- Reload systemd
|
||||
- Restart morz-agent
|
||||
|
||||
- name: Ensure journald drop-in directory exists
|
||||
ansible.builtin.file:
|
||||
path: /etc/systemd/journald.conf.d
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
become: true
|
||||
|
||||
- name: Configure journald volatile storage (RAM only, schont SD-Karte)
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/systemd/journald.conf.d/morz-volatile.conf
|
||||
content: |
|
||||
[Journal]
|
||||
Storage=volatile
|
||||
RuntimeMaxUse=20M
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: true
|
||||
notify: Restart journald
|
||||
|
||||
- name: Enable and start morz-agent
|
||||
ansible.builtin.systemd:
|
||||
name: morz-agent
|
||||
|
|
|
|||
|
|
@ -185,13 +185,9 @@ func (a *App) emitHeartbeat() {
|
|||
connectivity := a.serverConnectivity
|
||||
a.mu.Unlock()
|
||||
|
||||
a.logger.Printf("event=heartbeat_tick screen_id=%s", a.Config.ScreenID)
|
||||
|
||||
if a.mqttPub != nil {
|
||||
if err := a.mqttPub.SendHeartbeat(string(status), string(connectivity), now); err != nil {
|
||||
a.logger.Printf("event=mqtt_heartbeat_failed screen_id=%s error=%v", a.Config.ScreenID, err)
|
||||
} else {
|
||||
a.logger.Printf("event=mqtt_heartbeat_sent screen_id=%s", a.Config.ScreenID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -233,5 +229,4 @@ func (a *App) reportStatus(ctx context.Context) {
|
|||
a.consecutiveReportFailures = 0
|
||||
a.serverConnectivity = ConnectivityOnline
|
||||
a.mu.Unlock()
|
||||
a.logger.Printf("event=status_report_sent screen_id=%s", a.Config.ScreenID)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ func TestAppRunUpdatesHealthAndLogsStructuredEvents(t *testing.T) {
|
|||
for _, needle := range []string{
|
||||
"event=agent_configured",
|
||||
"screen_id=info01-dev",
|
||||
"event=heartbeat_tick",
|
||||
"event=agent_stopped",
|
||||
} {
|
||||
if !strings.Contains(logs, needle) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue