CMS 3D CMS Logo

Classes | Functions | Variables
dqm-mbProfile Namespace Reference

Classes

class  Profile
 

Functions

def build_process_list ()
 
def find_and_write_html (p, args)
 
def get_children (ppid)
 
def handle_alarm (num, frame)
 
def read_procfs (ppath, only_ppid=True)
 
def run_and_monitor (args)
 

Variables

 action
 
 ALARM_P_OBJECT
 
 ALARM_TIMER
 
 args
 
 default
 
 description
 
 format
 
 help
 
 int
 
 log
 
 LOG_FORMAT
 
 metavar
 
 nargs
 
 p
 
 pargs
 
 parser
 
 str
 
 type
 

Function Documentation

◆ build_process_list()

def dqm-mbProfile.build_process_list ( )

Definition at line 56 of file dqm-mbProfile.py.

References read_procfs().

Referenced by get_children().

56 def build_process_list():
57  lst = os.listdir("/proc/")
58  for f in lst:
59  if not f.isdigit(): continue
60 
61  proc = read_procfs(os.path.join("/proc", f))
62  if proc:
63  yield proc
64 
def build_process_list()
def read_procfs(ppath, only_ppid=True)

◆ find_and_write_html()

def dqm-mbProfile.find_and_write_html (   p,
  args 
)

Definition at line 244 of file dqm-mbProfile.py.

244 def find_and_write_html(p, args):
245  # create the dir if necessary
246  if p and not os.path.exists(p):
247  os.makedirs(p)
248 
249  html_paths = [
250  os.path.join(os.getenv("CMSSW_BASE"),"src/DQMServices/Components/data/html"),
251  os.path.join(os.getenv("CMSSW_RELEASE_BASE"), "src/DQMServices/Components/data/html"),
252  ]
253 
254  def find_file(f):
255  fails = []
256  for p in html_paths:
257  x = os.path.join(p, f)
258  if os.path.exists(x):
259  return x
260  else:
261  fails.append(x)
262 
263  log.warning("Could not find html file: %s (%s)", f, fails)
264 
265  for f in ['mbGraph.js', 'mbGraph.html']:
266  target_fn = os.path.join(p, f)
267  source_fn = find_file(f)
268  if source_fn:
269  log.info("Copying %s to %s", source_fn, target_fn)
270  shutil.copyfile(source_fn, target_fn)
271 
272  # create json file
273  target_fn = os.path.join(p, "mbGraph.json")
274  log.info("Creating %s", target_fn)
275  with open(target_fn, "w") as fp:
276  dct = {
277  "file": os.path.basename(args.file),
278  "interval": args.i,
279  "env": {
280  "CMSSW_GIT_HASH": os.getenv("CMSSW_GIT_HASH"),
281  "CMSSW_RELEASE_BASE": os.getenv("CMSSW_RELEASE_BASE"),
282  "SCRAM_ARCH": os.getenv("SCRAM_ARCH"),
283  },
284  }
285 
286  json.dump(dct, fp, indent=2)
287 
288 
def find_and_write_html(p, args)

◆ get_children()

def dqm-mbProfile.get_children (   ppid)
Select all processes which are descendant from ppid (exclusive). 

Definition at line 65 of file dqm-mbProfile.py.

References mps_setup.append, and build_process_list().

Referenced by dqm-mbProfile.Profile.update_proc().

65 def get_children(ppid):
66  """ Select all processes which are descendant from ppid (exclusive). """
67 
68  pid_dct = {}
69  for proc in build_process_list():
70  proc["_children"] = []
71  pid_dct[proc["pid"]] = proc
72 
73  # fill in children array
74  for pid in list(pid_dct.keys()):
75  parent_pid = pid_dct[pid]["parent_pid"]
76 
77  if parent_pid in pid_dct:
78  pid_dct[parent_pid]["_children"].append(pid)
79 
80  # now just walk down the tree
81  if ppid is None or ppid not in pid_dct:
82  # process has quit, we exit
83  return []
84 
85  accepted = []
86  to_accept = collections.deque([ppid, ])
87 
88  while to_accept:
89  head = pid_dct[to_accept.popleft()]
90 
91  # do not include the monitoring pid
92  if head["pid"] != ppid:
93  accepted.append(head)
94 
95  to_accept.extend(head.get("_children", []))
96  head["children"] = head["_children"]
97  del head["_children"]
98 
99  # deleting children breaks infinite loops
100  # but Dima, can a process tree contain a loop? yes - via race-condition in reading procfs
101 
102  return accepted
103 
def get_children(ppid)
def build_process_list()

