Ejemplo n.º 1
0
 def collect_mem_info(self, priority=2):
     ts = str(int(time.time()))
     if priority == CONS_COLLECT_FOR["CONTINUOUS"] or priority == CONS_COLLECT_FOR["BOOTH"]:
         meminfo = self.get_mem_info()
         self.write_key("os.mem_info.physical_total", fixfloat(kbytes2bytes(meminfo.memtotal)), ts)
         self.write_key("os.mem_info.physical_usage",
                        fixfloat(kbytes2bytes(long(meminfo.memtotal) - long(meminfo.memfree))), ts)
         self.write_key("os.mem_info.physical_free", fixfloat(kbytes2bytes(meminfo.memfree)), ts)
         self.write_key("os.mem_info.vm_cached", fixfloat(kbytes2bytes(meminfo.cached)), ts)
         self.write_key("os.mem_info.vm_buffers", fixfloat(kbytes2bytes(meminfo.buffers)), ts)
         self.write_key("os.mem_info.vm_swap_total", fixfloat(kbytes2bytes(meminfo.swaptotal)), ts)
         self.write_key("os.mem_info.vm_swap_free", fixfloat(kbytes2bytes(meminfo.swapfree)), ts)
         self.write_key("os.mem_info.vm_swap_usage",
                        fixfloat(kbytes2bytes(long(meminfo.swaptotal) - long(meminfo.swapfree))), ts)
Ejemplo n.º 2
0
    def get_mysql_mem_usage(self):
        my_dic = {}
        os_get = OS(None)
        mysql_usage = self.__my_conn.mysql_memory_usage()
        meminfo = os_get.get_mem_info()
        try:
            ram = long(kbytes2bytes(meminfo.memtotal)) # bytes
            if ram < mysql_usage:
                ram = CONS_RAM_SERVER # 128 GB Ram
        except:
            ram = CONS_RAM_SERVER # 128 GB Ram

        my_dic['mysql_usage'] = fixfloat(round(mysql_usage, 2))  #bytes
        my_dic['usage_ram_free_size'] = fixfloat(round(ram - mysql_usage, 2))
        my_dic['usagem_ram_percent'] = round(mysql_usage * 100 / ram, 2)
        return convert_dict_to_object(dict_key2lower(my_dic))
Ejemplo n.º 3
0
            if pid_file != None and pid == None:
                command = "cat %s" % pid_file
                result = os.popen(command).read()
                for line in result.split():
                    pass
                pid = line
        except Exception, e:
            log.debug("Error on get pid by pid_file: %s - %s" % (pid_file, e))
            pass

        #pid = 2200
        command = "cat /proc/%s/status" % pid
        result = os.popen(command).read()
        for line in result.split('\n'):
            if "VmPeak:" in line:
                status['vmpeak'] = kbytes2bytes(line.strip().split()[1])
            if "VmSize:" in line:
                status['vmsize'] = kbytes2bytes(line.strip().split()[1])
            if "VmLck" in line:
                status['vmlck'] = kbytes2bytes(line.strip().split()[1])
            if "VmHWM:" in line:
                status['vmhwm'] = kbytes2bytes(line.strip().split()[1])
            if "VmRSS:" in line:
                status['vmrss'] = kbytes2bytes(line.strip().split()[1])
            if "VmData:" in line:
                status['vmdata:'] = kbytes2bytes(line.strip().split()[1])
            if "VmStk:" in line:
                status['vmstk'] = kbytes2bytes(line.strip().split()[1])
            if "VmExe:" in line:
                status['vmexe'] = kbytes2bytes(line.strip().split()[1])
            if "VmLib:" in line: