Package Products :: Package ZenEvents :: Module HeartbeatUtils
[hide private]
[frames] | no frames]

Source Code for Module Products.ZenEvents.HeartbeatUtils

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 or (at your 
 8  # option) any later version as published by the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  # This program is part of Zenoss Core, an open source monitoring platform. 
14  # This program is free software; you can redistribute it and/or modify it 
15  # under the terms of the GNU General Public License version 2 or (at your 
16  # option) any later version as published by the Free Software Foundation. 
17  # For complete information please visit: http://www.zenoss.com/oss/ 
18  from Products.Zuul import getFacade 
19  from time import time 
20   
29   
30 -def getHeartbeatObjects(failures=True, limit=0, deviceRoot=None, 31 keys=('alink', 'comp', 'dtime', 'devId')):
32 beats = [] 33 now = int(time() * 1000) 34 heartbeats = getFacade('zep').getHeartbeats() 35 for heartbeat_dict in heartbeats: 36 # Seconds is difference between current time and last reported time 37 # ZEP returns milliseconds, so perform appropriate conversion 38 seconds = (now - heartbeat_dict['last_time']) / 1000 39 if failures is False or seconds >= heartbeat_dict['timeout_seconds']: 40 beat = { 41 keys[0]: deviceLink(deviceRoot, heartbeat_dict['monitor']), 42 keys[1]: heartbeat_dict['daemon'], 43 keys[2]: seconds 44 } 45 if len(keys) > 3: 46 beat[keys[3]] = heartbeat_dict['monitor'] 47 beats.append(beat) 48 if limit: 49 return beats[:limit] 50 return beats
51