mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-24 04:07:16 +00:00
improve: enhance VM disk usage detection for Windows guests (addresses #416)
- Add debug logging to guest agent filesystem API responses - Better handle Windows drive mountpoints (C:\, D:\, etc.) - Improve empty filesystem list detection and logging - Add specific handling for Windows filesystems that may report differently This should help diagnose why some VMs with guest agents installed still show 0% or missing disk usage, particularly on Windows systems.
This commit is contained in:
@@ -292,7 +292,10 @@ func (m *Monitor) pollVMsWithNodesOptimized(ctx context.Context, instanceName st
|
||||
Msg("Processing filesystem from guest agent")
|
||||
|
||||
// Skip special filesystems and Windows System Reserved
|
||||
if fs.Type == "tmpfs" || fs.Type == "devtmpfs" ||
|
||||
// For Windows, mountpoints are like "C:\\" or "D:\\" - don't skip those
|
||||
isWindowsDrive := len(fs.Mountpoint) >= 2 && fs.Mountpoint[1] == ':' && strings.Contains(fs.Mountpoint, "\\")
|
||||
|
||||
if !isWindowsDrive && (fs.Type == "tmpfs" || fs.Type == "devtmpfs" ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/dev") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/proc") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/sys") ||
|
||||
@@ -300,7 +303,7 @@ func (m *Monitor) pollVMsWithNodesOptimized(ctx context.Context, instanceName st
|
||||
fs.Mountpoint == "/boot/efi" ||
|
||||
fs.Mountpoint == "System Reserved" ||
|
||||
strings.Contains(fs.Mountpoint, "System Reserved") ||
|
||||
strings.HasPrefix(fs.Mountpoint, "/snap") { // Skip snap mounts
|
||||
strings.HasPrefix(fs.Mountpoint, "/snap")) { // Skip snap mounts
|
||||
log.Debug().
|
||||
Str("vm", vm.Name).
|
||||
Str("mountpoint", fs.Mountpoint).
|
||||
|
||||
+20
-3
@@ -913,6 +913,13 @@ func (c *Client) GetVMFSInfo(ctx context.Context, node string, vmid int) ([]VMFi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Log the raw response for debugging
|
||||
log.Debug().
|
||||
Str("node", node).
|
||||
Int("vmid", vmid).
|
||||
Str("response", string(bodyBytes)).
|
||||
Msg("Raw response from guest agent get-fsinfo")
|
||||
|
||||
// Try to unmarshal as an array first (expected format)
|
||||
var arrayResult struct {
|
||||
Data struct {
|
||||
@@ -961,10 +968,20 @@ func (c *Client) GetVMFSInfo(ctx context.Context, node string, vmid int) ([]VMFi
|
||||
}
|
||||
if err := json.Unmarshal(bodyBytes, &objectResult); err == nil {
|
||||
// If result is an object, it might be an error or empty response
|
||||
// Check if it's null or an error
|
||||
if objectResult.Data.Result == nil {
|
||||
log.Debug().
|
||||
Str("node", node).
|
||||
Int("vmid", vmid).
|
||||
Msg("GetVMFSInfo received null result - guest agent may not be providing disk info")
|
||||
} else {
|
||||
log.Debug().
|
||||
Str("node", node).
|
||||
Int("vmid", vmid).
|
||||
Interface("result", objectResult.Data.Result).
|
||||
Msg("GetVMFSInfo received object instead of array")
|
||||
}
|
||||
// Return empty array to indicate no filesystem info available
|
||||
log.Debug().
|
||||
Interface("result", objectResult.Data.Result).
|
||||
Msg("GetVMFSInfo received object instead of array, returning empty")
|
||||
return []VMFileSystem{}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user