Skip to content

Commit

Permalink
rename heartbeat interval to timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly committed Jun 25, 2013
1 parent 561e7ea commit fca3b98
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion alerta/api/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions alerta/common/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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
Expand All @@ -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,
}
Expand Down Expand Up @@ -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),
)
4 changes: 2 additions & 2 deletions alerta/server/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion alerta/server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion alerta/snmptrap/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions alerta/solarwinds/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion alerta/syslog/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dashboard/v2/assets/js/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 += '<div class="alert alert-error">' +
'<a class="close" data-dismiss="alert" href="#">&times;</a>' +
'<strong>Important!</strong> ' + hb.origin + ' has not sent a heartbeat for ' + since +
Expand Down

0 comments on commit fca3b98

Please sign in to comment.