Refactor monitoring package: remove platform-specific files and consolidate OS detection and process counting logic

- Deleted os_windows.go and process_windows.go, replacing them with platform-agnostic implementations in unit directory.
- Removed Linux-specific process counting logic from process_linux.go and integrated it into unit.
- Consolidated uptime and OS name retrieval into unit files for better organization.
- Updated update mechanism to use global variables for current version and repository.
- Introduced command-line flags for configuration, including disabling auto-update and web SSH.
- Implemented WebSocket connection handling and terminal interaction for both Unix and Windows systems.
- Added basic info upload functionality to server package, enhancing monitoring capabilities.
This commit is contained in:
Akizon77
2025-05-16 19:56:22 +08:00
parent b156e93409
commit e34367de69
26 changed files with 752 additions and 461 deletions

View File

@@ -0,0 +1,23 @@
//go:build windows
// +build windows
package monitoring
import (
"golang.org/x/sys/windows/registry"
)
func OSName() string {
key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
if err != nil {
return "Microsoft Windows"
}
defer key.Close()
productName, _, err := key.GetStringValue("ProductName")
if err != nil {
return "Microsoft Windows"
}
return productName
}