6

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.

R. Rahul
  • 1,166
  • 3
  • 16
  • 40
Kevin Korb
  • 135
  • 1
  • 10
  • Did you get any solution for your problem. I am also struggling to create a graph from my log file monitored data. Everything is working fine, showing data in history, firing triggers and actions. But when i am adding the same item in a graph, no data is displayed. Some people even told me that you can create a new orabbix template for monitoring your log file with zabbix. But i dont have any clue. Can you please share your solution. Thanks a lot. – R. Rahul Nov 17 '11 at 09:07
  • I am much cleared with templates now....nothing can be done with that.....please help me in creating graph from log file monitored data – R. Rahul Nov 23 '11 at 17:56

3 Answers3

2

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.

Algirdas
  • 677
  • 1
  • 6
  • 15
  • This didn't work. I changed the log file like this: log["/var/log/nginx/access.log",HTTP] and it said: Not support. Accessible only as active check – The One Sep 15 '17 at 02:26
  • `Accessible only as active check` is kinda different configuration problem, try some suggestions from [here](https://www.zabbix.com/forum/showthread.php?t=11023) (like setting host name in zabbix file, etc) – Algirdas Sep 16 '17 at 07:20
0

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]

user3132194
  • 2,381
  • 23
  • 17
0

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:\test.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

R. Rahul
  • 1,166
  • 3
  • 16
  • 40
  • I noticed that you used the log file in C drive which is of Windows. What about Linux log? Same script is OK? @echo off or /F %%x in ('findstr /r /n "ERROR" var/log/nginx/access.log ^| find /var/log/nginx ":"') do echo %%x – The One Sep 15 '17 at 02:19