Uptime checker with email notifications using API and workers

Workers are great, one thing you can do is check if a website is online using a ping test and if it is not online send a email to your account with only a few lines. Just replace where you see APIKEY in the url with your API key you can find under your account settings.

As you can see we return the ping results to the page so it will show under the worker history, but we also if the ping failed (can't reach host) send a notification via the panel email system.

if v.ping >= 500
	s.echo("Yikes, the ping test to the server took v.ping MS.")
	s.echo("Hey the server had a ping of v.ping MS. That is great!")

if v.ping false
	v.title=s.string_url_encode("Website down")
	v.message=s.string_url_encode("We are unable to reach your website, the ping test returned v.ping MS. Might want to take a look.")
	if notset v.response[data][error]
		s.echo("Alert sent via email")
		s.echo("Was not able to send alert")