Open famewolf opened 3 years ago
Should be able to register multiple logging channels and handlers so that there is flexibility in terms of which messages get logged to disk vs sent via email so users can have some granularity in how these things are handled.
Since the script's execution is short-lived rather than daemonized unless in conjunction with something like systemd, these emails are likely to be sent during each reboot incident rather than in a digest format if there are a large series of reboots in a short timeframe if someone is running the script on a short interval, but that's somewhat mitigated by bootloop prevention measures anyway.
Will plan to implement in some fashion @famewolf
Relates to #12
Because sending an email will require internet connectivity and failed connectivity tests are one of the reasons a reboot may be requested, email or other notifications may be unable to be sent immediately and need to be queued if T-Mobile Home Internet is the only internet connection.
At any rate, if a reboot is requested when there is still internet connectivity (e.g. because an undesired band or eNB ID is in use), the notification would need to either be sent before the reboot is performed or after the reboot is finished and an internet connection is re-established.
Until this is implemented in the Python script itself, it's easy to implement logging via bash redirects, like so (this is similar to how I have the command formatted in my nightly cronjob):
python3 tmo-monitor.py [options] admin [password] &>> /var/log/tmo-monitor.log
The >>
makes it append to that file rather than overwrite it on each run, and the &
directly before the redirect makes it catch both stdout and stderr.
I am a mac user mainly so being able to trigger something via a command line on my pi would be interesting to me. I run tmo-monitor on my pi. If a reboot could trigger the use of running a command I could do something like ssh user@maccomputer.local osascript -e 'display notification "Your gateway is down, rebooting now." with title "Gateway Down"' This would give me a local notification on my mac sent from the pi. Can't really use any other internet based service since that would rely on the network being on. Was thinking maybe pushbullet. But that would not work if there is no internet.
Have you considered allowing for an email or some other options that just basically says the gateway was rebooted? Email would have the timestamp. Might indicate if the issue is overheating. telegram-cli would have been perfect except it gives an error on pi and needs to have 2 lines commented out in the source then recompiled.