Modul zum senden von keep-alive Meldungen an systemd (watchdog)

Begonnen von hexenmeister, 20 August 2018, 21:29:02

Vorheriges Thema - Nächstes Thema

hexenmeister

FHEM startet nicht, weil sie angewiesen wurde, PID-File zu erstellen, geht aber nicht, da Verzeichnis angeblich nicht beschreibbar. Service-Script kann diese auch nicht erstellen. Warum? Angeblich schon vorhanden. Die Meldung ist unschön, sollte jedoch eigentlich nicht weiter stören. Ergänze Option -p bei mkdir (ich habe ersten Post entsprechend angepasst), dann ist die Meldung weg. Bitte schaue nach den Rechten für /var/run/fhem/
ls -l /var/run/fhem/

Ist genügend Platz vorhanden?
df /var/run

Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

Solala0815

Bei "sudo systemctl start fhem.service" bekomme ich nach wie vor eine Fehlermeldung.
Neu Meldung bei Abfrage des Status.

● fhem.service - FHEM Home Automation
   Loaded: loaded (/etc/systemd/system/fhem.service; enabled; vendor preset: enabled)
   Active: activating (start) since Sat 2019-01-19 21:58:35 CET; 1min 19s ago
  Process: 6716 ExecStart=/usr/bin/perl fhem.pl fhem.cfg (code=exited, status=0/SUCCESS)
  Process: 6712 ExecStartPre=/bin/chown -R fhem:dialout /var/run/fhem (code=exited, status=0/SUCCESS)
  Process: 6710 ExecStartPre=/bin/mkdir -p /var/run/fhem (code=exited, status=0/SUCCESS)
Main PID: 606 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/fhem.service
           └─6718 /usr/bin/perl fhem.pl fhem.cfg

Jan 19 21:58:35 Raspberry-Monitor systemd[1]: Starting FHEM Home Automation...
Jan 19 21:58:36 Raspberry-Monitor systemd[1]: fhem.service: PID file /var/run/fhem/fhem.pid not readable (yet?) after start: No such file or directory


" ls -l /var/run/fhem/" liefert den Wert "insgesamt 0",Verzeichnis ist leer und hat die Rechte "dailout" und "fhem"
" df /var/run" Listet dieses auf

Dateisystem    1K-Blöcke   Benutzt   Verfügbar   Verw%   Eingehängt auf
tmpfs               474724     12236      462488      3%         /run


Kann es damit zusammen hängen das es die
,,Raspbian Stretch with desktop and recommended software"
Version ist und nicht die lite?

Werde es noch mit der Lite versuchen.




hexenmeister

Mit den Verzeichnissen ist alles in Ordnung. Das Problem ist, dass fhem keine PID-Datei erstellt. Hast Du fhem entsprechend konfiguriert?

ZitatKann es damit zusammen hängen das es die
,,Raspbian Stretch with desktop and recommended software"
Version ist und nicht die lite?
Kann ich mir nicht vorstellen.
Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

Solala0815

Hallo Alexander,
herzlichen Dank für deine Hilfe. 

Habe auf den Raspi das Backup-File neu aufgespielt und die Konfigurationen aus dem 1.Poste neu durchgeführt.
Lief bis zum FHEM-Backup Einwandfrei (35 Minuten)
Führte zum Schluss vom Backup einen Reboot durch und kam anschließend wieder.

Log ist Reverse - Beachte die Zeitern (Zeitsprung)

2019.01.19 23:42:09 3: WEB: port 8083 opened
2019.01.19 23:42:08 3: telnetPort: port 7072 opened
2019.01.19 23:42:08 1: Including fhem.cfg
2019.01.19 23:43:18 2: Watchdog Client: deactivated
2019.01.19 23:43:18 2: Watchdog Client: Shutting down
2019.01.19 23:43:18 1: Shutdown executed
2019.01.19 23:43:18 0: Server shutdown
2019.01.19 23:41:31 1: Calling /usr/bin/perl ./contrib/commandref_join.pl -noWarnings, this may take a while
2019.01.19 23:41:31 1: ... rest of lines skipped.


Wäre es möglich den Watchdog inaktiv zu schalten um ungewollte Auslöser zu umgehen?

Solala0815

zu früh gefreut.
es wird ca. alle 8 Minuten ein Reboot durchgeführt.
werde es Morgen/Heute näher untersuchen.

Solala0815

1.Test
- raspbian "2018-11-13-raspbian-stretch-full" auf SD-Karte
- Fhem nach https://debian.fhem.de/ Manuell installiert
- bei beiden ein Update durchgeführt.
- Watchdog nach Anleitung 1.Poste installiert

Watchdog schlägt alle ca. 8Minuten zu.


2019.01.20 15:17:11 1: Including fhem.cfg
2019.01.20 15:17:11 3: WEB: port 8083 opened
2019.01.20 15:17:11 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:17:11 1: Including ./log/fhem.save
2019.01.20 15:17:12 1: usb create starting
2019.01.20 15:17:12 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:17:12 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:17:12 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:17:12 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:17:12 1: usb create end
2019.01.20 15:17:12 2: Watchdog Client: initialized
2019.01.20 15:17:12 3: NTFY return:  watchdog:active
2019.01.20 15:17:12 0: Featurelevel: 5.9
2019.01.20 15:17:12 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:677)
2019.01.20 15:21:10 0: Server shutdown
2019.01.20 15:21:10 2: Watchdog Client: Shutting down
2019.01.20 15:21:10 2: Watchdog Client: deactivated
2019.01.20 15:25:15 1: Including fhem.cfg
2019.01.20 15:25:15 3: WEB: port 8083 opened
2019.01.20 15:25:15 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:25:15 1: Including ./log/fhem.save
2019.01.20 15:25:16 1: usb create starting
2019.01.20 15:25:16 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:25:16 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:25:16 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:25:16 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:25:16 1: usb create end
2019.01.20 15:25:16 2: Watchdog Client: initialized
2019.01.20 15:25:16 3: NTFY return:  watchdog:active
2019.01.20 15:25:16 0: Featurelevel: 5.9
2019.01.20 15:25:16 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:762)
2019.01.20 15:29:14 0: Server shutdown
2019.01.20 15:29:14 2: Watchdog Client: Shutting down
2019.01.20 15:29:14 2: Watchdog Client: deactivated
2019.01.20 15:33:19 1: Including fhem.cfg
2019.01.20 15:33:19 3: WEB: port 8083 opened
2019.01.20 15:33:19 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:33:19 1: Including ./log/fhem.save
2019.01.20 15:33:19 1: usb create starting
2019.01.20 15:33:20 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:33:20 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:33:20 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:33:20 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:33:20 1: usb create end
2019.01.20 15:33:20 2: Watchdog Client: initialized
2019.01.20 15:33:20 3: NTFY return:  watchdog:active
2019.01.20 15:33:20 0: Featurelevel: 5.9
2019.01.20 15:33:20 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:813)
2019.01.20 15:37:18 0: Server shutdown
2019.01.20 15:37:18 2: Watchdog Client: Shutting down
2019.01.20 15:37:18 2: Watchdog Client: deactivated
2019.01.20 15:41:23 1: Including fhem.cfg
2019.01.20 15:41:23 3: WEB: port 8083 opened
2019.01.20 15:41:23 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:41:24 1: Including ./log/fhem.save
2019.01.20 15:41:24 1: usb create starting
2019.01.20 15:41:24 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:41:24 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:41:24 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:41:24 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:41:24 1: usb create end
2019.01.20 15:41:24 2: Watchdog Client: initialized
2019.01.20 15:41:24 3: NTFY return:  watchdog:active
2019.01.20 15:41:24 0: Featurelevel: 5.9
2019.01.20 15:41:24 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:860)


Braucht Fhem wirklich 2-3 Minuten zum Starten?? Es ist lange Zeit nicht erreichbar.

