方法:能夠利用crontab跑計劃任務,也能夠用shell腳本去執行icontrol來調用不一樣的pool,實現維護頁面和正常頁面的切換web
1) 根據icontrol的API,建立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 &