Created
February 9, 2020 14:42
-
-
Save max-arnold/0449aafd9578cc7d1b4674cb6825d096 to your computer and use it in GitHub Desktop.
Salt minion system boot beacon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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