mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-19 02:59:23 +08:00
- 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.
33 lines
491 B
Go
33 lines
491 B
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package monitoring
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func OSName() string {
|
|
file, err := os.Open("/etc/os-release")
|
|
if err != nil {
|
|
return "Linux"
|
|
}
|
|
defer file.Close()
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
for scanner.Scan() {
|
|
line := scanner.Text()
|
|
if strings.HasPrefix(line, "PRETTY_NAME=") {
|
|
return strings.Trim(line[len("PRETTY_NAME="):], `"`)
|
|
}
|
|
}
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
return "Linux"
|
|
}
|
|
|
|
return "Linux"
|
|
}
|