Created
January 24, 2014 22:02
-
-
Save conorbranagan/8607621 to your computer and use it in GitHub Desktop.
Running an AgentCheck at a different interval
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
import time | |
from checks import AgentCheck | |
CHECK_INTERVAL = 60 # in seconds | |
class MyCheck(AgentCheck): | |
def __init__(self, name, init_config, agentConfig, instances=None): | |
AgentCheck.__init__(self, name, init_config, agentConfig, instances) | |
self.last_check_ts = None | |
def check(self, instance): | |
now = time.time() | |
if self.last_check_ts and now - self.last_check_ts < CHECK_INTERVAL: | |
# We're not checking this time. | |
return | |
# | |
# Run your check here. | |
# | |
self.gauge('my.metric', 1) | |
self.last_check_ts = time.time() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment