From fb68a6aca76a35a01987f126399d504b5a07b482 Mon Sep 17 00:00:00 2001 From: Faye Amacker <33205765+fxamacker@users.noreply.github.com> Date: Wed, 23 Mar 2022 14:47:11 -0500 Subject: [PATCH] Add logs for system specs Add CPU microcode revision Add OS, Platform, PlatformVersion, KernelVersion, Uptime Add Go version, GOMAXPROCS, NumCPU --- cmd/execution/main.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/cmd/execution/main.go b/cmd/execution/main.go index 483900a25d7..46a4cff37bf 100644 --- a/cmd/execution/main.go +++ b/cmd/execution/main.go @@ -7,6 +7,7 @@ import ( "os" "path" "path/filepath" + goruntime "runtime" "time" awsconfig "github.com/aws/aws-sdk-go-v2/config" @@ -16,6 +17,7 @@ import ( "github.com/onflow/cadence/runtime" "github.com/rs/zerolog" cpu "github.com/shirou/gopsutil/v3/cpu" + host "github.com/shirou/gopsutil/v3/host" mem "github.com/shirou/gopsutil/v3/mem" "github.com/spf13/pflag" @@ -202,11 +204,11 @@ func main() { ) return err }). - Module("hardware specs", func(node *cmd.NodeConfig) error { - hwLogger := node.Logger.With().Str("system", "hardware").Logger() - err = logHardware(hwLogger) + Module("system specs", func(node *cmd.NodeConfig) error { + sysInfoLogger := node.Logger.With().Str("system", "specs").Logger() + err = logSysInfo(sysInfoLogger) if err != nil { - hwLogger.Error().Err(err) + sysInfoLogger.Error().Err(err) } return nil }). @@ -838,7 +840,7 @@ func copyBootstrapState(dir, trie string) error { return out.Close() } -func logHardware(logger zerolog.Logger) error { +func logSysInfo(logger zerolog.Logger) error { vmem, err := mem.VirtualMemory() if err != nil { @@ -864,10 +866,21 @@ func logHardware(logger zerolog.Logger) error { return fmt.Errorf("cpu info length is 0") } - logger.Info().Msgf("CPU: ModelName=%s, MHz=%.0f, Family=%s, Model=%s, Stepping=%d, PhysicalCores=%d, LogicalCores=%d", - info[0].ModelName, info[0].Mhz, info[0].Family, info[0].Model, info[0].Stepping, physicalCores, logicalCores) + logger.Info().Msgf("CPU: ModelName=%s, MHz=%.0f, Family=%s, Model=%s, Stepping=%d, Microcode=%s, PhysicalCores=%d, LogicalCores=%d", + info[0].ModelName, info[0].Mhz, info[0].Family, info[0].Model, info[0].Stepping, info[0].Microcode, physicalCores, logicalCores) logger.Info().Msgf("RAM: Total=%d, Free=%d", vmem.Total, vmem.Free) + hostInfo, err := host.Info() + if err != nil { + return fmt.Errorf("failed to get platform info: %w", err) + } + logger.Info().Msgf("OS: OS=%s, Platform=%s, PlatformVersion=%s, KernelVersion=%s, Uptime: %d", + hostInfo.OS, hostInfo.Platform, hostInfo.PlatformVersion, hostInfo.KernelVersion, hostInfo.Uptime) + + // goruntime.GOMAXPROCS(0) doesn't modify any settings. + logger.Info().Msgf("GO: GoVersion=%s, GOMAXPROCS=%d, NumCPU=%d", + goruntime.Version(), goruntime.GOMAXPROCS(0), goruntime.NumCPU()) + return nil }