Monitor User Processes and Send Email Shell Script Solaris10

Sometimes on a system it is important to know the maximum user processes does not increase so much that it consumes all shared memory. Recently we had an incident in our ORganization where a rogue application bug caused user processes to spike upto 20,000 and it consumed all memory and swap and the entire server crashed.  If we pro-actively monitored the system for increasing user processes we could have averted this disaster. Below is script to monitor user processes and send email.

swx – is name process name

500- threshold for permitted processes

#!/bin/ksh
VAL=`ps -ef | grep -c swx | awk ‘{if ( $1 > 500 ) print $1 }’`

if [ “$VAL” -ge “500” ]; then
echo “$VAL user processes found running with SWX user. Exceeded the Threshold,
Please take immediate action.” | /usr/bin/mailx -s “Alert !! $VAL SWX Applicati
on processes” email@test.com
fi

exit 0

You can add this to crontab like below:

* * * * * /u02/scripts/userprocmon.sh >/dev/null 2>&1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s