added check for scrubbing pool

This commit is contained in:
Marc Mance
2025-04-03 18:52:13 -04:00
parent 93b25ac90b
commit b07c9e7f90

View File

@@ -40,6 +40,44 @@ def runCollect(command):
return result.stderr return result.stderr
def isPoolScrubbing():
command="zpool status"
grep_string = "scrub.in.progress"
try:
process = subprocess.Popen(
command,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True, # Important for returning strings rather than bytes
)
stdout, stderr = process.communicate()
if process.returncode == 0: # Command executed successfully
if grep_string in stdout:
print("WARNING: Pool is SCRUBBING")
return True
else:
print("Checked for Pool Scrubbing; Good to Go...")
return False
else:
# Command failed. Print stderr for debugging.
print(f"Error executing command: {command}")
print(stderr) #Print the error that the command returned.
exit()
except FileNotFoundError:
print(f"Command not found: {command}")
exit()
except Exception as e:
print(f"An error occurred: {e}")
exit()
def coreIostat_disk(): def coreIostat_disk():
command = ["iostat", "-xd", "-t", "da", "1", "1"] command = ["iostat", "-xd", "-t", "da", "1", "1"]
filename = "ioStat.csv" filename = "ioStat.csv"
@@ -411,6 +449,7 @@ def welcome():
def main(): def main():
welcome() welcome()
isPoolScrubbing()
logging.basicConfig( logging.basicConfig(
filename="perf.log", filename="perf.log",
@@ -436,7 +475,7 @@ def main():
try: try:
if not minutes: if not minutes:
minutes = int(input("Enter the duration in minutes: ")) minutes = int(input("Enter the duration in minutes (1440 for 24hrs):"))
minutesToWait = int(input("Enter the delay before capture in minutes: ")) minutesToWait = int(input("Enter the delay before capture in minutes: "))
if not minutesToWait: if not minutesToWait: