zabbix灵活使用userparameters

zabbixversion:3.2.8

userparameters介绍

官网文献:https://www.zabbix.com/documentation/2.0/manual/config/items/userparameters

当我们需要检查的项目不在zabbix预定义的模板中的时候,我们需要用到userparameters来实现我们想要监控的目标。

基本用法:

UserParameter=<key>,<command>
key针对要监控的host必须是唯一的
User Parameter被zabbix agent执行,最多仅返回512KB的数据
command会在/bin/sh下执行

例子:
UserParameter=ping,echo 1
UserParameter=mysql.ping,mysqladmin -uroot ping|grep -c alive

灵活使用:
UserParameter=key[*],command

上文翻译的意识是:key[]中的内容是来自web页面定义item时传输过来的变量,command后面可以接$1,...,$9最多九个变量,这些变量的来源和key[]中的变量一一对应

例子:

UserParameter=mysql.ping[*],mysqladmin -u$1 -p$2 ping | grep -c alive

This parameter can be used for monitoring availability of MySQL database. We can pass user name and password:

mysql.ping[zabbix,our_password]

原文地址:https://www.cnblogs.com/janehoo/p/7661236.html