mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 02:44:59 +00:00
Adds diagnostics CPUArch field
This commit is contained in:
parent
1706e9b4e1
commit
2830fb46e6
4 changed files with 24 additions and 11 deletions
|
|
@ -174,6 +174,11 @@ func (d *diagnosticsCollector) logErr(err error) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// EnrichWithCPUInfo adds CPU information to the diagnostics payload.
|
||||
func (d *diagnosticsCollector) EnrichWithCPUInfo() {
|
||||
d.Set("CPUArch", d.server.systemInfo.CPUArch())
|
||||
}
|
||||
|
||||
// EnrichWithOSInfo adds OS information to the diagnostics payload.
|
||||
func (d *diagnosticsCollector) EnrichWithOSInfo() {
|
||||
uptime, err := d.server.systemInfo.Uptime()
|
||||
|
|
@ -265,6 +270,7 @@ type SystemInfo interface {
|
|||
MemFree() (uint64, error)
|
||||
MemTotal() (uint64, error)
|
||||
MemUsed() (uint64, error)
|
||||
CPUArch() string
|
||||
}
|
||||
|
||||
// newNopSystemInfo creates a no-op implementation of SystemInfo.
|
||||
|
|
@ -315,3 +321,8 @@ func (n *nopSystemInfo) MemTotal() (uint64, error) {
|
|||
func (n *nopSystemInfo) MemUsed() (uint64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// CPUArch returns the CPU architecture, such as amd64
|
||||
func (n *nopSystemInfo) CPUArch() string {
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
package gopsutil
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
|
|
@ -109,6 +111,11 @@ func (s *systemInfo) KernelVersion() (string, error) {
|
|||
return host.KernelVersion()
|
||||
}
|
||||
|
||||
// CPUArch returns the CPU architecture, such as amd64
|
||||
func (s *systemInfo) CPUArch() string {
|
||||
return runtime.GOARCH
|
||||
}
|
||||
|
||||
// NewSystemInfo is a constructor for the gopsutil implementation of SystemInfo.
|
||||
func NewSystemInfo() *systemInfo {
|
||||
return &systemInfo{}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
package gopsutil_test
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/pilosa/pilosa"
|
||||
|
|
@ -25,15 +24,6 @@ import (
|
|||
func TestSystemInfo(t *testing.T) {
|
||||
var systemInfo pilosa.SystemInfo = gopsutil.NewSystemInfo()
|
||||
|
||||
// Uptime()(uint64, error)
|
||||
// Platform()(string, error)
|
||||
// Family()(string, error)
|
||||
// OSVersion()(string, error)
|
||||
// KernelVersion()(string, error)
|
||||
// MemFree()(uint64, error)
|
||||
// MemTotal()(uint64, error)
|
||||
// MemUsed()(uint64, error)
|
||||
//
|
||||
uptime, err := systemInfo.Uptime()
|
||||
if err != nil || uptime == 0 {
|
||||
t.Fatalf("Error collecting uptime (error: %v)", err)
|
||||
|
|
@ -70,8 +60,12 @@ func TestSystemInfo(t *testing.T) {
|
|||
}
|
||||
|
||||
memtotal, err := systemInfo.MemTotal()
|
||||
log.Println(memtotal)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting memtotal. (memtotal: %v, error: %v)", memtotal, err)
|
||||
}
|
||||
|
||||
cpuArch := systemInfo.CPUArch()
|
||||
if cpuArch == "" {
|
||||
t.Fatalf("Error getting CPU arch.")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -675,6 +675,7 @@ func (s *Server) monitorDiagnostics() {
|
|||
s.diagnostics.Set("NumCPU", runtime.NumCPU())
|
||||
s.diagnostics.Set("NodeID", s.nodeID)
|
||||
s.diagnostics.Set("ClusterID", s.cluster.id)
|
||||
s.diagnostics.EnrichWithCPUInfo()
|
||||
s.diagnostics.EnrichWithOSInfo()
|
||||
|
||||
// Flush the diagnostics metrics at startup, then on each tick interval
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue