2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Restructure incomplete or broken "autoconf" implementations

Some plugins with non-zero autoconf exitcodes (it must be zero instead)
deserved a bit of code cleanup for improved readability.
This commit is contained in:
Lars Kruse 2018-09-16 05:03:47 +02:00
parent 46e2de55de
commit 9cef55a3ed
15 changed files with 85 additions and 105 deletions

View File

@ -15,10 +15,11 @@
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
# Search for arp # Search for arp
which arp >/dev/null 2>/dev/null || (echo "no (can't find arp binary)" && exit 1) if which arp >/dev/null; then
# ...or success
echo yes echo yes
else
echo "no (missing 'arp' executable)"
fi
exit 0 exit 0
fi fi

View File

@ -19,13 +19,11 @@
case "$1" in case "$1" in
autoconf) autoconf)
# Search for ip # Search for ip
which ip >/dev/null 2>&1 if which ip >/dev/null; then
if [ $? -ne 0 ]; then
echo "no (can't find ip binary)"
exit 1
fi
# ...or success
echo 'yes' echo 'yes'
else
echo "no (missing 'ip' executable)"
fi
exit 0 exit 0
;; ;;
suggest) suggest)

View File

@ -18,9 +18,12 @@ HOSTS=$(cd ${PCDIR} 2>/dev/null && ls -1)
. $MUNIN_LIBDIR/plugins/plugin.sh . $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
[ ! -z "${HOSTS}" ] && echo "yes" && exit 0 if [ -n "$HOSTS" ]; then
echo "yes"
else
echo "no" echo "no"
exit 1 fi
exit 0
fi fi
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then

View File

@ -40,14 +40,12 @@
# Auto Configure, Check it word 1 is defined # Auto Configure, Check it word 1 is defined
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ "$URL1" != "" ]; then if [ -n "$URL1" ] && [ -n "$WORD1" ]; then
if [ "$WORD1" != "" ]; then
echo yes echo yes
exit 0 else
fi
fi
echo no echo no
exit 1 fi
exit 0
fi fi
#Configure, loop through each variable defined WORDx URLx dumping it to munin #Configure, loop through each variable defined WORDx URLx dumping it to munin

View File

@ -110,15 +110,13 @@ if [ "$1" = "autoconf" ]; then
if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then
echo "no (No jstat found in ${JAVA_HOME}/bin)" echo "no (No jstat found in ${JAVA_HOME}/bin)"
exit 1 elif [ ! -f "$pidfilepath" ]; then
fi echo "no (missing file $pidfilepath)"
elif [ ! -r "$pidfilepath" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then echo "no (cannot read $pidfilepath)"
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}" else
exit 1
fi
echo "yes" echo "yes"
fi
exit 0 exit 0
fi fi

View File

@ -130,15 +130,13 @@ if [ "$1" = "autoconf" ]; then
if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then
echo "no (No jstat found in ${JAVA_HOME}/bin)" echo "no (No jstat found in ${JAVA_HOME}/bin)"
exit 1 elif [ ! -f "$pidfilepath" ]; then
fi echo "no (missing file $pidfilepath)"
elif [ ! -r "$pidfilepath" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then echo "no (cannot read $pidfilepath)"
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}" else
exit 1
fi
echo "yes" echo "yes"
fi
exit 0 exit 0
fi fi

View File

@ -185,15 +185,13 @@ if [ "$1" = "autoconf" ]; then
if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then if [ ! -x "${JAVA_HOME}/bin/jstat" ]; then
echo "no (No jstat found in ${JAVA_HOME}/bin)" echo "no (No jstat found in ${JAVA_HOME}/bin)"
exit 1 elif [ ! -f "$pidfilepath" ]; then
fi echo "no (missing file $pidfilepath)"
elif [ ! -r "$pidfilepath" ]; then
if [ ! -f "${pidfilepath}" ] || [ ! -r "${pidfilepath}" ]; then echo "no (cannot read $pidfilepath)"
echo "no (No such file ${pidfilepath} or cannot read ${pidfilepath}" else
exit 1
fi
echo "yes" echo "yes"
fi
exit 0 exit 0
fi fi

View File

@ -16,18 +16,15 @@
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
if [ -x /sbin/sysctl ]; then if [ -x /sbin/sysctl ]; then
/sbin/sysctl vm.kmem_size_max > /dev/null if /sbin/sysctl vm.kmem_size_max >/dev/null 2>&1; then
if [ $? = "0" ]; then echo "yes"
echo yes else
echo "no (missing sysctl variable 'vm.kmem_size_max')"
fi
else
echo "no (missing 'sysctl' executable)"
fi
exit 0 exit 0
else
echo no
exit 1
fi
else
echo no
exit 1
fi
fi fi
TEXT=`kldstat | tr a-f A-F | awk 'BEGIN {print "ibase=16"}; NR > 1 {print $4}' | bc | awk '{a+=$1}; END {print a}'` TEXT=`kldstat | tr a-f A-F | awk 'BEGIN {print "ibase=16"}; NR > 1 {print $4}' | bc | awk '{a+=$1}; END {print a}'`

