def listDiskUsageOverThreshold(config, updateDB): """ check whether disk usage is over threshold, return list of disk paths if updateDB is True update the aux couch db value. This function contains both check an update to avoide multiple db calls. """ defaultDiskThreshold = 85 defaultIgnoredDisks = [] if hasattr(config, "Tier0Feeder"): # get the value from config. ignoredDisks = getattr(config.AgentStatusWatcher, "ignoreDisks", defaultIgnoredDisks) diskUseThreshold = getattr(config.AgentStatusWatcher, "diskUseThreshold", defaultDiskThreshold) t0Flag = True else: reqMgrAux = ReqMgrAux(config.General.ReqMgr2ServiceURL) agentConfig = reqMgrAux.getWMAgentConfig(config.Agent.hostName) diskUseThreshold = agentConfig.get("DiskUseThreshold", defaultDiskThreshold) ignoredDisks = agentConfig.get("IgnoreDisks", defaultIgnoredDisks) t0Flag = False # Disk space warning diskUseList = diskUse() overThresholdDisks = [] for disk in diskUseList: if (float(disk['percent'].strip('%')) >= diskUseThreshold and disk['mounted'] not in ignoredDisks): overThresholdDisks.append(disk) if updateDB and not t0Flag: agentDrainMode = bool(len(overThresholdDisks)) if agentConfig and (agentDrainMode != agentConfig["AgentDrainMode"]): reqMgrAux.updateAgentConfig(config.Agent.hostName, "AgentDrainMode", agentDrainMode) return overThresholdDisks
def testDiskUse(self): """ Test the `diskUse` function. """ data = diskUse() # assuming nodes will always have at least 3 partitions/mount points self.assertTrue(len(data) > 2)
def listDiskUsageOverThreshold(config, updateDB): """ check whether disk usage is over threshold, return list of disk paths if updateDB is True update the aux couch db value. This function contains both check an update to avoide multiple db calls. """ reqMgrAux = ReqMgrAux(config.TaskArchiver.ReqMgr2ServiceURL) agentConfig = reqMgrAux.getWMAgentConfig(config.Agent.hostName) diskUseThreshold = agentConfig["DiskUseThreshold"] ignoredDisks = agentConfig["IgnoreDisks"] # Disk space warning diskUseList = diskUse() overThresholdDisks = [] for disk in diskUseList: if (float(disk['percent'].strip('%')) >= diskUseThreshold and disk['mounted'] not in ignoredDisks): overThresholdDisks.append(disk) if updateDB: agentDrainMode = bool(len(overThresholdDisks)) if agentDrainMode != agentConfig["AgentDrainMode"]: reqMgrAux.updateAgentDrainingMode(config.Agent.hostName, agentDrainMode) return overThresholdDisks
def listDiskUsageOverThreshold(config, updateDB): """ check whether disk usage is over threshold, return list of disk paths if updateDB is True update the aux couch db value. This function contains both check an update to avoide multiple db calls. """ defaultDiskThreshold = 85 defaultIgnoredDisks = [] if hasattr(config, "Tier0Feeder"): # get the value from config. ignoredDisks = getattr(config.AgentStatusWatcher, "ignoreDisks", defaultIgnoredDisks) diskUseThreshold = getattr(config.AgentStatusWatcher, "diskUseThreshold", defaultDiskThreshold) t0Flag = True else: reqMgrAux = ReqMgrAux(config.General.ReqMgr2ServiceURL) agentConfig = reqMgrAux.getWMAgentConfig(config.Agent.hostName) diskUseThreshold = agentConfig.get("DiskUseThreshold", defaultDiskThreshold) ignoredDisks = agentConfig.get("IgnoreDisks", defaultIgnoredDisks) t0Flag = False # Disk space warning diskUseList = diskUse() overThresholdDisks = [] for disk in diskUseList: if (float(disk['percent'].strip('%')) >= diskUseThreshold and disk['mounted'] not in ignoredDisks): overThresholdDisks.append(disk) if updateDB and not t0Flag: agentDrainMode = bool(len(overThresholdDisks)) if agentConfig and (agentDrainMode != agentConfig["AgentDrainMode"]): reqMgrAux.updateWMAgentConfig(config.Agent.hostName, {"AgentDrainMode": agentDrainMode}, inPlace=True) return overThresholdDisks
def listDiskUsageOverThreshold(config, updateDB): """ check whether disk usage is over threshold, return list of disk paths if updateDB is True update the aux couch db value. This function contains both check an update to avoide multiple db calls. """ if hasattr(config, "Tier0Feeder"): ignoredDisks = [] diskUseThreshold = 85 # get the value from config. if hasattr(config.AgentStatusWatcher, "ignoreDisks"): ignoredDisks = config.AgentStatusWatcher.ignoreDisks if hasattr(config.AgentStatusWatcher, "diskUseThreshold"): diskUseThreshold = config.AgentStatusWatcher.diskUseThreshold t0Flag = True else: reqMgrAux = ReqMgrAux(config.TaskArchiver.ReqMgr2ServiceURL) agentConfig = reqMgrAux.getWMAgentConfig(config.Agent.hostName) diskUseThreshold = agentConfig["DiskUseThreshold"] ignoredDisks = agentConfig["IgnoreDisks"] t0Flag = False # Disk space warning diskUseList = diskUse() overThresholdDisks = [] for disk in diskUseList: if (float(disk['percent'].strip('%')) >= diskUseThreshold and disk['mounted'] not in ignoredDisks): overThresholdDisks.append(disk) if updateDB and not t0Flag: agentDrainMode = bool(len(overThresholdDisks)) if agentDrainMode != agentConfig["AgentDrainMode"]: reqMgrAux.updateAgentDrainingMode(config.Agent.hostName, agentDrainMode) return overThresholdDisks