标签:src tcp script 指定端口 for config img 配置 etc
官方有模板示例,根据官方更改连接如下
https://zabbix.org/wiki/File:ZabbixTemplate_-_TCP_service_discovery.xml
root #cat tcp-port.conf
http,80
tomcat,8080
mq,1883
discovery_tcp_service.sh
#/bin/bash
CONFIG_FILE=/etc/zabbix/script/tcp-port.conf
portarray=(`cat ${CONFIG_FILE}|awk -F ‘,‘ ‘{print $1","$2}‘`)
PortDiscovery(){
length=${#portarray[@]}
printf "{\n"
printf ‘\t‘"\"data\":["
for ((i=0;i<$length;i++))
do
Name=`echo ${portarray[$i]}|awk -F‘,‘ ‘{print $1}‘`
Port=`echo ${portarray[$i]}|awk -F‘,‘ ‘{print $2}‘`
printf ‘\n\t\t{‘
printf ‘"{#NAME}":"%s", "{#PORT}":"%s"}‘ "$Name" "$Port"
if [ $i -lt $[$length-1] ];then
printf ‘,‘
fi
done
printf "\n\t]\n"
printf "}\n"
}
port(){
PortDiscovery
}
port
创建模板
自动发现
创建Item
创建触发器
标签:src tcp script 指定端口 for config img 配置 etc
原文地址:https://blog.51cto.com/foxhound/2487259