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