Hi peeps,
I have a python script that runs every 15minutes, it checks if two computers on my network is online, if neither is on, it shutdown FreeNAS. Works perfectly. I want to improve the script so that it checks if a scrub is running, because I dont want it to shutdown in this instance. Is there a command I can use to check if scrub is currently running?
Here is my script:
I have a python script that runs every 15minutes, it checks if two computers on my network is online, if neither is on, it shutdown FreeNAS. Works perfectly. I want to improve the script so that it checks if a scrub is running, because I dont want it to shutdown in this instance. Is there a command I can use to check if scrub is currently running?
Here is my script:
Code:
#!/usr/bin/env python from subprocess import Popen, PIPE import os, sys ip_list = [] ###### IP addresses ##### # IP addresses go underneath this line, one on each line in the format: ip_list.append('x.x.x.x') ip_list.append('192.168.1.200') ip_list.append('192.168.1.50') ###### End IP addresses shutdown = True for ip in ip_list: cmd = ['/sbin/ping', '-s 0', '-W 1', '-q', '-n' , '-c 1', ip] p1 = Popen(cmd, stdout=PIPE, stderr=PIPE) p1.wait() statusText = p1.communicate()[0].split('\n')[3].strip() if statusText.find(', 0.0% packet loss') > 0: shutdown = False if shutdown: cmd = ['/sbin/shutdown', '-p', 'now'] p1 = Popen(cmd)