本文整理汇总了Python中WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData.getComponentStatus方法的典型用法代码示例。如果您正苦于以下问题:Python WMAgentDBData.getComponentStatus方法的具体用法?Python WMAgentDBData.getComponentStatus怎么用?Python WMAgentDBData.getComponentStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData
的用法示例。
在下文中一共展示了WMAgentDBData.getComponentStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AgentStatusPoller
# 需要导入模块: from WMComponent.AnalyticsDataCollector.DataCollectAPI import WMAgentDBData [as 别名]
# 或者: from WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData import getComponentStatus [as 别名]
#.........这里部分代码省略.........
return results
def collectCouchDBInfo(self):
couchInfo = {'name': 'CouchServer', 'status': 'ok', 'error_message': ""}
if self.skipReplicationCheck:
# skipping the check this round set if False so it can be checked next round.
self.skipReplicationCheck = False
return couchInfo
for rp in self.replicatorDocs:
cInfo = self.localCouchMonitor.checkCouchServerStatus(rp['source'],
rp['target'], checkUpdateSeq=False)
if cInfo['status'] != 'ok':
couchInfo['status'] = 'error'
couchInfo['error_message'] = cInfo['error_message']
return couchInfo
def collectAgentInfo(self):
"""
Monitors the general health of the agent, as:
1. status of the agent processes
2. status of the agent threads based on the database info
3. couchdb active tasks and its replications
4. check the disk usage
5. check the number of couch processes
:return: a dict with all the info collected
"""
logging.info("Getting agent info ...")
agentInfo = self.wmagentDB.getComponentStatus(self.config)
agentInfo.update(self.agentInfo)
agentInfo['disk_warning'] = listDiskUsageOverThreshold(self.config, updateDB=True)
if isDrainMode(self.config):
logging.info("Agent is in DrainMode")
agentInfo['drain_mode'] = True
agentInfo['drain_stats'] = DrainStatusPoller.getDrainInfo()
else:
agentInfo['drain_mode'] = False
couchInfo = self.collectCouchDBInfo()
if couchInfo['status'] != 'ok':
agentInfo['down_components'].append(couchInfo['name'])
agentInfo['status'] = couchInfo['status']
agentInfo['down_component_detail'].append(couchInfo)
# Couch process warning
couchProc = numberCouchProcess()
logging.info("CouchDB is running with %d processes", couchProc)
couchProcessThreshold = self.config.AnalyticsDataCollector.couchProcessThreshold
if couchProc >= couchProcessThreshold:
agentInfo['couch_process_warning'] = couchProc
else:
agentInfo['couch_process_warning'] = 0
# This adds the last time and message when data was updated to agentInfo
lastDataUpload = DataUploadTime.getInfo()
if lastDataUpload['data_last_update']:
agentInfo['data_last_update'] = lastDataUpload['data_last_update']
if lastDataUpload['data_error']:
agentInfo['data_error'] = lastDataUpload['data_error']
示例2: AgentStatusPoller
# 需要导入模块: from WMComponent.AnalyticsDataCollector.DataCollectAPI import WMAgentDBData [as 别名]
# 或者: from WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData import getComponentStatus [as 别名]
#.........这里部分代码省略.........
"""
try:
logging.info("Getting Agent info ...")
agentInfo = self.collectAgentInfo()
#set the uploadTime - should be the same for all docs
uploadTime = int(time.time())
self.uploadAgentInfoToCentralWMStats(agentInfo, uploadTime)
logging.info("Agent components down:\n %s" % agentInfo['down_components'])
logging.info("Agent in drain mode:\n %s \nsleep for next WMStats alarm updating cycle"
% agentInfo['drain_mode'])
except Exception as ex:
logging.error("Error occurred, will retry later:")
logging.error(str(ex))
logging.error("Trace back: \n%s" % traceback.format_exc())
def collectCouchDBInfo(self):
couchInfo = {'status': 'ok', 'error_message': ""}
if self.skipReplicationCheck:
# skipping the check this round set if False so it can be checked next round.
self.skipReplicationCheck = False
return couchInfo
msg = ""
for rp in self.replicatorDocs:
cInfo = self.localCouchMonitor.checkCouchServerStatus(rp['source'],
rp['target'], checkUpdateSeq = False)
if cInfo['status'] != 'ok':
couchInfo['status'] = 'error'
couchInfo['error_message'] = msg
return couchInfo
def collectAgentInfo(self):
agentInfo = self.wmagentDB.getComponentStatus(self.config)
agentInfo.update(self.agentInfo)
if isDrainMode(self.config):
logging.info("Agent is in DrainMode")
agentInfo['drain_mode'] = True
agentInfo['status'] = "warning"
else:
agentInfo['drain_mode'] = False
couchInfo = self.collectCouchDBInfo()
if (couchInfo['status'] != 'ok'):
agentInfo['down_components'].append("CouchServer")
agentInfo['status'] = couchInfo['status']
couchInfo['name'] = "CouchServer"
agentInfo['down_component_detail'].append(couchInfo)
# Disk space warning
diskUseList = diskUse()
diskUseThreshold = float(self.config.AnalyticsDataCollector.diskUseThreshold)
agentInfo['disk_warning'] = []
for disk in diskUseList:
if float(disk['percent'].strip('%')) >= diskUseThreshold and disk['mounted'] not in self.config.AnalyticsDataCollector.ignoreDisk:
agentInfo['disk_warning'].append(disk)
# Couch process warning
couchProc = numberCouchProcess()
couchProcessThreshold = float(self.config.AnalyticsDataCollector.couchProcessThreshold)
if couchProc >= couchProcessThreshold:
agentInfo['couch_process_warning'] = couchProc
else:
agentInfo['couch_process_warning'] = 0
# This adds the last time and message when data was updated to agentInfo
lastDataUpload = DataUploadTime.getInfo(self)
if lastDataUpload['data_last_update']!=0:
agentInfo['data_last_update'] = lastDataUpload['data_last_update']
if lastDataUpload['data_error']!="":
agentInfo['data_error'] = lastDataUpload['data_error']
# Change status if there is data_error, couch process maxed out or disk full problems.
if agentInfo['status'] == 'ok':
if agentInfo['disk_warning'] != []:
agentInfo['status'] = "warning"
if agentInfo['status'] == 'ok' or agentInfo['status'] == 'warning':
if ('data_error' in agentInfo and agentInfo['data_error'] != 'ok') or \
('couch_process_warning' in agentInfo and agentInfo['couch_process_warning'] != 0):
agentInfo['status'] = "error"
return agentInfo
def uploadAgentInfoToCentralWMStats(self, agentInfo, uploadTime):
#direct data upload to the remote to prevent data conflict when agent is cleaned up and redeployed
agentDocs = convertToAgentCouchDoc(agentInfo, self.config.ACDC, uploadTime)
self.centralWMStatsCouchDB.updateAgentInfo(agentDocs)
示例3: AgentStatusPoller
# 需要导入模块: from WMComponent.AnalyticsDataCollector.DataCollectAPI import WMAgentDBData [as 别名]
# 或者: from WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData import getComponentStatus [as 别名]
#.........这里部分代码省略.........
couchInfo = {
'name': 'CouchServer',
'status': 'ok',
'error_message': ""
}
if self.skipReplicationCheck:
# skipping the check this round set if False so it can be checked next round.
self.skipReplicationCheck = False
return couchInfo
for rp in self.replicatorDocs:
cInfo = self.localCouchMonitor.checkCouchServerStatus(
rp['source'], rp['target'], checkUpdateSeq=False)
if cInfo['status'] != 'ok':
couchInfo['status'] = 'error'
couchInfo['error_message'] = cInfo['error_message']
return couchInfo
def collectAgentInfo(self):
"""
Monitors the general health of the agent, as:
1. status of the agent processes
2. status of the agent threads based on the database info
3. couchdb active tasks and its replications
4. check the disk usage
5. check the number of couch processes
:return: a dict with all the info collected
"""
logging.info("Getting agent info ...")
agentInfo = self.wmagentDB.getComponentStatus(self.config)
agentInfo.update(self.agentInfo)
if isDrainMode(self.config):
logging.info("Agent is in DrainMode")
agentInfo['drain_mode'] = True
else:
agentInfo['drain_mode'] = False
couchInfo = self.collectCouchDBInfo()
if couchInfo['status'] != 'ok':
agentInfo['down_components'].append(couchInfo['name'])
agentInfo['status'] = couchInfo['status']
agentInfo['down_component_detail'].append(couchInfo)
# Disk space warning
diskUseList = diskUse()
diskUseThreshold = float(
self.config.AnalyticsDataCollector.diskUseThreshold)
agentInfo['disk_warning'] = []
for disk in diskUseList:
if float(disk['percent'].strip('%')) >= diskUseThreshold and \
disk['mounted'] not in self.config.AnalyticsDataCollector.ignoreDisk:
agentInfo['disk_warning'].append(disk)
# Couch process warning
couchProc = numberCouchProcess()
logging.info("CouchDB is running with %d processes", couchProc)
couchProcessThreshold = self.config.AnalyticsDataCollector.couchProcessThreshold
if couchProc >= couchProcessThreshold:
agentInfo['couch_process_warning'] = couchProc
else:
agentInfo['couch_process_warning'] = 0
示例4: AgentStatusPoller
# 需要导入模块: from WMComponent.AnalyticsDataCollector.DataCollectAPI import WMAgentDBData [as 别名]
# 或者: from WMComponent.AnalyticsDataCollector.DataCollectAPI.WMAgentDBData import getComponentStatus [as 别名]
#.........这里部分代码省略.........
return results
def collectCouchDBInfo(self):
couchInfo = {'name': 'CouchServer', 'status': 'ok', 'error_message': ""}
if self.skipReplicationCheck:
# skipping the check this round set if False so it can be checked next round.
self.skipReplicationCheck = False
return couchInfo
for rp in self.replicatorDocs:
cInfo = self.localCouchMonitor.checkCouchServerStatus(rp['source'],
rp['target'], checkUpdateSeq=False)
if cInfo['status'] != 'ok':
couchInfo['status'] = 'error'
couchInfo['error_message'] = cInfo['error_message']
return couchInfo
def collectAgentInfo(self):
"""
Monitors the general health of the agent, as:
1. status of the agent processes
2. status of the agent threads based on the database info
3. couchdb active tasks and its replications
4. check the disk usage
5. check the number of couch processes
:return: a dict with all the info collected
"""
logging.info("Getting agent info ...")
agentInfo = self.wmagentDB.getComponentStatus(self.config)
agentInfo.update(self.agentInfo)
agentInfo['disk_warning'] = listDiskUsageOverThreshold(self.config, updateDB=True)
if isDrainMode(self.config):
logging.info("Agent is in DrainMode")
agentInfo['drain_mode'] = True
agentInfo['drain_stats'] = DrainStatusPoller.getDrainInfo()
else:
agentInfo['drain_mode'] = False
couchInfo = self.collectCouchDBInfo()
if couchInfo['status'] != 'ok':
agentInfo['down_components'].append(couchInfo['name'])
agentInfo['status'] = couchInfo['status']
agentInfo['down_component_detail'].append(couchInfo)
# Couch process warning
couchProc = numberCouchProcess()
logging.info("CouchDB is running with %d processes", couchProc)
couchProcessThreshold = self.config.AnalyticsDataCollector.couchProcessThreshold
if couchProc >= couchProcessThreshold:
agentInfo['couch_process_warning'] = couchProc
else:
agentInfo['couch_process_warning'] = 0
# Change status if there is data_error, couch process maxed out or disk full problems.
if agentInfo['status'] == 'ok' and (agentInfo['drain_mode'] or agentInfo['disk_warning']):
agentInfo['status'] = "warning"
if agentInfo['status'] == 'ok' or agentInfo['status'] == 'warning':
if agentInfo.get('data_error', 'ok') != 'ok' or agentInfo.get('couch_process_warning', 0):