import re
perDevicePattern = re.compile(r'zz(\d{3})')
fs_id = device.prepId(evt.component)
for f in device.os.filesystems():
if f.id != fs_id: continue
p = (float(f.usedBytes()) / f.totalBytes()) * 100
freeAmtGB = (float(f.totalBytes() - f.usedBytes())) / 1024 / 1024 / 1024
# Regardless of severity, this will be the message
evt.summary = "Disk space low: %3.1f%% used (%3.2f GB free)" % (p,freeAmtGB)
# Set a default for critical @ 95%
perDeviceThreshold = 95.0
# This is where we change to a per device threshold
if perDevicePattern.search(f.id):
perDeviceThreshold = float(perDevicePattern.search(f.id).groups()[0])
if p >= perDeviceThreshold: evt.severity = 5
break
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
Actually, the code posted by Chet is likely more what people want.
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
breakHi,
Where this event transform script is supposed to go? I tried to create EventClass mapping to /Perf/Filesystem (EventClassKey: 'usedBlocks_usedBlocks|high disk usage') but the events don't match the mapping. I think that the mapping is not executed because when filesystem performance template threshold it defines the eventclass /Perf/FileSystem.
You should put the transform in the existing /Perf/Filesystem event class.
--
James Pulver
Information Technology Area Supervisor
LEPP Computer Group
Cornell University
kwikman wrote, On 10/9/2009 8:49 AM:
Hi,
Where this event transform script is supposed to go? I tried to create EventClass mapping to /Perf/Filesystem (EventClassKey: 'usedBlocks_usedBlocks|high disk usage') but the events don't match the mapping. I think that the mapping is not executed because when filesystem performance template threshold it defines the eventclass /Perf/FileSystem.
>
Hi James,
I've done that, but what I should put into the mapping's 'Event Class Key'? Threshold generated events do not have eventClassKey value.
What eventclasskey? You aren't creating a new mapping. Go to
/Perf/Filesystem, click the dropdown, More, Transform.
--
James Pulver
Information Technology Area Supervisor
LEPP Computer Group
Cornell University
kwikman wrote, On 10/9/2009 8:59 AM:
Hi James,
I''ve done that, but what I should put into the mapping's 'Event Class Key'? Threshold generated events do not have eventClassKey value.
>
Hi again,
Now I got it working. I did not realize that there was transform selection for all events of the EventClass. Thanks for help.
|
Follow Us On Twitter »
|
Latest from the Zenoss Blog » |
|
Community | Products | Industries Customers | Services Partners | About Us | |
|
|
|
Copyright © 2005-2010 Zenoss, Inc.
|
||||||