corrected filename error in zpool iostat

This commit is contained in:
Marc Mance
2024-06-17 14:28:11 -04:00
parent b1b3886845
commit ed4d3c3d1a

View File

@@ -36,14 +36,6 @@ def runZpoolIostat():
# Check the return code (0 for success) # Check the return code (0 for success)
if result.returncode == 0: 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 # Access the captured output as a string
output = result.stdout output = result.stdout
@@ -81,6 +73,14 @@ def runZpoolIostat():
poolname = lineData[0] poolname = lineData[0]
filename = poolname + "-zio.csv" 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') # Now open the file in append mode ('a')
with open(filename, "a", newline="") as csvfile: with open(filename, "a", newline="") as csvfile:
csv_writer = csv.writer(csvfile) csv_writer = csv.writer(csvfile)