#!/bin/bashZABBIX_SENDER="/usr/local/sbin/zabbix_sender"ZABBIX_TRAPPER="localhost"ZABBIX_TRAPPER_PORT=10051ZABBIX_ITEM_KEY_PREFIX="memcached_"ZABBIX_HOST="Memcached"MEMCACHED_SERVER="localhost"MEMCACHED_SERVER_PORT=11211STATS=`(sleep 1 ; echo "stats"; sleep 1; echo "quit") | telnet $MEMCACHED_SERVER $MEMCACHED_SERVER_PORT`STAT //' | sed -e 's/ /:/g' | sed -e 's/:STAT:/\n/g')doOLD_IFS="$IFS"IFS=":"KEY_VALUE=($i)IFS="$OLD_IFS"ITEM_KEY=$ZABBIX_ITEM_KEY_PREFIX${KEY_VALUE[0]}echo $ITEM_KEY:${KEY_VALUE[1]}$ZABBIX_SENDER --zabbix-server $ZABBIX_TRAPPER --port $ZABBIX_TRAPPER_PORT --host $ZABBIX_HOST --key $ITEM_KEY --value ${KEY_VALUE[1]}done
Save it to a file and schedule it with CronD. You will also have to add the Memcached template to all your memcached hosts.
No comments:
Post a Comment