Menu

#14 regex help please

open
nobody
None
5
2004-10-21
2004-10-21
Anonymous
No

I need a bit of regex help for LOAD please.

The standard output from nagios on LOAD is :

OK - load average: 0.06, 0.06, 0.07

How do I extract those 3 values separately ?

TIA

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I have managed to pull the first 2 as such :

    "output:load1:/([0-9.]+)/" "output:load5:/, ([0-9.]+)/"
    "output:load15:/, ([0-9.]+)/"

    but that 3rd one just matches the second one.

    Any help appreciated.

     
  • Nobody/Anonymous

    Logged In: NO

    I would also as for some help on the following one:

    OUTPUT="NTP OK: Offset -0.000033 secs, jitter 0.201 msec,
    peer is stratum 3"

    OUTPUT="NTP OK: Offset 0.000020 secs, jitter 0.070 msec,
    peer is stratum 3"

    Sometimes the offset is negative, but the following does not
    pic it up:

    "output:offset:/Offset ([0-9.]+) secs/"

    How can I include negative numbers ?

    And, once this is solved, can these regexp be added as
    examples in the .conf ?

     
  • Nobody/Anonymous

    Logged In: NO

    I would also as for some help on the following one:

    OUTPUT="NTP OK: Offset -0.000033 secs, jitter 0.201 msec,
    peer is stratum 3"

    OUTPUT="NTP OK: Offset 0.000020 secs, jitter 0.070 msec,
    peer is stratum 3"

    Sometimes the offset is negative, but the following does not
    pic it up:

    "output:offset:/Offset ([0-9.]+) secs/"

    How can I include negative numbers ?

    And, once this is solved, can these regexp be added as
    examples in the .conf ?

     
  • Nobody/Anonymous

    Logged In: NO

    It took me a while, but here is the answer if any one is
    interested:

    ValueRegexTemplate ntp_offset_jitter
    "output:offset:/Offset (-[0-9.]+)/" "output:jitter:/jitter
    ([0-9.]+) msec/

    ValueRegexTemplate load
    "output:load1:/([0-9.]+)/" "output:load5:/, ([0-9.]+),/"
    "output:load15:/, ([0-9.]+)$/"

    The formatting might be bad ... in here, but this works for me.

     
  • Regis Rampnoux

    Regis Rampnoux - 2004-10-29

    Logged In: YES
    user_id=13623

    Look at the first reply:
    For load5 he uses two comma because it is enclosed beetwen
    them /, ([0-9.]+),/
    and for the last the $ which means 'end of line'.
    You use the same regex for the load15 than for the load5, it
    is the result, of course ;-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.