◆ handle_alarm()

def dqm-mbProfile.handle_alarm (   num,
  frame 
)

Definition at line 223 of file dqm-mbProfile.py.

223 def handle_alarm(num, frame):
224  if ALARM_P_OBJECT:
225  ALARM_P_OBJECT.update()
226 
227  signal.alarm(ALARM_TIMER)
228 
def handle_alarm(num, frame)

◆ read_procfs()

def dqm-mbProfile.read_procfs (   ppath,
  only_ppid = True 
)

Definition at line 20 of file dqm-mbProfile.py.

References int, SiPixelLorentzAngle_cfi.read, python.rootplot.root2matplotlib.replace(), and nano_mu_digi_cff.strip.

Referenced by build_process_list().

20 def read_procfs(ppath, only_ppid=True):
21  def read(f):
22  fp = os.path.join(ppath, f)
23  with open(fp) as fd:
24  return fd.read()
25 
26  def read_status():
27  st = {}
28 
29  fp = os.path.join(ppath, "status")
30  with open(fp) as fd:
31  for line in fd.readlines():
32  if not line: continue
33 
34  key, value = line.split(":", 1)
35  st[key] = value.strip()
36 
37  return st
38 
39  try:
40  dct = {}
41 
42  dct["statm"] = read("statm").strip()
43  dct["stat"] = read("stat").strip()
44  dct["cmdline"] = read("cmdline").strip().replace("\0", " ")
45 
46  status = read_status()
47  dct["status"] = status
48  dct["pid"] = int(status["Pid"])
49  dct["parent_pid"] = int(status["PPid"])
50 
51  return dct
52  except:
53  log.warning("Exception in read_procfs.", exc_info=True)
54  pass
55 
def replace(string, replacements)
def read_procfs(ppath, only_ppid=True)

◆ run_and_monitor()

def dqm-mbProfile.run_and_monitor (   args)

Definition at line 229 of file dqm-mbProfile.py.

229 def run_and_monitor(args):
230  profile = Profile(args)
231 
232  proc = subprocess.Popen(args.pargs)
233  profile.pid = proc.pid
234 
235  global ALARM_P_OBJECT
236  ALARM_P_OBJECT = profile
237 
238  signal.signal(signal.SIGALRM, handle_alarm)
239  signal.alarm(ALARM_TIMER)
240 
241  proc.wait()
242  profile.finish()
243 
def run_and_monitor(args)

Variable Documentation

◆ action

dqm-mbProfile.action

Definition at line 293 of file dqm-mbProfile.py.

◆ ALARM_P_OBJECT

dqm-mbProfile.ALARM_P_OBJECT

Definition at line 221 of file dqm-mbProfile.py.

◆ ALARM_TIMER

dqm-mbProfile.ALARM_TIMER

Definition at line 220 of file dqm-mbProfile.py.

◆ args

dqm-mbProfile.args

Definition at line 297 of file dqm-mbProfile.py.

◆ default

dqm-mbProfile.default

Definition at line 291 of file dqm-mbProfile.py.

◆ description

dqm-mbProfile.description

Definition at line 290 of file dqm-mbProfile.py.

◆ format

dqm-mbProfile.format

Definition at line 16 of file dqm-mbProfile.py.

