From fca3b982eb82a95f9bb3f51a0ddf4489c57c6334 Mon Sep 17 00:00:00 2001 From: Nick Satterly Date: Tue, 25 Jun 2013 10:07:49 +0100 Subject: [PATCH] rename heartbeat interval to timeout --- alerta/api/v2/views.py | 2 +- alerta/common/heartbeat.py | 10 +++++----- alerta/server/daemon.py | 4 ++-- alerta/server/database.py | 2 +- alerta/snmptrap/handler.py | 2 +- alerta/solarwinds/daemon.py | 4 ++-- alerta/syslog/daemon.py | 2 +- dashboard/v2/assets/js/console.js | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/alerta/api/v2/views.py b/alerta/api/v2/views.py index c9dff80e0..ce7c71f14 100644 --- a/alerta/api/v2/views.py +++ b/alerta/api/v2/views.py @@ -343,7 +343,7 @@ def create_heartbeat(): origin=data.get('origin', None), version=data.get('version', None), heartbeatid=data.get('id', None), - interval=data.get('interval', None), + timeout=data.get('timeout', None), ) LOG.debug('New heartbeat %s', heartbeat) mq.send(heartbeat) diff --git a/alerta/common/heartbeat.py b/alerta/common/heartbeat.py index 9e3cbd1dd..9bcb08f98 100644 --- a/alerta/common/heartbeat.py +++ b/alerta/common/heartbeat.py @@ -12,12 +12,12 @@ LOG = logging.getLogger(__name__) CONF = config.CONF -DEFAULT_HEARTBEAT = 3600 # seconds +DEFAULT_TIMEOUT = 300 # seconds class Heartbeat(object): - def __init__(self, origin=None, version='unknown', heartbeatid=None, create_time=None, interval=None): + def __init__(self, origin=None, version='unknown', heartbeatid=None, create_time=None, timeout=None): prog = os.path.basename(sys.argv[0]) @@ -26,7 +26,7 @@ def __init__(self, origin=None, version='unknown', heartbeatid=None, create_time self.origin = origin or '%s/%s' % (prog, os.uname()[1]) self.version = version self.create_time = create_time or datetime.datetime.utcnow() - self.interval = interval or DEFAULT_HEARTBEAT + self.timeout = timeout or DEFAULT_TIMEOUT def get_id(self): return self.heartbeatid @@ -45,7 +45,7 @@ def get_body(self): 'id': self.heartbeatid, 'type': self.event_type, 'createTime': self.create_time, - 'interval': self.interval, + 'timeout': self.timeout, 'origin': self.origin, 'version': self.version, } @@ -84,5 +84,5 @@ def parse_heartbeat(heartbeat): version=heartbeat.get('version', None), heartbeatid=heartbeat.get('id', None), create_time=heartbeat.get('createTime', None), - interval=heartbeat.get('interval', None), + timeout=heartbeat.get('timeout', None), ) diff --git a/alerta/server/daemon.py b/alerta/server/daemon.py index 91b36ef99..3f2b7f984 100644 --- a/alerta/server/daemon.py +++ b/alerta/server/daemon.py @@ -39,7 +39,7 @@ def run(self): incomingAlert = self.queue.get(True, CONF.loop_every) except Queue.Empty: LOG.debug('Send heartbeat...') - heartbeat = Heartbeat(version=Version, interval=CONF.loop_every) + heartbeat = Heartbeat(version=Version, timeout=CONF.loop_every) self.mq.send(heartbeat) continue @@ -208,7 +208,7 @@ def run(self): while not self.shuttingdown: try: LOG.debug('Send heartbeat...') - heartbeat = Heartbeat(version=Version, interval=CONF.loop_every) + heartbeat = Heartbeat(version=Version, timeout=CONF.loop_every) self.mq.send(heartbeat) LOG.debug('Internal queue size is %s messages', self.queue.qsize()) diff --git a/alerta/server/database.py b/alerta/server/database.py index 7a5f50b1a..c1a17d477 100644 --- a/alerta/server/database.py +++ b/alerta/server/database.py @@ -515,7 +515,7 @@ def update_hb(self, heartbeat): query = {"origin": heartbeat.origin} update = {"origin": heartbeat.origin, "version": heartbeat.version, "createTime": heartbeat.create_time, - "receiveTime": heartbeat.receive_time, "interval": heartbeat.interval} + "receiveTime": heartbeat.receive_time, "timeout": heartbeat.timeout} try: self.db.heartbeats.update(query, update, True) diff --git a/alerta/snmptrap/handler.py b/alerta/snmptrap/handler.py index 2fc95ca75..fa6789f94 100644 --- a/alerta/snmptrap/handler.py +++ b/alerta/snmptrap/handler.py @@ -191,7 +191,7 @@ def parse_snmptrap(data): snmptrapAlert.translate(trapvars) if snmptrapAlert.get_type() == 'Heartbeat': - snmptrapAlert = Heartbeat(origin=snmptrapAlert.origin, version='n/a') + snmptrapAlert = Heartbeat(origin=snmptrapAlert.origin, version='n/a', timeout=snmptrapAlert.timeout) return snmptrapAlert diff --git a/alerta/solarwinds/daemon.py b/alerta/solarwinds/daemon.py index 216bea0c7..565c8e59d 100644 --- a/alerta/solarwinds/daemon.py +++ b/alerta/solarwinds/daemon.py @@ -157,8 +157,8 @@ def parse_events(self, data): LOG.debug('%s', solarwindsAlert) continue - if solarwindsAlerts.get_type() == 'Heartbeat': - solarwindsAlerts = Heartbeat(origin=solarwindsAlerts.origin, version='n/a') + if solarwindsAlert.get_type() == 'Heartbeat': + solarwindsAlert = Heartbeat(origin=solarwindsAlert.origin, version='n/a', timeout=solarwindsAlert.timeout) solarwindsAlerts.append(solarwindsAlert) diff --git a/alerta/syslog/daemon.py b/alerta/syslog/daemon.py index ebf32bded..072382437 100644 --- a/alerta/syslog/daemon.py +++ b/alerta/syslog/daemon.py @@ -203,7 +203,7 @@ def parse_syslog(self, source, data): continue if syslogAlert.get_type() == 'Heartbeat': - syslogAlert = Heartbeat(origin=syslogAlert.origin, version='n/a') + syslogAlert = Heartbeat(origin=syslogAlert.origin, version='n/a', timeout=syslogAlert.timeout) syslogAlerts.append(syslogAlert) diff --git a/dashboard/v2/assets/js/console.js b/dashboard/v2/assets/js/console.js index 470ca714f..0a62643bf 100644 --- a/dashboard/v2/assets/js/console.js +++ b/dashboard/v2/assets/js/console.js @@ -144,7 +144,7 @@ function heartbeatAlerts() { since = secs + ' seconds'; } - if (diff > hb.interval * 4 && show_hb_alerts) { + if (diff > hb.timeout * 4 && show_hb_alerts) { hbalerts += '
' + '×' + 'Important! ' + hb.origin + ' has not sent a heartbeat for ' + since +