From 790220a77e42f901e9f03026d9b1f1fbb8335a08 Mon Sep 17 00:00:00 2001 From: Peter Eriksson <pen@lysator.liu.se> Date: Thu, 11 Jan 2007 10:08:35 +0000 Subject: [PATCH] Improved check_svcs a bit (CRITICAL if services in Maintenance, WARNING if dependant service aren't running due to disabled services) --- check_svcs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/check_svcs b/check_svcs index 74a48ce..634fdc4 100755 --- a/check_svcs +++ b/check_svcs @@ -46,18 +46,13 @@ fi RC=0 -nawk '($1 ~ /svc:*/) { print $1 }' <$TMP | while read svc; do - RC=1 - SL="${SL} ${svc}" -done - -case "$RC" in - 0) - echo "OK - All services running" - exit 0 - ;; - 1) - echo "WARNING - Services not running:${SL}" - exit 1 - ;; -esac +nawk '\ + BEGIN { sev=0; services="" } \ + ($1 ~ /^svc:*/) { service=$1 } \ + ($1 == "State:") { if ($2 == "maintenance") { sev=2 } else if (sev < 2) { sev=1 }; services=services" "service } \ + END { if (sev == 0) { print "OK - All enabled services running" } \ + else if (sev == 1) { print "WARNING - Problem services:"services } \ + else { print "CRITICAL - Problem services:"services }; \ + exit sev }' <$TMP + +exit $? -- GitLab