Skip to content

Instantly share code, notes, and snippets.

@sergio-bobillier
Created October 17, 2015 12:40
Show Gist options
  • Save sergio-bobillier/043cd7d4ae4f6d847f78 to your computer and use it in GitHub Desktop.
Save sergio-bobillier/043cd7d4ae4f6d847f78 to your computer and use it in GitHub Desktop.
A little script to check the status of system services with a nice colored output.
#!/bin/bash
# Checks if services are up by counting the number of processes.
function check_service {
PROCS=$(ps ax | grep "$1" | wc -l)
if [ $PROCS -gt 1 ] ; then
echo -e "[\e[1m\e[32mUP\e[0m]"
else
echo -e "[\e[1m\e[31mDOWN\e[0m]"
fi
}
echo "Apache: $(check_service apache2)"
echo "Courier: $(check_service courier)"
echo "Mysql: $(check_service mysql)"
echo "Open DKIM: $(check_service opendkim)"
echo "Postfix: $(check_service postfix)"
echo "SASL Auth: $(check_service saslauthd)"
echo "Spamassassin: $(check_service spamd)"
echo "VSFTP: $(check_service vsftpd)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment