Skip to content

Conversation

nbertoldo
Copy link
Member

@nbertoldo nbertoldo commented Mar 27, 2025

Description

Closes #691

The Windows agent service is currently named "Wazuh Agent". This PR renames it to "wazuh-agent" to maintain consistency across all platforms.

Proposed Changes

The service name is updated in:

  • Installation and uninstallation by package scripts.
  • Methods for installing/uninstalling and starting/restarting/stopping the service (windows_service.cpp).
  • Related documentation

Documentation Updates

  • docs/dev/run-agent.md
  • docs/ref/backup-restore.md

Review Checklist

  • Code changes reviewed
  • Relevant evidence provided
  • Developer documentation reflects the changes
  • Meets requirements and/or definition of done
  • No unresolved dependencies with other issues

@nbertoldo nbertoldo self-assigned this Mar 27, 2025
@nbertoldo
Copy link
Member Author

nbertoldo commented Mar 27, 2025

Results and Evidence

Running wazuh-agent from sources 🟢

1. Agent enrollment 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> .\wazuh-agent.exe --enroll --enroll-url https://192.168.56.132:55000 --user wazuh --password topsecret --name dummy
Starting wazuh-agent enrollment
wazuh-agent enrolled

2. Install service 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> .\wazuh-agent --install-service
Agent log
[2025-03-27 19:03:04.455] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:139] [InstallService] wazuh-agent service successfully installed.

3. Check service name 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> Get-Service | Where-Object { $_.DisplayName -like "*wazuh*" }
Status   Name               DisplayName
------   ----               -----------
Stopped  wazuh-agent        wazuh-agent

4. Start service 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> Start-Service -Name "wazuh-agent"
Agent log
[2025-03-27 19:06:37.454] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:239] [ServiceMain] Starting wazuh-agent.

5. Restart service 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> Restart-Service -Name "wazuh-agent"
Agent log
[2025-03-28 16:51:58.358] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:84] [HandleStopSignal] wazuh-agent is stopping. Performing cleanup.
[2025-03-28 16:51:58.631] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:240] [ServiceMain] Starting wazuh-agent.

6. Stop service 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> Stop-Service -Name "wazuh-agent" 
Agent log
[2025-03-27 19:10:25.659] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:84] [HandleStopSignal] wazuh-agent is stopping. Performing cleanup.

7. Remove service 🟢

PS C:\Users\vagrant\source\repos\wazuh-agent\build\Debug> .\wazuh-agent --remove-service
Agent log
[2025-03-27 19:13:18.831] [wazuh-agent] [info] [INFO] [C:\Users\vagrant\source\repos\wazuh-agent\src\agent\src\windows\windows_service.cpp:173] [RemoveService] wazuh-agent service successfully removed.

Installing wazuh-agent from packages 🟡

1. Install package 🟢

Package: wazuh-agent_5.0.0-0_windows_449b667

PS C:\Users\vagrant> .\wazuh-agent_5.0.0-0_windows_449b667.msi /q 
PS C:\Users\vagrant>
Logs
[2025-03-27 20:17:27.090] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:139] [InstallService] wazuh-agent service successfully installed.
Windows Installer installed the product. Product Name: Wazuh Agent. Product Version: 5.0.0. Product Language: 1033. Manufacturer: Wazuh, Inc.. Installation success or error status: 0.

2. Check service name 🟢

PS C:\Users\vagrant> Get-Service | Where-Object { $_.DisplayName -like "*wazuh*" }

Status   Name               DisplayName
------   ----               -----------
Stopped  wazuh-agent        wazuh-agent 
Windows Service Manager

Captura desde 2025-03-27 17-20-32

3. Agent enrollment 🟢

PS C:\Program Files\wazuh-agent> .\wazuh-agent.exe --enroll --enroll-url https://192.168.56.132:55000 --user wazuh --password topsecret --name dummy
Starting wazuh-agent enrollment
wazuh-agent enrolled

