Ad Widget

Collapse

Extract value from log file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tsalle
    Member
    Zabbix Certified Specialist
    • Oct 2012
    • 79

    #1

    Extract value from log file

    Hi !

    I want to extract value from a log file, and then create trigger based on last value time.
    My log file looks like :
    Code:
    * RECEPTION OK ** Fichier D:\path\to\file reçu de PARTENAIRE, idf=IDFILE nbr enr=422   , le 201311127 à 133515 
    * ENVOI OK ** Fichier D:\path\to\file2 envoyé vers PARTERNAIRE2, idf=IDFILE2 nbr enr=20    , le 20131129 à 103443
    Is it possible to auto create item to graph the "nbr enr".
    for example :
    key = IDFILE type uint and fetch the value 422
    key = IDFILE2 type uint and fetch the value 20

    I have created a log item
    log[C:\path\to\file.log, "idf=(.*) nbr enr=",,,,\1]
    And i can get all the id file, but not the "nbr enr" value corresponding.

    After that, i want to create trigger to alert when I don't receive or send a file for more than 24h hours (86400 seconds).
    my expression should be like :
    {hostname:log[C:\path\to\file.log,"idf=(.*) nbr enr=",,,,\1].str(IDFILE).fuzzytime(86400)}
    but it doesn't work.

    I see a comment on this article that say it may be possible ti create calculated items based on output of log items.
    In the previous article in 2.2 series we explored a new ability to extract values from a webpage. This was not the only feature that was extended this way – several other items gained similar functionality – notably, file content parsing and logfile parsing. The latter has been a popular feature request and should be good […]


    Any suggestion appreciated..

    Thanks,

    Thierry.
  • tsalle
    Member
    Zabbix Certified Specialist
    • Oct 2012
    • 79

    #2
    Update : I've successed extracting my value from the log file

    I've created as many log item as i have IDFILE (~80) using the API.
    My log items keys are like :
    Code:
    log[C:\path\to\log\file.log,"idf=MYIDFILE nbr enr=([0-9]+)",,,,\1]
    And i can get the history of "nbr enr" values for each IDFILE. (but can't graph it).

    After i have created triggers like :
    Code:
    {myhostname:log[C:\path\to\log\file.log,"idf=MYIDFILE nbr enr=([0-9]+)",,,,\1].nodata(86400)}=1
    for each IDFILE.

    I know it a very heavy / ugly solution, but it's the only one i found to solve my problem.

    I have a question :
    What's the difference between "skip" and "all" mode ?
    in "all" mode, does the zabbix agent parse the whole log file at each mesure ?

    Maybe i should use the "skip" mode to avoid disk IO ?

    Comment

    Working...