In this post we are going to pursue how to enabling beacons in saltstack, Through the beacons we are going to monitor the servers(minions) services and disk usages, The beacon system allows the minion to hook into a variety of system processes and continually monitor these processes. Beacons Beacon Modules
Server and IP information:
OS Description: Ubuntu 16.04.2 LTS
we have created the highstate file to install the nginx service and create the index.html file.
check the output of below File: /srv/salt/top.sls, /srv/salt/webserver/nginx.sls, /srv/salt/webserver/templates/index.html.tmpl
# curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com ; sh bootstrap-salt.sh -A 192.168.232.70 -i host1
Output of the above command:
Now the minions will sent their keys to Salt-Master and we need to accept the minion keys.
We have already create the highstate to install the nginx package and the index.html file, so we can call the file from minions via # salt-call state.highstate
# salt ‘*’ pkg.install python-pyinotify
# salt ‘*’ pkg.install python-psutil
If you receive the output like the above image then kindly make sure the package already installed in minions.
ADDING BEACONS (Nginx and Disk usage):
– /: 80%
– interval: 60
# salt ‘*’ saltutil.refresh_pillar # salt ‘*’ beacons.list # salt ‘*’ cmd.run ‘systemctl restart salt-minion’
# systemctl restart salt-master.service
We can see the beacons alert on the event bus through below command, run it on salt-master.
# salt-run state.event pretty=True
Service Monitoring(If nginx service down):
when nginx service back online:
Disk Usage Monitoring:
We have set the threshold ‘80%’ for ‘/’ in /srv/pillar/webserver/beacons.sls
to increase the disk size we are using:
# dd if=/dev/zero of=/tmp/bigfile2 bs=1M count=2000
We can see the disk-usage message in the event bus whenever the limit exceeds the threshold. Same way we can use ‘inotify:’ beacon to monitor a file for changes.