CMS 3D CMS Logo

Classes | Functions | Variables
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)
 

Variables

 action
 
 args
 
 CURRENT_PROC
 
 default
 
 description
 
 help
 
 nargs
 
 None
 
 pargs
 
 parser
 
 str
 
 type
 

Function Documentation

◆ dt2time()

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 

◆ handle_signal()

def esMonitoring.handle_signal (   signum,
  frame 
)

Definition at line 452 of file esMonitoring.py.

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

◆ launch_monitoring()

def esMonitoring.launch_monitoring (   args)

Definition at line 387 of file esMonitoring.py.

387 def launch_monitoring(args):
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 

References log(), and str.

◆ log()

def esMonitoring.log (   s)

Definition at line 11 of file esMonitoring.py.

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

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

Variable Documentation

◆ action

esMonitoring.action

Definition at line 458 of file esMonitoring.py.

◆ args

esMonitoring.args

Definition at line 462 of file esMonitoring.py.

◆ CURRENT_PROC

esMonitoring.CURRENT_PROC

Definition at line 386 of file esMonitoring.py.

◆ default

esMonitoring.default

Definition at line 459 of file esMonitoring.py.

◆ description

esMonitoring.description

Definition at line 457 of file esMonitoring.py.

◆ help

esMonitoring.help

Definition at line 458 of file esMonitoring.py.

◆ nargs

esMonitoring.nargs

Definition at line 461 of file esMonitoring.py.

◆ None

esMonitoring.None

Definition at line 459 of file esMonitoring.py.

◆ pargs

esMonitoring.pargs

Definition at line 469 of file esMonitoring.py.

◆ parser

esMonitoring.parser

Definition at line 457 of file esMonitoring.py.

◆ str

esMonitoring.str

◆ type

esMonitoring.type

Definition at line 459 of file esMonitoring.py.

esMonitoring.handle_signal
def handle_signal(signum, frame)
Definition: esMonitoring.py:452
esMonitoring.log
def log(s)
Definition: esMonitoring.py:11
esMonitoring.launch_monitoring
def launch_monitoring(args)
Definition: esMonitoring.py:387
str
#define str(s)
Definition: TestProcessor.cc:48
esMonitoring.dt2time
def dt2time(dt)
Definition: esMonitoring.py:15