I've combined some transforms that are already available from the ZenOss community. I have made it compatible for my own ZenOss 5.1.2, because the transform is written in such a way that both Linux and Windows are targeted.
Also I changed the folder where the transform should hit and I added a section for my Synology
You must add this piece of code on a specific location in order to let it work.
Also don't forget to change line 4, 11, 18 and 25 accordingly to match your own DeviceClasses, otherwise it won't work.
Go to Events > Event Classes, open on the left in the tree-view perf and CPU.
1. After this select in the dropdown box for transform and past afterwards the code beneath for CPU transform.
2. Do the same for the memory transform, but in this case under perf and memory.
Don't forget to save after pasted one transform. It cannot save both at the same time, you must do this after each change.
The nice CPU transform
# Converts Linux and Windows CPU to a percentage. This is assuming ssCpuIdle is being used for the Linux threshold import re regex = re.search('threshold of .*(CPU).* (exceeded|restored|not met): current value ([\d\.]+)', evt.message, re.I) if regex and device and device.getDeviceClassPath().startswith("/Server/SSH/Linux"): lincpu = re.search("current value ([\d\.]+)", evt.summary) if lincpu: currentcpu = 100 - float(lincpu.group(1)) evt.component = "CPU" evt.summary = "High CPU Utilization: Currently %3.0f%%" % (currentcpu) evt.message = evt.summary if regex and device and device.getDeviceClassPath().startswith("/Server/Synology"): lincpu = re.search("current value ([\d\.]+)", evt.summary) if lincpu: currentcpu = 100 - float(lincpu.group(1)) evt.component = "CPU" evt.summary = "High CPU Utilization: Currently %3.0f%%" % (currentcpu) evt.message = evt.summary if regex and device and device.getDeviceClassPath().startswith("/Server/Linux"): lincpu = re.search("current value ([\d\.]+)", evt.summary) if lincpu: currentcpu = 100 - float(lincpu.group(1)) evt.component = "CPU" evt.summary = "High CPU Utilization: Currently %3.0f%%" % (currentcpu) evt.message = evt.summary if regex and device and device.getDeviceClassPath().startswith("/Server/Microsoft/Windows"): wincpu = re.search("current value ([\d\.]+)", evt.summary) if wincpu: currentcpu = float(wincpu.group(1)) evt.component = "CPU" evt.summary = "High CPU Utilization: Currently %3.0f%%" % (currentcpu) evt.message = evt.summary
After pasting this, the transform will look like this:
The nice memory transform
# 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 total_gb = (float(device.hw.totalMemory) / 1048576) if total: percent_free = (available / total) * 100 percent_used = ((total - available) / total) * 100 evt.summary = "High Memory Utilization: Currently %3.0f%% used of %3.1fMB (%3.0f%% free)" % (percent_used, total_gb, 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
The memory transform will look like this: