Show Failed Service On Login
I was curious if anyone has ever configured a way to show the results of systemctl --failed as like a motd of sorts? Just every login it can basically show me if any services are in a failed or un-healthy state?
Anyone have any suggestions on how I can achieve this?
About this post
- Posted
- Archived
- Score
- 9 · 100% up
- Kind
- Text
- ID
- 38rfba
12 comments
To have systemd --failed display every time you open a virtual terminal (like motd) simply add the command to ~/.profile This file is sourced e every time you open a POSIX conform terminal emulator.
If you want something to run when you log in to your desktop, put it at the end of your .xinitrc or use the "run on startup" functionality in your desktop environment if you use one. I would just have it open a terminal window that runs systemctl --failed. It will need to run as root, right? Maybe setup sudoers to allow your user to run that specific command without a password.
No GUI
On most DEs xinitrc isn't used. Also the goal of the xinitrc is to initialise X, not display nonsense.
If you're using a login manager maybe. I certainly use it with my DEs.
What exactly is wrong with having it run extraneous commands after it starts X and your desktop stuff? Yeah, it's kinda meaningless (should probably just fix the broken service) but thinking about automation is interesting and that's the entire point of using Arch for a hobby is to learn stuff and have fun. Quit being a hater.
You can set up a startup script that sends you an email with the contents of systemctl --failed upon user login? Or you could just create a startup script that opens a terminal and shows you systemctl --failed?
cat ~/.zlogin
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && /usr/bin/systemctl --failed