Graphs

Andreas Ericsson ae at op5.se
Tue Oct 26 14:37:49 CEST 2004


martinus.nel at scarceskills.com wrote:
> Andreas,
> 
> I have spent a day or two reading up on regexp, playing with some of the
> on-line sites that you can test expressions out on and such.  It's not that
> I am completely new to it, it's just that with nagiostat not everything
> makes sense to me.
> 
> The basics I believe I understand.  There is something else I think I am
> missing here.
> 
> Let's take the following example:
> 
> This is from the nagiostat debug.log file ...
> 
> OUTPUT="NTP OK: Offset 0.000312 secs, jitter 0.055 msec, peer is stratum 3"
> 
> Now, in my nagiostat.conf I have:
> 
> ... "output:offset:/-?([0-9.]+)/" "output:jitter:/jitter ([0-9.]+) msec/"
> 
> As it is there ^^, this is what happens:
> 
>  +VALUE: 0.000492
>  +VALUE: 0.157
> 
> So far, so fine... Now I change the regexp to read "Offset -?([0-9.]+)", and
> still it only pulls the number (a good thing for me, I only want the number
> - but that is not how I was understanding things.  The same for the jitter
> part, why does nagiostat only pull the numbers ?).
>  
> But now, ntp offset is not always positive, that is why I added '-?', so, I
> get a line that reads:
> 
> OUTPUT="NTP OK: Offset -0.000509 secs, jitter 0.157 msec, peer is stratum 3"
> 
> And my regexp is ^^, the output:
> 
>  +VALUE: 0.000509
>  +VALUE: 0.157
> 
> What happened to '-' ?  I want to insert a negative value into RRD, so this
> is wrong for me.
> 

Parentheses create back-references. Include the minus (without the 
question mark) inside the parentheses and it will be output (I think. I 
haven't tried the regex engine of nagiostat).

> In that regex coach, I clich on the "split" tab, and what do I see ... it
> only picks the numbers.
> 
> Is this how nagiostat work, "split" ?
> What is "split" ?
> and how do I get negative values ?
> 
> All help much appreciated :-)
> 
> Martinus.
> p.s.
> 
> Tedman, thank you for that regex-coach :-)
> 
> 
> Andreas Ericsson <ae at op5.se> wrote: 
> 
>>martinus.nel at scarceskills.com wrote:
>>
>>>Michael,
>>>
>>>Since you are successful with it, may we lesser beings view some of your
>>>templates, especially the regexp ones ? :)
>>>
>>>Just in case someone here thinks that I am desperate ... yes I am, I
>>
>>just
>>
>>>can't seem to get the hang of the regular expressions :-)
>>>
>>
>>It's really pretty straightforward, so long as you remember a couple of 
>>simple rules;
>>[abc] denotes a character class and matches any of the characters a, b or
>>c.
>>* means 'match any or none of the previous character (class)'
>>. means 'match any char'.
>>There are others as well, but those are the ones that doesn't require 
>>odd escaping. Fling around with grep and sed a bit and I'm sure you'll 
>>get the idea. For instance, try;
>>grep '.*foo.*'
>>and then type a lot of gibberish. The lines you type with 'foo' 
>>somewhere in them will match and be printed twice.
>>
>>Regex matching with substitutions works the same way, but it has 
>>delimiters at the beginning, the end and between the match and the 
>>substitution. The delimiter can be any char, but / and , and # and | are 
>>commonly seen in shell-scripts.
>>thus
>>sed 's/foo/bar/'
>>(gibberish goes here)
>>will replace (the leading s in the sed command means substitute) foo 
>>with bar in any text you type.
>>
>>Fool around a bit. It's the best way to learn, and you'll learn more as 
>>you go along. Should all else fail, pick up a book on perl. It's main 
>>feature is just that, regexing, so they're bound to be covered in detail.
>>
>>-- 
>>Andreas Ericsson                   andreas.ericsson at op5.se
>>OP5 AB                             www.op5.se
>>Lead Developer
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
>>Use IT products in your business? Tell us what you think of them. Give us
>>Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
>>more
>>http://productguide.itmanagersjournal.com/guidepromo.tmpl
>>_______________________________________________
>>Nagios-users mailing list
>>Nagios-users at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/nagios-users
>>::: Please include Nagios version, plugin version (-v) and OS when
>>reporting any issue. 
>>::: Messages without supporting info will risk being sent to /dev/null
>>
> 
> --
> ---------------------------------------------------------------------------
> DISCLAIMER
> This e-mail message and any attachments are confidential and may also be a
> privileged communication. It is intended solely for the person(s) to whom
> it is addressed. If you are not the intended addressee of the message you
> must take no action based on it. Please reply to this message to let us
> know you received it in error and also delete the message from your system.
> Internet e-mails are not necessarily secure and you should be mindful of
> this when e-mailing us.
> 
> The contents of an attachment to this e-mail may contain software viruses
> which could damage your own computer system. Whilst we have taken every
> reasonable precaution to minimise this risk, we cannot accept liability for
> any damage which you sustain as a result of software viruses. You should
> carry out your own virus checks before opening the attachment.
> ---------------------------------------------------------------------------
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> Use IT products in your business? Tell us what you think of them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
> ::: Messages without supporting info will risk being sent to /dev/null
> 

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list