Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### Start
- iPorts=$1
- cTimeout=$2
- if [ $# != 2 ]; then
- echo "Usage: $0 ports timeout"
- exit 1
- fi
- wget=$(which wget)
- cCheckName="Merb Ports"
- tMessage="Fail ports: "
- countFails=0
- exitStatus=0
- if [ -x /usr/share/boo-box/plugins/utils.sh ]; then
- . /usr/share/boo-box/plugins/utils.sh
- fi
- for port in $(seq 0 $iPorts)
- do
- port=$((4000 + $port))
- $wget -q -T $cTimeout --tries=2 http://localhost:$port -O /dev/null
- if [ $? != 0 ]; then
- countFails=$((countFails + 1))
- tMessage="${tMessage}$port "
- fi
- done
- if [ $countFails -eq 0 ]; then
- tMessage="Everything OK"
- elif [ $countFails -le 1 ]; then
- tMessage="OK ${tMessage}"
- elif [ $countFails -gt 1 ] || [ $countFails -le 5 ]; then
- exitStatus=1
- elif [ $countFails -gt 5 ]; then
- exitStatus=2
- fi
- alert_nagios "$cCheckName" "$exitStatus" "$tMessage"
- exit 0
- ### End
Advertisement
Add Comment
Please, Sign In to add comment