99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

shell腳本怎樣實現定時監控http服務的運行狀態-創新互聯

這篇文章主要為大家展示了“shell腳本怎樣實現定時監控http服務的運行狀態”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“shell腳本怎樣實現定時監控http服務的運行狀態”這篇文章吧。

目前創新互聯公司已為成百上千家的企業提供了網站建設、域名、雅安服務器托管網站托管、企業網站設計、卡若網站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協力一起成長,共同發展。

注意:監控方法可以為端口、進程、URL模擬訪問方式,或者三種方法綜合。

說明:由于截止到目前僅講了if語句,因此,就請大家用if語句來實現。

  [root@oldboy-B scripts]# cat apachemon
  #!/bin/sh
  #created by oldboy 20110523
  . /etc/init.d/functions
  HTTPPRONUM=`ps -ef|grep http|grep -v grep|wc -l`
  #if [ $HTTPPRONUM -lt 1 ];then
  if [[ $HTTPPRONUM -lt 1 ]];then
  action “httpd is not running” /bin/false
  action “httpd is not running” /bin/false >/tmp/httpd.log
  httpdctl restart >/dev/null 2>&1
  action “httpd is restart” /bin/true
  mail -s “`uname -n`’s httpd restarted at `(date)`” 31333741@qq.com
  exit 1
  else
  action “httpd is running” /bin/true
  exit 0
  fi
  [root@oldboy-B scripts]# apachemon
  httpd is running [確定]
  [root@oldboy-B scripts]# pkill httpd
  [root@oldboy-B scripts]# ps -ef |grep http |grep -v grep
  [root@oldboy-B scripts]# apachemon
  httpd is not running [失敗]
  httpd is restart [確定]
  [root@oldboy-B scripts]# ps -ef|grep http|grep -v grep
  root 5845 1 1 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5852 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5853 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5854 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5855 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5856 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5857 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5858 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart
  apache 5859 5845 0 15:59 ? 00:00:00 /usr/sbin/httpd -k restart

腳本 改進

  [root@oldboy-B /]# echo oldboytest >/var/www/html/index.htm
  [root@oldboy-B /]# wget –quiet –spider http://10.0.0.161/index.htm
  [root@oldboy-B /]# echo $?
  0
  [root@oldboy-B /]# ll index.htm
  ls: index.htm: 沒有那個文件或目錄
  [root@oldboy-B scripts]# cat apachemon1
  #!/bin/sh
  #created by oldboy 20110523
  
  . /etc/init.d/functions
  #HTTPPRONUM=`ps -ef|grep http|grep -v grep|wc -l` #=====>這個是基于http方式進行判斷
  wget –quiet –spider http://10.0.0.161/index.htm #=====>這個是基于WGET URL方式進行判斷
  if [ $? -ne 0 ];then
  action “httpd is not running” /bin/false >/tmp/httpd.log
  httpdctl restart >/dev/null 2>&1
  action “httpd is restart” /bin/true >>/tmp/httpd.log
  mail -s “`uname -n`’s httpd restarted at `(date)`” mail@qq.com
  exit 1
  else
  action “httpd is running” /bin/true
  exit 0
  fi

真正使用時,有些輸出是不需要的就去掉

  [root@oldboy-B scripts]# cat apachemon1
  #!/bin/sh
  #created by oldboy 20110523
  #
  . /etc/init.d/functions
  wget –quiet –spider http://10.0.0.161/index.htm #=====>這個是基于WGET URL方式進行判斷
  if [ $? -ne 0 ];then
  action “httpd is not running” /bin/false >/tmp/httpd.log
  httpdctl restart >/dev/null 2>&1
  action “httpd is restart” /bin/true >>/tmp/httpd.log
  mail -s “`uname -n`’s httpd restarted at `(date)`” 31333741@qq.com
  exit 1
  fi

多條件判斷的寫法

  [root@oldboy-B scripts]# cat apachemon1
  #!/bin/sh
  #created by oldboy 20110523
  #
  . /etc/init.d/functions
  HTTPPORTNUM=`netstat -lnt|grep 80|grep -v grep|wc -l`
  HTTPPRONUM=`ps -ef|grep http|grep -v grep|wc -l`
  wget –quiet –spider http://10.0.0.161/index.htm && RETVAL=$?
  if [ $RETVAL -ne 0 ] || [ $HTTPPORTNUM -ne 1 ] || [ $HTTPPRONUM -lt 1 ] ;then
  #if [ "$RETVAL" != "0" -o "$HTTPPORTNUM" != "1" -o "$HTTPPRONUM" \< "1" ] ;then
  action “httpd is not running” /bin/false
  action “httpd is not running” /bin/false >/tmp/httpd.log
  httpdctl restart >/dev/null 2>&1
  action “httpd is restart” /bin/true
  mail -s “`uname -n`’s httpd restarted at `(date)`” 31333741@qq.com
  exit 1
  else
  action “httpd is running” /bin/true
  exit 0
  fi

以上是“shell腳本怎樣實現定時監控http服務的運行狀態”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注創新互聯-成都網站建設公司行業資訊頻道!

當前名稱:shell腳本怎樣實現定時監控http服務的運行狀態-創新互聯
瀏覽路徑:http://www.yijiale78.com/article18/ddoigp.html

成都網站建設公司_創新互聯,為您提供響應式網站手機網站建設關鍵詞優化網站制作品牌網站建設營銷型網站建設

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都定制網站建設