Ad Widget

Collapse

Extract useful information from a log file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alledm
    Member
    • May 2012
    • 84

    #1

    Extract useful information from a log file

    Hello,

    I am trying to extract (and retain as "item" data) some information that we have stored in log file.

    For example say that a process writes down every run the amount of processed data in a log file

    timestamp: Process (1811) wrote 30894 rows
    [cut]
    timestamp: Process (1854) wrote 45354 rows

    What is the best approach to read those values and import them in the zabbix framework?

    The LOG item type is useful but does not do the trick of actually exporting (through a regexp) the value and importing it in zabbix.

    Can you think of a way? Do you think this would be a nice feature to have?

    Regards
    Alessandro
  • meb5
    Junior Member
    • Jun 2012
    • 1

    #2
    Yes, I think this would be a very helpful feature. A new Item type call "vfs.file.regextract" that would allow you to match on a string and then extract and return only a portion of data from within the line.

    Using your example:
    timestamp: Process (1811) wrote 30894 rows
    timestamp: Process (1854) wrote 45354 rows

    It would be cool if you could create an Item like this:

    vfs.file.regextract[/logs/row-data.log,"wrote (\d+) rows", 1]

    would result in this data:
    1st match: 30894
    2nd match: 45354

    Item definition:

    vfs.file.regextract[<path to file>, <pattern to match>, <number of lines to read>]

    Comment

    Working...