- 论坛徽章:
- 0
|
20.检查系统的进程
a.check_proc.sh:
#check_proc.sh
cat check_proc.list|awk -F "," {'print "Check_proc.sh "$1" \""$2"\"" " "$3 '}|sh
b.check_proc.list:(可修改)
telnet,telnetd -a,2
xcom,xcommanager.py,1
c.Check_proc.sh:
#Check_proc.sh
export LANG=en_US
count=`ps -ef|grep "$2"|grep -v grep|wc -l`
if [ $count -lt $3 ];then
echo $1 has not be started all,the number is $count/$3!
fi
运行示例:
[test3][root][/home/mxin]>ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Aug 10 - 0:11 /etc/init
root 77910 1 0 Aug 10 - 5:53 /usr/sbin/syncd 60
root 102470 1 0 Aug 10 - 0:00 /usr/ccs/bin/shlap64
root 106572 1 0 Aug 10 - 0:00 /usr/lib/errdemon
root 139366 1 0 Aug 10 - 0:00 /usr/sbin/srcmstr
root 164068 139366 0 Aug 10 - 0:00 /usr/sbin/snmpd
root 184466 139366 0 Aug 10 - 4:38 /usr/sbin/aixmibd
root 246002 1 0 Aug 10 vty0 8:50 -ksh
root 409612 139366 0 Aug 10 - 0:05 sendmail: accepting connections
root 417830 139366 0 Aug 10 - 0:00 /usr/sbin/syslogd
root 421898 1 0 Aug 10 - 0:00 /usr/sbin/uprintfd
root 442602 782494 0 16:19:29 - 0:00 telnetd -a
root 446688 442602 0 16:19:29 pts/1 0:00 -ksh
root 466976 782494 0 Sep 07 - 0:00 ftpd
root 471108 139366 0 Aug 10 - 0:01 /usr/sbin/hostmibd
root 495680 1 0 Aug 10 - 0:04 /usr/sbin/cron
root 508018 139366 0 Aug 10 - 0:00 /usr/sbin/portmap
root 708686 782494 0 Sep 07 - 0:00 ftpd
root 729196 139366 0 Aug 10 - 0:04 /usr/sbin/snmpmibd
root 733290 139366 0 Aug 10 - 0:00 /usr/sbin/muxatmd
root 762026 446688 0 17:46:17 pts/1 0:00 ps -ef
root 782494 139366 0 Sep 07 - 0:00 /usr/sbin/inetd
[test3][root][/home/mxin]>check_proc.sh
telnet has not be started all,the number is 1/2!
xcom has not be started all,the number is 0/1!
[ 本帖最后由 mxin 于 2006-9-21 17:51 编辑 ] |
|