Skip to content

Monitor website status with Huginn

After setting up Huginn, and implementing the actions on my todo list, I had a look at the available agents and started thinking what else they can be useful for.

One of the ideas I came up with is monitoring if a website is available, or has some trouble. I already have a monitoring system in place, but it's a nice exercise to learn more about the other agents.

 

For this scenario I only need two agents:

  • Http Status Agent
  • Email Agent

 

Http Status Agent

First thing to do is monitor the website in question. Ideally use an URL which normally returns a 200 status code, and no redirect.

Set a name for the agent, and define how often the agent is to monitor the website. The dropdown allows different values between 1 minute and weekly. In my case I picked 10 minutes. Enter the URL, set "Disable redirect follow" to "True", "Changes only" to "True" and save everything.

Email Agent

The second step is the Email Agent. Again define a name, and select the "Http Status Agent" as Event Source. The options can loog as follow:

  • expected_receive_period_in_days: how often do you expect the website to go down? I set 365 day here, just to be on the safe side.
  • content_type: text/html

The "subject" and "body" can include Liquid formats, remove the "headline", and maybe set "recipients" and "from".

Subject:

Website: <insert website name here> {% if response_received == false %}is offline{% else %}{% if status == "200" %}is online{% else %}has problems{% endif %}{% endif %}

Body:

<br/>The website {% if response_received == false %}is offline{% else %}{% if status == "200" %}is online{% else %}has problems{% endif %}{% endif %}!{% if response_received == true %}<br/><br/>Status code: {{ status }}<br/>{% endif %}

How does it work?

Every time the status of the website changes, Huginn (more exactly: the Http Status Agent) will emit an event. This event is picked up by the Email Agent, Subject and Body are formatted, and everything is send out.

Possible improvements

  • Feel free to update the templates for Subject and Body, and include more information
  • Find a way to implement a threshold: only alert if the status is != 200 for a certain number of events
  • Use the "Website Agent" to check the actual content of the website

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options