0

Let's say a storage is monitored with zabbix through an agent. We want that when the storage fails for zabbix to email us with the error description, produced by some script. Is it possible for zabbix to get string output(ala nagios) and report it (not just string monitoring and report found/notfound) or does reporting only work with integers?

sivann
  • 2,083
  • 4
  • 29
  • 44

2 Answers2

2

Doing string or text regex checks with Zabbix is very easy. You can do this with a simple command line check that will echo an error or an "ok" message.

For example, you want to check the log for "drive failure" and have it email, I would do something like this as the "key" in Zabbix.

system.run[grep 'drive failure' /var/log/message || echo 'okay']

Set the check to "text" and it will either report a grepped match or an okay message. You can then use a regular expression in the alarm to send out an email for anything that doesn't match "OK", for example:

{your_template:system.run[grep 'drive failure' /var/log/message || echo 'OK'].regexp(OK)}#1

This will alarm if it receives a text line of anything other than "OK".

There are a couple of constraints when working with text in Zabbix. The first is that Zabbix only reports the first line. The second is that the check must always return text, either an okay message or an error. If you check comes up empty Zabbix will think it's broken.

Stephen Wood
  • 1,257
  • 1
  • 12
  • 13
1

You can create a text or log item, that contains the text of the error, and create a trigger with this item, that checks, for example, for the word "error" or some value. Create an action for that trigger and to include the value of the item in the notification, use the {ITEM.LASTVALUE} macro.

Here's a list of macros you can use in notifications http://www.zabbix.com/documentation/2.0/manual/appendix/macros/supported_by_location.

v-star
  • 126
  • 2