Created
March 12, 2015 12:18
-
-
Save komeda-shinji/22742389a2e740598304 to your computer and use it in GitHub Desktop.
Zabbixの外部チェックアイテムでNagiosのプラグインを利用すラッパー
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
#!/bin/sh | |
ZABBIX_SENDER=/usr/bin/zabbix_sender | |
ZABBIX_SERVER=localhost | |
HOSTNAME="$1"; shift | |
PLUGIN="$1"; shift | |
CHECK_PLUGIN=/usr/lib/nagios/plugins/"$PLUGIN" | |
output=$("$CHECK_PLUGIN" "$@" 2>/dev/null) | |
status=$? | |
{ | |
for perf in ${output##*|}; do | |
key=${perf%%'='*} | |
val=${perf##$key'='} | |
val=${val%%';'*} | |
val=${val%%[%A-Za-z]*} | |
echo "-" "$PLUGIN"."$key" "$val" | |
done | |
echo "-" "$PLUGIN"."output" ${output%%|*} | |
} | $ZABBIX_SENDER -z $ZABBIX_SERVER -s "$HOSTNAME" -i - >/dev/null 2>&1 | |
echo "$status" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment