Script implementation: When the number of MWM processes is greater than 2 and consumes more than 100 CPU time, send a mail alert with the following script:
#!/usr/bin/ksh#---------------------------------------------------------------## script name : mwm check shell# version : 3# created by : xin23# on : 2015.02.04 # updated by : xin23# on : 2015.02.15# Updated by : Xin23# on : 2015.02.25#------------------------------------------------------------ ---## define directorymwmcheckdir=/home/monitor/mwm_check_dircd $MWMCHECKDIR # define mail address listmaillist= " [Email protected] "hostname=$ (HOSTNAME) # define mail Titlesubject= "[$HOSTNAME] mwm process warning "# define mail message mwmprocessnum=$ (PS&NBSP;-EF&NBSP;|&NBSP;GREP&NBSP;MWM&NBSP;|&NBSP;GREP&NBSP;-V&NBSP;GREP&NBSP;|&NBSP;WC -l| awk ' {print $1} ') typeset -i mwm_cpu_time= "$ (ps -ef | grep mwm | grep -v grep | awk ' {print $8} ' | grep -ev ' XINIT|MWM ' | cut -d ': ' -f 1 | tr ' \ n ' ' + ') 0 " Generatemailmessage () {cat <<eof >> mailmessagesubject: $SUBJECTTo: "$HOSTNAME administrator" <[email protected]>From: "$HOSTNAME crontab" <[email protected]>Reply-To: $MAILLISTDear customer : Server Current Time: $ (date) MWM the current number of processes is [$MWMPROCESSNUM] and consumes CPU time slices [$MWM _cpu_time], follow , specific as follows: $ (ps -ef | GREP&NBSP;MWM&NBSP;|&NBSP;GREP&NBSP;-V&NBSP;GREP) above eofsendmail "$MAILLIST" < mailmessagerm -f MAILMESSAGE}# Mainif [ "$MWMPROCESSNUM" -gt "2" ] && [ "$MWM _cpu _time " -gt " ] then generatemailmessage fi
As follows:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/F5/wKiom1TxKB7QmklXAAMczgyCYHk042.jpg "title=" Mail "alt = "Wkiom1txkb7qmklxaamczgycyhk042.jpg"/>
The END
This article from "Xin23 Journal" blog, declined reprint!
AIX process Monitoring script sharing (ii)