import string, os.path, time

class MalwareMonitor:
    '''
    Class for Malware Monitoring based on ClamAV
    '''
    malware = {'detected':0, 'last_scan':"-"}

	def __init__(self):
        self.server = '150.162.63.32'
	
    def get_malware_info(self):	
		pattern = "Infected files:"
		
		#defined in clamd.conf variable LogFile
		log_path = "/var/log/clamav/clamav.log" 
		
		f = open(log_path, 'r')
		lines = f.readlines()
		
		count = 0		
		last_scan = time.ctime(os.path.getmtime(log_path))
		
		for line in lines:
			split_line = line.split(pattern)
			if len(split_line) == 2:
				count = split_line[1]
			
		self.malware['detected'] = count
		self.malware['last_scan'] = last_scan
		
        return self.malware

if __name__=="__main__":
    malwareMon = MalwareMonitor()
    print malwareMon.get_malware_info()
