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 
def dt2time(dt)
Definition: esMonitoring.py:15

◆ handle_signal()

def esMonitoring.handle_signal (   signum,
  frame 
)

Definition at line 453 of file esMonitoring.py.

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

◆ launch_monitoring()

def esMonitoring.launch_monitoring (   args)

Definition at line 388 of file esMonitoring.py.

References log(), and str.

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

◆ log()

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 

Variable Documentation

◆ action

esMonitoring.action

Definition at line 459 of file esMonitoring.py.

◆ args

esMonitoring.args

Definition at line 463 of file esMonitoring.py.

◆ CURRENT_PROC

esMonitoring.CURRENT_PROC

Definition at line 387 of file esMonitoring.py.

◆ default

esMonitoring.default

Definition at line 460 of file esMonitoring.py.

◆ description

esMonitoring.description

Definition at line 458 of file esMonitoring.py.

◆ help

esMonitoring.help

Definition at line 459 of file esMonitoring.py.

◆ nargs

esMonitoring.nargs

Definition at line 462 of file esMonitoring.py.

◆ None

esMonitoring.None

Definition at line 460 of file esMonitoring.py.

◆ pargs

esMonitoring.pargs

Definition at line 470 of file esMonitoring.py.

◆ parser

esMonitoring.parser

Definition at line 458 of file esMonitoring.py.

◆ str

esMonitoring.str

◆ type

esMonitoring.type

Definition at line 460 of file esMonitoring.py.