# Squid Proxy Heath Check

**URL:** <https://community.a10networks.com/t/squid-proxy-heath-check/206>\
**Category:** System\
**Tags:** health-monitor\
**Created:** [May 23, 2013, 8:31am UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206 "2013-05-23T08:31:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HA](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@HA](https://community.a10networks.com/u/HA)\
**Post date:** [May 23, 2013, 8:31am UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/1 "2013-05-23T08:31:09Z")

</div>

Hello,

I’m currently evaluating A10 (so I’m a newbie !) and I have question about Health Check.  
I configured two Squid Servers for Load Balancing.  
The health check is done using a TCP session (to port 8080) and sending the command 'GET [http://www.google.com](http://www.google.com)\r\n".  
It works fine but I would like also check the Response HTTP code from the proxy (basically 200,301,302) to be sure the proxy is working correctly (no problem on the ISP line, etc)

Next, I will create two other checks (like [www.facebook.com](http://www.facebook.com) and [www.microsoft.com](http://www.microsoft.com)) and if 2 of the 3 checks fails (compund check), the squid proxy should be consider EOS.

How to write such script ?

Regards,

HA

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/a10_community/original/1X/bb9f186d33804d3044a0374e589f49fdf3be1328.png) [@system](https://community.a10networks.com/u/system)\
**Post date:** [May 23, 2013, 9:40am UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/2 "2013-05-23T09:40:06Z")

</div>

Hi HA,  
&nbsp;&nbsp;&nbsp;&nbsp;You can set a HTTP health monitor to look at response codes using the standard health template - see attached image.  
&nbsp;&nbsp;&nbsp;&nbsp;You could also on the server in question have a script that checks the other two site and put the logic there.

Another option would be to create an external health monitor that check the three sites and use that monitor.

Thanks  
Michael.

---

<div class="post-metadata">

**Author:** ![HA](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@HA](https://community.a10networks.com/u/HA)\
**Post date:** [May 23, 2013, 10:01am UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/3 "2013-05-23T10:01:45Z")

</div>

Hello Michael,

First, thanks a lot for your help.  
Unfortunately, the HTTP Health Monitoring doesn’t work in this case.  
In fact, the Proxy is expecting a URL in the format ‘GET [http://X.Y.Z](http://X.Y.Z)’.  
In the URL field of the GUI, you cannot enter such kind of text (must start with /).  
PS : I have no experience with TCL or Perl script.  
PS2: I coming from Netscaler planet where everything is done from the GUI…  
Regards,

HA

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [May 23, 2013, 2:25pm UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/4 "2013-05-23T14:25:38Z")

</div>

You can do this in the GUI as well. You just need to add an External Program.

Config Mode → Service → Health Monitor → External Program → Add Name: squid.sh Add the below script: `#!/bin/bash if [x"$1" == x]; then exit -1 fi curl -I -x/ --proxy $HM_SRV_IPADDR:$HM_SRV_PORT HTTP://$1 > /dev/null 2>&1 exit $? `

Config Mode → Service → Health Monitor → Health Monitor → Add Name: hm-proxy Method: External Program: squid.sh

Add this Health Monitor to the service-group or server port.

---

<div class="post-metadata">

**Author:** ![kdunaev](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@kdunaev](https://community.a10networks.com/u/kdunaev)\
**Post date:** [May 23, 2013, 3:00pm UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/5 "2013-05-23T15:00:32Z")

</div>

Hi,

We did such a healthchecking for Bluecoat cacheservers and used just a “host:” option.

I can’t give you a GUI example, but here is the CLI config:

_health monitor HM\_GG interval 3 retry 2 timeout 3 strictly-retry-on-server-error-response method http url HEAD / expect response-code 200,301,302 host [www.google.com](http://www.google.com) ! health monitor HM\_FB interval 3 retry 2 timeout 3 strictly-retry-on-server-error-response method http url HEAD / expect response-code 200,301,302 host [www.facebook.com](http://www.facebook.com) ! health monitor HM\_MS interval 3 retry 2 timeout 3 strictly-retry-on-server-error-response method http url HEAD / expect response-code 200,301,302 host [www.microsoft.com](http://www.microsoft.com) ! health monitor Compound\_Or\_HM interval 10 retry 1 timeout 10 strictly-retry-on-server-error-response method compound sub HM\_GG sub HM\_FB or sub HM\_MS or_

if you assign the compound check to the server, it will fail if ALL 3 checks fail. You can play around with “or’s” and “and’s” to achieve your expected configuration.

---

<div class="post-metadata">

**Author:** ![mischa](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mischa](https://community.a10networks.com/u/mischa)\
**Post date:** [May 23, 2013, 5:26pm UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/6 "2013-05-23T17:26:42Z")

</div>

One thing I forgot the $1 is set when you add an argument to the Health Monitor:

Argument: http://

Thanx Dave! 🙂

---

<div class="post-metadata">

**Author:** ![HA](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@HA](https://community.a10networks.com/u/HA)\
**Post date:** [May 24, 2013, 7:54am UTC](https://community.a10networks.com/t/squid-proxy-heath-check/206/7 "2013-05-24T07:54:40Z")

</div>

Hello,

First, thanks a lot for your help.  
When I try kdunaev’s solution, I got an error message :

```auto
SoftAX(config)\#health monitor HM\_GG interval 3 retry 2 timeout 3
SoftAX(config-health:monitor)\#strictly-retry-on-server-error-response
SoftAX(config-health:monitor)\#$ode 200,301,302 host http://www.google.com

```

method http url HEAD / expect response-code 200,301,302 host [http://www.google.c](http://www.google.c)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^  
% Unrecognized command.Invalid input detected at ‘^’ marker.  
Now with Mischa’s script, I got a valid response from the squid :

```auto
192.168.1.210 TCP\_MISS/302 934 HEAD http://www.google.com/ - DIRECT/173.194.69.147 text/html

Now If my change my firewall to block HTTP from the proxy (ISP failure simulation), I got the following message from the squid :
TCP\_MISS/000 0 HEAD http://www.google.com/ - DIRECT/www.google.com -

```

The Health Check fails, so the script is working fine !

Thanks Mischa !!

Regards,

HA
