Chinaunix首页 | 论坛 | 博客
  • 博客访问: 10808869
  • 博文数量: 2905
  • 博客积分: 20098
  • 博客等级: 上将
  • 技术积分: 36298
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-23 05:00
文章存档

2012年(1)

2011年(3)

2009年(2901)

分类: LINUX

2009-03-23 11:16:00

# 自动判断samba,http,named,dovecot,tomcat等服务是否正常启动
#
#作者:胡昌文
#时间:2008-09-28
#MSN:
#
#
#!/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
 
阅读(1202) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~