def run(self): try: utc_time = self.get_now_utc_time() usage_rate = Host.get_cpu_rate() event = { "time": utc_time, "host": self.hostname, "type": "cpu", "type_instance": "usage_rate", "value": usage_rate } self.octopusd.sendMessage(self.paramter['output'], event) loadavg = Host.get_load_stat() event = { "time": utc_time, "host": self.hostname, "type": "cpu", "type_instance": "lavg_1", "value": loadavg['lavg_1'] } self.octopusd.sendMessage(self.paramter['output'], event) except Exception, ex: print ex
def loadavg(): try: hostUtil = HostUtil() message = hostUtil.get_load_stat() except Exception, e: message = "error get cpu loadavg, Ex:%s" % (str(e)) return Response.make_json_response(message, success=False, code=-1)