本脚本可获取服务器Site值和服务器ip,执行之后可通过RTX推送系统消息

脚本例子如下:

#!/bin/bash
function alarm(){
    user="$1"
    content="$2"
    stat=$(curl --connect-timeout 60 -s "http://yw.test.com:8082/alarmServer/bus?user_name="${user}"&sendType=2,3&title=【服务器IP信息】&systemId=5&password=I6rXbaO****&content="${content}"")
    echo ${stat}
}

#site = web_guanwangtest_0001 | web_4399_0001

function setconf(){
    site=$1
    number=$(echo ${site##*_})
    echo $site $number ${site%_*}
    case ${site%_*} in
        web_duowan)
            title="多玩${number}区";;
        web_4399)
            title="4399${number}区";;
        web_guanwangtest)
            title="测试服${number}区";;
        *)
            echo "没有这个代理的信息,请更新脚本!"
    esac
}

function getconf(){
    ip_config=($(ifconfig eth0|awk -F'[ :]+' '/inet/{print $4}') $(ifconfig eth0:1|awk -F'[ :]+' '/inet/{print $4}'))
    setconf "$(hostname)"
    content="${title}%0Aip地址:${ip_config[0]}%20${ip_config[1]}"
}

function main(){
    getconf
    alarm "jerry.huang,Shelly.yu" "${content}"
    #echo ${content}
}
main
code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2021-09-17
  • 2022-12-23
  • 2021-06-28
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案