Skip to content

Commit

Permalink
Merge 8a777fa into 5dc5a4a
Browse files Browse the repository at this point in the history
  • Loading branch information
srstack authored Jan 11, 2022
2 parents 5dc5a4a + 8a777fa commit 267d0f3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ replace (
)

require (
github.com/AstroProfundis/sysinfo v0.0.0-20210901042104-765f00aa1304
github.com/AstroProfundis/sysinfo v0.0.0-20211201040748-b52c88acb418
github.com/AstroProfundis/tabby v1.1.1-color
github.com/BurntSushi/toml v0.4.1
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
Expand Down Expand Up @@ -42,15 +42,15 @@ require (
github.com/pingcap/failpoint v0.0.0-20210918120811-547c13e3eb00
github.com/pingcap/fn v0.0.0-20200306044125-d5540d389059
github.com/pingcap/kvproto v0.0.0-20210915062418-0f5764a128ad
github.com/pingcap/tidb-insight/collector v0.0.0-20210923072556-14ae4968ce78
github.com/pingcap/tidb-insight/collector v0.0.0-20220104095042-8dad166491c2
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.30.0
github.com/prometheus/prom2json v1.3.0
github.com/r3labs/diff/v2 v2.14.0
github.com/relex/aini v1.5.0
github.com/sergi/go-diff v1.2.0
github.com/sethvargo/go-password v0.2.0
github.com/shirou/gopsutil v3.21.8+incompatible
github.com/shirou/gopsutil v3.21.10+incompatible
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
Expand All @@ -64,7 +64,7 @@ require (
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/mod v0.5.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf
google.golang.org/genproto v0.0.0-20210921142501-181ce0d877f6
google.golang.org/grpc v1.40.0
Expand Down
17 changes: 8 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20211209071554-9910ebdf514e h1:4j6hTmpAhrJYt8XhG/mLJYywzsclH6pqAim1H7HBM/o=
github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20211209071554-9910ebdf514e/go.mod h1:SnOlkuIAoaj8FvRIGcWp2BbLOwvHZnNNOva+DBMbHWU=
github.com/AstroProfundis/sysinfo v0.0.0-20210901042104-765f00aa1304 h1:xjoJdgLCgiPv8CNEnsHP+W6UJ/JiNbALll6csqw3hbg=
github.com/AstroProfundis/sysinfo v0.0.0-20210901042104-765f00aa1304/go.mod h1:4m15VhW6ZffaqJNAK/HtN3Qvf97aCe1T39u3UXaA2lA=
github.com/AstroProfundis/sysinfo v0.0.0-20211201040748-b52c88acb418 h1:mBWbJ+qSooaOMIAaSOtzA8PYDfhwyUWAJYT4AM8Rtoc=
github.com/AstroProfundis/sysinfo v0.0.0-20211201040748-b52c88acb418/go.mod h1:WP2xTB42TPPFNpTmPiOm4Zjm9jdHwhi8wrMYGAv1BRA=
github.com/AstroProfundis/tabby v1.1.1-color h1:gi/Fs4W2KVcC1m29lqa39tDnsGfZG/PYvZmwOhAH5m0=
github.com/AstroProfundis/tabby v1.1.1-color/go.mod h1:Wcm+uinH1saEOFGLK2LdY37lAOts8HLevz64Y3y3M3Q=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
Expand Down Expand Up @@ -430,8 +430,8 @@ github.com/pingcap/kvproto v0.0.0-20210915062418-0f5764a128ad h1:suBPTeuY6yVF7xv
github.com/pingcap/kvproto v0.0.0-20210915062418-0f5764a128ad/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9 h1:AJD9pZYm72vMgPcQDww9rkZ1DnWfl0pXV3BOWlkYIjA=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/tidb-insight/collector v0.0.0-20210923072556-14ae4968ce78 h1:JN3fWkxAJ78atG2uo2dcTN8sleJhsr+TrnsMfrlu0do=
github.com/pingcap/tidb-insight/collector v0.0.0-20210923072556-14ae4968ce78/go.mod h1:k+GJKVPIdlV/J6hGJy7VKsxRVWV99BJfDKXGVrs4vH4=
github.com/pingcap/tidb-insight/collector v0.0.0-20220104095042-8dad166491c2 h1:r+nBxodqYUS1cEZh3MQfy3R5WEmnIC9yLAJbrwlFtHM=
github.com/pingcap/tidb-insight/collector v0.0.0-20220104095042-8dad166491c2/go.mod h1:w04Qnjn8hiTNR4fTMgm4+TfXtDBcCq2i1SKlXwqX69o=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -485,8 +485,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sethvargo/go-password v0.2.0 h1:BTDl4CC/gjf/axHMaDQtw507ogrXLci6XRiLc7i/UHI=
github.com/sethvargo/go-password v0.2.0/go.mod h1:Ym4Mr9JXLBycr02MFuVQ/0JHidNetSgbzutTr3zsYXE=
github.com/shirou/gopsutil v3.21.8+incompatible h1:sh0foI8tMRlCidUJR+KzqWYWxrkuuPIGiO6Vp+KXdCU=
github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.10+incompatible h1:AL2kpVykjkqeN+MFe1WcwSBVUjGjvdU8/ubvCuXAjrU=
github.com/shirou/gopsutil v3.21.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down Expand Up @@ -782,9 +782,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210921065528-437939a70204/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 h1:c20P3CcPbopVp2f7099WLOqSNKURf30Z0uq66HpijZY=
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf h1:Ihq/mm/suC88gF8WFcVwk+OV6Tq+wyA1O0E5UEvDglI=
Expand Down
42 changes: 39 additions & 3 deletions pkg/cluster/operation/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type CheckOptions struct {
var (
CheckNameGeneral = "general" // errors that don't fit any specific check
CheckNameNTP = "ntp"
CheckNameChrony = "chrony"
CheckNameOSVer = "os-version"
CheckNameSwap = "swap"
CheckNameSysctl = "sysctl"
Expand Down Expand Up @@ -112,8 +113,21 @@ func CheckSystemInfo(opt *CheckOptions, rawData []byte) []*CheckResult {
// check basic system info
results = append(results, checkSysInfo(opt, &insightInfo.SysInfo)...)

// check NTP sync status
results = append(results, checkNTP(&insightInfo.NTP))
// check time sync status
switch {
case insightInfo.ChronyStat.LeapStatus != "none":
results = append(results, checkChrony(&insightInfo.ChronyStat))
case insightInfo.NTP.Status != "none":
results = append(results, checkNTP(&insightInfo.NTP))
default:
results = append(results,
&CheckResult{
Name: CheckNameNTP,
Err: fmt.Errorf("The NTPd daemon or Chronyd daemon may be not installed"),
Warn: true,
},
)
}

epollResult := &CheckResult{
Name: CheckNameEpoll,
Expand Down Expand Up @@ -202,11 +216,33 @@ func checkNTP(ntpInfo *insight.TimeStat) *CheckResult {
return result
}

if ntpInfo.Sync == "none" {
result.Err = fmt.Errorf("The NTPd daemon may be not start")
result.Warn = true
return result
}

// check if time offset greater than +- 500ms
if math.Abs(ntpInfo.Offset) >= 500 {
result.Err = fmt.Errorf("time offet %fms too high", ntpInfo.Offset)
result.Err = fmt.Errorf("time offset %fms too high", ntpInfo.Offset)
}
return result
}

func checkChrony(chronyInfo *insight.ChronyStat) *CheckResult {
result := &CheckResult{
Name: CheckNameChrony,
}

if chronyInfo.LeapStatus == "none" {
zap.L().Info("The Chrony daemon may be not installed, skip.")
return result
}

// check if time offset greater than +- 500ms
if math.Abs(chronyInfo.LastOffset) >= 500 {
result.Err = fmt.Errorf("time offset %fms too high", chronyInfo.LastOffset)
}
return result
}

Expand Down

0 comments on commit 267d0f3

Please sign in to comment.