From d6c062b73d0aa778b325acf32140edead6cb72db Mon Sep 17 00:00:00 2001 From: Marc Mance Date: Fri, 2 Aug 2024 16:35:59 -0400 Subject: [PATCH] added gstat.err to Popen --- collect.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/collect.py b/collect.py index 8193e90..3bcaa9f 100644 --- a/collect.py +++ b/collect.py @@ -385,10 +385,6 @@ def welcome(): print("") -def is_two_digit_number(number): - return 10 <= number < 100 - - def main(): welcome() @@ -446,9 +442,14 @@ def main(): "15s", ] - 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) + gstatData = open("gstat.csv", "a") + gstatError = open("gstat.err", "a") + + # with as output_file: + # # Create a Popen object with stdout redirected to the file + process = subprocess.Popen( + gstat_command, stdout=gstatData, stderr=gstatError + ) collect_data(minutes) @@ -456,6 +457,8 @@ def main(): if is_freebsd(): process.terminate() process.kill() + gstatData.close() + gstatError.close() except KeyboardInterrupt: print("Caught Ctrl-C, cancelling collection...") @@ -463,6 +466,9 @@ def main(): if is_freebsd(): process.terminate() process.kill() + gstatData.close() + gstatError.close() + exit() # Copy data files to /var/log (replace with appropriate copying function)