How to use Shell script to monitor the number of Squid running processes and restart automatically
This article introduces the knowledge of "how to use Shell scripts to monitor the number of Squid running processes and restart automatically". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The code is as follows:
#! / bin/sh
While sleep 30
Do
SquidNum= `ps-ef | grep squid | grep-v grep | wc-l`
# HttpNum= `netstat-an | grep 0.0.0.0 grep 80 | grep-v grep | wc-l` # 80 status
If [$SquidNum! = 3]; then
/ etc/rc3.duid start
Adddate= `date +% Ymuri% mmury% d` "" `HRU +% date% M:% S` "
Echo "$adddate squid started!" > > / home/resquid.log
Fi
# restart squid service after more than 5000 http requests
HttpNum= `netstat-an | grep 80 | grep-v grep | wc-l`
If [$HttpNum-gt 5000]; then
/ etc/rc3.duid restart
Adddate= `date +% Ymuri% mmury% d` "" `HRU +% date% M:% S` "
Echo "$adddate http out 5000 squid started!" > > / home/resquid.log
Fi
Done
"how to use Shell script to monitor the number of Squid running processes and automatically restart" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!