×
ENABLING BEACONS IN SALTSTACK
Automation Blog

ENABLING BEACONS IN SALTSTACK

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

Saltmaster: 192.168.232.70

host1: 192.168.232.71

host2: 192.168.232.72

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

enabling beacons in saltstack

enabling beacons in saltstack

enabling beacons in saltstack

INSTALLING SALT-MINION:

# 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:

Host1:

enabling beacons in saltstack

Host2:

enabling beacons in saltstack

Now the minions will sent their keys to Salt-Master and we need to accept the minion keys.

Salt-Master:

enabling beacons in saltstack

enabling beacons in saltstack

INSTALLING NGINX:

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

Host1:

enabling beacons in saltstack

enabling beacons in saltstack

Host2:

enabling beacons in saltstack

enabling beacons in saltstack

DEPLOYING BEACONS:

# salt ‘*’ pkg.install python-pyinotify

enabling beacons in saltstack

# salt ‘*’ pkg.install python-psutil

enabling beacons in saltstack

If you receive the output like the above image then kindly make sure the package already installed in minions.

clip_image018

ADDING BEACONS (Nginx and Disk usage):

FILE: /srv/pillar/top.sls,

base:

‘*’:

– webserver.beacons

enabling beacons in saltstack

FILE: /srv/pillar/webserver/beacons.sls

beacons:

service:

nginx:

onchangeonly: True

diskusage:

– /: 80%

– interval: 60

enabling beacons in saltstack

# salt ‘*’ saltutil.refresh_pillar  # salt ‘*’ beacons.list   # salt ‘*’ cmd.run ‘systemctl restart salt-minion’

enabling beacons in saltstack

enabling beacons in saltstack

enabling beacons in saltstack

# systemctl restart salt-master.service

clip_image025

We can see the beacons alert on the event bus through below command, run it on salt-master.

# salt-run state.event pretty=True

Events:

Service Monitoring(If nginx service down):

enabling beacons in saltstack

when nginx service back online:

enabling beacons in saltstack

Disk Usage Monitoring:

enabling beacons in saltstack

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

enabling beacons in saltstack

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.

Video:

Thanks!!

Leave a Reply

Your email address will not be published.

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