[Xymon] Any way to do http tests with HEAD request?

Jeremy Laidman jlaidman at rebel-it.com.au
Tue Apr 14 07:06:49 CEST 2015


On 14 April 2015 at 06:45, Andrew Rakowski <landrew at pnnl.gov> wrote:

> Thanks for the reply Jeremy.  I thought about making a "httphead" test in
> the protocols.cfg file, and using the "curl" utility to do what BigBrother
> used to do,


You would do one or the other.


> but I don't see how to pass the URL to the test.
>

To use protocols.cfg, you would have to specify it in the protocols.cfg
file.  For example:

[httphead]
  port 80
  send "HEAD
/xyz/portal/user/anon/js_peid/123456790/panel/Main/template/content\r\nHost:
xyz.somewhere.com\r\n\r\n"
  expect "HTTP/1.1 200 OK"

Actually, my protocols.cfg (and probably the installed version) already had
a similar definition as [cuspd] which queries a CUPS protocol print server,
which is essentially a web service running on port 631.


> Is there some implicit passing of test URL to these protocols.cfg defined
> tests (like the string from the hosts.cfg file is stuck at the end of the
> invoked command taken from protocols.cfg?)


No.  But you can do this with a script.  For example:

0.0.0.0 xyz-web2 # noconn HTTPHEAD:TIMEOUT=15,URL=
https://xyz.somewhere.com/xyz/portal/user/anon/js_peid/123456789/panel/Main/template/content

Then:

#!/bin/sh

[ "$XYMONHOME" ] || exit 1
TEST=httphead
CURL=/usr/bin/curl

$XYMONHOME/bin/xymongrep "HTTPHEAD:*" | sed 's/ *# */ /;s/ dialup//;s/
testip//'|
        while read IP HOST STRING; do
                PART=`IFS=":"; set - $STRING; shift; echo "$*"`
                (
                        IFS=,
                        set - $PART
                        TIMEOUT=15
                        URL=""
                        while [ "$1" ]; do
                                VAR=`IFS="="; set - $1; echo $1`
                                VAL=`IFS="="; set - $1; shift; echo "$*"`
                                case "$VAR" in
                                        TIMEOUT) TIMEOUT="$VAL";;
                                        URL) URL="$VAL";;
                                esac
                                shift
                        done
                        RESULT=`$CURL -g -s -S -m 45 -I -k
--connect-timeout $TIMEOUT "$URL" 2>&1`
                        [ $? -eq 0 ] && COL=green || COL=red
                        #printf "status $HOST.$TEST $COL `date` HEAD status
$COL\n\n$RESULT\n" | $XYMON $XYMSRV "@"
                        printf "status $HOST.$TEST $COL `date` HEAD status
$COL\n\n$RESULT\n"
                )
        done
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20150414/4fd30f2a/attachment.html>


More information about the Xymon mailing list