Ad Widget

Collapse

Can Zabbix log/logrt items return more than one line at a time from a logfile?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krzysztofmajewski
    Junior Member
    • May 2014
    • 6

    #1

    Can Zabbix log/logrt items return more than one line at a time from a logfile?

    I posted this same question last week under the title "problem sending ITEM.LASTVALUE to remote command". This title is actually misleading, so I am re-posting the question with a more appropriate title.

    ---------------------------------------------------------------------------

    Hi,

    I am running Zabbix 2.2.3 on CentOS 6.3. The problem I want to solve is as follows.

    First, I want to monitor a logfile for errors by matching the string "ERROR". (This part I am able to do successfully). A typical match looks like this:

    2014-05-21 19:16:01.424 [ExtractScheduler_Worker-14-XYZ.XYZ_CR_TICKET_STG] [ERROR] [com.acme.foomatic.etl.cdc.extract.ExtractJob]
    Exception occured:

    java.lang.Exception: Failure in process execution for :[/opt/acme/foomatic/v2.1/etl/magictool/magictool.sh, --config, /opt/acme/foomatic/v2.1/etl/cdc/extract/config/tts/tts-crt--out.xml, --log, /data/acme/foomatic/v2.1/data_pending/XYZ_CR_TICKET_STG.2014-05-21--19-15-00-002.sts, XYZ_CR_TICKET_STG]
    at com.acme.foomatic.etl.cdc.extract.ExtractJob.execu te(ExtractJob.java:195)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:2 13)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run (SimpleThreadPool.java:557)

    Now, for each error of this form, I want to look into the corresponding .sts file, (e.g. /data/acme/foomatic/v2.1/data_pending/XYZ_CR_TICKET_STG.2014-05-21--19-15-00-002.sts above) and perform different actions depending on the contents of that file. For example, if the .sts file contains a connection timeout error, send a notification email.

    Question 1: What is the recommended way of solving this problem with
    Zabbix?

    Here's what I've tried so far.

    I've configured an Action which runs a remote command whenever there is a
    new entry in the logfile matching the string "ERROR". For now, the
    remote command simply echoes its arguments to a tmp file. In the
    Action configuration, I have this in the Commands textbox:

    /opt/acme/foomatic/v2.1/monitoring/multiline-test.sh {ITEM.LASTVALUE}

    Consider the example error (Java stack trace) above. I force this
    error to appear in the monitored logfile. I then check my tmp file,
    and I see only this:

    2014-05-21 19:16:01.424 [ExtractScheduler_Worker-14-XYZ.XYZ_CR_TICKET_STG] [ERROR] [com.acme.foomatic.etl.cdc.extract.ExtractJob]

    In other words, {ITEM.LASTVALUE} only contains the first line of the
    error. This is no good for my purpose, since the name of the .sts file
    only appears on the 4th line.

    If I look in the mysql database used by Zabbix, in the table
    history_log I again see only the first line in the "value"
    column. It looks to me like Zabbix is only storing one line of context from
    the error in the log.

    Question 2: Is there any way to recover more than one line from a
    logfile?
Working...