View Full Version : Quicky: is it possible to use vars in keys?
Justleen
16-02-2010, 07:52
Can I create keys with variables in them?
something like hostname in the following:
jmx[user:impl-class-name=com.domain.application.jmx.Statistics,name=St atistics,server=$HOST][L1CacheMissCounter]
short version - yes. a bit longer version - yes, depending on what you want.
see http://www.zabbix.com/documentation/1.8/manual/config/macros or http://www.zabbix.com/documentation/1.8/manual/config/macros#global_and_host_level_macros
Justleen
16-02-2010, 11:12
Ehm, is there any more documentation om macros for zabbix 1.8?
Im trying to create one on the host, but I keep getting errors..
" * Wrong macro : instance001"
Or should I add something like {$MACRO} -> instance001 on the host config?
was the linked one insufficient ? what _exactly_ are you trying to do when you get the error message ?
Justleen
16-02-2010, 11:38
was the linked one insufficient ? what _exactly_ are you trying to do when you get the error message ?
Well, yes, since it doenst explain how to use the macros, it only mentions them.
I did manage to get it working.
Went to a Host, added a macro there
{$MACRO} -> instance001
in my key I use this ${MACRO}, and working as expected..
Leaves me one question: are the macro names pre-defined, as per the links you posted, or are the names arbitrary, and could I have used something like {$THISISAMACROFORINSTANCEONE} too?
hmm, docs might indeed be confusing at some places. there are two different tings.
1. predefined, hardcoded macros. these are listed in the first table, and their syntax is {MACRO};
2. user definable macros. there currently are no predefined macros, and their names can be freely set by the user.
these macros can be configured either on a global, template or host level, with downstream definitions overriding upstream ones. these have syntax of {$MACRO} - note the placement of the dollar sign !
so ${MACRO} highly likely use the built-in macro and ignore your custom one.
Justleen
16-02-2010, 11:46
Just tested some arbitrary names, and yes, that works.
Seems 'm sorted again! thnx for the quick response!