I have started to play around with "wget" a bit and have got a working command that will test the download time.
How would I take the writen skript and use that in a service check with nagios. This has always confused me, how one would use or combine a skript in a nagios command check. What would such a command look like?
You will need to add the script into a command object in your command.cfg file, perhaps something like
# 'check_www_loadtime' command definition
command_line /path/to/myscript -u $ARG1$ -w $ARG2$ -c $ARG3$
[blockquote]And how would you tell nagios to run the skript every time nagios ran the service check to compare the time of the download from the webpage with the preset threshold?[/blockquote]
...then you reference the command object in the service object definition as per normal, for example:
service_description Webpage Load Time
Obviously I've no idea how you've created your script (bash? perl?) but assume for simplicity that it accepts three arguments, one (-u) for the URL you are timing, and a warning (-w) and critical (-c) value. The arguments are passed from the service description to the command object in the order that they are delimited (by the ! character - i.e, value after the first '!' is $ARG1$, after the second is $ARG2$ and so on) so you end up running "myscript" with arguments -u www.myurl.com -w 200 -c 500. Nagios will call that every time the service check is required by your check schedule. Your script then needs to return an exit code back to nagios in the range 0-4 in order for it to tell nagios what the state of the check is i.e. exit code 0 = OK, exit code 1 = warning, and so forth.
Hopefully that should sort you out, although if you've just gone "Eh? Arguments? Exit Codes? Burble..." and you are using perl, then have a peek at the little scriptette about halfway down the replies here - should be enough there to unpick and re-use. If its a bash script though, can't really proffer any useful advice as I don't know how, mebey someone else will chime in if req'd...