send an email when a process goes down


We are moving to Red Hat Linux and I was wondering if linux had something like

If a process is shut down - send email
If a process is using more than x gb of memory send an email


can we write a shell script for that.
Who is Participating?
ravenplConnect With a Mentor Commented:
So far I know, no.

But I'm doing this very thing by myself. I created /root/bin/check_up script with following content


ps -C qmail-send >/dev/null 2>&1 || MSG="$MSG; qmail is not running"
#more checks
LARGEST=$( ps -eo vsize | sort -nr | head -n1 )
if [ -n "$MSG" -o $LARGEST -gt 102400 ]; then #some stopped, or largest > 100M
 TENLARGE=$( ps -eo vsize,rss,pid,cmd | sort -nr | head -n10 )
 echo -e "$MSG\nlargest procs:\n$TENLARGE" | mail -s "died processes detected"
Then ust add it to cron for regular runs
Jan SpringerConnect With a Mentor Commented:
You should look into Nagios and Nagios plugins.  This will accomplish what you want.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.