Changeset 859 for trunk/Monitoring


Ignore:
Timestamp:
05/20/13 09:13:18 (11 years ago)
Author:
jripsl
Message:
  • add killed/segfault detection.
  • database communication implementation (suite).
  • trap BREAK signal to stop consumer before exiting.
Location:
trunk/Monitoring
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Monitoring/Watch/watch

    r857 r859  
    1313################################## 
    1414 
    15 #from smon import dao 
    1615import pika 
    1716import base64 
     
    2524 
    2625 
    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  
     26from smon import repo_io 
    3627 
    3728 
    3829""" 
    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) 
     30Code list reminder 
     31 
     320000 (la simulation démarre) 
     331000 (le job d'une simulation démarre) 
     342000 (PushStack) 
     353000 (PopStack OK) 
     369000 (PopStack NOK) 
     379999 (FATAL) 
    4538""" 
    4639 
    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 
     40class Mail(): 
    9541 
    9642        @classmethod 
     
    10450 
    10551        @classmethod 
    106         def mail(cls): 
    107                 cls.mail_example() 
    108  
    109         @classmethod 
    11052        def send_mail(cls,me,you,object,body): 
    11153                msg = MIMEText(body) 
     
    11961                s.quit() 
    12062 
     63class 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 
    12183        @classmethod 
    12284        def print_stdout(cls,message): 
     
    13092        @classmethod 
    13193        def log(cls,message): 
    132  
    13394                with open("/home/jripsl/supervisor/log/supervisor.log", "a") as log_file: 
    13495                        log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message["code"],message["jobid"])) 
     
    139100                message_code=message["code"] 
    140101 
    141                 for action in cls.message_code_action_mapping[message_code]: 
     102                for action in MessageActionsMapping.mapping[message_code]: 
    142103                        proc_name=action 
    143104 
    144105                        try: 
    145                                 getattr(cls, proc_name)(message) 
     106                                getattr(Actions, proc_name)(message) 
    146107                        except Exception,e: 
    147108                                traceback.print_exc() 
     
    149110                                raise Exception("WATCH-ERR002","procedure error (%s,%s)"%(proc_name,str(e))) 
    150111 
     112class 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 
     121class Watcher(): 
     122 
     123        @classmethod 
     124        def start(cls): 
     125                pass 
     126 
     127        @classmethod 
     128        def stop(cls): 
     129                pass 
     130 
    151131        @classmethod 
    152132        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() 
    162133 
    163134                """ 
     
    217188 
    218189        signal.signal(signal.SIGINT, signal_handler) 
    219         #print 'Press Ctrl+C' 
    220190 
    221191        try: 
  • trunk/Monitoring/doc/README

    r857 r859  
    2121                                - packages below are needed by Prodiguer library 
    2222                                        - 
     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 
    2331                                                - pip install Sqlalchemy 
    2432                                                - pip install elixir 
     
    2937                                                - SQLAlchemy-0.7.8-py2.6.egg-info 
    3038                - 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/src 
     39                        - svn co svn+ssh://<login here>@forge.ipsl.jussieu.fr/ipsl/forge/projets/prodiguer/svn/sw/src/python/trunk/prodiguer_shared/src 
    3240                        - edit "watch" script and edit line below accordingly 
    3341                                - sys.path.append("/home/jripsl/snapshot/src")  
Note: See TracChangeset for help on using the changeset viewer.