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