From 2ec4e4c1f7050ba03dfe5e9edc150f43863e1dbc Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sun, 16 Sep 2018 04:09:21 +0200 Subject: [PATCH] Improve incorrect or unspecific output for "autoconf" Some plugins emit wrongly formatted "no" messages or lack the "yes" message on success. --- plugins/amule/amule_queue | 7 +++---- plugins/amule/amule_shares | 7 +++---- plugins/amule/amule_transfers | 7 +++---- plugins/amule/amule_uptime | 7 +++---- plugins/bind/bind95_ | 8 ++++---- plugins/disk/lvm_snap_used | 6 +++--- plugins/disk/raid | 5 ++--- plugins/disk/xfs | 5 ++--- plugins/http/wget_page | 32 ++++++++++-------------------- plugins/mysql/mysql_report | 5 ++--- plugins/mythtv/mythtv_programs | 6 ++---- plugins/other/listeners | 2 +- plugins/php/php_errors_ | 6 +++--- plugins/punbb/punbb_users | 7 ++++--- plugins/snmp/snmp__fn | 26 ++++++++---------------- plugins/solaris/zones_cpu | 5 ++--- plugins/solaris/zones_mem | 5 ++--- plugins/vbulletin/vbulletin4_users | 8 ++++---- plugins/vbulletin/vbulletin_users | 8 ++++---- plugins/vmware/esxi | 5 ++--- 20 files changed, 68 insertions(+), 99 deletions(-) diff --git a/plugins/amule/amule_queue b/plugins/amule/amule_queue index 53f5afd0..e73d37b0 100755 --- a/plugins/amule/amule_queue +++ b/plugins/amule/amule_queue @@ -28,16 +28,15 @@ if [ "$1" = "autoconf" ]; then if [ -z "$(which amule)" ]; then - echo "$0: error: amule not installed" - exit 1 + echo "no (amule not installed)" else if [ ! -e /tmp/amulesig.dat ]; then - echo "$0: error: amulesig.dat not found" + echo "no (amulesig.dat not found)" else echo yes - exit 0 fi fi + exit 0 fi if [ "$1" = "config" ]; then diff --git a/plugins/amule/amule_shares b/plugins/amule/amule_shares index 33789a36..c0129e35 100755 --- a/plugins/amule/amule_shares +++ b/plugins/amule/amule_shares @@ -28,16 +28,15 @@ if [ "$1" = "autoconf" ]; then if [ -z "$(which amule)" ]; then - echo "$0: error: amule not installed" - exit 1 + echo "no (amule not installed)" else if [ ! -e /tmp/amulesig.dat ]; then - echo "$0: error: amulesig.dat not found" + echo "no (amulesig.dat not found)" else echo yes - exit 0 fi fi + exit 0 fi if [ "$1" = "config" ]; then diff --git a/plugins/amule/amule_transfers b/plugins/amule/amule_transfers index 2591c344..79623d66 100755 --- a/plugins/amule/amule_transfers +++ b/plugins/amule/amule_transfers @@ -28,16 +28,15 @@ if [ "$1" = "autoconf" ]; then if [ -z "$(which amule)" ]; then - echo "$0: error: amule not installed" - exit 1 + echo "no (amule not installed)" else if [ ! -e /tmp/amulesig.dat ]; then - echo "$0: error: amulesig.dat not found" + echo "no (amulesig.dat not found)" else echo yes - exit 0 fi fi + exit 0 fi if [ "$1" = "config" ]; then diff --git a/plugins/amule/amule_uptime b/plugins/amule/amule_uptime index fbf34e39..c58114d8 100755 --- a/plugins/amule/amule_uptime +++ b/plugins/amule/amule_uptime @@ -28,16 +28,15 @@ if [ "$1" = "autoconf" ]; then if [ -z "$(which amule)" ]; then - echo "$0: error: amule not installed" - exit 1 + echo "no (amule not installed)" else if [ ! -e /tmp/amulesig.dat ]; then - echo "$0: error: amulesig.dat not found" + echo "no (amulesig.dat not found)" else echo yes - exit 0 fi fi + exit 0 fi if [ "$1" = "config" ]; then diff --git a/plugins/bind/bind95_ b/plugins/bind/bind95_ index bf42fe81..edad0815 100755 --- a/plugins/bind/bind95_ +++ b/plugins/bind/bind95_ @@ -122,12 +122,12 @@ if ( defined($ARGV[0]) && $ARGV[0] eq "config" ) { if ( defined($ARGV[0]) && $ARGV[0] eq "autoconf" ) { if (! -f $stat_file) { - printf "Unable to file bind stat file on %s",$stat_file; - exit 1; + printf "no (Unable to file bind stat file on %s)",$stat_file; + exit 0; } if (! -f $rndc) { - printf "Unable to file rndc tool (configured : %s)",$rndc; - exit 1; + printf "no (Unable to file rndc tool (configured : %s))",$rndc; + exit 0; } exit 0; } diff --git a/plugins/disk/lvm_snap_used b/plugins/disk/lvm_snap_used index aabbe460..4be838a7 100755 --- a/plugins/disk/lvm_snap_used +++ b/plugins/disk/lvm_snap_used @@ -26,10 +26,10 @@ lvdisplay=$(which lvdisplay) if [ "$1" = "autoconf" ]; then if test -n "${lvdisplay}"; then echo yes - exit 0 + else + echo "no (lvdisplay not found)" fi - echo "no lvdisplay found" - exit 1 + exit 0 fi diff --git a/plugins/disk/raid b/plugins/disk/raid index bbfc0e8a..c02a1689 100755 --- a/plugins/disk/raid +++ b/plugins/disk/raid @@ -13,11 +13,10 @@ if ($ARGV[0] and $ARGV[0] eq "autoconf") { if (-r "/proc/mdstat" and `grep md /proc/mdstat`) { print "yes\n"; - exit 0; } else { - print "no RAID devices\n"; - exit 1; + print "no (no RAID devices found)\n"; } + exit 0; } if ( $ARGV[0] and $ARGV[0] eq "config" ) { diff --git a/plugins/disk/xfs b/plugins/disk/xfs index 8a06a555..55919038 100755 --- a/plugins/disk/xfs +++ b/plugins/disk/xfs @@ -20,13 +20,12 @@ if ($ARGV[0] and $ARGV[0] eq "autoconf") if (-r "/proc/fs/xfs/stat") { print "yes\n"; - exit 0; } else { - print "/proc/fs/xfs/stat not found\n"; - exit 1; + print "no (/proc/fs/xfs/stat not found)\n"; } + exit 0; } my %runtime_stats = ( diff --git a/plugins/http/wget_page b/plugins/http/wget_page index 00081281..c137ff96 100755 --- a/plugins/http/wget_page +++ b/plugins/http/wget_page @@ -97,30 +97,20 @@ default_timeout=20 default_join_lines=true if [ "${1}" = "autoconf" ]; then - result=0 - if [ -z "${wget_bin}" -o ! -f "${wget_bin}" -o ! -x "${wget_bin}" ]; then - result=1 + if [ -z "$wget_bin" ] || [ ! -f "$wget_bin" ] || [ ! -x "$wget_bin" ]; then + echo "no (missing 'wget' executable)" + elif [ -z "$time_bin" ] || [ ! -f "$time_bin" ] || [ ! -x "$time_bin" ]; then + echo "no (missing 'time' executable)" + elif [ -z "$mktemp_bin" ] || [ ! -f "$mktemp_bin" ] || [ ! -x "$mktemp_bin" ]; then + echo "no (missing 'mktemp' executable)" + elif [ -z "$grep_bin" ] || [ ! -f "$grep_bin" ] || [ ! -x "$grep_bin" ]; then + echo "no (missing 'grep' executable)" + elif [ -z "$tail_bin" ] || [ ! -f "$tail_bin" ] || [ ! -x "$tail_bin" ]; then + echo "no (missing 'tail' executable)" else - if [ -z "${time_bin}" -o ! -f "${time_bin}" -o ! -x "${time_bin}" ]; then - result=2 - else - if [ -z "${mktemp_bin}" -o ! -f "${mktemp_bin}" -o ! -x "${mktemp_bin}" ]; then - result=3 - else - if [ -z "${grep_bin}" -o ! -f "${grep_bin}" -o ! -x "${grep_bin}" ]; then - result=4 - else - [ -z "${tail_bin}" -o ! -f "${tail_bin}" -o ! -x "${tail_bin}" ] && result=5 - fi - fi - fi - fi - if [ ${result} -eq 0 ]; then echo "yes" - else - echo "no" fi - exit $result + exit 0 fi if [ -z "${names}" ]; then diff --git a/plugins/mysql/mysql_report b/plugins/mysql/mysql_report index 06df41f6..a680df38 100755 --- a/plugins/mysql/mysql_report +++ b/plugins/mysql/mysql_report @@ -60,13 +60,12 @@ default_args="--base 1000 -l 0" default_scale="no" if [ "${1}" = "autoconf" ]; then - result=0 if [ -z "${mysqlbin}" ]; then - echo "no" + echo "no (missing mysql executable)" else echo "yes" fi - exit $result + exit 0 fi if [ -z "${names}" ]; then diff --git a/plugins/mythtv/mythtv_programs b/plugins/mythtv/mythtv_programs index e205329b..4abcf559 100755 --- a/plugins/mythtv/mythtv_programs +++ b/plugins/mythtv/mythtv_programs @@ -42,12 +42,10 @@ my $Channel=""; if ($ARGV[0] and $ARGV[0] eq "autoconf" ) { if ( $SQLDBName ne "" ) { print "yes\n"; - exit 0; } else { - print "no\n"; - print "cannot find MythTV configuration file my.txt\n"; - exit 1; + print "no (cannot find MythTV configuration file my.txt)\n"; } + exit 0; } #Config Options diff --git a/plugins/other/listeners b/plugins/other/listeners index 8f426d36..235bcb08 100755 --- a/plugins/other/listeners +++ b/plugins/other/listeners @@ -71,7 +71,7 @@ LASTSTREAM=${#STREAMS[*]} # --- check whether any stream found --- run_autoconf() { if (( $LASTSTREAM )) ; then echo yes ; exit 0 ; fi # found streams - echo U ; exit 1 ; } # no radio or streams + echo no ; exit 0 ; } # no radio or streams diff --git a/plugins/php/php_errors_ b/plugins/php/php_errors_ index fd4f43fe..d02f8064 100755 --- a/plugins/php/php_errors_ +++ b/plugins/php/php_errors_ @@ -34,9 +34,9 @@ LOGS=${logfile:-/var/log/apache2/error.log} if [[ $1 == autoconf ]]; then for LOG in $LOGS; do - if [[ ! -r $LOGS ]]; then - echo no - exit 1 + if [[ ! -r $LOG ]]; then + echo "no (cannot read '$LOG')" + exit 0 fi done diff --git a/plugins/punbb/punbb_users b/plugins/punbb/punbb_users index 453fc923..954233d9 100755 --- a/plugins/punbb/punbb_users +++ b/plugins/punbb/punbb_users @@ -42,11 +42,12 @@ my $type = undef; if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) { - if ($ret) - { + if ($ret) { print "no ($ret)\n"; - exit 1; + } else { + print "yes\n"; } + exit 0; } diff --git a/plugins/snmp/snmp__fn b/plugins/snmp/snmp__fn index 521b19a9..051408b1 100755 --- a/plugins/snmp/snmp__fn +++ b/plugins/snmp/snmp__fn @@ -87,26 +87,16 @@ ATUN=`$SNMPGET $fnVPNSslStatsActiveTunnels | cut -d ":" -f4 | cut -d " " -f2` autoconf() { - if [ $SCPU ]; then - echo yes, OID $FGTcpu can be readed. + if [ -z "$SCPU" ]; then + echo "no (one or multiple OID can not be read)" + elif [ -z "$SMEM" ]; then + echo "no (one or multiple OID can not be read)" + elif [ -z "$SCNT" ]; then + echo "no (one or multiple OID can not be read)" else - echo no, one or multiple OID can not be readed. - exit 1 + echo "yes" fi - - if [ $SMEM ]; then - echo yes, OID $fnSysMemUsage can be readed. - else - echo no, one or multiple OID can not be readed. - exit 1 - fi - if [ $SCNT ]; then - echo yes, OID $fnSysSesCount can be readed. - else - echo no, one or multiple OID can not be read. - exit 1 - fi -exit 0 + exit 0 } config() diff --git a/plugins/solaris/zones_cpu b/plugins/solaris/zones_cpu index 003d6d1a..5fb58f45 100755 --- a/plugins/solaris/zones_cpu +++ b/plugins/solaris/zones_cpu @@ -12,13 +12,12 @@ if [ "$1" = 'autoconf' ]; then if [ $zones -gt 1 ]; then echo yes else - echo yes + echo no fi - exit 0 else echo no - exit 1 fi + exit 0 fi if [ "$1" = 'config' ]; then diff --git a/plugins/solaris/zones_mem b/plugins/solaris/zones_mem index d492af05..a25cb830 100755 --- a/plugins/solaris/zones_mem +++ b/plugins/solaris/zones_mem @@ -14,13 +14,12 @@ if [ "$1" = 'autoconf' ]; then if [ $zones -gt 1 ]; then echo yes else - echo yes + echo no fi - exit 0 else echo no - exit 1 fi + exit 0 fi if [ "$1" = 'config' ]; then diff --git a/plugins/vbulletin/vbulletin4_users b/plugins/vbulletin/vbulletin4_users index ead4ebb8..b8ea1c12 100755 --- a/plugins/vbulletin/vbulletin4_users +++ b/plugins/vbulletin/vbulletin4_users @@ -47,12 +47,12 @@ my $timeout = 30; if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) { - if ($ret) - { + if ($ret) { print "no ($ret)\n"; - exit 1; + } else { + print "yes\n"; } - + exit 0; } if ( defined $ARGV[0] and $ARGV[0] eq "config" ) diff --git a/plugins/vbulletin/vbulletin_users b/plugins/vbulletin/vbulletin_users index 663eb3d0..27dd837d 100755 --- a/plugins/vbulletin/vbulletin_users +++ b/plugins/vbulletin/vbulletin_users @@ -47,12 +47,12 @@ my $timeout = 30; if ( defined $ARGV[0] and $ARGV[0] eq "autoconf" ) { - if ($ret) - { + if ($ret) { print "no ($ret)\n"; - exit 1; + } else { + print "yes\n"; } - + exit 0; } if ( defined $ARGV[0] and $ARGV[0] eq "config" ) diff --git a/plugins/vmware/esxi b/plugins/vmware/esxi index 00c5b982..0c2894a6 100755 --- a/plugins/vmware/esxi +++ b/plugins/vmware/esxi @@ -119,11 +119,10 @@ if [ "$1" = "autoconf" ]; then get_infos if [ -n "$summary" ]; then echo yes - exit 0 else - echo "Cannot connect to ESX server $HOST" - exit 1 + echo "no (cannot connect to ESX server $HOST)" fi + exit 0 fi if [ "$1" = "config" ]; then