View File

@ -83,15 +83,11 @@ ACTION="$(basename "$0" | sed 's/^.*_//')"
do_autoconf () { do_autoconf () {
if [ -z "$NCBIN" ] ; then if [ -z "$NCBIN" ] ; then
echo "no (missing netcat program ('nc'))" echo "no (missing netcat program ('nc'))"
exit 1 elif ! echo version | "$NCBIN" "$MPDHOST" "$MPDPORT" >/dev/null 2>&1; then
fi
if ! echo version | "$NCBIN" "$MPDHOST" "$MPDPORT" >/dev/null 2>&1; then
echo "no (connection failed)" echo "no (connection failed)"
exit 1 else
fi
echo "yes" echo "yes"
fi
exit 0 exit 0
} }

View File

@ -18,19 +18,15 @@ Tuner=0
case $1 in case $1 in
autoconf|detect) autoconf|detect)
REQ=`which femon` if ! which femon >/dev/null; then
if [ "$REQ" = "" ]; then
echo "no (femon not installed)" echo "no (femon not installed)"
exit 1 elif [ -e "/dev/dvb/adapter$Tuner/" ]; then
fi
if [ -e /dev/dvb/adapter$Tuner/ ]; then
echo yes echo yes
exit 0
else else
echo "no (dvb tuner $Tuner not found)" echo "no (dvb tuner $Tuner not found)"
exit 1 fi
fi;; exit 0
;;
config) config)
echo "graph_title DVB signal strength" echo "graph_title DVB signal strength"

View File

@ -77,11 +77,11 @@ EOF
do_autoconf () { do_autoconf () {
case $WLERR in case $WLERR in
0) echo yes; exit 0;; 0) echo yes;;
127) echo "no ($AL)"; exit 1;; 127) echo "no ($AL)";;
*) echo "no (wl error: $AL)"; exit 1;; *) echo "no (wl error: $AL)";;
*) echo "no (no wl executable, or error)"; exit 1;;
esac esac
exit 0
} }
case $1 in case $1 in

View File

@ -39,8 +39,12 @@ WGET_FLAGS="-Yoff"; # refer to wget manual, you may set extra parameters like di
act=`basename $0 | sed 's/^php_apc_//g'` act=`basename $0 | sed 's/^php_apc_//g'`
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
[ -z "$URL" ] && echo "no (edit URL config in header file !)" && exit 1 if [ -z "$URL" ]; then
[ -n "$URL" ] && echo "yes" && exit 0 echo "no (missing URL config in header file)"
else
echo "yes"
fi
exit 0
fi fi
if [ "$1" = "suggest" ]; then if [ "$1" = "suggest" ]; then

View File

@ -21,8 +21,12 @@ WGET_FLAGS="-Yoff"; # refer to wget manual, you may set extra parameters like di
act=memory act=memory
if [ "$1" = "autoconf" ]; then if [ "$1" = "autoconf" ]; then
[ -z "$URL" ] && echo "no (edit URL config in header file !)" && exit 1 if [ -z "$URL" ]; then
[ -n "$URL" ] && echo "yes" && exit 0 echo "no (missing URL config in header file)"
else
echo "yes"
fi
exit 0
fi fi
if [ "$1" = "suggest" ]; then if [ "$1" = "suggest" ]; then

View File

@ -32,23 +32,16 @@ do_config () {
} }
do_autoconf () { do_autoconf () {
if [ ! -f $PNWL ] ; then if [ ! -f "$PNWL" ]; then
echo "no (no $PNWL)" echo "no (missing file '$PNWL')"
exit 1 elif [ ! -r "$PNWL" ]; then
fi echo "no (cannot read file '$PNWL')"
elif grep -qs : "$PNWL"; then
if [ ! -r $PNWL ] ; then
echo "no (could not read $PNWL)"
exit 1
fi
if grep -qs : $PNWL ; then
echo yes echo yes
exit 0 else
fi
echo "no (no devices in $PNWL)" echo "no (no devices in $PNWL)"
exit 1 fi
exit 0
} }
case $1 in case $1 in

View File

@ -216,22 +216,18 @@ EOF
autoconf) autoconf)
if [ ! -x ${sysctl} ]; then if [ ! -x ${sysctl} ]; then
echo "no (${sysctl} is not executable)" echo "no (${sysctl} is not executable)"
exit 1 elif [ "${ostype}" = "FreeBSD" ]; then
fi
if [ ${ostype} = "FreeBSD" ]; then
echo "yes" echo "yes"
exit 0 elif [ "${ostype}" = "Linux" ]; then
fi
if [ ${ostype} = "Linux" ]; then
if [ -f ${procfile} ]; then if [ -f ${procfile} ]; then
echo "yes" echo "yes"
exit 0 else
fi
echo "no (The statsfile does not exist: ${procfile})" echo "no (The statsfile does not exist: ${procfile})"
exit 1
fi fi
echo "no (You're OS is not supported by this plugin)" else
exit 1 echo "no (Your OS is not supported by this plugin)"
fi
exit 0
;; ;;
suggest) suggest)
exit 0 exit 0