Referenced by edm::ThinnedAssociationsHelper.addAssociation(), edm::eventsetup::ComponentMaker< edm::eventsetup::LooperMakerTraits, TType >.addTo(), HGCalLayerClusterHeterogeneousDumper.analyze(), HGCalLayerClusterHeterogeneousSoADumper.analyze(), TestAlpakaHostDeviceCompare.analyze(), DiMuonValidation.beginJob(), RPCSummaryMapHisto.book(), RPCRollMapHisto.bookBarrel(), RPCRollMapHisto.bookEndcap(), RPCDigiValid.bookHistograms(), RPCTTUMonitor.bookHistograms(), SiPixelMonitorTrackSoAAlpaka< T >.bookHistograms(), GlobalTest.bookHistograms(), SiStripLorentzAnglePCLMonitor.bookHistograms(), SiStripHitEfficiencyWorker.bookHistograms(), SiStripMonitorApproximateCluster.bookHistograms(), PrimaryVertexMonitor::IPMonitoring.bookIPMonitor(), GeneralPurposeVertexAnalyzer::IPMonitoring.bookIPMonitor(), RPCMonitorDigi.bookRollME(), RPCMonitorDigi.bookSectorRingME(), RPCMonitorDigi.bookWheelDiskME(), sistrip::MeasureLA.calibration_key(), RPCNameHelper.chamberName(), RPCClusterSizeTest.clientOperation(), RPCEventSummary.clientOperation(), SiStripHitEffFromCalibTree.computeEff(), sistrip::RawToDigiUnpacker.createDigis(), sistrip::DigiToRaw.createFedBuffers_(), edm::eventsetup::ESSourceProductResolverBase.doPrefetchAndSignals(), RPCRecHitProbabilityClient.dqmEndJob(), SiStripHitEfficiencyHarvester.dqmEndJob(), SiStripLorentzAnglePCLHarvester.dqmEndJob(), SiPixelLorentzAnglePCLHarvester.dqmEndJob(), SiPixelLorentzAnglePCLHarvesterMCS.dqmEndJob(), RPCEventSummary.dqmEndLuminosityBlock(), hgcalUtils::DumpClusters.dumpInfos(), hgcalUtils::DumpClustersSoA.dumpInfos(), hgcalUtils::DumpCellsSoA.dumpInfos(), hgcalUtils::DumpLegacySoA.dumpInfos(), RPCRawDataCountsHistoMaker.emptyReadoutErrorHisto(), RPCRawDataCountsHistoMaker.emptyReadoutErrorMapHisto(), RPCRawDataCountsHistoMaker.emptyRecordTypeHisto(), trackerTFP::KalmanFilterFormats.endJob(), CalibrationSummaryFactory.extract(), CalibrationScanSummaryFactory.extract(), SummaryPlotFactory< CommissioningAnalysis *>.fill(), RPCBookFolderStructure.folderStructure(), edm::service::CPU.getModelFromCPUFeatures(), RPCDqmClient.getMonitorElements(), edm::StreamSchedule.initializeEarlyDelete(), edm::RootInputFileSequence.initTheFile(), CTPPSPixelDataFormatter.interpretRawData(), RPCFEDIntegrity.labelBins(), HcalFEDIntegrityTask.labelBins(), main(), edm::service::IgProfService.makeDump(), edm::service::JeProfService.makeDump(), ModuleTypeResolverMakerAlpaka.makeResolver(), SiStripHitEfficiencyHarvester.makeSummary(), SiStripHitEffFromCalibTree.makeSummaryVsBx(), SiStripHitEfficiencyHarvester.makeSummaryVsVariable(), RPCDCSSummary.myBooker(), RPCDataCertification.myBooker(), RPCDaqInfo.myBooker(), DQMNet.onPeerConnect(), RPCMonitorDigi.performSourceOperation(), TritonService.postEndJob(), TrackExtenderWithMTDT< TrackCollection >.produce(), l1t::demo.read(), TotemVFATRawToDigi.run(), DQMNet.run(), FWTriggerTableView.saveImageTo(), FWTableView.saveImageTo(), sistrip::EnsembleCalibrationLA.write_ensembles_text(), cmsswFiletrace.writeoutput(), edm::writeParameterValue.writeValue(), edm::writeParameterValue.writeValueInVector(), edm::writeParameterValue.writeValueInVectorWithSpace(), and edm::writeParameterValue.writeVector().

◆ help

dqm-mbProfile.help

Definition at line 291 of file dqm-mbProfile.py.

◆ int

dqm-mbProfile.int

Definition at line 292 of file dqm-mbProfile.py.

Referenced by read_procfs(), and dqm-mbProfile.Profile.read_smaps().

◆ log

dqm-mbProfile.log

Definition at line 17 of file dqm-mbProfile.py.

◆ LOG_FORMAT

dqm-mbProfile.LOG_FORMAT

Definition at line 15 of file dqm-mbProfile.py.

◆ metavar

dqm-mbProfile.metavar

Definition at line 291 of file dqm-mbProfile.py.

◆ nargs

dqm-mbProfile.nargs

Definition at line 295 of file dqm-mbProfile.py.

◆ p

dqm-mbProfile.p

Definition at line 312 of file dqm-mbProfile.py.

◆ pargs

dqm-mbProfile.pargs

Definition at line 304 of file dqm-mbProfile.py.

◆ parser

dqm-mbProfile.parser

Definition at line 290 of file dqm-mbProfile.py.

◆ str

dqm-mbProfile.str

Definition at line 291 of file dqm-mbProfile.py.

◆ type

dqm-mbProfile.type

Definition at line 291 of file dqm-mbProfile.py.