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

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”
exit 0

You can add this to crontab like below:
* * * * * /u02/scripts/ >/dev/null 2>&1

Category: Shell ScriptsSolarisUnix


Leave a Reply

Article by: Shadab Mohammad