Disk thresholding exclusions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Disk thresholding exclusions

(private) HKS
I found a few questions in the mailing list archives on this, but no
clear answers. Hopefully this won't end up being one of those.

I'd like to write a threshold that only trips on hrStorageDescr fields
that begin with '/' and aren't '/dev' or '/proc'.'. The first half is
easy:
<resource-filter field="hrStorageDescr">^/$</resource-filter>

But I'm unclear on the second. In Perl I can do this with a negative
lookahead assertion:
^/(?!dev|proc)

But I don't believe GNU Regexes support this. Can anybody give me a
pointer on this? Many of my servers have different mount schemes
depending on their role, so I'd prefer to stay away from the "define
every partition I want to check" route.

Thanks for the help.

-HKS

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Disk thresholding exclusions

Jeff Gehlbach
On Aug 29, 2008, at 1:42 PM, (private) HKS wrote:

> But I'm unclear on the second. In Perl I can do this with a negative
> lookahead assertion:
> ^/(?!dev|proc)
>
> But I don't believe GNU Regexes support this.

What's a GNU Regex?

openNMS uses the classes from the java.util.regex package.  The syntax  
includes much that is borrowed from Perl, and is documented here:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html

That document mentions negative lookahead, so I think that will work  
here.  If it does, please let me know -- although I consider my own  
regex-fu reasonably strong, I'd never heard of negative lookahead.

-jeff

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Disk thresholding exclusions

(private) HKS
> What's a GNU Regex?

Java implements the GNU regex package, as opposed to Perl which has
its own regex engine. GNU emulates much of Perl's style (as well as
awk, sed, emacs, etc), but isn't Perl.


> openNMS uses the classes from the java.util.regex package.  The syntax
> includes much that is borrowed from Perl, and is documented here:
>
> http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
>
> That document mentions negative lookahead, so I think that will work
> here.  If it does, please let me know -- although I consider my own
> regex-fu reasonably strong, I'd never heard of negative lookahead.


Great, I should have searched for Java-specific regex information
rather than GNU regex info. Thanks for the link. The negative
lookahead works perfectly.

In a nutshell, zero-width look_____ assertions look at the characters
ahead/behind and try to match them to the expression in the assertion.
Once they've decided it does or doesn't, they continue on from the
original character. Since I don't have the programming knowledge to
explain it with appropriate language, examples will make this much
easier:

This regex contains a positive lookahead assertion:
^/(?=dev|usr|bin)

This would match:
/dev
/usr/local
/bin/

It would not match:
/tmp
/var
/etc
/mnt/usr

To illustrate the zero-width part, change it to this:
^/(?=dev|usr|bin)$

This would never find a match. Why? Because you're looking for a /
that's followed by dev, usr, or bin, AND followed by the end of the
string. The two are incompatible.

So, here's why my filter rules look like (using a negative lookahaed assertion):
  <resource-filter
field="hrStorageDescr">^/(?!dev|proc|usr/compat/linux/proc)</resource-filter>
  <resource-filter field="hrStorageDescr">^\w\:</resource-filter>

My testing looks good so far. Hopefully this will help someone else in
a similar situation.

-HKS

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-discuss mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-discuss