IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置: 首頁(yè)操作系統(tǒng)LINUX → Linux下基于端口的服務(wù)檢查腳本

Linux下基于端口的服務(wù)檢查腳本

時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(1)

  #!/bin/bash

  #program:Usingtostudythe[if...then...fi]program

  #dsk2007/10/83:00

  #content:Iwillusingthisprogramtoshowyousevices

  #1.printtheprogram''sworkinyourscreen

  echo "Now,the service of your Linux system will be detect!"

  echo "The www,ftp,ssh,and sendmail pop3 will be detect!"

  echo ""

  #2.www

  www=`netstat -ntlp | awk '{print $4}' | grep :80$`

  if [ "$www" != "" ];

  then

  echo $www

  echo "WWW is runing"

  else

  echo $www

  echo "WWW is NOT runing"

  killall -9 httpd

  /usr/sbin/apachectl start

  #service httpd start

  fi

  #3.ftp

  ftp=`netstat -an | grep LISTEN | grep :21`

  if [ "$ftp" != "" ]; then

  echo $ftp

  echo "FTP is runing "

  else

  echo "FTP is not runing"

  killall -9 vsftpd

  #service vsftpd start

  /etc/init.d/vsftpd start

  fi

  #4.ssh

  ssh=`netstat -ntlp | awk '{print $4}' | grep :22$`

  #ssh=`netstat -an | grep LISTEN | grep :22`

  if [ "$ssh" != "" ]; then

  echo $ssh

  echo "SSH is running"

  else

  echo "SSH is not running"

  fi

  #5.sendmail pop3

  smtp=`netstat -an | grep LISTEN | grep :25`

  pop3=`netstat -an | grep LISTEN | grep :110`

  if [ "$smtp" != "" ] && [ "$pop3" != "" ]; then

  echo "Send mail is OK!"

  elif [ "$smtp" != "" ] && [ "$pop3" = "" ]; then

  echo " Send mail have some problems of your pop3!"

  elif [ "$smtp" = "" ] && [ "$pop3" != "" ]; then

  echo "Send mail have so me problems of your smtp!"

  else

  echo "Send mail is NO Trunning!"

  fi

關(guān)鍵詞標(biāo)簽:Linux

相關(guān)閱讀

文章評(píng)論
發(fā)表評(píng)論

熱門文章 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 Tomcat9.0如何安裝_Tomcat9.0環(huán)境變量配置方法 Tomcat9.0如何安裝_Tomcat9.0環(huán)境變量配置方法 多種操作系統(tǒng)NTP客戶端配置 多種操作系統(tǒng)NTP客戶端配置 Linux操作系統(tǒng)修改IP Linux操作系統(tǒng)修改IP

相關(guān)下載

    人氣排行 Linux下獲取CPUID、硬盤序列號(hào)與MAC地址 dmidecode命令查看內(nèi)存型號(hào) linux tc實(shí)現(xiàn)ip流量限制 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 linux下解壓rar文件 lcx.exe、nc.exe、sc.exe入侵中的使用方法 Ubuntu linux 關(guān)機(jī)、重啟、注銷 命令 查看linux服務(wù)器硬盤IO讀寫負(fù)載