If you have a lot of servers then you probably want to have your templates a bit more dynamic. There are probably also some cases where a certain value in your template is not fit for just one server in your park. For this, we can make use of macros in our templates.
For this recipe to work, we need a Zabbix server and a Zabbix host. We also need to make sure that we have a SSH session active on port 22 on our host as we will monitor the SSH service on our host. For this, we will make use of macros. We also need to make use of the super administrator account in Zabbix.
{$SSH_PORT}
and give it the value 422
or something other than 22
. It must be a port that is not in use by SSH.Template SSH port
.Check SSH port $3
.Simple check
.net.tcp.service[ssh,,{$SSH_PORT}]
Numeric
.Decimal
.ssh check
.{$SSH_PORT}
with value 22
.In the Administration panel under General | Macros, we can define global macros. Those global macros can be used in our templates. So by defining {$SSH_PORT}
macro in our item to monitor the SSH port, we were telling our template to look to the global macro. This means that our template would always check, in this case, port 422
. Because we defined a new macro on our host with the value 22
, that specific macro was over written for only this particular host. So in our case the template would always look for a service on port 422
, but only for our host it would look for a service on port 22
.