Linux SystemD Services

Linux SystemD Services Monitoring

We are recommending you to use Mogie Pete's zabbix-systemd-service-monitoring template for monitoring Linux SystemD services. It has service discovery, blacklisting, whitelisting capabilities and provides alerting when a service stops or restarts.

You can access to the template by clicking this link:

https://github.com/MogiePete/zabbix-systemd-service-monitoring

Example blacklist for RHEL,CENTOS,ROCKYLINUX
/etc/zabbix/service_discovery_blacklist

autovt|getty|systemd-readahead-collect|systemd-readahead-drop|systemd-readahead-replay|rhel-autorelabel|rhel-configure|rhel-loadmodules|microcode|NetworkManager-dispatcher|dbus-org.fedoraproject.FirewallD1|dbus-org.freedesktop.NetworkManager|dbus-org.freedesktop.nm-dispatcher|microcode|kdump|loadmodules|selinux-autorelabel-mark|mdmonitor|timedatex|dbus-org.freedesktop.timedate1

Hint:
If you want to check the running enabled services via ssh shell manually, you can use this shell script after installing the template to the server.

/usr/local/bin/zbx.sh (don't forget to make it executable with chmod +x)

#!/bin/bash

service_list=$(systemctl list-unit-files | grep -E '\.service\s+(generated|enabled)' | awk -F'.service ' '{print $1}')

[[ -r /etc/zabbix/service_discovery_whitelist ]] && {
    service_list=$(echo "$service_list" | grep -E -f /etc/zabbix/service_discovery_whitelist)
}

[[ -r /etc/zabbix/service_discovery_blacklist ]] && {
    service_list=$(echo "$service_list" | grep -Ev -f /etc/zabbix/service_discovery_blacklist)
}

echo -n "Services to Monitor:
----------------------
";for s in ${service_list}; do echo -n "$s --> "
$(systemctl status $s 2>/dev/null | grep -Ei 'running|active \(exited\)|active \(running\)' > /dev/null) && echo OK || echo "$(tput setaf 1)NOT WORKING <========== $(tput sgr 0)"
done