forked from brunoterkaly/linux-perfmon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStopCaptureLoadData.py
More file actions
executable file
·78 lines (64 loc) · 2.01 KB
/
StopCaptureLoadData.py
File metadata and controls
executable file
·78 lines (64 loc) · 2.01 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import subprocess
from shutil import copyfile
import sys
import os
import time
import socket
import datetime
import signal
def printMessage(s):
print("--------------------------------------------------------")
print(" ", s)
print("--------------------------------------------------------")
def KillAll():
printMessage("Finding running python scripts")
command = ['bash', './KillAll.sh']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
d = process.stdout.readline().decode('utf-8')
if not d:
break
d = d.replace("\n","")
print(d)
process.terminate()
KillAll()
printMessage("Install Start importing process")
commands = [ \
['python3', 'BulkImportDiskIo.py'], \
['python3', 'BulkImportCpu.py'], \
['python3', 'BulkImportNetwork.py'], \
['python3', 'BulkImportTop.py'], \
['python3', 'BulkImportIoTop.py'], \
['python3', 'BulkImportFreeMem.py'] \
]
printMessage("Run BulkImportDiskIo.py, BulkImportTop.py, BulkImportIoTop.py, \
BulkImportCpu.py, BulkImportNetwork.py, BulkImportFreeMem.py")
for i in range(len(commands)):
cmd = " ".join(commands[i])
printMessage("Running...." + cmd)
process = subprocess.Popen(commands[i], stdout=subprocess.PIPE)
while True:
s = process.stdout.readline().decode('utf-8')
s = s.replace("\n","")
if not s:
break
print(s)
"""
def killProcess(s):
printMessage("Finding Running python scripts")
command = ['ps', 'aux']
process = subprocess.Popen(command, stdout=subprocess.PIPE)
while True:
d = process.stdout.readline().decode('utf-8')
d = d.replace("\n","")
if not d:
break
myapp = d[65:].strip()
mypid = d[9:15].strip()
if myapp == s:
print("myapp = ", myapp)
print("mypid = ", mypid)
os.kill(int(mypid), signal.SIGKILL)
#-------------------------------------------------------------
killProcess("python3 ParseIoStat.py")
"""