Changeset 876 for trunk/Monitoring/Analyze/analyze
- Timestamp:
- 06/12/13 11:14:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/Analyze/analyze
r859 r876 21 21 from datetime import datetime 22 22 23 from smon import repo_io 23 24 # line below is to include "smon" package in the search path 25 sys.path.append("/home/jripsl/snapshot/Monitoring") 26 27 import smon.repo_io as repo_io 28 import smon.types as types 24 29 25 30 26 27 """28 Code list reminder29 30 0000 (la simulation démarre)31 1000 (le job d'une simulation démarre)32 2000 (PushStack)33 3000 (PopStack OK)34 9000 (PopStack NOK)35 9999 (FATAL)36 """37 31 38 32 class CheckList(): … … 52 46 diff=current_time-msg_time 53 47 48 # debug 49 print "diff=%s"%diff 54 50 55 51 if diff>cls.max_time_between_msg: … … 68 64 changing the simulation status 69 65 """ 70 running_simulations=repo_io.get_running_simulations() 71 for simulation in running_simulations: 72 message=repo_io.retrieve_last_messages(simulation) 66 67 68 for simulation in repo_io.get_running_simulations(): 69 70 print "checking heartbeat for '%s'"%simulation.name 71 72 try: 73 74 message=repo_io.retrieve_last_message(simulation) 75 except types.MessageNotFoundException, e: 76 77 continue 78 73 79 74 80 if msg_timeout(message): 75 81 76 repo_io.update_simulation_status(simulation) #from "running" to "killed" 82 simulation.status="error" 83 84 repo_io.update_simulation_status(simulation) 85 86 print "heartbeat NOK (simulation status set to 'error')"%simulation.name 87 88 89 else: 90 print "heartbeat OK"%simulation.name 77 91 78 92 class Analyzer(): … … 80 94 @classmethod 81 95 def start(cls): 82 pass 96 repo_io.init() # open DB connection 97 98 Analyzer.main() 83 99 84 100 @classmethod 85 101 def stop(cls): 86 pass102 repo_io.free() # close DB connection 87 103 88 104 @classmethod … … 104 120 print ' [*] Analyzer running. To exit press CTRL+C' 105 121 106 CheckList.C0001() 122 while True: 123 124 print "checking simulations heartbeats" 125 126 CheckList.C0001() 107 127 108 128 109 sleep(10)129 time.sleep(1) 110 130 111 131 """ … … 115 135 def signal_handler(signal, frame): 116 136 print 'You pressed Ctrl+C!' 137 138 Analyzer.stop() 139 117 140 sys.exit(0) 118 141 … … 122 145 123 146 try: 124 Analyzer. main()147 Analyzer.start() 125 148 126 149 sys.exit(0)
Note: See TracChangeset
for help on using the changeset viewer.