PDA

View Full Version : Fetch URL


sojeshj
16-05-2005, 17:45
Hi,

Can Zabbix fetch a particular URL. I mean I want to check if I can retrieve a logo on a particular URL (website) in a way to check if that website is up and running fine.

Can Zabbix do that? If so, please let me know how it is done? :confused:

Thanks,
Soj

tbri
22-05-2005, 20:09
Hello.

What I tend to do is to make a small script (I love python) that does some operation on a web page and prints -1 if it fails, and the time used if it's ok. So I graph the value + set a trigger for <0 which notifies me by SMS.

-Torvald

tbri
22-05-2005, 20:10
forgot to mention that I naturally invoke the script as a UserParameter in zabbix_agentd.conf

-Torvald

sojeshj
23-05-2005, 11:19
Thank you Torvald.. Like you said, the script will work when the site (server) is completely down. But what if the apache on the server is running too slow, ie. if the server is crawling and tries to pull out the site for about 5 or 7 minutes, then whole server is as bad as being down and it notify me unless the server/apache service goes completely down. What can be done so that the script compares with the time and notifies?

tbri
23-05-2005, 22:19
I would do something like the following (untested) script to check for elapsed time.

If you want to go really crazy you could add this bit before the print result line:

if data.find(PHRASE)==-1:
result = -1

where PHRASE is some text you wish to have on the HTML page.


-Torvald


#!/usr/bin/env python

import urllib
import time

URL = 'http://www.zabbix.com' # URL to be checked
MAXTIME = 10 # Maximum allowed time

starttime = time.time()

result = None

try:
hdl = urllib.urlopen(URL)
data = hdl.read()
except:
result = -1 # Something failed
else:
endtime = time.time()
if (endtime-starttime)>MAXTIME:
result = -1
else:
result = (endtime-starttime)

print result # Either the duration, or -1 if failure.

sojeshj
24-05-2005, 11:03
Thank you Torvald.. Much appreciated. Let me try this script. :)

sojeshj
13-06-2005, 07:03
Hi Torvald,

For some reason, this didnt work for me. Can you please send me the same script in perl (time dependant) so that i can try it out.

Thanks,
Soj