Skip to content

Comments

Fixed CPU Usage spiking when RDP Monitoring is enabled#387

Merged
TibixDev merged 4 commits intoTibixDev:mainfrom
Kuritsu243:chore/fix-guest-cpu-usage
Oct 24, 2025
Merged

Fixed CPU Usage spiking when RDP Monitoring is enabled#387
TibixDev merged 4 commits intoTibixDev:mainfrom
Kuritsu243:chore/fix-guest-cpu-usage

Conversation

@Kuritsu243
Copy link
Contributor

When the "RDP Monitoring" Option is enabled in the WinBoat GUI, the guest VM tends to suffer from high CPU usage due to the amount of times that powershell.exe is being instanced. I have resolved this by letting the guest server use quser.exe, usually returns an output such as:

PS C:\Users\kuritsu> quser.exe
 USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME
>kuritsu               rdp-tcp#0           1  Active          .  10/21/2025 12:53 PM
PS C:\Users\kuritsu>

I have then updated main.go to let the output still be returnable in json format as expected by the remainder of the program, by implementing a new struct:

type StatusResponse struct {
	RdpConnection bool `json:"rdp_connection"`
}

and then updating the function "getRdpConnectedStatus" accordingly:

func getRdpConnectedStatus(w http.ResponseWriter, r *http.Request) {
	// Check for RDP Status via quser.exe
	cmd := exec.Command("quser.exe")
	output, err := cmd.Output()
	if err != nil {
		http.Error(w, "Failed to execute script: "+err.Error(), http.StatusInternalServerError)
		return
	}
	// Check if the output contains both "active" and "rdp" todo: Check for VNC Sessions
	hasRdpSession := strings.Contains(strings.ToLower(string(output)), "active") &&
		strings.Contains(strings.ToLower(string(output)), "rdp")

	response := StatusResponse{
		RdpConnection: hasRdpSession,
	}

	// Convert the response from guest server to JSON
	// Expected output { "rdp_connected": "true" } if a session is active
	jsonResponse, err := json.Marshal(response)
	if err != nil {
		http.Error(w, "Failed to marshal JSON response: "+err.Error(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	w.Write(jsonResponse)
}

CPU Usage on an idle VM as it is currently:

screenshot-2025-10-21_22-42-13

CPU Usage on an Idle VM with my method:

screenshot-2025-10-21_22-11-13

…d in the WinBoat GUI. Now checks for active sessions using 'quser.exe' instead of 'powershell.exe'.
@Kuritsu243
Copy link
Contributor Author

Will commit the changes shortly

@Kuritsu243
Copy link
Contributor Author

Should all be ready now :)

@Kuritsu243
Copy link
Contributor Author

image

Guest server now completely mirrors the original powershell output

@TibixDev
Copy link
Owner

Seems good now, thanks Kuritsu! 🎉

@TibixDev TibixDev merged commit 23053bb into TibixDev:main Oct 24, 2025
chevybowtie pushed a commit to chevybowtie/dosboat that referenced this pull request Feb 15, 2026
…#387)

* Fixed CPU Usage spiking in the guest VM when RDP Monitoring is enabled in the WinBoat GUI. Now checks for active sessions using 'quser.exe' instead of 'powershell.exe'.

* Updated naming of the struct for RDP Connection Status, should be ready to merge.

* Fixed RDP JSON Response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants