PDA

View Full Version : custom items syntax: arguments


Zabbixazzer
13-07-2006, 15:11
Talking about zabbix 1.1 (and so referring to 1.1 syntax), it is possible to put custom intems into zabbix_agentd.conf, for example:

UserParameter=mysql.ping,mysqladmin -uroot ping|grep alive|wc -l
UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
UserParameter=mysql.threads,mysqladmin -uroot status|cut -f3 -d":"|cut -f1 -d"Q"
UserParameter=mysql.questions,mysqladmin -uroot status|cut -f4 -d":"|cut -f1 -d"S"
UserParameter=mysql.slowqueries,mysqladmin -uroot status|cut -f5 -d":"|cut -f1 -d"O"
UserParameter=mysql.qps,mysqladmin -uroot status|cut -f9 -d":"
UserParameter=mysql.version,mysql -V

If I want to create a custom item that accepts arguments, how can I do?

If I write something like this:
UserParameter=mycommand ,
then after the comma goes the shell command, in that command how can I refer to the item's argument? Can I write something like this:
UserParameter=mycommand ,shellcommand $1
where $1 refers to mycommand[] argument?

Or maybe just isn't possible to use arguments?

stever
13-07-2006, 21:00
You are correct across the board... Here's an example form my config:

UserParameter=usr.net.in ,netstat -v -I $1 | grep -v Name | head -1 | awk "{print $ 5}"

and to use it:

usr.net.in[bge1]

Zabbixazzer
14-07-2006, 16:01
Thank you!!

It works!!

:)

SebD
30-07-2007, 18:40
Hello,

I've got a problem with argument in an item.

Here is how I write my check :

In the item configuration : reboot.check[apache]

In the zabbix_agentd.conf :
UserParameter=reboot.check ,/opt/zabbix/rebootSvce $1

And when I redirect this argument (in the script) to a text file, I can see that the argument is empty!

When I try my script directly in bash, it's ok!

Any idea?

Thanks!

Sébastien

SebD
31-07-2007, 10:17
Hello,

It's running, I've modified zabbix_agentd.conf :
UserParameter=reboot.check ,/opt/zabbix/rebootSvce "$1"

$1 must be in ""

Sébastien