moved gstat command to a redirect

This commit is contained in:
Marc Mance
2024-08-02 14:57:35 -04:00
parent 7df502be8c
commit b5908618e2

View File

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