FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cloudstack/scripts/vm/pingtest.sh at vmsync-rebase · kwanggithub/cloudstack · GitHub
This repository was archived by the owner on Jan 15, 2020. It is now read-only.
kwanggithub
/
cloudstack
Public archive
forked from
apache/cloudstack
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cloudstack
/
scripts
/
vm
/
pingtest.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
168 lines (145 loc) · 3.36 KB
Breadcrumbs
cloudstack
/
scripts
/
vm
/
pingtest.sh
Copy path
File metadata and controls
executable file
·
168 lines (145 loc) · 3.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!
/usr/bin/env bash
#
Licensed to the Apache Software Foundation (ASF) under one
#
or more contributor license agreements. See the NOTICE file
#
distributed with this work for additional information
#
regarding copyright ownership. The ASF licenses this file
#
to you under the Apache License, Version 2.0 (the
#
"License"); you may not use this file except in compliance
#
with the License. You may obtain a copy of the License at
#
#
http://www.apache.org/licenses/LICENSE-2.0
#
#
Unless required by applicable law or agreed to in writing,
#
software distributed under the License is distributed on an
#
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#
KIND, either express or implied. See the License for the
#
specific language governing permissions and limitations
#
under the License.
#
$Id: pingtest.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/vm/pingtest.sh $
#
pingtest.sh -- ping
usage
() {
printf
"
Usage:\n %s -i <domR eth1 ip> -p <private-ip-address> \n
"
$(
basename
$0
)
>&2
printf
"
%s -h <computing-agent-host-ip> \n
"
$(
basename
$0
)
>&2
printf
"
%s -g \n
"
$(
basename
$0
)
>&2
}
check_gw
() {
ping -c 1 -n -q
$1
>
/dev/null
if
[
$?
-gt
0 ]
then
sleep 1
ping -c 1 -n -q
$1
>
/dev/null
fi
return
$?
;
}
#
ping the vm's private IP from the domR
ping_vm
() {
local
routerIp=
$1
local
vmIp=
$2
ssh -o StrictHostKeyChecking=no -p 3922 -i /root/.ssh/id_rsa.cloud root@
$routerIp
"
ping -c 1 -n -q
$vmIp
"
if
[
$?
-gt
0 ]
then
arping_vm
$routerIp
$vmIp
return
$?
fi
return
$?
;
}
arping_vm
() {
local
routerIp=
$1
local
vmIp=
$2
ssh -o StrictHostKeyChecking=no -p 3922 -i /root/.ssh/id_rsa.cloud root@
$routerIp
"
arping -c 1 -q
$vmIp
"
#
if return code of ping is > 0, the ping failed, return a result
if
[
$?
-gt
0 ]
then
return
1
fi
return
$?
;
}
#
ping the default route
ping_default_route
() {
defaultRoute=
`
route
|
grep default
|
awk
'
{print $2}
'
`
ping -c 1 -n -q
$defaultRoute
>
/dev/null
return
$?
}
#
ping the computing host
ping_host
() {
ping -c 1 -n -q
$1
>
/dev/null
if
[
$?
-gt
0 ]
then
return
1
fi
return
$?
;
}
iflag=
pflag=
hflag=
gflag=
while
getopts
'
i:p:h:g
'
OPTION
do
case
$OPTION
in
i) iflag=1
domRIp=
"
$OPTARG
"
;;
p) pflag=1
privateIp=
"
$OPTARG
"
;;
h) hflag=1
hostIp=
"
$OPTARG
"
;;
g) gflag=1
;;
?
) usage
exit
2
;;
esac
done
#
make sure both domRIp and vm private ip are set
if
[
"
$iflag$hflag$gflag
"
!=
"
1
"
]
then
usage
exit
2
fi
if
[
"
$iflag
"
==
"
1
"
]
then
if
[
"
$pflag
"
!=
"
1
"
]
then
usage
exit
3
fi
fi
if
[
"
$iflag
"
==
"
1
"
]
then
#
check if gateway domain is up and running
if
!
check_gw
"
$domRIp
"
then
printf
"
Unable to ping the routing domain, exiting\n
"
>&2
exit
4
fi
if
!
ping_vm
$domRIp
$privateIp
then
printf
"
Unable to ping the vm, exiting\n
"
>&2
exit
5
fi
fi
if
[
"
$hflag
"
==
"
1
"
]
then
if
!
ping_host
"
$hostIp
"
then
#
first ping default route to make sure we can get out successfully before returning error
if
!
ping_default_route
then
printf
"
Unable to ping default route, exiting\n
"
>&2
exit
7
fi
printf
"
Unable to ping computing host, exiting\n
"
>&2
exit
6
fi
fi
if
[
"
$gflag
"
==
"
1
"
]
then
if
!
ping_default_route
then
printf
"
Unable to ping default route\n
"
>&2
exit
8
fi
fi
exit
0
Back
|
FazBrowse Home
|
New Git URL