🐛 agent v0.3.2: fix http service check
This commit is contained in:
parent
cffb05768b
commit
92e8080d7e
@ -52,9 +52,14 @@ var (
|
||||
ctx = context.Background()
|
||||
delayWhenError = time.Second * 10
|
||||
updateCh = make(chan struct{}, 0)
|
||||
httpClient = &http.Client{Transport: &http.Transport{
|
||||
httpClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}}
|
||||
},
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func doSelfUpdate() {
|
||||
@ -179,7 +184,7 @@ func doTask(task *pb.Task) {
|
||||
resp, err := httpClient.Get(task.GetData())
|
||||
if err == nil {
|
||||
result.Delay = float32(time.Now().Sub(start).Microseconds()) / 1000.0
|
||||
if resp.StatusCode > 299 || resp.StatusCode < 200 {
|
||||
if resp.StatusCode > 399 || resp.StatusCode < 200 {
|
||||
err = errors.New("\n应用错误:" + resp.Status)
|
||||
}
|
||||
}
|
||||
@ -192,6 +197,8 @@ func doTask(task *pb.Task) {
|
||||
result.Data = c.Issuer + "|" + c.NotAfter
|
||||
result.Successful = true
|
||||
}
|
||||
} else {
|
||||
result.Successful = true
|
||||
}
|
||||
} else {
|
||||
result.Data = err.Error()
|
||||
|
@ -9,15 +9,14 @@ import (
|
||||
"os/exec"
|
||||
"time"
|
||||
|
||||
"github.com/genkiroid/cert"
|
||||
"github.com/go-ping/ping"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
)
|
||||
|
||||
func main() {
|
||||
icmp()
|
||||
// icmp()
|
||||
// tcpping()
|
||||
// httpWithSSLInfo()
|
||||
httpWithSSLInfo()
|
||||
// diskinfo()
|
||||
}
|
||||
|
||||
@ -48,12 +47,14 @@ func httpWithSSLInfo() {
|
||||
transCfg := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
httpClient := &http.Client{Transport: transCfg}
|
||||
_, err := httpClient.Get("https://expired-ecc-dv.ssl.com")
|
||||
fmt.Println(err)
|
||||
httpClient := &http.Client{Transport: transCfg, CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
}}
|
||||
resp, err := httpClient.Get("http://mail.nai.ba")
|
||||
fmt.Println(err, resp.StatusCode)
|
||||
// SSL 证书信息获取
|
||||
c := cert.NewCert("expired-ecc-dv.ssl.com")
|
||||
fmt.Println(c.Error)
|
||||
// c := cert.NewCert("expired-ecc-dv.ssl.com")
|
||||
// fmt.Println(c.Error)
|
||||
}
|
||||
|
||||
func icmp() {
|
||||
|
Loading…
Reference in New Issue
Block a user