amuck-landowner

Zabbix Series 2: Trappers

splitice

Just a little bit crazy...
Verified Provider
Part 3 (in case you havent figured it out by now there is no particular order to my ramblings). I will probably bug a mod to rename these into order when I am done.

What are trappers?

Instead of asking the agent for the values defined on the server side, the monitored location can decide what items to send and on what interval.

This can be useful where there are many items receiving updates at different intervals or to feed the output from one command into multiple items on the server.

This doesn't make sense, do you have an example?

Sure. This script will send all the MySQL status variables (its a WIP so might be non functioning).


#!/bin/bash
echo "show global status" | mysql -N -uroot -pMYSQL_PASSWORD | awk -F'\t' '{ printf("- "); printf("mysql.status[\"%s\"]",$1); printf(" \"%s\"",$2); print ""; }' | zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -i - | grep sent | awk '{ print $2 }' | sed 's/;$//'
echo "show variables" | mysql -N -pMYSQL_PASSWORD | awk -F'\t' '{ printf("- "); printf("mysql.var[\"%s\"]",$1); printf(" \"%s\"",$2); print ""; }' | zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -vv -i -

This script uses zabbix_sender to send the values for all mysql variables and status variables to the monitoring server, it is then possible to create items to receive this data and triggers to act upon it. Additional data that does not have a matching key will be discarded.

This script should be run on a cron, or even via a system.run item (or UserParameter). In which case you can also monitor its status.

Create items you say... how?

Create an item of type "Zabbix trapper", the key should exactly match the data sent from the trapper. Here is an example below of an item matching the output of this script.

58sM1.png
 

tchen

New Member
One thing I never really understood is why bother using the zabbix_sender trapper if you could setup an active item check with userparameters?
 

splitice

Just a little bit crazy...
Verified Provider
"This can be useful where there are many items receiving updates at different intervals or to feed the output from one command into multiple items on the server."

You definitely do not want to connect to mysql, execute SHOW GLOBAL STATUS and extract the 80 odd MySQL status variables I am currently extracting. The performance of that would be horrible, completely overloading the server you are monitoring.

You can also vary the interval in which you send results and easily integrate it into other scripts (e.g if an application provides the ability to run an external script on a certain event).
 
Top
amuck-landowner