pi@raspberrypi:~ $ sudo systemctl status fhem.service
● fhem.service - FHEM Home Automation
   Loaded: loaded (/etc/systemd/system/fhem.service; enabled; vendor preset: ena
   Active: deactivating (final-sigkill) (Result: timeout)
  Process: 906 ExecStartPre=/bin/chown -R fhem:dialout /var/run/fhem (code=exite
  Process: 903 ExecStartPre=/bin/mkdir -p /var/run/fhem (code=exited, status=0/S
Main PID: 908 (code=exited, status=0/SUCCESS); Control PID: 908
   Status: "stopping"
   CGroup: /system.slice/fhem.service

Jan 20 15:49:26 raspberrypi systemd[1]: Starting FHEM Home Automation...
Jan 20 15:53:26 raspberrypi systemd[1]: fhem.service: Start operation timed out.
Jan 20 15:55:26 raspberrypi systemd[1]: fhem.service: State 'stop-final-sigterm'
Jan 20 15:55:26 raspberrypi systemd[1]: fhem.service: Killing process 908 (n/a)


2019.01.20 15:45:22 0: Server shutdown
2019.01.20 15:45:22 2: Watchdog Client: Shutting down
2019.01.20 15:45:22 2: Watchdog Client: deactivated
2019.01.20 15:49:27 1: Including fhem.cfg
2019.01.20 15:49:27 3: WEB: port 8083 opened
2019.01.20 15:49:27 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:49:28 1: Including ./log/fhem.save
2019.01.20 15:49:28 1: usb create starting
2019.01.20 15:49:28 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:49:28 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:49:28 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:49:28 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:49:28 1: usb create end
2019.01.20 15:49:28 2: Watchdog Client: initialized
2019.01.20 15:49:28 3: NTFY return:  watchdog:active
2019.01.20 15:49:28 0: Featurelevel: 5.9
2019.01.20 15:49:28 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:908)
2019.01.20 15:53:26 0: Server shutdown
2019.01.20 15:53:26 2: Watchdog Client: Shutting down
2019.01.20 15:53:26 2: Watchdog Client: deactivated
2019.01.20 15:57:31 1: Including fhem.cfg
2019.01.20 15:57:31 3: WEB: port 8083 opened
2019.01.20 15:57:31 2: eventTypes: loaded 2 events from ./log/eventTypes.txt
2019.01.20 15:57:31 1: Including ./log/fhem.save
2019.01.20 15:57:32 1: usb create starting
2019.01.20 15:57:32 3: Probing ZWDongle device /dev/serial0
2019.01.20 15:57:32 1: ZWDongle: Can't open /dev/serial0: Permission denied
2019.01.20 15:57:32 3: Probing CUL device /dev/ttyAMA0
2019.01.20 15:57:32 1: CUL: Can't open /dev/ttyAMA0: Permission denied
2019.01.20 15:57:32 1: usb create end
2019.01.20 15:57:32 2: Watchdog Client: initialized
2019.01.20 15:57:32 3: NTFY return:  watchdog:active
2019.01.20 15:57:32 0: Featurelevel: 5.9
2019.01.20 15:57:32 0: Server started with 7 defined entities (fhem.pl:18343/2019-01-20 perl:5.024001 os:linux user:fhem pid:1051)

Solala0815

2. Test
mit "2018-11-13-raspbian-stretch-lite", Verfahren wie ein Poste höher.
Auch hier schlägt der Watchdog zu.

hexenmeister

War eine Woche unterwegs, kam nicht dazu, Forum zu lesen.
Besteht das Problem weiterhin? Ich sehe leider nicht mehr, was falsch sein könnte :/
Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy

Solala0815

Hallo Alexander,

herzlichen Dank für deine Hilfe.
Leider lese ich hier nur sporadisch mit.

ZitatBesteht das Problem weiterhin?
Zu deiner Frage: Nein. Habe den Watchdog nicht mehr installiert.

Gisbert

Hallo hexenmeister,

ZitatWenn in dem Script "Type=notify" verwendet wird, muss global Attribute "nofork=1" gesetzt sein.
Code: [Auswählen]

attr global nofork 1

Bei "Type=forking" muss in Script der korrekte Pfad zu dem PID-Datei angegeben werden, diese Datei muss auch in FHEM mit dem global Attribute "pidfilename" aktiviert sein.
Code: [Auswählen]

attr global pidfilename /var/run/fhem/fhem.pid

Kannst Du mir erklären, was es mit den Optionen "Type=notify bzw. forking" auf sich hat?
Sowohl der Ordner als die Datei fehlen bei mir: /var/run/fhem/fhem.pid
Welche Rechte muss der Ordner fhem und die Datei fhem.pid haben, und welchen Inhalt hat diese Datei?

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY

hexenmeister

Das hat was mit der Konfiguration von systemd zu tun.
ZitatIf set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when start-up is complete and all communication channels are set up. The child continues to run as the main daemon process. This is the behavior of traditional UNIX daemons. If this setting is used, it is recommended to also use the PIDFile= option, so that systemd can identify the main process of the daemon. systemd will proceed with starting follow-up units as soon as the parent process exits.
https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=

Der Ordner /var/run/fhem wird im dem systemd-Script erstellt und mit Rechten versehen (Soll zu dem Uder / der Gruppe des FHEMs passen):
...
ExecStartPre=-/bin/mkdir -p /var/run/fhem
ExecStartPre=/bin/chown -R fhem:dialout /var/run/fhem
...

fhem.pid wird dann dort von dem FHEM erstellt. Dafür muss Attribut pidfilename gesetzt werden.
attr global pidfilename /var/run/fhem/fhem.pid
Maintainer: MQTT_GENERIC_BRIDGE, SYSMON, SMARTMON, systemd_watchdog, MQTT, MQTT_DEVICE, MQTT_BRIDGE
Contrib: dev_proxy