-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdumpProcs.py
34 lines (26 loc) · 954 Bytes
/
dumpProcs.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
#!/usr/bin/env python3
""" dumpProcesses Module """
# -*- coding: utf-8 -*-
# =============================================================================
# Title : dumpProcesses.py
# Description : This script handles process identification
# Created By : Tim Owings
# Created Date : Feb 16, 2022
# Python : 3.9.2
# =============================================================================
import psutil
def dumpProcs():
""" Dump processes """
proclist = []
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['name', 'pid', 'status'])
proclist.append(pinfo)
except Exception as e:
print("Exception {} for processName: {} processStatus \n".format(e, proc.name(), proc.status()))
pass
return proclist
if __name__ == "__main__":
procList = dumpProcs()
for x in procList:
print(" {}\n".format(x))