30 lines
449 B
Bash
Executable File
30 lines
449 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
WWW_PATH="/cgi-bin/stations"
|
|
|
|
while getopts ":p:h:" opt; do
|
|
case $opt in
|
|
p)
|
|
WWW_PATH="$OPTARG"
|
|
;;
|
|
h)
|
|
HOST="$OPTARG"
|
|
;;
|
|
\?)
|
|
echo "Invalid option: -$OPTARG"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
OUTPUT="UNKNOWN: Script failed"
|
|
EXIT_CODE=3
|
|
|
|
stations=$(curl -s http://$HOST$WWW_PATH | wc -l)
|
|
VALUE="|Stations=$stations"
|
|
OUTPUT="OK: $stations Stations"
|
|
EXIT_CODE=0
|
|
|
|
echo "$OUTPUT" "$VALUE"
|
|
exit $EXIT_CODE
|