monit is an opensource service status monitoring tool that can be coupled with a centralized daemon such as m/monit in order to display an overview for all services monitored via monit.
This tutorial presents a software project that combines monit, m/monit, OpenHab2 and Amazon Alexa in order to announce any service status changes. In other words, whilst monitoring daemons on a large server farm, Alexa will be able to announce service status changes.
For example, given a server with the hostname set to yolo
, when a daemon goes down, Alexa will say "yolo: 5 services out of 6 are running and 1 service is down." When the service recovers, Alexa will say "yolo: All 6 services are running".
The project can be retrieved from the following Subversion repository:
for instance, by issuing the command:
svn co http://svn.grimore.org/alexa-monit/trunk alexa-monit
Although this tutorial does not cover making Alexa talk via OpenHAB2, with the amazoechocontrol binding installed, an item file can be created at /etc/openhab2/items/MQTTSay.items
with the following contents:
/*************************************************************************/ /* MQTTSay */ /*************************************************************************/ Group MQTTSay "MQTTSay" <power> String MQTTSay_String (MQTTSay) { mqtt="<[mosquitto:alexa/say:state:default]" } String EchoTTS "Text to Speech" (MQTTSay) {channel="amazonechocontrol:echo:alexaAccount:echo:textToSpeech"}
in order to allow messages sent on the topic alexa/say
to be spoken by Alexa.
In order to test, one would issue the following command:
mosquitto_pub -h MQTT_SERVER -t 'alexa/say' -m 'Test'
where:
MQTT_SERVER
is the hostname or IP address of the MQTT server,
in order to make Alexa say Test
.
Checkout the repository to, say /srv
on Linux:
cd /srv svn co http://svn.grimore.org/alexa-monit/trunk alexa-monit
Next, install the node modules required by changing directory to, say, /srv/alexa-monit/node_modules
and issue the command:
npm install
Finally, copy config.yml.dist
to config.yml
and edit the configuration file config.yml
to set the polling interval (by default ), the URL to the mmonit web interface including the username and password used to access the interface as well as the MQTT server URL and the topic depending on the item file created in the previous step.
Once set up, the software can be run by issuing the command:
node main.js
at which point alexa-monit will start monitoring mmonit and push any status changes to the MQTT server that will be picked up by OpenHAB2 and pushed to Alexa to be spoken.
On any machine monitored by monit, stop a service using monit stop
and Alexa should announce the change.