-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyProc.py
executable file
·42 lines (31 loc) · 1.1 KB
/
pyProc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
import argparse
import os
import sys
from proc_scraper.proc_directory import ProcDirectory
if __name__ == '__main__':
if os.name != 'posix':
print('pyProc only supports UNIX systems, exiting')
sys.exit()
# Parse CLI arguments
parser = argparse.ArgumentParser(prog='pyProc')
parser.add_argument('-p', '--pid', type=int,
help='Display details for /proc/[pid]. '
'Use pid 0 for /proc/self.')
parser.add_argument('-n', '--net', action='store_true',
help='Display information from /proc/net')
parser.add_argument('-s', '--sys', action='store_true',
help='Display information from /proc/sys')
args = parser.parse_args()
proc_dir = ProcDirectory()
if args.pid == 0:
proc_dir.dump_proc('self')
elif args.pid:
proc_dir.dump_proc(args.pid)
if args.net:
proc_dir.dump_net()
if args.sys:
proc_dir.dump_sys()
# Print details from root /proc dir
if len(sys.argv) == 1:
proc_dir.dump_base()