提交 abbb0848 编写于 作者: 张文治(治)'s avatar 张文治(治)

Add new file

上级 72b103fc
package main
func getHealth() {
start := time.Now()
tr := &http.Transport {
TLSClientConfig: &tls.Config { InsecureSkipVerify: true},
}
client := &http.Client {Transport: tr} // 忽略证书校验
resp, err := client.Get("https://baidu.com/health")
if err != nil {
fmt.Println("get error: ", err)
return
}
// defer resp.Body.Close()
fmt.Println("get resp.Status: ", resp.Status)
body, err := ioutil.ReadAll(resp.Body)
fmt.Println("resp.Body", string(resp.Body))
elapsed := time.Since(start)
if strings.Contains(resp.Status, "200") {
bommer.RecordSuccess("https", "/health", elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))
} else {
boomer.RecordFailure("https", "/health", elapsed.Nanoseconds()/int64(time.Millisecond), "health not equal 200!")
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
fmt.Println("Body.Close() error: ", err)
}(resp.Body)
}
}
func postApiWebhook() {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册