F5定时切换维护页面

方法:能够利用crontab跑计划任务,也能够用shell脚本去执行icontrol来调用不一样的pool,实现维护页面和正常页面的切换web

 

1)  根据icontrolAPI,建立XML请求的文件,soapreq_install_pool.txt为切换到维护页面shell

<?xml version="1.0" encoding="utf-8"?>curl

<SOAP-ENV:Envelopeide

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"url

  xmlns:xsd="http://www.w3.org/2001/XMLSchema"spa

  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"orm

  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/envelope/">server

  <SOAP-ENV:Body>xml

    <m:set_default_pool_name xmlns:m="urn:iControl:LocalLB/VirtualServer">crontab

      <virtual_servers type="tns:Common.StringSequence">

        <virtual_server>web_vs</virtual_server>

      </virtual_servers>

      <default_pools type="tns:Common.StringSequence">

        <default_pool>install_pool</default_pool>

      </default_pools>

    </m:set_default_pool_name>

  </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

 

soapreq_web_pool.txt为切换到正常页面

<?xml version="1.0" encoding="utf-8"?>

<SOAP-ENV:Envelope

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  xmlns:xsd="http://www.w3.org/2001/XMLSchema"

  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/envelope/">

  <SOAP-ENV:Body>

    <m:set_default_pool_name xmlns:m="urn:iControl:LocalLB/VirtualServer">

      <virtual_servers type="tns:Common.StringSequence">

        <virtual_server>web_vs</virtual_server>

      </virtual_servers>

      <default_pools type="tns:Common.StringSequence">

        <default_pool>web_pool</default_pool>

      </default_pools>

    </m:set_default_pool_name>

  </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

 

2)  建立定时执行的shell脚本,autosetpool.sh,1点切换到维护页面,5点切换到正常页面,30秒执行一次循环。

while true; do

    A=`date -d "1 minute" +%Y%m%d%H%M`

    if [ $A -eq '201103200100' ]; then

    curl --data-binary @soapreq_install_pool.txt https://admin:admin@192.168.1.245/iControl/iControlPortal.cgi --insecure

    elif [ $A -eq '201103200500' ]; then

    curl --data-binary @soapreq_web_pool.txt https:// admin:admin@192.168.1.245/iControl/iControlPortal.cgi --insecure

    fi 

    sleep 30

done

 

3)设置后台执行脚本,不挂断的运行命令,

nohup ./autosetpool.sh >/dev/null 2>&1 &

相关文章
相关标签/搜索