Changeset 857 for trunk/Monitoring
- Timestamp:
- 05/15/13 15:25:03 (11 years ago)
- Location:
- trunk/Monitoring
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Monitoring/CNClient
-
Property
svn:ignore
set to
sendAMQPMsg
-
Property
svn:ignore
set to
-
trunk/Monitoring/CNClient/send_AMQP_msg.c
r854 r857 260 260 case 'e': 261 261 fprintf(stderr, "Usage: amqp_producer host port rate_limit message_count\n"); 262 fprintf(stderr, "Example 1: ./sendAMQPMsg -h localhost -p 5672 -b '{\"jobid\":\"toto\"}'\n"); 262 263 fprintf(stderr, "Example 1: ./sendAMQPMsg -h localhost -p 5672 -b 'eyJqb2JpZCI6InRvdG8iLCJjb2RlIjoiMDAwMCJ9Cg=='\n"); 264 265 // obsolete (from now all sent data must be B64 encoded) 263 266 fprintf(stderr, "Example 2: ./sendAMQPMsg -h localhost -p 5672 -f /home/foobar/config.card -b '{\"jobid\":\"toto\"}'\n"); 267 268 fprintf(stderr, "Example 3: ./sendAMQPMsg -h localhost -p 5672 -b 'am9iaWQ6dG90byBjb2RlOjAwMDAK' -f ../sample/config.card.base64\n"); 264 269 exit(0); 265 270 case 'f': … … 363 368 free(buf); 364 369 370 371 //this is to prevent overwhelming rabbitMQ server (and to prevent triggering rabbitMQ defensive behaviours (e.g. connection blocking)) 372 usleep( 200 000 ); // O.2 second 373 374 365 375 return 0; 366 376 } -
trunk/Monitoring/Watch/watch
r854 r857 18 18 import json 19 19 import sys 20 import signal 20 21 import traceback 21 22 import smtplib 22 23 from email.mime.text import MIMEText 24 from datetime import datetime 25 26 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 36 37 38 """ 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) 45 """ 46 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 """ 23 67 24 68 class Watcher(): 25 message_code_action_mapping = {"0000":["log","mail"],"1000":["log"],"2000":["log"],"3000":["log"],"9000":["log"],"9999":["log","mail"]} 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"]} 26 78 27 79 @classmethod … … 68 120 69 121 @classmethod 122 def print_stdout(cls,message): 123 # used for debug 124 125 if "file" in message: 126 print "%s %s %s\n"%(message["code"],message["jobid"],message["file"]) 127 else: 128 print "%s %s\n"%(message["code"],message["jobid"]) 129 130 @classmethod 70 131 def log(cls,message): 71 132 72 133 with open("/home/jripsl/supervisor/log/supervisor.log", "a") as log_file: 73 log_file.write("%s %s \n"%(message["code"],message["jobid"]))134 log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message["code"],message["jobid"])) 74 135 75 136 @classmethod … … 88 149 raise Exception("WATCH-ERR002","procedure error (%s,%s)"%(proc_name,str(e))) 89 150 90 def main(): 91 92 """ 93 # parse args 94 parser = argparse.ArgumentParser(prog='watcher') 95 parser.add_argument('-v', dest='verbose',required=False,action='store_true') 96 args = parser.parse_args() 97 98 # check 99 if not os.path.exists(SMON.smon_home): 151 @classmethod 152 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 163 """ 164 # parse args 165 parser = argparse.ArgumentParser(prog='watcher') 166 parser.add_argument('-v', dest='verbose',required=False,action='store_true') 167 args = parser.parse_args() 168 169 # check 170 if not os.path.exists(SMON.smon_home): 171 sys.exit(1) 172 173 SMON.init_singleton() 174 """ 175 176 connection = pika.BlockingConnection(pika.ConnectionParameters( host='localhost')) 177 self.channel = connection.channel() 178 179 #self.channel.queue_declare(queue='myqueue') 180 181 print ' [*] Waiting for messages. To exit press CTRL+C' 182 183 def callback(ch, method, properties, raw_msg): 184 # 185 #return 186 187 base64_decoded_msg=base64.b64decode(raw_msg) 188 189 # debug 190 #print " [x] Received %s" % raw_msg 191 #print " [x] Received %s (uudecoded)" % base64_decoded_msg 192 193 message=None 194 try: 195 message=json.loads(base64_decoded_msg) 196 197 # message code based action 198 Watcher.execActions(message) 199 except Exception,e: 200 print "Exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg) 201 202 self.channel.basic_consume(callback, queue='myqueue', no_ack=True) 203 204 self.channel.start_consuming() 205 206 207 """ 208 SMON.free_singleton() 209 """ 210 211 def signal_handler(signal, frame): 212 print 'You pressed Ctrl+C!' 213 Watcher.channel.stop_consuming() 214 sys.exit(0) 215 216 if __name__ == '__main__': 217 218 signal.signal(signal.SIGINT, signal_handler) 219 #print 'Press Ctrl+C' 220 221 try: 222 Watcher.main() 223 224 sys.exit(0) 225 226 except Exception, e: 227 228 traceback.print_exc() 229 100 230 sys.exit(1) 101 102 SMON.init_singleton()103 """104 105 connection = pika.BlockingConnection(pika.ConnectionParameters( host='localhost'))106 channel = connection.channel()107 108 #channel.queue_declare(queue='myqueue')109 110 print ' [*] Waiting for messages. To exit press CTRL+C'111 112 def callback(ch, method, properties, raw_msg):113 #114 #return115 116 base64_decoded_msg=base64.b64decode(raw_msg)117 118 # debug119 #print " [x] Received %s" % raw_msg120 #print " [x] Received %s (uudecoded)" % base64_decoded_msg121 122 try:123 message=json.loads(base64_decoded_msg)124 except Exception,e:125 print base64_decoded_msg126 127 # message code based action128 Watcher.execActions(message)129 130 channel.basic_consume(callback, queue='myqueue', no_ack=True)131 132 channel.start_consuming()133 134 135 """136 SMON.free_singleton()137 """138 139 if __name__ == '__main__':140 try:141 main()142 143 sys.exit(0)144 145 except Exception, e:146 147 traceback.print_exc()148 149 sys.exit(1) -
trunk/Monitoring/doc/README
r854 r857 9 9 - Virtualenv installation 10 10 - TODO: add virtual env install instructions here 11 - libraries installation 12 - cd /opt 13 - cd python2.6_ve/ 14 - cd bin 15 - source activate 16 - pip install pika # RabbitMQ client library 17 - pip install Sqlalchemy 18 - pip install elixir 11 - Python PYPI libraries installation 12 - procedure (as root) 13 - cd /opt 14 - cd python2.6_ve/ 15 - cd bin 16 - source activate 17 - pip install <package name> 18 - packages list 19 - packages below are needed by SMON 20 - pip install pika # RabbitMQ client library 21 - packages below are needed by Prodiguer library 22 - 23 - pip install Sqlalchemy 24 - pip install elixir 25 - pip install simplejson 26 - note: some Elixir/SQLAlchemy versions are not compatible. 27 to be sure, you can use version below which are compatible 28 - Elixir-0.7.1-py2.6.egg-info 29 - SQLAlchemy-0.7.8-py2.6.egg-info 30 - 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 32 - edit "watch" script and edit line below accordingly 33 - sys.path.append("/home/jripsl/snapshot/src")
Note: See TracChangeset
for help on using the changeset viewer.