Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logs with more system specs #2187

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions cmd/execution/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path"
"path/filepath"
goruntime "runtime"
"time"

awsconfig "github.com/aws/aws-sdk-go-v2/config"
Expand All @@ -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"

Expand Down Expand Up @@ -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
}).
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}