Ad Widget

Collapse

checking for http response headers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moses.moore
    Junior Member
    • Dec 2014
    • 24

    #1

    checking for http response headers

    I've been asked to monitor a web url to make sure the 'Location:' http header is correct, and alert if it changes.

    I don't know how to do this in Zabbix. I can make a web check step that fetches only headers, or a webcheck step that sends custom http request headers, or a web check step that searches the http response body for a substring... but I don't know how to write a web check step that searches the http response headers for a substring.

    Is there something I'm overlooking when reading the manual?
  • jamesNJ
    Senior Member
    • Jun 2015
    • 103

    #2
    I don't see that there is a trivial way to check the headers with a web scenario, however probably the scenario was not really designed to do that.

    If all you are interested in is a basic check of a page for a particular header, you could write a script and use UserParameter to invoke your scrip with the URL and have it return the header of interest. Then your trigger would check for the desired string.

    If invoking a script from zabbix is undesirable, you could also write a very simple cron job which dumps the page headers to a file, and then use the zabbix agent (like log monitoring) to look for a particular string.

    curl can dump just the headers of a url using -I option

    I hope that helps

    Comment

    • moses.moore
      Junior Member
      • Dec 2014
      • 24

      #3
      Yeah I can easily write

      Code:
      curl -s |grep "Location: http://blah" >/dev/null \
        || mail sysdamin@company <<<"Problem with website xyz"
      ... but then I'm discarding Zabbix for something handcrafted, and it makes the people I work for wonder why I deployed Zabbix.

      The webcheck stuff is already weird; I have to associate each webcheck with a Host-object, but the Host-object may not be the same as the host where the website lives; especially in cases where I must watch a machine I can't install a Zabbix agent into. It's really weird getting an alert that says "Host saturn webcheck failed" when I know the website is actually hosted on host mars.

      I was hoping there was a Zabbix-y way, instead of bolting some other monitoring system onto the side of a Zabbix agentd. Is there a better way?

      Comment

      • jamesNJ
        Senior Member
        • Jun 2015
        • 103

        #4
        Well, I somewhat agree that the Item association with hosts takes some thought. I think maybe "applications" were meant to help there but I haven't used that yet.

        Zabbix won't accommodate every single thing so some customization is usually needed.

        I wasn't suggesting to set up a completely separate monitor via e-mail, but was suggesting you can write a script that pulls that data into zabbix and then use the zabbix system to poll for status, trigger, action/alert/etc.

        I like UserParameter, but it looks like your need might be simple enough for system.run, try something like this:

        system.run["curl -Is http://192.168.1.1 | fgrep Location"]

        Curl will just dump the headers and fgrep will filter on Location. Pull that in as s string to Zabbix. Once you have it in the system as a periodic poll, you can write a trigger to check the location. You could hard-code this, or set a per-host macro, or set up another zabbix item which pulls in the desired location and compare against it.

        I hope this helps.

        Comment

        Working...