提供zabbix-trapper数据的bash脚本 :
-
#!/bin/bash
-
####Remote Get RM2000 Data####
-
declare -A INFO
-
INFO=([FJ-CTC-RM99101]=192.168.99.101 [FJ-CTC-RM99102]=192.168.99.102)
-
terminal=/opt/geo/RM2000/script/dqsh.out
-
file=/usr/local/zabbix-proxy/ret/RM2000Data
-
OPTION=(RM2000[recvhttp] RM2000[recvradius] RM2000[gdracs] RM2000[gdrradius] RM2000[hwport])
-
UinxTimeStamp=$(date -d "$(date "+%F %H:%M")" +%s)
-
PostLog="/usr/local/zabbix-proxy/ret/postlog"
-
timeout=/usr/bin/timeout
-
-
-
server=192.168.9.12
-
-
-
COMMAND() {
-
case $2 in
-
"RM2000[recvhttp]")
-
${timeout} 7 ${terminal} -h ${1} stream.show \
-
|awk 'BEGIN{FS="[ :M)]+"}/recvhttp/{print $(NF-2)*1000*1000}'
-
;;
-
"RM2000[recvradius]")
-
${timeout} 7 ${terminal} -h ${1} stream.show \
-
|awk 'BEGIN{FS="[ p]+"}/recvradius/{print $(NF-1)}'
-
;;
-
"RM2000[gdracs]")
-
${timeout} 7 ${terminal} -h ${1} gdr.show \
-
|awk 'BEGIN{FS="[ M]+"}/acs/{print $(NF-2)*1000*1000'}
-
;;
-
"RM2000[gdrradius]")
-
${timeout} 7 ${terminal} -h ${1} gdr.show \
-
| awk 'BEGIN{FS="[ p]+"}/radius/{print $(NF-1)}'
-
;;
-
"RM2000[hwport]")
-
${timeout} 7 ${terminal} -h ${1} hwport.show \
-
| awk '/Total/{print $(NF-1)*1000*1000}'
-
;;
-
esac
-
-
}
-
/bin/rm -fr ${file}
-
for hosts in FJ-CTC-RM99101 FJ-CTC-RM99102
-
do
-
for((i=0;i<${#OPTION[@]};i++))
-
do
-
Middle=$(COMMAND ${INFO[${hosts}]} ${OPTION[${i}]})
-
ret=${Middle:-0}
-
key=$(echo ${OPTION[${i}]})
-
echo "${hosts}" "${key}" "${UinxTimeStamp}" "${ret}" >> ${file}
-
done
-
done
-
sleep 2
-
echo >> ${PostLog}
-
date "+%F %H:%M" >> ${PostLog}
-
/usr/local/zabbix-proxy/bin/zabbix_sender -z ${server} -p 10051 -i ${file} -T -vv &>> ${PostLog}
阅读(1340) | 评论(0) | 转发(0) |