Chapter 7. Beacons

By default, beacon modules run on a fast, one-second interval and emit Salt events. Their main function is to import external events on the Salt bus. For this reason, they pair quite well with the Salt reactor (introduced in Chapter 9). For example, the inotify beacon can watch a file or directory and emit an event if any files are modified, then the reactor can kick off a state run to put the file back into the desired state.

There are many beacon modules that cover a wide variety of tasks. To name just a few: btmp and wtmp watch user logins; sh watches user shell activity; diskusage, load, memusage, and network_info regularly poll relevant system stats and emit events if a threshold has been crossed; status can emit regular events containing current system stats; log and journald can watch log files for certain patterns and emit an event with matching log entries; haproxy and service can monitor services and emit events if the service is down or overloaded. Like other Salt modules, new beacon modules are easy to write if you have a custom need.

Configuration

Beacon configuration lives in the Salt minion configuration file under a beacons key. As usual, make sure any dependencies for the module are also installed on the minion, and restart the minion daemon after making changes to the config file.

Beacons can be equally used to ensure that processes are alive, and restart them otherwise. Considering that a number of proxy minion processes are executed on a ...

Get Network Automation at Scale now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.