linux网络服务偶尔失效,判断linux下的网络服务是否正常启动

# 自动判断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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值