2

I'm trying to figure what's the right way for me to be notified when some systemd service is having problems. Manually checking systemctl status isn't a sustainable option; at the very least I want to have a simple tray icon, like just green or red. Some sounds and/or visual notifications can be useful too. Surprisingly I don't seem to find any existing tools for that, so the best I can think of is to write my own, maybe some simple bash script which would poll systemctl once in a while, and update the icon status.

Pretty poor but alas.

Before I actually start spending time on that, want to make sure, am I by any chance missing some better options?

Dmitry Frank
  • 2,668
  • 8
  • 27
  • 38

2 Answers2

0
sudo systemctl --type=service

sudo systemctl --state=active  

sudo systemctl --state=failed 

journalctl -b -p err

These should be enough to monitor and to find any misbehaving services.

  • Your answer assumes I'm gonna be executing those commands manually, but as I mentioned in my question, checking it manually isn't a sustainable option. I have better things to do, you know; and I just need some status icon plus ideally some visual+sound notification when something breaks. And when I get that notification, _then_ I'm going to get logs etc. – Dmitry Frank Jul 06 '21 at 16:04
  • 1
    @DmitryFrank so your computer will play marche funebre, you will start fixing the service, then immediately after, you will get a support call and tell them you are on it. – nurettin Jul 24 '22 at 06:34
0

Use the check_systemd command line tool from the Nagios monitoring plugin collection. You can just call this without parameter or setting up Nagios (which is a hell to do).

On Ubuntu you only need to call:

sudo apt -y install monitoring-plugins-systemd 

and then you can check

/usr/lib/nagios/plugins/check_systemd 

If $? is 0 all is ok, if 1 its bad and 2 if its critical

All other return values should tell you to get the heck out because the world is on fire.

Peregrino69
  • 2,337
  • 1
  • 15
  • 22
Lothar
  • 143
  • 5