Refactor command line options for all scripts to include a help option.
This commit is contained in:
parent
e849092a4d
commit
d41ba60101
@ -3,13 +3,14 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-disk.sh --warning=<level> --critical=<level>
|
#/ check-disk.sh --warning=<level> --critical=<level> --help
|
||||||
#/
|
#/
|
||||||
#/ Checks the disk usage
|
#/ Checks the disk usage
|
||||||
#/
|
#/
|
||||||
#/ Options:
|
#/ Options:
|
||||||
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
||||||
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
#/ 0 Everything OK
|
#/ 0 Everything OK
|
||||||
@ -25,8 +26,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=w:c:
|
OPTIONS=w:c:h
|
||||||
LONGOPTS=warning:,critical:
|
LONGOPTS=warning:,critical:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -54,6 +55,9 @@ GetOptions() {
|
|||||||
crit="$2"
|
crit="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-dummy.sh [--ok|--warning|--critical]
|
#/ check-dummy.sh [--ok|--warning|--critical] --help
|
||||||
#/
|
#/
|
||||||
#/ Does not check anything.
|
#/ Does not check anything.
|
||||||
#/
|
#/
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#/ -w, --warning Trigger a warning
|
#/ -w, --warning Trigger a warning
|
||||||
#/ -c, --critical Trigger a critical warning
|
#/ -c, --critical Trigger a critical warning
|
||||||
#/ -u, --unknown Trigger a unknown status
|
#/ -u, --unknown Trigger a unknown status
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
@ -27,8 +28,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS='owcu'
|
OPTIONS='owcuh'
|
||||||
LONGOPTS='ok,warning,critical,unknown'
|
LONGOPTS='ok,warning,critical,unknown,help'
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -67,6 +68,9 @@ GetOptions() {
|
|||||||
rmsg="UNKNOWN"
|
rmsg="UNKNOWN"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-load.sh --warning=<level> --critical=<level> --average=<level>
|
#/ check-load.sh --warning=<level> --critical=<level> --average=<level> --help
|
||||||
#/
|
#/
|
||||||
#/ Checks the system load
|
#/ Checks the system load
|
||||||
#/
|
#/
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
||||||
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
||||||
#/ -a, --average=<average> Which avarage to use for the load level (possible values are 1, 5 and 15)
|
#/ -a, --average=<average> Which avarage to use for the load level (possible values are 1, 5 and 15)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
#/ 0 Everything OK
|
#/ 0 Everything OK
|
||||||
@ -26,8 +27,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=w:c:a:
|
OPTIONS=w:c:a:h
|
||||||
LONGOPTS=warning:,critical:,avarage:
|
LONGOPTS=warning:,critical:,avarage:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -63,6 +64,9 @@ GetOptions() {
|
|||||||
check="$2"
|
check="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
10
check-md.sh
10
check-md.sh
@ -3,13 +3,14 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-md.sh --warning=<events> --critical=<events> <md-device>
|
#/ check-md.sh --warning=<events> --critical=<events> --help <md-device>
|
||||||
#/
|
#/
|
||||||
#/ Checks the raid-device status
|
#/ Checks the raid-device status
|
||||||
#/
|
#/
|
||||||
#/ Options:
|
#/ Options:
|
||||||
#/ -w, --warning=<events> The events of when to trigger a warning (comma-separated)
|
#/ -w, --warning=<events> The events of when to trigger a warning (comma-separated)
|
||||||
#/ -c, --critical=<events> The events of when to trigger a critical warning (comma-separated)
|
#/ -c, --critical=<events> The events of when to trigger a critical warning (comma-separated)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Possible events
|
#/ Possible events
|
||||||
#/ - clean
|
#/ - clean
|
||||||
@ -31,8 +32,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=w:c:
|
OPTIONS=w:c:h
|
||||||
LONGOPTS=warning:,critical:
|
LONGOPTS=warning:,critical:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -65,6 +66,9 @@ GetOptions() {
|
|||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
10
check-mem.sh
10
check-mem.sh
@ -3,13 +3,14 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-memory.sh --warning=<level> --critical=<level>
|
#/ check-memory.sh --warning=<level> --critical=<level> --help
|
||||||
#/
|
#/
|
||||||
#/ Checks the memory usage
|
#/ Checks the memory usage
|
||||||
#/
|
#/
|
||||||
#/ Options:
|
#/ Options:
|
||||||
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
#/ -w, --warning=<level> The level of when to trigger a warning (level=loadavg/nproc)
|
||||||
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
#/ -c, --critical=<level> The level of when to trigger a critical warning (level=loadavg/nproc)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
#/ 0 Everything OK
|
#/ 0 Everything OK
|
||||||
@ -25,8 +26,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=w:c:
|
OPTIONS=w:c:h
|
||||||
LONGOPTS=warning:,critical:
|
LONGOPTS=warning:,critical:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -54,6 +55,9 @@ GetOptions() {
|
|||||||
crit="$2"
|
crit="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-systemctl-service.sh <unit-file>
|
#/ check-systemctl-service.sh --help <unit-file>
|
||||||
#/
|
#/
|
||||||
#/ Options:
|
#/ Options:
|
||||||
#/ -u, --user Check for running within current user
|
#/ -u, --user Check for running within current user
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Checks if a systemd unit is active
|
#/ Checks if a systemd unit is active
|
||||||
#/
|
#/
|
||||||
@ -23,8 +24,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=u
|
OPTIONS=uh
|
||||||
LONGOPTS=user
|
LONGOPTS=user,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -48,6 +49,9 @@ GetOptions() {
|
|||||||
user='--user'
|
user='--user'
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
10
check-url.sh
10
check-url.sh
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-url.sh --proxy=<proxy-url> --warning=<level> --critical=<level> <URL>
|
#/ check-url.sh --proxy=<proxy-url> --warning=<level> --critical=<level> --help <URL>
|
||||||
#/
|
#/
|
||||||
#/ Checks if URL is available
|
#/ Checks if URL is available
|
||||||
#/
|
#/
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#/ -p, --proxy=<proxy-url> The proxy server to use
|
#/ -p, --proxy=<proxy-url> The proxy server to use
|
||||||
#/ -w, --warning=<sec> The amount of response time to trigger a warning (in sec)
|
#/ -w, --warning=<sec> The amount of response time to trigger a warning (in sec)
|
||||||
#/ -c, --critical=<sec> The amount of response time to trigger a critcal warning (in sec)
|
#/ -c, --critical=<sec> The amount of response time to trigger a critcal warning (in sec)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
#/ 0 Everything OK
|
#/ 0 Everything OK
|
||||||
@ -26,8 +27,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=p:w:c:
|
OPTIONS=p:w:c:h
|
||||||
LONGOPTS=proxy:,warning:,critical:
|
LONGOPTS=proxy:,warning:,critical:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -59,6 +60,9 @@ GetOptions() {
|
|||||||
crit="$2"
|
crit="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
#/
|
#/
|
||||||
#/ Usage:
|
#/ Usage:
|
||||||
#/ check-webcron.sh --proxy=<proxy-url> [--daemon] --warning=<level> --critical=<level> <URL>
|
#/ check-webcron.sh --proxy=<proxy-url> [--daemon] --warning=<level> --critical=<level> --help <URL>
|
||||||
#/
|
#/
|
||||||
#/ Checks webcron jobs
|
#/ Checks webcron jobs
|
||||||
#/
|
#/
|
||||||
@ -12,6 +12,7 @@
|
|||||||
#/ -d, --daemon When no daemon is running trigger a critical warning
|
#/ -d, --daemon When no daemon is running trigger a critical warning
|
||||||
#/ -w, --warning=<ratio> The ratio of failed jobs to trigger a warning (1 = all jobs; 0.5 = half of all jobs)
|
#/ -w, --warning=<ratio> The ratio of failed jobs to trigger a warning (1 = all jobs; 0.5 = half of all jobs)
|
||||||
#/ -c, --critical=<ratio> The ratio of failed jobs to trigger a critcal warning (1 = all jobs; 0.5 = half of all jobs)
|
#/ -c, --critical=<ratio> The ratio of failed jobs to trigger a critcal warning (1 = all jobs; 0.5 = half of all jobs)
|
||||||
|
#/ -h, --help Display this help message
|
||||||
#/
|
#/
|
||||||
#/ Exit Codes:
|
#/ Exit Codes:
|
||||||
#/ 0 Everything OK
|
#/ 0 Everything OK
|
||||||
@ -27,8 +28,8 @@ Usage() {
|
|||||||
|
|
||||||
GetOptions() {
|
GetOptions() {
|
||||||
# https://stackoverflow.com/a/29754866
|
# https://stackoverflow.com/a/29754866
|
||||||
OPTIONS=p:dw:c:
|
OPTIONS=p:dw:c:h
|
||||||
LONGOPTS=proxy:,daemon,warning:,critical:
|
LONGOPTS=proxy:,daemon,warning:,critical:,help
|
||||||
|
|
||||||
# -use ! and PIPESTATUS to get exit code with errexit set
|
# -use ! and PIPESTATUS to get exit code with errexit set
|
||||||
# -temporarily store output to be able to check for errors
|
# -temporarily store output to be able to check for errors
|
||||||
@ -63,6 +64,9 @@ GetOptions() {
|
|||||||
crit="$2"
|
crit="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
Usage
|
||||||
|
exit 0;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user