import time, re, logging match = re.search('threshold of .*(swap|ESXHost Memory Utilization Error|ESXHost Memory Utilization Warning).* (exceeded|restored|not met): current value ([\d\.]+)', evt.message, re.I) if match and device and component: consumed = float(match.groups()[2]) total = component.totalMemory / 1024 evt.memoryavailable = total - consumed evt.total = total if total: percent_consumed = (consumed / total) * 100 percent_free = ((total - consumed) / total) * 100 evt.summary = "High Memory Utilization: Currently %3.0f%% used (%3.0f%% free)" % (percent_consumed, percent_free) evt.message = evt.summary else: evt.summary = 'High Memory Utilization: Currently: %s' %(convToUnits(consumed)) evt.message = evt.summary