From ed4d3c3d1a5973ed90a022de1ea83d4fd692091a Mon Sep 17 00:00:00 2001 From: Marc Mance Date: Mon, 17 Jun 2024 14:28:11 -0400 Subject: [PATCH] corrected filename error in zpool iostat --- zpooliostat.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zpooliostat.py b/zpooliostat.py index 8d93143..619ccf9 100644 --- a/zpooliostat.py +++ b/zpooliostat.py @@ -36,14 +36,6 @@ def runZpoolIostat(): # Check the return code (0 for success) if result.returncode == 0: - # Check if the file exists - if not os.path.exists(filename): - # Create the file in write mode ('w') if it doesn't exist - with open(filename, "w", newline="") as csvfile: - csv_writer = csv.writer(csvfile) - # Write the header row (optional) - csv_writer.writerow(headerRow) - # Access the captured output as a string output = result.stdout @@ -81,6 +73,14 @@ def runZpoolIostat(): poolname = lineData[0] filename = poolname + "-zio.csv" + # Check if the file exists + if not os.path.exists(filename): + # Create the file in write mode ('w') if it doesn't exist + with open(filename, "w", newline="") as csvfile: + csv_writer = csv.writer(csvfile) + # Write the header row (optional) + csv_writer.writerow(headerRow) + # Now open the file in append mode ('a') with open(filename, "a", newline="") as csvfile: csv_writer = csv.writer(csvfile)