# Path: amonagent/modules/core.py
# def get_memory_info():
# 
# 	memory_dict = {}
# 	_save_to_dict = ['MemFree', 'MemTotal', 'SwapFree', 'SwapTotal', 'Buffers', 'Cached']
# 
# 	regex = re.compile(r'([0-9]+)')
# 
# 	with open('/proc/meminfo', 'r') as lines:
# 
# 		for line in lines:
# 			values = line.split(':')
# 		
# 			match = re.search(regex, values[1])
# 			if values[0] in _save_to_dict:
# 				memory_dict[values[0].lower()] = int(match.group(0)) / 1024 # Convert to MB
# 
# 		# Unix releases buffers and cached when needed
# 		buffers = memory_dict.get('buffers', 0)
# 		cached = memory_dict.get('cached', 0)
# 
# 		memory_free = memory_dict['memfree']+buffers+cached
# 		memory_used = memory_dict['memtotal']-memory_free
# 		
# 		memory_percent_used = (float(memory_used)/float(memory_dict['memtotal'])*100)
# 		
# 		swap_total = memory_dict.get('swaptotal', 0)
# 		swap_free = memory_dict.get('swapfree', 0)
# 		swap_used = swap_total-swap_free
# 		swap_percent_used = 0
# 		
# 		if swap_total > 0:
# 			swap_percent_used = (float(swap_used)/float(swap_total) * 100)
# 
# 		extracted_data = {
# 			"total_mb": memory_dict["memtotal"],
# 			"free_mb": memory_free,
# 			"used_mb": memory_used,
# 			"used_percent": memory_percent_used,
# 			"swap_total_mb":swap_total,
# 			"swap_free_mb": swap_free,
# 			"swap_used_mb": swap_used,
# 			"swap_used_percent": swap_percent_used
# 		}
# 
# 		# Convert everything to int to avoid float localization problems
# 		for k,v in extracted_data.items():
# 			extracted_data[k] = int(v)
# 	   
# 		return extracted_data


import subprocess
import re
import logging
from amonagent.modules.core import get_memory_info

log = logging.getLogger(__name__)


class ProcessesDataCollector(object):

	def __init__(self):

# Path: amonagent/modules/core.py
# def get_memory_info():
# 
# 	memory_dict = {}
# 	_save_to_dict = ['MemFree', 'MemTotal', 'SwapFree', 'SwapTotal', 'Buffers', 'Cached']
# 
# 	regex = re.compile(r'([0-9]+)')
# 
# 	with open('/proc/meminfo', 'r') as lines:
# 
# 		for line in lines:
# 			values = line.split(':')
# 		
# 			match = re.search(regex, values[1])
# 			if values[0] in _save_to_dict:
# 				memory_dict[values[0].lower()] = int(match.group(0)) / 1024 # Convert to MB
# 
# 		# Unix releases buffers and cached when needed
# 		buffers = memory_dict.get('buffers', 0)
# 		cached = memory_dict.get('cached', 0)
# 
# 		memory_free = memory_dict['memfree']+buffers+cached
# 		memory_used = memory_dict['memtotal']-memory_free
# 		
# 		memory_percent_used = (float(memory_used)/float(memory_dict['memtotal'])*100)
# 		
# 		swap_total = memory_dict.get('swaptotal', 0)
# 		swap_free = memory_dict.get('swapfree', 0)
# 		swap_used = swap_total-swap_free
# 		swap_percent_used = 0
# 		
# 		if swap_total > 0:
# 			swap_percent_used = (float(swap_used)/float(swap_total) * 100)
# 
# 		extracted_data = {
# 			"total_mb": memory_dict["memtotal"],
# 			"free_mb": memory_free,
# 			"used_mb": memory_used,
# 			"used_percent": memory_percent_used,
# 			"swap_total_mb":swap_total,
# 			"swap_free_mb": swap_free,
# 			"swap_used_mb": swap_used,
# 			"swap_used_percent": swap_percent_used
# 		}
# 
# 		# Convert everything to int to avoid float localization problems
# 		for k,v in extracted_data.items():
# 			extracted_data[k] = int(v)
# 	   
# 		return extracted_data


# Path: amonagent/modules/processes.py
import subprocess
import re
import logging
from amonagent.modules.core import get_memory_info


log = logging.getLogger(__name__)


class ProcessesDataCollector(object):

	def __init__(self):

		memory = get_memory_info()