So I have a Nagios server which monitors a cPanel server. One of the checks I wanted to make is to check the cPanel service and make sure it's running. Custom nagios checks can be done in bash like I have. When I run the check, I don't get any errors BUT it does not produce any output:
SERVICE=$(service cpanel status | head -1);
if [ "$SERVICE" = running ] ; then
echo "OK - cPanel is running."
elif [ "$SERVICE" = stopped ] ; then
echo "CRITICAL - cPanel is NOT running!!"
As you can see, I want to run the
service cpanel status | head -1
command and take that output and pass it so depending on the output it will determine the exit code and output. I'm new to bash scripting so I'm at a lost as to what I'm doing wrong.
Thank you SO MUCH in advance for any and all help!!