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)