Skip to content

cfalguiere/SimpleServiceStatusMonitor

Repository files navigation

Simple Service Status Monitor

A simple service status monitor based on Groovy and D3

Motivation

Nagios or other monitoring tools are great but they require some infrastructure (a web server, a database, a linux server …).

This tool is a very simple status monitor HTML page. It relies on very common components and does not require an infrastructure or a database.

As a consequence, it has no memory and you should publish the HTML file in the Web Server to make it available to the network.

It is also a D3 demo.

Overview

It consists in:

  • an HTML page template
  • some D3 code to draw circles
  • a script

When the script runs, it checks the services, build a json string and generate a new HTML page from the template.

image

Prerequisites

The tools relies only on a few very common components

If Groovy is an issue, you may rewrite the script with another langage and share it. Check "Implementation details"

Getting Started

install

Clone the repository or download it as a zip file.

git clone [email protected]:cfalguiere/SimpleServiceStatusMonitor.git

Move into the project directory

Get the D3 library library (currently d3.V3) and extract in d3.v3.

curl http://d3js.org/d3.v3.zip -o d3.v3.zip
unzip d3.v3.test.zip -d d3.v3

setup

Edit updateStatusPage.groovy to put your own services.

Look up the services map and replace with your own:

def services = 
	[ [ 'server': 'does not exist',  'url': 'http://does not exist' ],
	[ 'server': 'www.google.com',  'url': 'http://www.google.com' ]]

run

Open a terminal and run

groovy updateStatusPage.groovy
at Sat Jun 08 15:18:54 CEST 2013
checking [server:does not exist, url:http://does not exist] ...
checking [server:www.google.com, url:http://www.google.com] ...
waiting 1 mn ...

Every minute, a new HTML page is generated. Here is an exemple exemple status page.

more setups

check interval

By default the script runs forever and check the services every minute. If you want the script to run only once or prefer another check interval, you may change the maxReadingCount and waitIntervalMn values in Edit updateStatusPage.groovy :

def maxReadingCount = -1 // -1 stands for forever
def waitIntervalMn = 1

change template

You may edit the template or provide a CSS Stylesheet pour change the look of this page.

You may take care of these lines when changing the template

Head must have the d3 library and the status panel function.

    <script type="text/javascript" src="d3.v3/d3.v3.js"></script>
    <script type="text/javascript" src="d3-status-panel.js"></script>

In body, take care of the following lines

<p> At <%= date %> </p>
<div id="svg"> </div>
    <script type="text/javascript"> 
var dataset = <%= data %>;
statusPanel("#svg")
    </script>

The page reloads itself every 5 minutes. You may change the 5000 value (en milliseconds) or remove the onload.

<body onload="JavaScript:timedRefresh(5000);">

Feedback

Please feel free to give feedback, make requests for features or report bugs and share your contributions (more check functions, CSS stylesheets, …).

Main files

filedescription
d3.v3/d3.v3.jsthe D3 library
d3-status-panel.jsdraw the status panel
template-status-page.htmlthe page template
updateStatusPage.groovycollect information and generate the page from template
output/status-page.htmlgenerated HTML page

There are roughly 150 lines of code (not including D3 library)

Build a script

If Groovy is not convenient, you may rewrite the script with another langage and share it.

These are features you will have to deal with:

  • run a ping or execute a system command
  • fetch a url
  • generate a JSON string
  • generate a string or a file from a template

The template expects 2 binded data

  • date : the date formatted as a String
  • data : a list of maps as a JSON bloc

Depending on your templating system you may have to change the binding systax as well :

<p> At <%= date %> </p>
...
var dataset = <%= data %>;

This result in

<p> At Sat Jun 08 13:55:50 CEST 2013 </p>
…
var dataset = [{"server":"does not exist","url":"http://does not exist","serverstatus":64,"urlstatus":-1},{"server":"www.google.com","url":"http://www.google.com","serverstatus":0,"urlstatus":0}];

License

Copyright (C) 2013

Distributed under the Eclipse Public License

About

A simple service status monitor based on Groovy and D3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published