On Jan 16, 2009, at 3:21 PM, coyote wrote:
> Because a majority of our systems can have a standard threshold I
> ended up using the below as a transform, I got most of the code from
> another post I found within this forum. The reason the 105% is
> there because we have seen admins remove mounts or change mounts
> around and it caused event that report 300% used. Also, I if
> someone can point out why the evt.summary in the > 105 does not
> work. Sorry, I am not a python coder.
>
> 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])
> per_used = (usedBlocks / f.totalBlocks) * 100
>
> freeAmtPer = 100-per_used
>
> # Make a nicer summary
> evt.summary = "Disk space low: %3.1f%% used (%3.2f%% free)" %
> (per_used,freeAmtPer)
>
> if per_used > 105 and evt.severity == 5:
> evt.severity = 3
> evt.summary = "There was a problem checking a filesystem, %3.1%
> % was returned as being used" % (per_used)
> elif per_used >= 100 and evt.severity == 5:
> evt.severity = 5
> elif per_used >= 98 and per_used < 100 and evt.severity == 4:
> evt.severity = 4
> elif per_used >= 90 and per_used < 98 and evt.severity == 3:
> evt.severity = 3
> else:
> evt._action="drop"
> break
This is definitely the way to accomplish what you want. The > 105
summary is just missing a designation that the %3.1 is a float.
evt.summary = "There was a problem checking a filesystem, %3.1f%% was
returned as being used" % per_used
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users