Monitor ethOS Distro with Elastic Search – 2

Posted by in IT, Software, Tutorial

Following the previous post, we are now in position to install the monitoring code on the monitoried machine, of course. The easiest way is to download the code on the machine in /home/ethos. Following steps will assume you have the unpacked code in

Once you have downloaded the code, you need to add the location of the ElasticSearch server to the local.conf:

Dissecting the scripts

The scripts are written in PHP, like ethOS‘s own scripts. I did that for two reasons:

  1. Take advantage of the already written code (parsing and stuff)
  2. Make it easier for users to adapt and improve the code with their own tweaks

The scripts follow the same structure too:

  • bin/ contains monitoring the script
  • lib/ contains various helper libraries
  • sbin/ contains a daemon-like script which can be executed as a once-off or as a loop.

lib

The lib directory extends the functions already present in /opt/ethos/lib. More specific, the data array is extended with numeric variants for text fields. New fields like cores, voltages, miner_hash_values and fan_rpms are added to the array. A function to send the array via curl and a POST request is also present, to allow pushing data to ElasticSearch.

The full list of variables added (at the moment of writing) are:

sbin

This directory contains a script which can be executed either as a one-off or as a adaemon in background. Its usage is:

The [once-off] implies an optional word which specifies the script is sending the data only once. The <ES-URI> specifies the ES url wher ewe want the data do be sent to.

bin

This is the wrapper script which allows you to just run it:

It reads the ElasticSearch URI from local.conf with:

and executes the daemon script as a once-off:

Running it all

The easiest way to execute the update script is via a cronjob. I’m executing it every 10 minutes:

You can also execute directly the daemon, but then you’ll need to parse the ElasticSearch URI yourself.

The next article will give some example of visualisations with Kibana, like this:

HTH,


A little experiment: If you find this post and ad below useful, please check the ad out :-)