Esempio n. 1
0
 def __initMem():
     '''
     Author      : LHearen
     E-mail      : [email protected]
     Time        : 2016-01-12 15:37
     Description : get the static total, used and free amount of memory and
                 it utilization and store them in db;
     '''
     ret = executeShellScripts("../shells/current_ram.sh")[0]
     print ret
     ret = json.loads(ret)
     total = int(ret["total"])
     used = int(ret["used"])
     free = int(ret["free"])
     dataDict = {"mem.total": str(total)+"M", "mem.used": str(used)+"M",
                 "mem.free": str(free)+"M"}
     ret = HostHelper.update({"_id":1}, dataDict)
     print ret
Esempio n. 2
0
 def __initCpu():
     '''
     Author      : LHearen
     E-mail      : [email protected]
     Time        : 2016-01-12 15:36
     Description : get all the static cpu profile and store it in db;
     '''
     ret = executeShellScripts("../shells/cpu_info.sh")
     ret = ret[0]
     # turn string to a dictionary
     ret = json.loads(ret)
     arch = ret["Architecture"].strip()
     byteOrder = ret["Byte Order"].strip()
     numberOfCpus = ret["CPU(s)"].strip()
     name = ret["Model name"].strip()
     ret = executeShellCommand("cat /proc/version")
     version = ret[0].strip()
     dataDict = {"cpu.Architecture": arch, "cpu.ByteOrder": byteOrder,
                 "cpu.cpus": numberOfCpus, "cpu.Model": name,
                 "cpu.version": version}
     ret = HostHelper.update({"_id": 1}, dataDict)
     print ret