1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #Copyright (C) 2016,2023 Weber Yann
- #
- #This program is free software; you can redistribute it and/or modify
- #it under the terms of the GNU General Public License as published by
- #the Free Software Foundation; either version 3 of the License, or
- #any later version.
- #
- #This program is distributed in the hope that it will be useful,
- #but WITHOUT ANY WARRANTY; without even the implied warranty of
- #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- #GNU General Public License for more details.
- #
- #You should have received a copy of the GNU General Public License
- #along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- check_ping() {
- hostname=$1
- count=$2
- proto="$3"
- if [ -z "$count" ]
- then
- count=5
- fi
- case "$proto" in
- ipv4)
- protoping="ping -4";;
- ipv6)
- protoping="ping -6";;
- *)
- protoping="ping";;
- esac
-
- if $protoping -i 0.2 -c "$count" "$hostname" >/dev/null
- then
- success "successfully send $count ping to '$hostname'"
- else
- fail "unable to ping '$hostname'"
- fi
- }
-
- check_dns() {
- hostname=$1
- field=$2
- expt=$3
- result=$(dig +short "$hostname" "$field")
- if echo "$result" | grep -e "$expt" >/dev/null
- then
- success "DNS replied '$expt' for '$field $hostname'"
- else
- fail "Unexpected DNS reply '$result' expecting '$expt' for '$hostname $field'"
- fi
- }
|