Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Created February 9, 2020 14:42
Show Gist options
  • Save max-arnold/0449aafd9578cc7d1b4674cb6825d096 to your computer and use it in GitHub Desktop.
Save max-arnold/0449aafd9578cc7d1b4674cb6825d096 to your computer and use it in GitHub Desktop.
Salt minion system boot beacon
# Save into salt://_beacons/system_boot.py and then run
# saltutil.sync_beacons
from __future__ import absolute_import, unicode_literals
__virtualname__ = 'system_boot'
def beacon(config):
"""
beacons:
system_boot:
- interval: 5
- threshold: 180
"""
_config = {}
list(map(_config.update, config))
ret = []
threshold = _config.get('threshold', 180)
if __virtualname__ not in __context__:
__context__[__virtualname__] = True
uptime = __salt__['status.uptime']()
if not isinstance(uptime, (int, float)):
uptime = uptime['seconds']
uptime = int(uptime)
if uptime < threshold:
ret.append({'uptime': uptime})
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment