added check for scrubbing pool
This commit is contained in:
43
collect.py
43
collect.py
@@ -40,6 +40,44 @@ def runCollect(command):
|
||||
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():
|
||||
command = ["iostat", "-xd", "-t", "da", "1", "1"]
|
||||
filename = "ioStat.csv"
|
||||
@@ -411,7 +449,8 @@ def welcome():
|
||||
|
||||
def main():
|
||||
welcome()
|
||||
|
||||
isPoolScrubbing()
|
||||
|
||||
logging.basicConfig(
|
||||
filename="perf.log",
|
||||
level=logging.DEBUG,
|
||||
@@ -436,7 +475,7 @@ def main():
|
||||
|
||||
try:
|
||||
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: "))
|
||||
|
||||
if not minutesToWait:
|
||||
|
||||
Reference in New Issue
Block a user