Skip to content

Instantly share code, notes, and snippets.

@conorbranagan
Created January 24, 2014 22:02
Show Gist options
  • Save conorbranagan/8607621 to your computer and use it in GitHub Desktop.
Save conorbranagan/8607621 to your computer and use it in GitHub Desktop.
Running an AgentCheck at a different interval
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