1 #! /usr/bin/ksh -p 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 23 # 24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25 # Use is subject to license terms. 26 # 27 # ident "@(#)ce_host_reachable.ksh 1.4 07/11/09 SMI" 28 # 29 30 # 31 # Function ce_host_reachable 32 # 33 # This function checks whether the host is reachable 34 # 35 # Args: 36 # $1 - host name 37 # 38 function ce_host_reachable 39 { 40 print "checkenv: ce_host_reachable($*)" 41 42 errmsg="usage: ce_host_reachable <host_name>" 43 [ $# -ne 1 ] && abort $errmsg 44 45 req_label="the host is reachable or not" 46 req_value="$1" 47 48 if [ $OPERATION == "dump" ]; then 49 ce_host_reachable_doc 50 return $PASS 51 fi 52 53 errmsg="$req_value is unreachable" 54 result=FAIL 55 if [ $OPERATION == "verify" ]; then 56 /usr/sbin/ping $1 > /dev/null 2>&1 57 [[ $? -eq 0 ]] && errmsg="" && result=PASS 58 fi 59 60 print_line $TASK "$req_label" "$req_value" "$result" "$errmsg" 61 eval return \$$result 62 } 63 64 function ce_host_reachable_doc 65 { 66 cat >&1 << EOF 67 68 Check ce_host_reachable 69 ================================= 70 Description: 71 check whether the host is reachable 72 Arguments: 73 #1 - host name 74 Requirement label (for this check): 75 $req_label 76 Requirement value (for this check): 77 $req_value 78 EOF 79 } 80