/nethserver-alerts

Manage machines alerts using Collectd

Primary LanguagePHPGNU General Public License v3.0GPL-3.0

nethserver-alerts

This package monitors the machine using Collectd and route notifications to a remote server.

Collectd listens for notification on a well known socket: /var/run/collectd.sock.

Notifications can be generated by Collectd thresholds, cron jobs or even external daemons like NMS.

Collectd thresholds

You can trigger an alarm named testalarm from command line:

echo -e "PUTNOTIF host=$(hostname) type=custom type_instance=testalarm severity=failure time=$(date +%s) message=\"$1 FAILURE\"" | nc -U /var/run/collectd.sock &>/dev/null

You can also resolve the above alarm:

echo -e "PUTNOTIF host=$(hostname) type=custom type_instance=testalarm severity=okay time=$(date +%s) message=\"$1 OK\"" | nc -U /var/run/collectd.sock &>/dev/null

Adding a threshold configuration

Create a /etc/collectd.d/threshold.conf template fragment using collectd threshold syntax. Enjoy collectd docs here https://collectd.org/documentation/manpages/collectd-threshold.5.shtml

Collectd python plugin

The nethserver_alerts.py file implements a Collectd plugin. The plugin dispatches each notification to remote Dartagnan instance. If the remote Dartagnan instance is not available, the plugin will save the notifications inside a local queue and will retry to resend them later.

Plugin options (inside /etc/collectd.d/threshold.conf):

  • api_url URL where alerts will be dispatched
  • lk: System ID
  • secret: (optional) if set, the secret will be used as authorization token
  • debug: enable the debug, can be yes or no. Default to no

NethServer Monitor Services (NMS)

NMS is a python daemon which monitor the status of all services registered inside the configuration db. Each service is checked every 300 seconds, if the status of a service changes, NMS writes a notification to Collectd socket.

Configuration

NethServer subscrptions

URL: https://my.nethserver.com/api/machine/

To configure execute:

config setprop subscription AlertsUrl https://my.nethserver.com/api/machine/
signal-event nethserver-alerts-update

Nethesis partner program

URL: https://my.nethesis.it/isa

To configure execute:

config setprop subscription AlertsUrl https://my.nethesis.it/isa
signal-event nethserver-alerts-update