-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker.go
40 lines (33 loc) · 1.03 KB
/
checker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package funcs
import (
"fmt"
"github.com/toolkits/nux"
"github.com/toolkits/sys"
)
func CheckCollector() {
output := make(map[string]bool)
_, procStatErr := nux.CurrentProcStat()
_, listDiskErr := nux.ListDiskStats()
ports, listeningPortsErr := nux.ListeningPorts()
procs, psErr := nux.AllProcs()
_, duErr := sys.CmdOut("du", "--help")
output["kernel "] = len(KernelMetrics()) > 0
output["df.bytes"] = len(DeviceMetrics()) > 0
output["net.if "] = len(CoreNetMetrics([]string{})) > 0
output["loadavg "] = len(LoadAvgMetrics()) > 0
output["cpustat "] = procStatErr == nil
output["disk.io "] = listDiskErr == nil
output["memory "] = len(MemMetrics()) > 0
output["netstat "] = len(NetstatMetrics()) > 0
output["ss -s "] = len(SocketStatSummaryMetrics()) > 0
output["ss -tln "] = listeningPortsErr == nil && len(ports) > 0
output["ps aux "] = psErr == nil && len(procs) > 0
output["du -bs "] = duErr == nil
for k, v := range output {
status := "fail"
if v {
status = "ok"
}
fmt.Println(k, "...", status)
}
}