moved gstat command to a redirect
This commit is contained in:
52
collect.py
52
collect.py
@@ -298,7 +298,9 @@ def collect_data(minutes):
|
||||
if is_freebsd():
|
||||
coreCPUstat()
|
||||
coreMemstat()
|
||||
coreIostat_disk()
|
||||
|
||||
# gives same data each interval
|
||||
# coreIostat_disk()
|
||||
|
||||
if i == minutes:
|
||||
print("")
|
||||
@@ -433,40 +435,42 @@ def main():
|
||||
print("Starting Collection")
|
||||
|
||||
# Collect data
|
||||
# if is_freebsd():
|
||||
# # timeout = f"{minutes}m"
|
||||
# # "timeout",
|
||||
# # timeout,
|
||||
if is_freebsd():
|
||||
# timeout = f"{minutes}m"
|
||||
# "timeout",
|
||||
# timeout,
|
||||
|
||||
# gstat_command = [
|
||||
# "gstat",
|
||||
# "-C",
|
||||
# "-s",
|
||||
# "-d",
|
||||
# "-o",
|
||||
# "-p",
|
||||
# "-I",
|
||||
# "5s",
|
||||
# ]
|
||||
gstat_command = [
|
||||
"gstat",
|
||||
"-C",
|
||||
"-s",
|
||||
"-d",
|
||||
"-o",
|
||||
"-p",
|
||||
"-I",
|
||||
"5s",
|
||||
">",
|
||||
"gstat.csv",
|
||||
]
|
||||
|
||||
# with open("gstat.csv", "a") as output_file:
|
||||
# # Create a Popen object with stdout redirected to the file
|
||||
# process = subprocess.Popen(gstat_command, stdout=output_file)
|
||||
# Create a Popen object with stdout redirected to the file
|
||||
process = subprocess.Popen(gstat_command)
|
||||
|
||||
collect_data(minutes)
|
||||
|
||||
# # kill gstat if freebsd
|
||||
# if is_freebsd():
|
||||
# process.terminate()
|
||||
# process.kill()
|
||||
if is_freebsd():
|
||||
process.terminate()
|
||||
process.kill()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("Caught Ctrl-C, cancelling collection...")
|
||||
# kill gstat if freebsd
|
||||
# if is_freebsd():
|
||||
# process.terminate()
|
||||
# process.kill()
|
||||
# exit()
|
||||
if is_freebsd():
|
||||
process.terminate()
|
||||
process.kill()
|
||||
exit()
|
||||
|
||||
# Copy data files to /var/log (replace with appropriate copying function)
|
||||
collect_csv()
|
||||
|
||||
Reference in New Issue
Block a user