def getLDMSData(self, gen): return LDMSData({ "instance_name": "{}/{}/{}".format(self.prdcr, self.job_id, self.pid), "schema_name": "app_sampler", "metrics": dict( self.common_metrics(gen).items() + self.cmdline_metrics(gen).items() + self.n_open_files_metrics(gen).items() + self.io_metrics(gen).items() + self.oom_score_metrics(gen).items() + self.oom_score_adj_metrics(gen).items() + self.stat_metrics(gen).items() + self.status_metrics(gen).items() + self.syscall_metrics(gen).items() + self.timerslack_ns_metrics(gen).items() + self.wchan_metrics(gen).items() + self.root_metrics(gen).items() ) })
def src2ldmsdata(src): metrics = dict() cpu_cols = [ "user", "nice", "sys", "idle", "iowait", "irq", "softirq", "steal", "guest", "guest_nice" ] per_core = {k: list() for k in cpu_cols} RE = re.compile("\\S+") for l in src.content.splitlines(): tkns = RE.findall(l) name = tkns.pop(0) if name == "cpu": for k, v in zip(cpu_cols, tkns): metrics[k] = long(v) elif name.startswith("cpu"): for k, v in zip(cpu_cols, tkns): per_core[k].append(long(v)) elif name == "intr": metrics["hwintr_count"] = long(tkns[0]) elif name == "ctxt": metrics["context_switches"] = long(tkns[0]) elif name in ["processes", "procs_running", "procs_blocked"]: metrics[name] = long(tkns[0]) elif name == "softirq": metrics["softirq_count"] = long(tkns[0]) # cpu_enabled metrics["cpu_enabled"] = 1 cpus = len(per_core["user"]) metrics["cores_up"] = cpus per_core["cpu_enabled"] = [1] * cpus # extend per_core metrics, filling 0's and assign to metrics for k, v in per_core.iteritems(): name = "per_core_" + k metrics[name] = tuple(v + [0] * (MAXCPU - cpus)) return LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": metrics, })
def src2ldmsdata(src): assert (type(src) == Src) lines = iter(src.content.splitlines()) hdr = next(lines) hdr_tkns = TKN.findall(hdr) cols = len(hdr_tkns) D.cols = cols metrics = dict() for l in lines: D.l = l tkns = TKN.findall(l) D.tkns = tkns name = tkns[0].rstrip(':') n = min(cols, len(tkns) - 1) for c in range(0, n): val = int(tkns[c + 1]) mname = 'irq.%s#%d' % (name, c) metrics[mname] = val return LDMSData({ 'instance_name': INST_NAME, 'schema_name': SCHEMA_NAME, 'metrics': metrics, })
os.mkdir(DIR) src_data = [ # 1st SrcData() record for initialization + 1st ldms update SrcData( [ # 1 Src() per source file Src("/generic/file", "neg: -1\npos: 2\ndbl: 1.234"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "neg": -1, "pos": 2, "dbl": 1.234, } }), ]), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file Src("/generic/file", "neg: -11\npos: 22\ndbl: 31.234"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME,
# 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "mc0_ce_count": 0, "mc0_ce_noinfo_count": 0, "mc0_ue_count": 0, "mc0_ue_noinfo_count": 0, "mc0_csrow0_ce_count": 0, "mc0_csrow0_ue_count": 0, "mc0_csrow0_ch0_ce_count": 0, "mc0_csrow1_ce_count": 0, "mc0_csrow1_ue_count": 0, "mc0_csrow1_ch0_ce_count": 0, "mc0_csrow2_ce_count": 0, "mc0_csrow2_ue_count": 0, "mc0_csrow2_ch0_ce_count": 0, "mc0_csrow3_ce_count": 0, "mc0_csrow3_ue_count": 0, "mc0_csrow3_ch0_ce_count": 0, "mc0_csrow4_ce_count": 0, "mc0_csrow4_ue_count": 0, "mc0_csrow4_ch0_ce_count": 0, "mc0_csrow5_ce_count": 0, "mc0_csrow5_ue_count": 0, "mc0_csrow5_ch0_ce_count": 0, "mc0_seconds_since_reset": 432540, } }), ]),
eno1: 3716612055 3094869 0 0 0 0 0 9223 196675177 1664275 0 0 0 0 0 0 """), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "rx_bytes": 21777730, "rx_packets": 61486, "rx_errs": 0, "rx_drop": 0, "rx_fifo": 0, "rx_frame": 0, "rx_compressed": 0, "rx_multicast": 0, "tx_bytes": 21777730, "tx_packets": 61486, "tx_errs": 0, "tx_drop": 0, "tx_fifo": 0, "tx_colls": 0, "tx_carrier": 0, "tx_compressed": 0, } }), ]), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file
}) return ret src_data = [ # 1st SrcData() record for initialization + 1st ldms update SrcData( [ # 1 Src() per source file Src(x, open(x.replace("/proc/fs/lustre", "proc-fs-lustre-server0"))) \ for x in PROCFILES ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": mds_metrics("proc-fs-lustre-server0") }), ] ), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file Src(x, open(x.replace("/proc/fs/lustre", "proc-fs-lustre-server1"))) \ for x in PROCFILES ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME,
""" src_data = [ # 1st SrcData() record for initialization + 1st ldms update SrcData( [ # 1 Src() per source file Src("/sys/class/net/lo/statistics/rx_bytes", "20000"), Src("/sys/class/net/lo/statistics/tx_bytes", "10000"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "lo.rx_bytes": 20000, "lo.tx_bytes": 10000, } }), ]), SrcData( [ # 1 Src() per source file Src("/sys/class/net/lo/statistics/rx_bytes", "20002"), Src("/sys/class/net/lo/statistics/tx_bytes", "10001"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME,
LDMSData({ "instance_name": LDMSD_PREFIX + "/test", "schema_name": "meminfo", "metrics": { "MemTotal": 32367228, "MemFree": 20445628, "MemAvailable": 27341052, "Buffers": 1462996, "Cached": 5849868, "SwapCached": 0, "Active": 7348560, "Inactive": 3545304, "Active(anon)": 3582472, "Inactive(anon)": 692004, "Active(file)": 3766088, "Inactive(file)": 2853300, "Unevictable": 64, "Mlocked": 64, "SwapTotal": 2097148, "SwapFree": 2097148, "Dirty": 172, "Writeback": 0, "AnonPages": 3581244, "Mapped": 993828, "Shmem": 693484, "Slab": 813140, "SReclaimable": 738492, "SUnreclaim": 74648, "KernelStack": 17328, "PageTables": 65920, "NFS_Unstable": 0, "Bounce": 0, "WritebackTmp": 0, "CommitLimit": 18280760, "Committed_AS": 11090120, "VmallocTotal": 34359738367, "VmallocUsed": 0, "VmallocChunk": 0, "HardwareCorrupted": 0, "AnonHugePages": 0, "ShmemHugePages": 0, "ShmemPmdMapped": 0, "CmaTotal": 0, "CmaFree": 0, "HugePages_Total": 0, "HugePages_Free": 0, "HugePages_Rsvd": 0, "HugePages_Surp": 0, "Hugepagesize": 2048, "DirectMap4k": 323972, "DirectMap2M": 32649216, } })),
SDA_DIR + "/stat", "257739 33065 15486109 84912 549876 " "338338 1167148067 4849576 0 188316 4935124"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "reads_comp": 257739, "reads_merg": 33065, "sect_read": 15486109, "time_read": 84912, "writes_comp": 549876, "writes_merg": 338338, "sect_written": 1167148067, "time_write": 4849576, "ios_in_progress": 0, "time_ios": 188316, "weighted_time": 4935124, "disk.byte_read": 15486109 * 512, "disk.byte_written": 1167148067 * 512, } }), ]), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file Src(SDA_DIR + "/queue/hw_sector_size", "512"),
LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "nr_free_pages": 7004937, "nr_zone_inactive_anon": 105239, "nr_zone_active_anon": 545377, "nr_zone_inactive_file": 204018, "nr_zone_active_file": 149069, "nr_zone_unevictable": 16, "nr_zone_write_pending": 79, "nr_mlock": 16, "nr_page_table_pages": 12785, "nr_kernel_stack": 14672, "nr_bounce": 0, "nr_zspages": 0, "nr_free_cma": 0, "numa_hit": 9012402, "numa_miss": 0, "numa_foreign": 0, "numa_interleave": 57210, "numa_local": 9012402, "numa_other": 0, "nr_inactive_anon": 105239, "nr_active_anon": 545377, "nr_inactive_file": 204018, "nr_active_file": 149069, "nr_unevictable": 16, "nr_slab_reclaimable": 22199, "nr_slab_unreclaimable": 13917, "nr_isolated_anon": 0, "nr_isolated_file": 0, "workingset_refault": 0, "workingset_activate": 0, "workingset_nodereclaim": 0, "nr_anon_pages": 545100, "nr_mapped": 167156, "nr_file_pages": 458664, "nr_dirty": 79, "nr_writeback": 0, "nr_writeback_temp": 0, "nr_shmem": 105580, "nr_shmem_hugepages": 0, "nr_shmem_pmdmapped": 0, "nr_anon_transparent_hugepages": 0, "nr_unstable": 0, "nr_vmscan_write": 0, "nr_vmscan_immediate_reclaim": 0, "nr_dirtied": 167700, "nr_written": 146886, "nr_dirty_threshold": 1458118, "nr_dirty_background_threshold": 728169, "pgpgin": 1233050, "pgpgout": 670824, "pswpin": 0, "pswpout": 0, "pgalloc_dma": 2, "pgalloc_dma32": 57, "pgalloc_normal": 9156027, "pgalloc_movable": 0, "allocstall_dma": 0, "allocstall_dma32": 0, "allocstall_normal": 0, "allocstall_movable": 0, "pgskip_dma": 0, "pgskip_dma32": 0, "pgskip_normal": 0, "pgskip_movable": 0, "pgfree": 16162133, "pgactivate": 386545, "pgdeactivate": 0, "pglazyfree": 0, "pgfault": 9637312, "pgmajfault": 5590, "pglazyfreed": 0, "pgrefill": 0, "pgsteal_kswapd": 0, "pgsteal_direct": 0, "pgscan_kswapd": 0, "pgscan_direct": 0, "pgscan_direct_throttle": 0, "zone_reclaim_failed": 0, "pginodesteal": 0, "slabs_scanned": 0, "kswapd_inodesteal": 0, "kswapd_low_wmark_hit_quickly": 0, "kswapd_high_wmark_hit_quickly": 0, "pageoutrun": 0, "pgrotated": 34, "drop_pagecache": 0, "drop_slab": 0, "oom_kill": 0, "numa_pte_updates": 0, "numa_huge_pte_updates": 0, "numa_hint_faults": 0, "numa_hint_faults_local": 0, "numa_pages_migrated": 0, "pgmigrate_success": 0, "pgmigrate_fail": 0, "compact_migrate_scanned": 0, "compact_free_scanned": 0, "compact_isolated": 0, "compact_stall": 0, "compact_fail": 0, "compact_success": 0, "compact_daemon_wake": 0, "compact_daemon_migrate_scanned": 0, "compact_daemon_free_scanned": 0, "htlb_buddy_alloc_success": 0, "htlb_buddy_alloc_fail": 0, "unevictable_pgs_culled": 10707, "unevictable_pgs_scanned": 0, "unevictable_pgs_rescued": 9080, "unevictable_pgs_mlocked": 11180, "unevictable_pgs_munlocked": 11164, "unevictable_pgs_cleared": 0, "unevictable_pgs_stranded": 0, "thp_fault_alloc": 0, "thp_fault_fallback": 0, "thp_collapse_alloc": 0, "thp_collapse_alloc_failed": 0, "thp_file_alloc": 0, "thp_file_mapped": 0, "thp_split_page": 0, "thp_split_page_failed": 0, "thp_deferred_split_page": 0, "thp_split_pmd": 0, "thp_split_pud": 0, "thp_zero_page_alloc": 0, "thp_zero_page_alloc_failed": 0, "thp_swpout": 0, "thp_swpout_fallback": 0, "balloon_inflate": 0, "balloon_deflate": 0, "balloon_migrate": 0, "swap_ra": 0, "swap_ra_hit": 0, } })),
os.mkdir(DIR) src_data = [ # 1st SrcData() record for initialization + 1st ldms update SrcData( [ # 1 Src() per source file Src("/sys/PATH_XXX_0", "data0.0"), Src("/sys/PATH_XXX_1", "data1.0"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "NAME": _VALUE_ } }), ]), # More SrcData() record for 2nd ldms update ] class XXXTest(LDMSChrootTest, unittest.TestCase): CHROOT_DIR = DIR + "/chroot" @classmethod def getLdmsConfig(cls): return """ load name=test plugin=XXX_PLUGIN
SrcData( [ # 1 Src() per source file Src("/proc/sys/lnet/stats", "0 3 0 434 433 0 0 105597 122856 0 0"), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "msgs_alloc": 0, "msgs_max": 3, "errors": 0, "send_count": 434, "recv_count": 433, "route_count": 0, "drop_count": 0, "send_length": 105597, "recv_length": 122856, "route_length": 0, "drop_length": 0, } }), ]), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file Src("/proc/sys/lnet/stats", "1 3 1 434 433 1 1 105597 122856 1 1"), ],
INST_NAME = LDMSD_PREFIX + "/test" SCHEMA_NAME = "cray_power_sampler" DIR = "test_cray_power_sampler" # a work directory for this test, so that # everything is in one place if not os.path.exists(DIR): os.mkdir(DIR) src_data = [ SrcData([ Src("/sys/cray/pm_counters/energy", "127381720 J"), Src("/sys/cray/pm_counters/power", "44 W"), ], LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "energy": 127381720, "power": 44, } })), SrcData([ Src("/sys/cray/pm_counters/energy", "127466523 J"), Src("/sys/cray/pm_counters/power", "37 W"), ], LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "energy": 127466523, "power": 37, } })),
"JOB_START=1554768000\n" "JOB_STATUS=1\n" "JOB_USER=user100\n" "JOB_USER_ID=100\n" ), ], [ # 1 LDMSData() per set LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "component_id": LDMSChrootTest.COMPONENT_ID, "app_id": 10, "job_id": 20, "job_status": 1, "user_id": 100, "job_start": 1554768000, "job_end": 1554769000, "job_exit_status": 0, "job_user": "******", "job_name": "job20", } }), ] ), # More SrcData() record for 2nd ldms update SrcData( [ # 1 Src() per source file Src("/var/run/ldms_jobinfo.data", "JOB_APP_ID=101\n"
LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "time": 1554894618, # only retain the seconds part "ntx": 0, "npeers": 15, "nconns": 7, "nEPs": 7, "ndgrams": 4, "nfmablk": 1, "n_mdd": 1, "n_mdd_held": 0, "n_eager_allocs": 0, "GART_map_bytes": 74309632, "TX_queued_maps": 0, "TX_phys_nmaps": 0, "TX_phys_bytes": 0, "TX_virt_nmaps": 0, "TX_virt_bytes": 0, "RDMAQ_bytes_auth": 7020988896, "RDMAQ_bytes_left": 9223372029833786911, "RDMAQ_nstalls": 0, "dev_mutex_delay": 3569, "dev_n_yield": 4960533, "dev_n_schedule": -1609036116, "SMSG_fast_try": 151364744, "SMSG_fast_ok": 151364214, "SMSG_fast_block": 21288675, "SMSG_ntx": 177614377, "SMSG_tx_bytes": 75792495969, "SMSG_nrx": 170165045, "SMSG_rx_bytes": 71930531529, "RDMA_ntx": 1807923, "RDMA_tx_bytes": 146269342238, "RDMA_nrx": 1298480, "RDMA_rx_bytes": 15607145934, "VMAP_short": 0, "VMAP_cksum": 0, "KMAP_short": 1103904, "RDMA_REV_length": 0, "RDMA_REV_offset": 0, "RDMA_REV_copy": 0, } }),
LDMSData({ "instance_name": INST_NAME, "schema_name": SCHEMA_NAME, "metrics": { "rpc.retrans": 0, "rpc.authrefresh": 3238, "nfs3.getattr": 0, "nfs3.setattr": 0, "nfs3.lookup": 0, "nfs3.access": 0, "nfs3.readlink": 0, "nfs3.read": 0, "nfs3.write": 0, "nfs3.create": 0, "nfs3.mkdir": 0, "nfs3.symlink": 0, "nfs3.mknod": 0, "nfs3.remove": 0, "nfs3.rmdir": 0, "nfs3.rename": 0, "nfs3.link": 0, "nfs3.readdir": 0, "nfs3.readdirplus": 0, "nfs3.fsstat": 0, "nfs3.fsinfo": 0, "nfs3.pathconf": 0, "nfs3.commit": 0, "nfs4.read": 0, "nfs4.write": 0, "nfs4.commit": 0, "nfs4.open": 1, "nfs4.open_confirm": 0, "nfs4.open_noattr": 0, "nfs4.open_downgrade": 0, "nfs4.close": 0, "nfs4.setattr": 0, "nfs4.fsinfo": 3, "nfs4.renew": 0, "nfs4.setclientid": 0, "nfs4.setclientid_confirm": 0, "nfs4.lock": 0, "nfs4.lockt": 0, "nfs4.locku": 0, "nfs4.access": 6, "nfs4.getattr": 29, "nfs4.lookup": 6, "nfs4.lookup_root": 1, "nfs4.remove": 0, "nfs4.rename": 0, "nfs4.link": 0, "nfs4.symlink": 0, "nfs4.create": 0, "nfs4.pathconf": 2, "nfs4.statfs": 0, "nfs4.readlink": 3, "nfs4.readdir": 1, "nfs4.server_caps": 5, "nfs4.delegreturn": 0, "nfs4.getacl": 0, "nfs4.setacl": 0, "nfs4.fs_locations": 0, "nfs4.release_lockowner": 0, "nfs4.secinfo": 0, "nfs4.fsid_present": 0, "nfs4.exchange_id": 2, "nfs4.create_session": 1, "nfs4.destroy_session": 0, "nfs4.sequence": 3175, "nfs4.get_lease_time": 0, "nfs4.reclaim_complete": 1, "nfs4.layoutget": 0, "nfs4.getdeviceinfo": 0, "nfs4.layoutcommit": 0, "nfs4.layoutreturn": 0, "nfs4.secinfo_no_name": 1, "nfs4.test_stateid": 0, "nfs4.free_stateid": 0, "nfs4.getdevicelist": 0, "nfs4.bind_conn_to_session": 0, "nfs4.destroy_clientid": 0, "nfs4.seek": 0, "nfs4.allocate": 0, "nfs4.deallocate": 0, "nfs4.layoutstats": 0, "nfs4.clone": 0, "nfs4.copy": 0, } }),