Skip to content

Instantly share code, notes, and snippets.

@maesoser
Created January 4, 2019 08:40
Show Gist options
  • Save maesoser/11635c9bec822d28a466287b46220fde to your computer and use it in GitHub Desktop.
Save maesoser/11635c9bec822d28a466287b46220fde to your computer and use it in GitHub Desktop.
Quick and dirty process monitor, something like Monit
#!/usr/bin/env bash
FAIL='\033[0;31m'
OK='\033[0;32m'
END='\033[0m' # No Color
declare -a arr=("rsyslogd" "crond" "noelement")
## now loop through the above array
for i in "${arr[@]}"
do
pid=$(pgrep -o -f $i)
if [ $? -eq 0 ]; then
printf "${OK}[$pid]${END}\t$i\n"
else
printf "${FAIL}[FAIL]${END}\t$i\n"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment