Created
August 3, 2016 09:54
-
-
Save julcap/268a4338594038fc79674d60139ad4ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The purpose of this script is to help push monitoring information gathered using other scripts to all zabbix servers | |
# example of usage script | |
# ****** | |
# send="/etc/zabbix/zabbix_sender.sh" | |
# value=$(/script/to/fetch/value.py) | |
# if [ -z "$value" ];then value=Null;fi | |
# $send {zabbix.key} $value 2>&1 >/dev/null | |
# ******* | |
#!/bin/bash | |
#required args: | |
# $1=item key | |
# $2=item key value | |
sender=/usr/bin/zabbix_sender | |
cfg=/etc/zabbix/zabbix_agentd.conf | |
hostname=$(cat ${cfg} | egrep '^[[:space:]]*Hostname=' | cut -d= -f2) | |
test "z${hostname}" == "z" && hostname=`hostname -s` | |
sport=10051 | |
servers=`grep -im1 ^ServerActive= ${cfg} | cut -f2 -d= | sed 's/,/ /g'` | |
#sendvalue $servers $sender $sport $hostname $1 $2 | |
for i in $servers; do | |
$sender -vv -z $i -p $sport -s $hostname -k $1 -o $2 2>&1 >>/dev/null | |
echo "[$(date)]: $sender -z $i -p $sport -s $hostname -k $1 -o $2" >>/var/log/zabbix/zabbix_sender.log | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script allows to gather multiple values using one some script (e.g full MySQL status) and send the values to the server keys efficiently.
Eliminates unnecessary queries and preserves system resources in Zabbix server.
Requires active checks to be enabled.