Skip to content

feat: Add Windows Server monitoring support via PowerShell over SSH#1251

Open
Ivydevdre wants to merge 3 commits intognmyt:mainfrom
Ivydevdre:feat/windows-monitoring
Open

feat: Add Windows Server monitoring support via PowerShell over SSH#1251
Ivydevdre wants to merge 3 commits intognmyt:mainfrom
Ivydevdre:feat/windows-monitoring

Conversation

@Ivydevdre
Copy link
Copy Markdown

What this PR does

Adds Windows Server monitoring support to the monitoring service.
Currently all metric collection uses Linux-specific commands (/proc/stat,
free -b, lsblk, etc.), which causes N/A for all metrics on Windows hosts.

Approach

  • Detects OS on connect by attempting to read /proc/version (Linux succeeds, Windows fails)
  • If Windows is detected, runs PowerShell equivalents via SSH for all metrics
  • Falls back to existing Linux collection path unchanged
  • Load Average returns null on Windows (no equivalent concept)

Windows metrics implemented

Metric PowerShell command
CPU Usage Get-WmiObject Win32_Processor
Memory Get-WmiObject Win32_OperatingSystem
Uptime gcim Win32_OperatingSystem LastBootUpTime
Disk Get-WmiObject Win32_LogicalDisk
Processes Get-Process
OS Info Win32_OperatingSystem + Win32_ComputerSystem
Network Get-NetAdapter + Get-NetAdapterStatistics

Tested on

  • Windows Server 2022 Datacenter (via Azure)
  • Ubuntu 24.04 (existing Linux monitoring unaffected)
  • Debian 12 (existing Linux monitoring unaffected)
Screenshot

@eduardomozart
Copy link
Copy Markdown
Contributor

It seems great, but please check the quality issues review from sonarqubecloud (those are small fixes as far as I'm concerned).
Also, I don't think that it should fall back to "Windows" simply because cat /proc/version fails. I think the code should try to run a WMI query and check the response before assumes "Windows".

@Ivydevdre
Copy link
Copy Markdown
Author

image

Fixed previous issues

@Ivydevdre
Copy link
Copy Markdown
Author

Fixed the two issues in our Windows code (optional chain on L79, replaceAll on L285). The remaining parseInt issues on L326-358 are in the pre-existing Linux metrics code, not part of this PR's changes — happy to fix those too if you'd like, but wanted to confirm before modifying code outside the scope of this PR.

@sonarqubecloud
Copy link
Copy Markdown

@eduardomozart
Copy link
Copy Markdown
Contributor

It seems great to me. I'll try to test into my environment, but we need to wait for review by other Nexterm developers.

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