-
-
Save ZoomQuiet/81c4c9421fdcb6b06c6ee4c2e95fb84d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
# | |
# clock_skew.py | |
# This script reads json data from /tmp/sigsci-agents.json | |
# and prints a message if an agent's clock skew is greater | |
# or equal to the defined thresholds. | |
# | |
# SigSciApiPy (https://github.com/signalsciences/SigSciApiPy) is | |
# an easy way to pull agent data from the Signal Sciences API and | |
# save it to /tmp/sigsci-agents.json | |
# | |
# Example usage with SigSciApi.py: | |
# ./SigSci.py --agents > /tmp/sigsci-agents.json; ./clock_skew.py | |
# | |
# Thresholds | |
WARN = 3 | |
ALERT = 5 | |
import json | |
agents = open('/tmp/sigsci-agents.json', 'r') | |
data = json.load(agents) | |
skew = 0 | |
count = 0 | |
agents.close() | |
for agent in data['data']: | |
skew = int(agent['host.clock_skew']) | |
if skew >= ALERT: | |
print("ALERT: Clock skew for {0} is {1}".format(agent['agent.name'], skew)) | |
count += 1 | |
elif skew >= WARN: | |
print("WARNING: Clock skew on {0} is {1}".format(agent['agent.name'], skew)) | |
count += 1 | |
if count == 0: | |
print("Everything is running on time!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment