def __init__(self, agent, mib, cfg): threading.Thread.__init__(self) self.logger = logging.getLogger('agent.Worker') self._agent = agent self._mib = mib self._cfg = cfg self.setDaemon(True) self.client = QumuloClient(cfg.clusters[0]) # only one cluster for now self.notified_offline = False self.notified_dead_drives = False # Use an array of dictionaries to track per-node PS notify states self.notified_power_supply_failure = \ [{'PS1': False, 'PS2': False} for node in cfg.clusters[0].ipmi.ipmi_servers] # print self.notified_power_supply_failure self.snmp_enabled = cfg.snmp.enabled self.email_enabled = cfg.email.enabled self.ipmi_enabled = cfg.clusters[0].ipmi.enabled if self.email_enabled: self.email_acct = os.getenv('SNMP_AGENT_EMAIL_ACCT') self.email_pwd = os.getenv('SNMP_AGENT_EMAIL_PWD')
import time from config import Config from qumulo_client import QumuloClient if __name__ == '__main__': # see if we can read config f = file('snmp_agent.cfg') cfg = Config(f) client = QumuloClient(cfg.clusters[0]) # only one cluster for now notified_offline = False while True: time.sleep(3) client.get_cluster_state() if len(client.offline_nodes) > 0: notified_offline = True print "There are currently " + str(len( client.offline_nodes)) + " nodes offline:" for n in client.offline_nodes: print "\tNode " + n["node_name"] + " is currently offline." else: if notified_offline == True: notified_offline = False print "All nodes back online."