From f99110a0be14cea1693f8be3e9727e4be21e167b Mon Sep 17 00:00:00 2001 From: Dan Snyder Date: Fri, 23 May 2025 11:32:04 -0400 Subject: [PATCH] Removed old Python code --- py/ps_fields.py | 76 ------------------------------------------------ py/ps_parse.py | 33 --------------------- py/stat_flags.py | 39 ------------------------- 3 files changed, 148 deletions(-) delete mode 100644 py/ps_fields.py delete mode 100644 py/ps_parse.py delete mode 100644 py/stat_flags.py diff --git a/py/ps_fields.py b/py/ps_fields.py deleted file mode 100644 index e23ea6c..0000000 --- a/py/ps_fields.py +++ /dev/null @@ -1,76 +0,0 @@ -field_defs = { - 'PID': { - 'desc': 'PID', - 'dtype': str, - }, - 'PPID': { - 'desc': 'Parent PID', - 'dtype': str, - }, - 'UID': { - 'desc': 'User ID', - 'dtype': str, - }, - 'LXC': { - 'desc': 'LXC ID', - 'dtype': str, - }, - '%CUU': { - 'desc': 'CPU Use', - 'dtype': float, - }, - '%MEM': { - 'desc': 'Memory Use', - 'dtype': float, - }, - 'VSZ': { - 'desc': 'Virtual Memory', - 'dtype': int, - 'mult': 1024, - }, - 'RSS': { - 'desc': 'Resident Memory', - 'dtype': int, - 'mult': 1024, - }, - 'PSS': { - 'desc': 'Proportional Shared Memory', - 'dtype': int, - 'mult': 1024, - }, - 'USS': { - 'desc': 'Unique Memory', - 'dtype': int, - 'mult': 1024, - }, - 'SZ': { - 'desc': 'Core Size', - 'dtype': int, - 'mult': 4096, - }, - 'SIZE': { - 'desc': 'Approximate Memory', - 'dtype': int, - 'mult': 1024, - }, - 'THCNT': { - 'desc': 'Thread Count', - 'dtype': int, - }, - 'TIME': { - 'desc': 'Execution Time', - 'dtype': int, - }, - 'ELAPSED': { - 'desc': 'Elapsed Time', - 'dtype': int, - }, - 'STAT': { - 'desc': 'Status', - 'dtype': str, - }, - 'COMMAND': { - 'desc': 'Command', - 'dtype': str, - } -} diff --git a/py/ps_parse.py b/py/ps_parse.py deleted file mode 100644 index 265ca0d..0000000 --- a/py/ps_parse.py +++ /dev/null @@ -1,33 +0,0 @@ -from ps_fields import * -import mongodb - -def parsePsOutput(output): - data = output.split('\n') - data = list(filter(bool, [line.split() for line in data])) - header = data[0] - procs = [] - - for line in data[1:]: - proc = {} - for i in range(len(header)): - field = field_defs[header[i]] - value = line[i] - if i == len(header): - # combine command arguments together to one string - value = ' '.join(line[i:]) - - value = field['dtype'](value) - if 'mult' in field: - # mult if applicable - value *= field['mult'] - - proc[header[i]] = value - - procs.append(proc) - return procs - -def parseFile(fname): - f = open(fname, 'r') - data = f.read() - f.close() - return parsePsOutput(data) diff --git a/py/stat_flags.py b/py/stat_flags.py deleted file mode 100644 index 3ec1113..0000000 --- a/py/stat_flags.py +++ /dev/null @@ -1,39 +0,0 @@ -reverse_lookup = { - 0x00000001: "PF_VCPU", # I'm a virtual CPU - 0x00000002: "PF_IDLE", # I am an IDLE thread - 0x00000004: "PF_EXITING", # Getting shut down - 0x00000008: "PF_POSTCOREDUMP", # Coredumps should ignore this task - 0x00000010: "PF_IO_WORKER", # Task is an IO worker - 0x00000020: "PF_WQ_WORKER", # I'm a workqueue worker - 0x00000040: "PF_FORKNOEXEC", # Forked but didn't exec - 0x00000080: "PF_MCE_PROCESS", # Process policy on mce errors - 0x00000100: "PF_SUPERPRIV", # Used super-user privileges - 0x00000200: "PF_DUMPCORE", # Dumped core - 0x00000400: "PF_SIGNALED", # Killed by a signal - 0x00000800: "PF_MEMALLOC", # Allocating memory - 0x00001000: "PF_NPROC_EXCEEDED", # set_user() noticed that RLIMIT_NPROC was exceeded - 0x00002000: "PF_USED_MATH", # If unset the fpu must be initialized before use - 0x00004000: "PF_USER_WORKER", # Kernel thread cloned from userspace thread - 0x00008000: "PF_NOFREEZE", # This thread should not be frozen - 0x00010000: "PF__HOLE__00010000", - 0x00020000: "PF_KSWAPD", # I am kswapd - 0x00040000: "PF_MEMALLOC_NOFS", # All allocation requests will inherit GFP_NOFS - 0x00080000: "PF_MEMALLOC_NOIO", # All allocation requests will inherit GFP_NOIO - 0x00100000: "PF_LOCAL_THROTTLE", # Throttle writes only against the bdi I write to, I am cleaning dirty pages from some other bdi. - 0x00200000: "PF_KTHREAD", # I am a kernel thread - 0x00400000: "PF_RANDOMIZE", # Randomize virtual address space - 0x00800000: "PF__HOLE__00800000", - 0x01000000: "PF__HOLE__01000000", - 0x02000000: "PF__HOLE__02000000", - 0x04000000: "PF_NO_SETAFFINITY", # Userland is not allowed to meddle with cpus_mask - 0x08000000: "PF_MCE_EARLY", # Early kill for mce process policy - 0x10000000: "PF_MEMALLOC_PIN", # Allocation context constrained to zones which allow long term pinning. - 0x20000000: "PF__HOLE__20000000", - 0x40000000: "PF__HOLE__40000000", - 0x80000000: "PF_SUSPEND_TASK", # This thread called freeze_processes() and should not be frozen -} - -def listFlags(flag): - for i in reverse_lookup.keys(): - if flag & i: - print(reverse_lookup[i]) \ No newline at end of file