zoukankan      html  css  js  c++  java
  • web站点检查简易shell脚本

    1.web样式

    <h4>THE STATUS OF RS:</h4>
    <meta http-equiv="refresh" content="1">
    <table border="1">
    <tr>
    <th>NO:</th>
    <th>IP:</th>
    <th>STATUS</th>
    </tr>
    
    <tr>
    <td bgcolor="green">0</td>
    <td bgcolor="green">192.168.100.175</td>
    <td bgcolor="green">up</td>
    </tr>
    
    <tr>
    <td bgcolor="red">1</td>
    <td bgcolor="red">192.168.100.169</td>
    <td bgcolor="red">down</td>
    </tr>
    
    </table>

    2.shell脚本

    #!/bin/bash
    
    rs_arr=(
        192.168.100.175
        192.168.100.169
    )
    
    model_file=./test.html
    
    function web_result {
        rs=`curl -o /dev/null -s -w %{http_code} $1`
        return $rs
    }
    
    function new_row {
    cat >> $model_file <<eof
    <tr>
    <td bgcolor="$4">$1</td>
    <td bgcolor="$4">$2</td>
    <td bgcolor="$4">$3</td>
    </tr>
    
    eof
    }
    
    function auto_html {
        web_result $2
        rs=$?
        if [ $rs -eq 200 ]
        then
        new_row $1 $2 up green
        else
        new_row $1 $2 down red
        fi
        
    }
    
    while true
    do
    
    cat >> $model_file <<eof
    <h4>THE STATUS OF RS:</h4>
    <meta http-equiv="refresh" content="1">
    <table border="1">
    <tr>                 
    <th>NO:</th>        
    <th>IP:</th>
    <th>STATUS</th>
    </tr>
    
    eof
    
    for ((i=0;i<${#rs_arr[*]};i++));do
        auto_html $i ${rs_arr[$i]}
    done
    
    cat >> $model_file <<eof
    </table>
    
    eof
    
    sleep 2
    >$model_file
    
    done
    
    #<meta http-equiv="refresh" content="1">

    3.预览

  • 相关阅读:
    Delphi源程序格式书写规范
    ORACLE常用傻瓜问题1000问
    世界上最健康的作息时间表
    poj1657
    poj1604
    poj1654
    poj1635
    poj1655
    成为一个不折不扣的时间管理专家[推荐]
    男人的十三怕
  • 原文地址:https://www.cnblogs.com/vijayfly/p/5497956.html
Copyright © 2011-2022 走看看