Difference between revisions of "Transforms - Nice Memory Events"

From Zenoss Wiki
Jump to: navigation, search
m
m (Put not on which Event Class to sue)
 
Line 1: Line 1:
 
This provides a nice percentage utilization with raw amount free.
 
This provides a nice percentage utilization with raw amount free.
  
 +
Event Class: Perf > Memory
 
<syntaxhighlight lang=python>
 
<syntaxhighlight lang=python>
 
# Converts memory events into percentage with raw values
 
# Converts memory events into percentage with raw values

Latest revision as of 17:39, 6 May 2014

This provides a nice percentage utilization with raw amount free.

Event Class: Perf > Memory

# Converts memory events into percentage with raw values
import time, re, logging
 
match = re.search('threshold of .*(swap|memory).* (exceeded|restored|not met): current value ([\d\.]+)', evt.message, re.I)
if match and device:
    available = float(match.groups()[2])
    total = device.hw.totalMemory
    evt.component = "Memory"
    if match.groups()[0].lower() == "swap":
        total = device.os.totalSwap
        evt.component = "Swap"
    evt.memoryavailable = available
    evt.total = total
    if total:
        percent_free = (available / total) * 100
        percent_used = ((total - available) / total) * 100
        evt.summary = "High Memory Utilization: Currently %3.0f%% used (%3.0f%% free)" % (percent_used, percent_free)
        evt.message = evt.summary
    else:
        evt.summary = 'High Memory Utilization: Currently: %s' %(convToUnits(available))
        evt.message = evt.summary
 
sum=evt.summary
if (sum.find("cbsModuleFreePageAvailableNorm") >= 0):
  sum=re.sub ("cbsModuleFreePageAvailableNorm", "cbsModuleFreePageAvailableHigh", sum)
  evt.summary=sum
  evt.message = evt.summary
  evt._action="history"