#!/bin/bash
#根据测试背景填写连接超时时长,单位秒
ct=5
#根据测试背景填写响应最大时长,单位秒
cm=5
#根据测试背景填写URL
#uri1=“http://10.10.160.23/nedy/123_init”
#uri2=“http://10.10.160.24/sso/345_list” #
SERVERHOST=“10.10.160.23 10.10.160.24”
#查看API状态
for i in
S
E
R
V
E
R
H
O
S
T
d
o
r
e
s
p
1
=
‘
c
u
r
l
−
I
−
s
−
−
c
o
n
n
e
c
t
−
t
i
m
e
o
u
t
"
SERVERHOST do resp1=`curl -I -s --connect-timeout "
SERVERHOSTdoresp1=‘curl−I−s−−connect−timeout"ct" -m “
c
m
"
−
w
"
cm" -w "%{http_code}" -o /dev/null http://"
cm"−w"i”/nedy/123_initt resp2=
curl -I -s --connect-timeout “
c
t
"
−
m
"
ct" -m "
ct"−m"cm” -w “%{http_code}” -o /dev/null http://“$i”/sso/345_list`
if [
r
e
s
p
1
=
=
200
]
;
t
h
e
n
e
c
h
o
"
resp1 == 200 ] ; then echo "
resp1==200];thenecho"i ===API01 status 200 ok"
else
echo “$i ===API01 status faild”
fi
#查看API状态
if [
r
e
s
p
2
=
=
200
]
;
t
h
e
n
e
c
h
o
"
resp2 == 200 ] ; then echo "
resp2==200];thenecho"i ===API01 status 200 ok"
else
echo “$i ===API02 status faild”
fi
done