Skip to content

Instantly share code, notes, and snippets.

@komeda-shinji
Created March 12, 2015 12:18
Show Gist options
  • Save komeda-shinji/22742389a2e740598304 to your computer and use it in GitHub Desktop.
Save komeda-shinji/22742389a2e740598304 to your computer and use it in GitHub Desktop.
Zabbixの外部チェックアイテムでNagiosのプラグインを利用すラッパー
#!/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