Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

send an email when a process goes down

Hi,

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

etc

can we write a shell script for that.
0
anshuma
Asked:
anshuma
2 Solutions
 
ravenplCommented:
So far I know, no.

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

#!/bin/bash

MSG=""
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" me@somewhere.com
fi
#---
Then ust add it to cron for regular runs http://www.deluxnetwork.com/linux/guides/crons.php
0
 
Jan SpringerCommented:
You should look into Nagios and Nagios plugins.  This will accomplish what you want.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now