Saltstack : state for monitorix + ASD to monitor docker (Archlinux)

As I’m using monitorix to monitor all my servers, I naturally did a dedicated state for saltstack. I also coupled this with a state to install Anything-sync-Daemon which is an Archlinux’s AUR Package that use tmpfs together with overlayfs to reduce wear on physical disk (data are stored to memory and synchronized on a regular basis on disk).

I also use states to add specific monitoring for some services like docker.

Build scripts

Monitorix and Anything-sync-daemon are both available from AUR on Archlinux. I just use some small scripts to quickly build the binary packages without any fingerprint on the host used to build. The two scripts a very similar and are just used to save few lines of shell commands ( yes, I’m that lazy…)

Anything-sync-daemon

build-asd.sh : 

Monitorix

build_monitorix.sh:

States

The states below basicaly handle dependencies, packages installation and custom configuration file deployment.

Anything-sync-daemon

The ASD state is pretty simple:

The “overlay.conf ” is used to activate the overlay kernel module at boot.

The reason I use a custom configuration for ASD file (asd.conf) is to allow adding directories to sync. In fact, I’m using ASD both for monitorix and docker, so my custom config file contains markers to easily adapt the config file in other states (eg. “# monitorix start” and “# monitorix end”)

The pushed asd.conf file:

As shown in the monitorix state below, I use the following lines to add the corresponding ASD line in asd.conf file from the monitorix state:

Monitorix

The monitorix state install all required softwares and a custom configuration file, again, to allow customization depending on other states I have (eg: docker monitoring).

The monitorix state

My monitorix.conf file is based on the original one, on which I changed some parts to be able to change or add parameters from saltstack states with markers. 

As an example, below are parts of the monitorix configuration file where I put markers for my “monitorix for docker” state.

The FS part

;
As you can see, I use a custom script for disk space alert handling (which are also deployed as a state), as explained in the official monitorix documentation

The Du part

 

The process part

Monitorix state for docker monitoring

I use a “sub monitorix state” to add docker monitoring for hosts that run docker containers. This state is named “4docker.sls” and include the monitorix state. So adding monitoring support for docker host is easily done with a call like :

The 4docker.sls file :

As a example of result, the file monitoring graph is like the following :

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.