Changeset 859 for trunk/Monitoring
- Timestamp:
- 05/20/13 09:13:18 (11 years ago)
- Location:
- trunk/Monitoring
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/Watch/watch
r857 r859 13 13 ################################## 14 14 15 #from smon import dao16 15 import pika 17 16 import base64 … … 25 24 26 25 27 28 29 sys.path.append("/home/jripsl/snapshot/src") 30 import elixir 31 import prodiguer_repository 32 33 #import prodiguer_repository.operations.mq_hooks_stub as mq_hooks 34 import prodiguer_repository.operations.mq_hooks as mq_hooks 35 26 from smon import repo_io 36 27 37 28 38 29 """ 39 mq_hooks.retrieve_simulation(name) 40 mq_hooks.delete_simulation(name) 41 mq_hooks.create_simulation(activity, 42 mq_hooks.update_simulation_status(name, 43 mq_hooks.retrieve_messages(name) 44 mq_hooks.delete_messages(name) 30 Code list reminder 31 32 0000 (la simulation démarre) 33 1000 (le job d'une simulation démarre) 34 2000 (PushStack) 35 3000 (PopStack OK) 36 9000 (PopStack NOK) 37 9999 (FATAL) 45 38 """ 46 39 47 """ 48 from prodiguer_repository.models import ( 49 ExecutionState, 50 EXECUTION_STATE_RUNNING, 51 EXECUTION_STATE_SET, 52 Message, 53 Simulation, 54 SIMULATION_SPACE_TEST 55 ) 56 """ 57 58 59 60 """ 61 scenarios from ticket 136 62 63 libIGCM simulent des erreurs (killed, segfault, 1% d'erreur) 64 le watcher temps réel change le status des erreurs détéctés 65 le watcher temps différé détécte et change le statut des killed 66 """ 67 68 class Watcher(): 69 # prod 70 #message_code_action_mapping = {"0000":["log","mail"],"1000":["log"],"2000":["log"],"3000":["log"],"9000":["log"],"9999":["log","mail"]} 71 72 # dev 73 message_code_action_mapping = {"0000":["log","print_stdout"],"1000":[],"2000":[],"3000":[],"9000":["log"],"9999":["log"]} 74 #message_code_action_mapping = {"0000":[],"1000":[],"2000":[],"3000":[],"9000":["log"],"9999":["log"]} 75 76 # debug 77 #message_code_action_mapping = {"0000":["print_stdout"],"1000":["log"],"2000":[],"3000":[],"9000":["log"],"9999":["log"]} 78 79 @classmethod 80 def get_fake_progress_messages(cls): 81 pass 82 83 @classmethod 84 def start(cls): 85 #dao.insert_progress_messages(cls.get_fake_progress_messages()) 86 pass 87 88 @classmethod 89 def stop(cls): 90 pass 91 92 @classmethod 93 def add(cls,message): 94 pass 40 class Mail(): 95 41 96 42 @classmethod … … 104 50 105 51 @classmethod 106 def mail(cls):107 cls.mail_example()108 109 @classmethod110 52 def send_mail(cls,me,you,object,body): 111 53 msg = MIMEText(body) … … 119 61 s.quit() 120 62 63 class Actions(): 64 65 @classmethod 66 def store_msg(cls): 67 repo_io.store_messages(name) 68 69 @classmethod 70 def set_sim_status_to_error(cls): 71 repo_io.update_simulation_status() 72 73 @classmethod 74 def crea_sim(cls): 75 #repo_io.retrieve_simulation(name) 76 #repo_io.delete_simulation(name) 77 repo_io.create_simulation() 78 79 @classmethod 80 def mail(cls): 81 cls.mail_example() 82 121 83 @classmethod 122 84 def print_stdout(cls,message): … … 130 92 @classmethod 131 93 def log(cls,message): 132 133 94 with open("/home/jripsl/supervisor/log/supervisor.log", "a") as log_file: 134 95 log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message["code"],message["jobid"])) … … 139 100 message_code=message["code"] 140 101 141 for action in cls.message_code_action_mapping[message_code]:102 for action in MessageActionsMapping.mapping[message_code]: 142 103 proc_name=action 143 104 144 105 try: 145 getattr( cls, proc_name)(message)106 getattr(Actions, proc_name)(message) 146 107 except Exception,e: 147 108 traceback.print_exc() … … 149 110 raise Exception("WATCH-ERR002","procedure error (%s,%s)"%(proc_name,str(e))) 150 111 112 class MessageActionsMapping(): 113 114 mapping = { "0000":["log", "store_msg", "crea_sim"], 115 "1000":["log", "store_msg"], 116 "2000":["log", "store_msg"], 117 "3000":["log", "store_msg"], 118 "9000":["log", "store_msg", "mail"], 119 "9999":["log", "store_msg", "set_sim_status_to_error", "mail"] } 120 121 class Watcher(): 122 123 @classmethod 124 def start(cls): 125 pass 126 127 @classmethod 128 def stop(cls): 129 pass 130 151 131 @classmethod 152 132 def main(self): 153 154 """155 _CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer" # Repo connection string.156 prodiguer_repository.connect(_CONNECTION) # Connect to repo.157 mq_hooks.create_message("test", 2, "bla")158 elixir.session.commit()159 #elixir.session.rollback()160 """161 mq_hooks.create_message()162 133 163 134 """ … … 217 188 218 189 signal.signal(signal.SIGINT, signal_handler) 219 #print 'Press Ctrl+C'220 190 221 191 try: -
trunk/Monitoring/doc/README
r857 r859 21 21 - packages below are needed by Prodiguer library 22 22 - 23 - pip install psycopg2 24 - doesn't work (Error: pg_config executable not found) 25 - solution is 26 - yum install python-psycopg2.x86_64 27 - yum install libpqxx-devel 28 - yum install python-devel 29 - pip install psycopg2 30 - works 23 31 - pip install Sqlalchemy 24 32 - pip install elixir … … 29 37 - SQLAlchemy-0.7.8-py2.6.egg-info 30 38 - Prodiguer library installation 31 - svn co svn+ssh://<login here>@forge.ipsl.jussieu.fr/ipsl/forge/projets/prodiguer/svn/sw/src/python/trunk/prodiguer_ repository/src39 - svn co svn+ssh://<login here>@forge.ipsl.jussieu.fr/ipsl/forge/projets/prodiguer/svn/sw/src/python/trunk/prodiguer_shared/src 32 40 - edit "watch" script and edit line below accordingly 33 41 - sys.path.append("/home/jripsl/snapshot/src")
Note: See TracChangeset
for help on using the changeset viewer.