package main import ( "encoding/json" "fmt" "log" "path/filepath" "runtime" "github.com/redflag-aggregator/aggregator-agent/internal/system" ) func main() { // Get the absolute path to this file's directory _, filename, _, _ := runtime.Caller(0) dir := filepath.Dir(filename) // Change to the project root to find the go.mod file projectRoot := filepath.Dir(dir) // Test lightweight metrics (most common use case) fmt.Println("=== Enhanced Lightweight Metrics Test ===") metrics, err := system.GetLightweightMetrics() if err != nil { log.Printf("Error getting lightweight metrics: %v", err) } else { // Pretty print the JSON jsonData, _ := json.MarshalIndent(metrics, "", " ") fmt.Printf("LightweightMetrics:\n%s\n\n", jsonData) // Show key findings fmt.Printf("Root Disk: %.1fGB used / %.1fGB total (%.1f%%)\n", metrics.DiskUsedGB, metrics.DiskTotalGB, metrics.DiskPercent) if metrics.LargestDiskTotalGB > 0 { fmt.Printf("Largest Disk (%s): %.1fGB used / %.1fGB total (%.1f%%)\n", metrics.LargestDiskMount, metrics.LargestDiskUsedGB, metrics.LargestDiskTotalGB, metrics.LargestDiskPercent) } } // Test full system info (detailed disk inventory) fmt.Println("\n=== Enhanced System Info Test ===") sysInfo, err := system.GetSystemInfo("test-v0.1.5") if err != nil { log.Printf("Error getting system info: %v", err) } else { fmt.Printf("Found %d disks:\n", len(sysInfo.DiskInfo)) for i, disk := range sysInfo.DiskInfo { fmt.Printf(" Disk %d: %s (%s) - %s, %.1fGB used / %.1fGB total (%.1f%%)", i+1, disk.Mountpoint, disk.Filesystem, disk.DiskType, float64(disk.Used)/(1024*1024*1024), float64(disk.Total)/(1024*1024*1024), disk.UsedPercent) if disk.IsRoot { fmt.Printf(" [ROOT]") } if disk.IsLargest { fmt.Printf(" [LARGEST]") } fmt.Printf("\n") } } }