# 自动判断samba,http,named,dovecot,tomcat等服务是否正常启动
#
#作者:胡昌文
#时间:2008-09-28
#MSN:[email]hucw_rhce@hotmail.com[/email]
#
#
#!/bin/sh
SAMBA1=`netstat -nutlp | grep :137 | grep smbd`
SAMBA2=`netstat -nutlp | grep :138 | grep smbd`
SAMBA3=`netstat -nutlp | grep :139 | grep smbd`
SAMBA4=`netstat -nutlp | grep :445 | grep smbd`
SAMBA=$SAMBA1$SAMBA2$SAMBA3$SAMBA4
if [ "$SAMBA" ]; then
echo -e "Checking samba services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking samba services...... [ \033[31mNG\033[m ]"
fi
APACHE=`netstat -nutlp | grep :80 | grep httpd`
if [ "$APACHE" ]; then
echo -e "Checking httpd services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking httpd services...... [ \033[31mNG\033[m ]"
fi
SMTP=`netstat -nutlp | grep :25 | grep master`
if [ "$SMTP" ]; then
echo -e "Checking smtpd services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking smtpd services...... [ \033[31mNG\033[m ]"
fi
POP3=`netstat -nutlp | grep :110 | grep dovecot`
if [ "$POP3" ]; then
echo -e "Checking dovecot services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking dovecot services...... [ \033[31mNG\033[m ]"
fi
MYSQL=`netstat -nutlp | grep :3306 | grep mysql`
if [ "$MYSQL" ]; then
echo -e "Checking mysqld services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking mysqld services...... [ \033[31mNG\033[m ]"
fi
NAMED=`netstat -nutlp | grep :53 | grep named`
if [ "$NAMED" ]; then
echo -e "Checking named services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking named services...... [ \033[31mNG\033[m ]"
fi
JAVA=`netstat -nutlp | grep 8080 | grep java`
if [ "$JAVA" ]; then
echo -e "Checking tomcat services...... [ \033[32mOK\033[m ]"
else
echo -e "Checking tomcat services...... [ \033[31mNG\033[m ]"
fi