Zionetrix::Git
Repositories
Help
Report an Issue
check_mysql_with_perfdata
Code
Commits
Branches
Tags
Search
Tree:
61169b6
Branches
Tags
master
check_mysql_with_perfdata
install.sh
Initial commit
Benjamin Renard
commited
61169b6
at 2011-01-17 22:19:42
install.sh
Blame
History
Raw
#!/bin/bash SD=$( dirname $0 ) SD=$( pwd $SD ) SRC=$SD/check_mysql_with_perfdata DD=/usr/local/lib/nagios/plugins DST=$DD/check_mysql_with_perfdata NAGIOS_PLUGINS_CFG_DIR=/etc/nagios-plugins/config NAGIOS_PLUGINS_CFG_DST=$NAGIOS_PLUGINS_CFG_DIR/mysql_with_perfdata.cfg case "$1" in "-u") echo "Uninstall plugin : " echo " - Remove plugin (symbolic link) : $DST" rm $DST echo " - Remove configuration file : $NAGIOS_PLUGINS_CFG_DST" rm $NAGIOS_PLUGINS_CFG_DST exit 0 ;; "--reinstall") $SD/$0 -u ;; "-h") echo "Usage : $0 [-u] [--reinstall] [-h]" echo " -u Uninstall plugin" echo " --reinstall Reinstall plugin" echo " -h Display this message" exit 0 ;; esac [ ! -d $DD ] && mkdir -p $DD DO=1 if [ -e $DST ] then ASK=1 if [ -L $DST ] then D=`ls -l $DST|sed 's/.* -> //'` if [ "$D" = "$SRC" ] then echo "Symbolic link $DST already exist. Pass." ASK=0 DO=0 fi fi if [ $ASK -eq 1 ] then echo "File $DST already exists." echo -n "Abort (Y,n) ? " read a [ "$a" != "N" -a "$a" != "n" ] && exit echo "Saved old file in $DST.orig" mv $DST $DST.orig fi fi [ $DO -eq 1 ] && echo "Create symbolic link for plugin : $DST" && ln -s $SRC $DST [ ! -d $NAGIOS_PLUGINS_CFG_DIR ] && mkdir -p $NAGIOS_PLUGINS_CFG_DIR DO=1 TMP=`mktemp` echo "# 'check_mysql_with_perfdata' command definition define command{ command_name check_mysql_with_perfdata command_line $DST -H '\$HOSTADDRESS\$' } # 'check_mysql_with_perfdata_cmdlinecred' command definition define command{ command_name check_mysql_with_perfdata_cmdlinecred command_line $DST -H '\$HOSTADDRESS\$' -u '\$ARG1\$' -p '\$ARG2\$' } # 'check_mysql_with_perfdata_database' command definition define command{ command_name check_mysql_with_perfdata_database command_line $DST -d '\$ARG3\$' -H '\$HOSTADDRESS\$' -u '\$ARG1\$' -p '\$ARG2\$' }" > $TMP if [ -e $NAGIOS_PLUGINS_CFG_DST ] then ASK=1 if [ ! -n "`diff $NAGIOS_PLUGINS_CFG_DST $TMP`" ] then echo "Configuration file $NAGIOS_PLUGINS_CFG_DST already and is correct. Pass." ASK=0 DO=0 fi if [ $ASK -eq 1 ] then echo "File $NAGIOS_PLUGINS_CFG_DST already exists." echo -n "Abort (Y,n) ? " read a [ "$a" != "N" -a "$a" != "n" ] && exit echo "Saved old configuration file in $NAGIOS_PLUGINS_CFG_DST.orig" mv "$NAGIOS_PLUGINS_CFG_DST" "$NAGIOS_PLUGINS_CFG_DST.orig" fi fi [ $DO -eq 1 ] && echo "Create configuration file : $NAGIOS_PLUGINS_CFG_DST" && cp $TMP $NAGIOS_PLUGINS_CFG_DST && chmod 644 $NAGIOS_PLUGINS_CFG_DST rm -f $TMP