[packages/monitoring-plugin-check_mysql-heartbeat: 2/10] update commandline options parser

glen glen at pld-linux.org
Tue Mar 22 12:32:31 CET 2016


commit b1f5220b0bfe499053e5774979825fab5121dcd3
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Sep 2 08:54:29 2012 +0000

    update commandline options parser
    
    Changed files:
        check_mysql-heartbeat.sh -> 1.2

 check_mysql-heartbeat.sh | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/check_mysql-heartbeat.sh b/check_mysql-heartbeat.sh
index 378f5b0..031644f 100755
--- a/check_mysql-heartbeat.sh
+++ b/check_mysql-heartbeat.sh
@@ -35,8 +35,16 @@ Usage: check_mysql-heartbeat
 EOF
 }
 
+# Parse arguments
+args=$(getopt -o hVH:P:u:p:D: --long help,version,mk,maatkit,pt,percona-tookit,host:,port:,username:,password:,database: -u -n $PROGRAM -- "$@")
+if [ $? != 0 ]; then
+	usage
+	exit 1
+fi
+eval set -- "$args"
+
 ## Start of main program ##
-while [ $# -gt 0 ]; do
+while :; do
 	case "$1" in
 	-h|--help)
 		usage
@@ -72,6 +80,13 @@ while [ $# -gt 0 ]; do
 		shift
 		database=$1
 		;;
+	--)
+		shift
+		break
+		;;
+	*)
+		die UNKNOWN "Internal error: [$1] Not recognized!"
+		;;
 	esac
 	shift
 done
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/monitoring-plugin-check_mysql-heartbeat.git/commitdiff/c97836d2e3bccf7d77e278a624bc4dd433f544f9



More information about the pld-cvs-commit mailing list