4. Start service 🟢

PS C:\Users\vagrant> Start-Service -Name "wazuh-agent"
Agent Log
[2025-03-27 20:28:29.338] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:239] [ServiceMain] Starting wazuh-agent. 

5. Restart service 🟢

PS C:\Users\vagrant> Restart-Service -Name "wazuh-agent"
Agent Log
[2025-03-28 17:12:03.992] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:84] [HandleStopSignal] wazuh-agent is stopping. Performing cleanup.
[2025-03-28 17:12:04.273] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:239] [ServiceMain] Starting wazuh-agent.

6. Stop service 🟢

PS C:\Users\vagrant> Stop-Service -Name "wazuh-agent"
Agent Log
[2025-03-27 20:31:01.371] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:84] [HandleStopSignal] wazuh-agent is stopping. Performing cleanup.

7. Uninstall package 🟢

  • From powershell 🟢
PS C:\Users\vagrant> msiexec /x wazuh-agent_5.0.0-0_windows_449b667.msi /l*v uninstall.log
Logs
[2025-03-28 15:34:32.479] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:173] [RemoveService] wazuh-agent service successfully removed.
Windows Installer removed the product. Product Name: Wazuh Agent. Product Version: 5.0.0. Product Language: 1033. Manufacturer: Wazuh, Inc.. Removal success or error status: 0.
  • From "Add or remove programs" 🟢

Captura desde 2025-03-27 18-06-46

Logs
[2025-03-27 21:06:47.631] [wazuh-agent] [info] [INFO] [C:\Users\wazuh-user\wazuh-agent\src\agent\src\windows\windows_service.cpp:173] [RemoveService] wazuh-agent service successfully removed.
Windows Installer removed the product. Product Name: Wazuh Agent. Product Version: 5.0.0. Product Language: 1033. Manufacturer: Wazuh, Inc.. Removal success or error status: 0.

@nbertoldo nbertoldo marked this pull request as ready for review March 28, 2025 14:49
@nbertoldo nbertoldo requested a review from Copilot March 28, 2025 14:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the Windows agent service from "Wazuh Agent" to "wazuh-agent" to ensure consistency across platforms. The key changes include updates in documentation commands for starting and stopping the service.

Reviewed Changes

Copilot reviewed 2 out of 9 changed files in this pull request and generated no comments.

File Description
docs/ref/backup-restore.md Updates service commands for stopping and starting the service
docs/dev/run-agent.md Updates service commands for starting and stopping the service
Files not reviewed (7)
  • packages/windows/cleanup.ps1: Language not supported
  • packages/windows/postinstall.ps1: Language not supported
  • src/agent/restart_handler/src/restart_handler.cpp: Language not supported
  • src/agent/restart_handler/src/restart_handler_win.cpp: Language not supported
  • src/agent/src/windows/windows_service.cpp: Language not supported
  • src/agent/src/windows/windows_service.hpp: Language not supported
  • src/agent/tests/windows/windows_service_test.cpp: Language not supported

@nbertoldo nbertoldo requested review from LucioDonda and cborla March 28, 2025 14:51
Copy link
Member

@LucioDonda LucioDonda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@cborla cborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The executed examples are correct, I do not see the restart test, is it possible to generate it? the file restart_handler_win.cpp is modified, and contains the Restart-Service command.

@nbertoldo nbertoldo force-pushed the enhancement/691-rename-windows-agent-service branch from 449b667 to 8cd9e10 Compare March 28, 2025 17:06
Copy link
Member

@cborla cborla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

  • Code changes reviewed
  • Relevant evidence provided
  • Developer documentation reflects the changes
  • Meets requirements and/or definition of done
  • No unresolved dependencies with other issues

@cborla cborla merged commit 732c6d3 into main Mar 28, 2025
6 checks passed
@cborla cborla deleted the enhancement/691-rename-windows-agent-service branch March 28, 2025 18:49
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.

Rename Windows agent service

3 participants