Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c3e5c21931
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (35 sloc) 1.363 kb
import logging
import datetime
import simplejson as json
from eeagent.util import unmake_id
def beat_it(dashi, CFG, pm, log=logging):
try:
beat_msg = make_beat_msg(pm, CFG)
log.log(logging.DEBUG, "Sending the heartbeat : %s" % (json.dumps(beat_msg)))
dashi.fire(CFG.pd.name, "heartbeat", message=beat_msg)
except Exception, ex:
log.exception("Error Sending the heartbeat : %s" % (str(ex)))
def make_beat_msg(pm, CFG):
beat_msg = {}
beat_msg['eeagent_id'] = CFG.eeagent.name
# include node ID if it is present in config
node_id = CFG.eeagent.get('node_id')
if node_id is not None:
beat_msg['node_id'] = CFG.eeagent.node_id
beat_msg['timestamp'] = str(datetime.datetime.now())
beat_processes = []
# we can have many process managers per eeagent, walk them all to get all the processes
pm.poll()
processes = pm.get_all()
for pname in processes:
p = processes[pname]
(name, round) = unmake_id(p.get_name())
try:
state = p.get_state()
except:
log.exception("Had a problem getting process state")
raise
beat_p = {'upid': name, 'round': round, 'state': state, 'msg': p.get_error_message()}
beat_processes.append(beat_p)
beat_msg['processes'] = beat_processes
return beat_msg
Jump to Line
Something went wrong with that request. Please try again.