inspector/modules/services.sh

26 lines
602 B
Bash

#!/bin/sh
slug='services'
name='Services'
recommend=0
if command -v systemctl >/dev/null 2>&1; then
available=1
else
available=0
fi
check() {
systemctl list-units --type=service --plain --no-legend --no-pager | while IFS= read -r line; do
service=$(printf '%s\n' "$line" | awk '{print $1}')
state=$(printf '%s\n' "$line" | awk '{print $4}')
[ -n "$service" ] || continue
if [ "$state" = "failed" ]; then
warn "$service" "" "Service $service failed"
else
ok "$service" "" "Service $service is $state"
fi
done
}