Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
Linux/Unix shell script to check the status of a service. Capable of using sysvinit, systemd, upstart, etc, or choose your own status command. Tested on Ubuntu Linux, Fedora Linux, Red Hat Linux, FreeBSD, OSX, and AIX.
Current Version
Last Release Date
2014-01-23
Owner
Jon Schipp
Download URL
https://github.com/jonschipp/nagios-plugins/blob/master/check_service.sh
Compatible With
Check status of system services for Linux, FreeBSD, OSX, and AIX.
Options: -s <service> Specify service name -l List services -o <os> OS type, "linux/osx/freebsd/aix" -u <user> User if you need to ``sudo -u'' for launchctl (def: nagios, osx only) -t <tool> Manually specify service management tool (def: autodetect) with status and service e.g. ``-t "service nagios status"''
# Author: Jon Schipp
######## # Examples:
# 1.) List services for osx # $ ./check_service.sh -l -o osx # # 2.) Check status of SSH service on a linux machine # $ ./check_service.sh -o linux -s sshd
# 3.) Manually select service management tool and service # $ ./check_service.sh -o linux -t "service rsyslog status"
Please check and disable your sestatus (selinux)
I have used this script in environmentand successfully able to monitor thr service Thanks For this 68
First of all great script. I'm running RedHat 7.5 and had a problem with the $TRUST_EXIT_CODE. The check was allways ok, even when the checked service was not running. Because of line 255: [ $TRUST_EXIT_CODE -eq 1 ] && [ $EXIT_CODE -eq 0 ] && echo "Trust $STATUS_MSG" && exit $OK I changed in the if section for $OS == linux line 85 from $TRUST_EXIT_CODE=1 to $TRUST_EXIT_CODE=0 and script is working as expected. determine_service_tool() { if [[ $OS == linux ]]; then if command -v systemctl >/dev/null 2>&1; then SERVICETOOL="systemctl status $SERVICE | grep -i Active" LISTTOOL="systemctl" if [ $USERNAME ]; then SERVICETOOL="sudo -u $USERNAME systemctl status $SERVICE" LISTTOOL="sudo -u $USERNAME systemctl" fi TRUST_EXIT_CODE=0 # changed from 1 to 0 Maybe this will help some one or you can fix it permenantly. Kind regards
I can“t get this script to work when running check_nrpe from nagios server. Only get NRPE: Unable to read output Running script directly on server to check works fine. Am i missing something here ?
You must be logged in to submit a review.
To:
From: