percona / percona-monitoring-plugins

Percona Monitoring Plugins
GNU General Public License v2.0
135 stars 113 forks source link

bashism in /bin/sh script in nagios/bin/ #32

Open waja opened 7 years ago

waja commented 7 years ago

Running checkbashisms (https://anonscm.debian.org/cgit/collab-maint/devscripts.git/plain/scripts/checkbashisms.pl) against nagios/bin/* from the 1.1.5 release results into the following error.

Not using bash as /bin/sh is likely to lead to errors or unexpected behaviours. Please be aware that dash is the default /bin/sh in Debian (and Derivates) and maybe other Distributions.

possible bashism in nagios/bin/pmp-check-lvm-snapshots line 103 ($_):
   [ "${0##*/}" = "pmp-check-lvm-snapshots" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-deadlocks line 97 ($_):
   [ "${0##*/}" = "pmp-check-mysql-deadlocks" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-deleted-files line 154 ($_):
   [ "${0##*/}" = "pmp-check-mysql-deleted-files" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-file-privs line 147 ($_):
   [ "${0##*/}" = "pmp-check-mysql-file-privs" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-innodb line 237 ($_):
   [ "${0##*/}" = "pmp-check-mysql-innodb" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-pidfile line 163 ($_):
   [ "${0##*/}" = "pmp-check-mysql-pidfile" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-processlist line 184 ($_):
   [ "${0##*/}" = "pmp-check-mysql-processlist" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-replication-delay line 139 ($_):
   [ "${0##*/}" = "pmp-check-mysql-replication-delay" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-replication-running line 126 ($_):
   [ "${0##*/}" = "pmp-check-mysql-replication-running" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-status line 304 ($_):
   [ "${0##*/}" = "pmp-check-mysql-status" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 64 (should be 'b = a'):
   if [ "${OPT_TARGET}" == "kills" ]; then
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 67 (should be 'b = a'):
   elif [ "${OPT_TARGET}" == "fkerrors" ]; then
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 109 ($_):
   [ "${0##*/}" = "pmp-check-mysql-ts-count" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-unix-memory line 118 ($_):
   [ "${0##*/}" = "pmp-check-unix-memory" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]

Hints about how to fix bashisms can be found at: https://wiki.ubuntu.com/DashAsBinSh

See also https://bugs.debian.org/772278

Many thanks in advance for fixing this, Jan.

waja commented 7 years ago

The updated test for the 1.1.6 release:

possible bashism in nagios/bin/pmp-check-lvm-snapshots line 103 ($_):
   [ "${0##*/}" = "pmp-check-lvm-snapshots" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-deadlocks line 97 ($_):
   [ "${0##*/}" = "pmp-check-mysql-deadlocks" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-deleted-files line 156 ($_):
   [ "${0##*/}" = "pmp-check-mysql-deleted-files" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-file-privs line 149 ($_):
   [ "${0##*/}" = "pmp-check-mysql-file-privs" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-innodb line 239 ($_):
   [ "${0##*/}" = "pmp-check-mysql-innodb" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-pidfile line 165 ($_):
   [ "${0##*/}" = "pmp-check-mysql-pidfile" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-processlist line 186 ($_):
   [ "${0##*/}" = "pmp-check-mysql-processlist" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-replication-delay line 71 (should be 'b = a'):
      if [ "${OPT_SRVID}" == "MASTER" ]; then
possible bashism in nagios/bin/pmp-check-mysql-replication-delay line 130 ($_):
   [ "${0##*/}" = "pmp-check-mysql-replication-delay" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-replication-running line 128 ($_):
   [ "${0##*/}" = "pmp-check-mysql-replication-running" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-status line 306 ($_):
   [ "${0##*/}" = "pmp-check-mysql-status" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 64 (should be 'b = a'):
   if [ "${OPT_TARGET}" == "kills" ]; then
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 67 (should be 'b = a'):
   elif [ "${OPT_TARGET}" == "fkerrors" ]; then
possible bashism in nagios/bin/pmp-check-mysql-ts-count line 111 ($_):
   [ "${0##*/}" = "pmp-check-mysql-ts-count" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
possible bashism in nagios/bin/pmp-check-unix-memory line 118 ($_):
   [ "${0##*/}" = "pmp-check-unix-memory" ] || [ "${0##*/}" = "bash" -a "$_" = "$0" ]
jkramarz commented 7 years ago

Yup, pmp-check-mysql-replication-delay hangs on CentOS if heartbeat table is specified because of undefined variables.