I have a couple of webservers running and at some point one of them was not working anymore so I thought it was about time to do some regular monitoring. Of course there are plenty solutions out there but I though: let's do it with dzVents. And... turns out it is very simple to do.
So, I started by creating a dummy switch 'mySiteA' that will represent the state of my website A. If the switch is Off then... well.. the site is down. I also create a switch 'testSite' so I can manually trigger a test. Then I created this script:
Code: Select all
return {
on = {
timer = { 'at 09:00' },
devices = { 'testSite' },
httpResponses = { 'mySite'}
}
execute = function(domoticz, item)
if (item.isTimer or item.isDevice) then
-- start the test
domoticz.openURL({ url = 'http://mysite', callback = 'mySite', method = 'GET' })
end
if (item.isHTTPResponse) then
if (item.ok) then
domoticz.email('Web server status', 'mySite is active', '[email protected]')
domoticz.devices('mySite').switchOn()
else
domoticz.email('Web server status', 'mySite is down', '[email protected]')
domoticz.devices('mySite').switchOff()
end
end
end
}
Oh, and the switch mySite is just there so you can see in Domoticz the state of your site as well. In case you missed the email (you might create a script to test that as well if this is the case )