def collectMetrics(self): #获取当前集群的状态 metrics = self.getMetrics() meRecord = metricsRecord(self.recordTime); recordKey=["appsCompleted","appsPending","appsRunning", "appsFailed","appsKilled","totalMB","allocatedMB", "containersAllocated","containersReserved", "containersPending","totalNodes","activeNodes"] print metrics for key in recordKey: print metrics['clusterMetrics'][key] meRecord.set(key,metrics['clusterMetrics'][key]) session = database.getSession() session.merge(meRecord) session.commit()
def collectMetrics(self): #获取当前集群的状态 metrics = self.getMetrics() meRecord = metricsRecord(self.recordTime) recordKey = [ "appsCompleted", "appsPending", "appsRunning", "appsFailed", "appsKilled", "totalMB", "allocatedMB", "containersAllocated", "containersReserved", "containersPending", "totalNodes", "activeNodes" ] print metrics for key in recordKey: print metrics['clusterMetrics'][key] meRecord.set(key, metrics['clusterMetrics'][key]) session = database.getSession() session.merge(meRecord) session.commit()
def collectMetrics(self): #获取当前集群的状态 metrics = self.getMetrics() #recordTime指向上个10分钟的开头时间,所以要往后移动一个10分钟 meRecord = metricsRecord(self.recordTime + config.collect_interval) recordKey = [ "appsCompleted", "appsPending", "appsRunning", "appsFailed", "appsKilled", "totalMB", "availableMB", "allocatedMB", "containersAllocated", "totalNodes", "activeNodes" ] #totalMB=availableMB+allocatedMB temp = metrics['clusterMetrics'] temp["totalMB"] = int(temp["availableMB"]) + int(temp["allocatedMB"]) for key in recordKey: meRecord.set(key, temp[key]) session = database.getSession() session.merge(meRecord) session.commit()
def collectMetrics(self): #获取当前集群的状态 metrics = self.getMetrics() #recordTime指向上个10分钟的开头时间,所以要往后移动一个10分钟 meRecord = metricsRecord(self.recordTime+config.collect_interval); recordKey=["appsCompleted","appsPending","appsRunning", "appsFailed","appsKilled", "totalMB","availableMB", "allocatedMB","containersAllocated", "totalNodes","activeNodes"] #totalMB=availableMB+allocatedMB temp = metrics['clusterMetrics']; temp["totalMB"] = int(temp["availableMB"]) + int (temp["allocatedMB"]) for key in recordKey: meRecord.set(key,temp[key]) session = database.getSession() session.merge(meRecord) session.commit()