mirror of
https://github.com/fankes/komari-agent.git
synced 2025-10-18 10:39:24 +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.
36 lines
725 B
Go
36 lines
725 B
Go
package monitoring
|
|
|
|
import (
|
|
"github.com/shirou/gopsutil/disk"
|
|
)
|
|
|
|
type DiskInfo struct {
|
|
Total uint64 `json:"total"`
|
|
Used uint64 `json:"used"`
|
|
}
|
|
|
|
func Disk() DiskInfo {
|
|
diskinfo := DiskInfo{}
|
|
usage, err := disk.Partitions(true)
|
|
if err != nil {
|
|
diskinfo.Total = 0
|
|
diskinfo.Used = 0
|
|
} else {
|
|
for _, part := range usage {
|
|
if part.Mountpoint != "/tmp" && part.Mountpoint != "/var/tmp" && part.Mountpoint != "/dev/shm" {
|
|
// Skip /tmp, /var/tmp, and /dev/shm
|
|
// 获取磁盘使用情况
|
|
u, err := disk.Usage(part.Mountpoint)
|
|
if err != nil {
|
|
diskinfo.Total = 0
|
|
diskinfo.Used = 0
|
|
} else {
|
|
diskinfo.Total += u.Total
|
|
diskinfo.Used += u.Used
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return diskinfo
|
|
}
|