English 中文(简体)
How do I create a graph in Zabbix with a calucated field based on the count of log entries?
原标题:

I have an item setup to monitor fatal errors, and I want to add another item so that it calculates the count of the fatal errors and graphs them.

Using this key: log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100]

It properly gets the data that I m wanting, however it will not graph this, I imagine I have to count the entries and get the format as an integer, but this does not work:

count(log["/d2/httpd/logs/myDomain-error_log","PHP Fatal","UTF-8",100], 60)

Any ideas of what my key should be, or how I would go about graphing this data to see over time how many errors there were?

Actions and triggers are working fine and doing what is supposed but unable to create graph out of it.

问题回答

What worked for me:

Create item for parsing some string in log.

  • Key log["C:/Logs/log.log",ERROR].
  • Type Zabbix agent (active)
  • Type of information Log.

This item should show all the lines from log with specified string "ERROR".

Second, create calculated item with escaped quotation marks:

  • Key my.special.app.error.count
  • Type Calculated
  • Formula count("log["C:/Logs/log.log",ERROR]", 60)

This would count how many times "ERROR" was repeated in log during 60 seconds.

Now this item can be graphed, triggered, etc.

I m not really sure why parsing item is required, but without it this calculated item does not work.

Here are the steps for monitoring log file through Zabbix.

1) Create a batch file eg.

//test.bat

@echo off

or /F %%x in ( findstr /r /n "ERROR" C: est.log ^| find /C ":" ) do echo %%x

2) Replace the “test.log” with your log file

3) Do the below changes in Zabbix_agentd.config file

EnableRemoteCommands=1

DisableActive=0

UnsafeUserParameters=1

UserParameter=key.in.zabbix.frontend,c:/temp/test.bat

4) C:/temp/test.bat is the path of batch file

5) Create a Item in Zabbix GUI with following detail

Key= key.in.zabbix.frontend // This is any name but the name in GUI and abbix_agentd.config file must be same.

Type=Zabbix_Agent or Zabbix_Agent(Active)

Type of Information= Numeric(Unsigned)

Rest all are same.

6) Restart the Zabbix agent. And check in Monitoring->Latest Value.

7) For testing we can check the output on server also by command

Go to root->zabbix 1.8.6->src->zabbix_get

This will count matches of regular expression @NginxNotOK in new log records since last check in file with name, defined in macro {$NGINX_ACCESS_LOG_FILE}:

log.count[{$NGINX_ACCESS_LOG_FILE},@NginxNotOK,,,skip]





相关问题
Checking the status of my PHP beanstalkd background processes

I have a website written in PHP (CakePHP) where certain resource intensive tasks are handled by a background process. This is done through the Beanstalkd message queue. I need some way to retrieve the ...

Process monitoring

Is there an application that is capable of monitoring AND logging information (to file) about another process (in particular IIS aspnet_wp.exe) like (in periods of time): - memory usage of process - ...

Jamon statistics aggregation across multiple JVMs

I have a tomcat server running a webapp. Apart from this there are two other JVMs that run batch processing tasks. Jamon is a really cool way to monitor performance, hits etc., and can be viewed on ...

How to tell the graphic card memory usage?

My application seems to be slow, but in terms of CPU and RAM, it seems that it is OK. So, I want to know how much memory of the graphic card I am using. I ve seen some questions about this on SO, but ...

multiple services with same self-signed certificate

I ve got a WCF intranet application I m working on that will have 150 clients controlled/monitored by a control application. Is it kosher to create a self-signed certificate and install this same ...

热门标签