Ad Widget

Collapse

regular expressions at log monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dephil
    Junior Member
    • Mar 2010
    • 4

    #1

    regular expressions at log monitoring

    Hi guys,

    I need to monitor some logs from a meassurement software with Zabbix 1.6.7 (upgrade to new version will be next month). A log-file (/var/test.txt) looks like this:
    entry1: 123
    entry2: 456
    entry3: 789
    ...

    This file always have the same entries but the values changes everytime the log-file is updated. I need to get the value of every entry.

    I created an item in Zabbix with the key log[/var/test.txt,"entry1:"] which generates an output of "entry1: 123" (exactly like it is written in the log). Zabbix returns the right entry from the log but the output should only contain "123" without the leading "entry1: " string. I tried to add a regex in the key but I can't find the right regex for my problem.
    I tried many many regex with egrep under linux without any success. I do not know much about regex at all, so it's quite possible that I'm doing it completely wrong

    example (doesn't work):
    egrep 'entry1:[[:space:]][[:digit:]]' /var/test.txt

    I also tried the ( ) and \1 which doesn't work, too.
    egrep 'entry1[[:space:]][([:digit:])\1]' /var/test.txt


    Can someone help me? That would be great!

    Thanks!!!
  • trikke
    Senior Member
    • Aug 2007
    • 140

    #2
    Hi dephil,

    as far as i know, your logfile item will always return the whole string found in your file. So the output will be entryd: ddd (with d being a digit) no matter what your regexp looks like!
    I guess u are looking for a trigger that compares the output to some threshold?
    In that case u could try one of those:

    regexp(entry1: [1][0-5][0-9]) = 1 --> could mean all entries with values 100 through 159 or stuff like that.

    hope i could help u with this,

    greets
    Patrick

    Comment

    Working...