| Home | Docs | Support | Buy | Blog | Forums |
|
Show the % usage in a filesytem threshold?Ever needed the need to see the %usage of a filesystem threshold event? This is possible using an event mapping. Okay let's hit it. navigate to the web interface to: Classes => Events > Perf > Filesystem
http://YOUR-ZENOSS:8080/zport/dmd/Events/Perf/Filesystem/editEventClassTransform
This brings you to a event transform rule. It is will be called when an event comes in for /Perf/Filesystem. Now add this to the rule box:
import re
fs_id = device.prepId(evt.component)
for f in device.os.filesystems():
if f.id != fs_id: continue
# Extract the percent and free from the summary
m = re.search("threshold of [^:]+: current value ([\d\.]+)", evt.summary)
if not m: continue
usedBlocks = float(m.groups()[0])
p = (usedBlocks / f.totalBlocks) * 100
freeAmtGB = ((f.totalBlocks - usedBlocks) * f.blockSize) / 1073741824
# Make a nicer summary
evt.summary = "Disk space low: %3.1f%% used (%3.2f GB free)" % (p,freeAmtGB)
# This is where we change to a per device threshold
perDeviceThreshold = 95.0
m = re.search("zz(\d{3})", f.id)
perDeviceThreshold = m and float(m.groups()[0]) or 95.0
if p >= perDeviceThreshold: evt.severity = 5
break
6-oct-2008 UPDATE: Chet pointed me to a problem which happens with remote collecters. He sended me an updated script so please use the once in this page. It should also be more performant
|
