Skip to content

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Siumauricio committed Jan 4, 2025
1 parent e9adf9a commit 3292aa0
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions apps/golang/monitoring/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package monitoring

import (
"fmt"
"log"
"runtime"
"time"

Expand Down Expand Up @@ -43,6 +44,26 @@ func GetServerMetrics() database.ServerMetric {
netInfo, _ := net.IOCounters(false)
hostInfo, _ := host.Info()

// CPU
// Apple M1 Pro

// 8 Physical Cores (8 Threads) @ 2.4GHz

// Operating System
// macOS

// Kernel: 23.4.0 (arm64)

// CPU
// Apple M1 Pro

// 1 Physical Cores (8 Threads) @ 3228GHz

// Operating System
// darwin

// Kernel: 23.4.0 (arm64)

cpuModel := ""
if len(cpuInfo) > 0 {
cpuModel = fmt.Sprintf("%s %s", cpuInfo[0].VendorID, cpuInfo[0].ModelName)
Expand All @@ -59,13 +80,13 @@ func GetServerMetrics() database.ServerMetric {
networkIn = float64(netInfo[0].BytesRecv) / 1024 / 1024
networkOut = float64(netInfo[0].BytesSent) / 1024 / 1024
}

log.Printf("Host Info: %v, Network In: %f MB, Network Out: %f MB", hostInfo, networkIn, networkOut)
return database.ServerMetric{
Timestamp: time.Now().Unix(),
CPU: c[0],
CPUModel: cpuModel,
CPUCores: int32(runtime.NumCPU()),
CPUPhysicalCores: int32(len(cpuInfo)),
CPUPhysicalCores: int32(runtime.NumCPU()), // En Apple Silicon, los cores físicos son iguales a los lógicos
CPUSpeed: float64(cpuInfo[0].Mhz),
OS: hostInfo.OS,
Distro: hostInfo.Platform,
Expand Down

0 comments on commit 3292aa0

Please sign in to comment.