View Full Version : Fetch URL
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
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
forgot to mention that I naturally invoke the script as a UserParameter in zabbix_agentd.conf
-Torvald
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?
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.
Thank you Torvald.. Much appreciated. Let me try this script. :)
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