CMS 3D CMS Logo

Classes | Functions
esMonitoring Namespace Reference

Classes

class  AsyncLineReaderMixin
 
class  AsyncLineReaderTimeoutMixin
 
class  ElasticReport
 
class  FDJsonHandler
 
class  FDJsonServer
 
class  FDOutputListener
 
class  JsonEncoder
 
class  LineHistoryEnd
 
class  LineHistoryStart
 

Functions

def dt2time (dt)
 
def handle_signal (signum, frame)
 
def launch_monitoring (args)
 
def log (s)
 

Function Documentation

def esMonitoring.dt2time (   dt)

Definition at line 15 of file esMonitoring.py.

15 def dt2time(dt):
16  # convert datetime timstamp to unix
17  return time.mktime(dt.timetuple())
18 
def dt2time(dt)
Definition: esMonitoring.py:15
def esMonitoring.handle_signal (   signum,
  frame 
)

Definition at line 452 of file esMonitoring.py.

References launch_monitoring().

452 def handle_signal(signum, frame):
453  for proc in CURRENT_PROC:
454  proc.send_signal(signum)
455 
def handle_signal(signum, frame)
def esMonitoring.launch_monitoring (   args)

Definition at line 387 of file esMonitoring.py.

References log(), and harvestTrackValidationPlots.str.

Referenced by handle_signal().

388  es = ElasticReport(args=args)
389 
390  json_handler = FDJsonServer(es=es, args=args)
391  env = os.environ.copy()
392  env["DQM2_SOCKET"] = json_handler.fn
393 
394  def preexec():
395  try:
396  # ensure the child dies if we are SIGKILLED
397  import ctypes
398  libc = ctypes.CDLL("libc.so.6")
399  PR_SET_PDEATHSIG = 1
400  libc.prctl(PR_SET_PDEATHSIG, signal.SIGKILL)
401  except:
402  log("Failed to setup PR_SET_PDEATHSIG.")
403  pass
404 
405  p = subprocess.Popen(args.pargs, preexec_fn=preexec, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True, env=env)
406  CURRENT_PROC.append(p)
407 
408  zlog = None
409  if args.zlog:
410  try:
411  relpath = os.path.dirname(__file__)
412  sys.path.append(relpath)
413  from ztee import GZipLog
414 
415  zlog_ = GZipLog(log_file=args.zlog)
416  es.update_doc({ "stdlog_gzip": args.zlog })
417 
418  log("Open gzip log file: %s" % args.zlog)
419  zlog = zlog_
420  except Exception as e:
421  log("Failed to setup zlog file: " + str(e))
422 
423  es.update_doc({ "pid": p.pid })
424  es.update_doc({ "monitoring_pid": os.getpid() })
425  es.update_doc({ "monitoring_socket": json_handler.fn })
426  es.defaults()
427  es.make_report()
428 
429  log_handler = FDOutputListener(fd=p.stdout.fileno(), es=es, zlog=zlog, close_socket=json_handler)
430  log_handler.handle_line("-- starting process: %s --\n" % str(args.pargs))
431 
432  try:
433  #manager.event_loop(timeout=5, exit_fd=p.stdout.fileno())
434  asyncore.loop(timeout=5)
435  except select.error as e:
436  # we have this on ctrl+c
437  # just terminate the child
438  log("Select error (we will terminate): " + str(e))
439  p.terminate()
440 
441  # at this point the program is dead
442  r = p.wait()
443  log_handler.handle_line("\n-- process exit: %s --\n" % str(r))
444  log_handler.finish()
445 
446  es.update_doc({ "exit_code": r })
447  es.make_report()
448 
449  CURRENT_PROC.remove(p)
450  return r
451 
def launch_monitoring(args)
def esMonitoring.log (   s)

Definition at line 11 of file esMonitoring.py.

Referenced by esMonitoring.FDJsonHandler.handle_line(), launch_monitoring(), and esMonitoring.ElasticReport.make_report().

11 def log(s):
12  sys.stderr.write("m: " + s + "\n");
13  sys.stderr.flush()
14