Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for agent self-restarting for Windows #552

Closed
2 tasks done
Tracked by #54
lchico opened this issue Jan 28, 2025 · 1 comment · Fixed by #627
Closed
2 tasks done
Tracked by #54

Add support for agent self-restarting for Windows #552

lchico opened this issue Jan 28, 2025 · 1 comment · Fixed by #627
Assignees
Labels

Comments

@lchico
Copy link
Member

lchico commented Jan 28, 2025

Parent issue:

Description

We need to develop a Minimum Viable Product (MVP) that enables the Wazuh agent to support a command for self-restart for Windows.

Functional requirements

  • The agent should accept a command to initiate a restart.
  • The agent should perform a clean restart, ensuring all processes are correctly shut down and restarted.
  • Log the restart event, including the timestamp and initiating command details.

Non-functional requirements

  • The restart process should not exceed a predefined time limit (e.g., 30 seconds) to minimize downtime.

Implementation restrictions

  • Start from the Spike issue: Agent command manager #4
  • Ensure that the implementation is thoroughly tested with unit tests and integration tests.

Plan

  • Add support for Windows agent self-restarting: Development Phase
    • Implement the command to initiate a restart.
    • Add logging for restart events.
  • Add support for Windows agent self-restarting: Testing Phase
    • Develop and execute unit tests for the new functionality.
    • Perform integration tests to ensure the command works across different environments.
@aritosteles
Copy link
Contributor

aritosteles commented Feb 24, 2025

Update

  • 21-02-2025:
    Setting up the environment. Getting up to date with the status of the Agent in Windows OS.
  • 24-02-2025:
    Trying to devise a strategy for the implementation of the Restart command.
    Ran into an issue with the configuration_parser which is not working with the default configuration file (and so the Windows agent won´t run as a service). There is an extra "/" at the beginning of the default path.

Image

Implementation of the Restart command in Windows doesn´t seem as straightforward as in other platforms. Windows SCM does not have a restart command and so the service can´t restart itself so easily. Looking for a solution.

  • 25-02-2025:
    Implemented restart command support for both the agent running in foreground and as a service. In the case of the service we opted for a Powershell command to restart the service. In the case of the agent running in foreground used a call to cmd with a delay to allow the running agent to close. Output is lost after restart same as what happens in linux. Will put PR ready for review.
  • 26-02-2025:
    Did some refactoring. Addressed issues that came up in the review. Changes merged.

@aritosteles aritosteles linked a pull request Feb 25, 2025 that will close this issue
8 tasks
@wazuhci wazuhci moved this from In progress to In review in XDR+SIEM/Release 5.0.0 Feb 26, 2025
@wazuhci wazuhci moved this from In review to Done in XDR+SIEM/Release 5.0.0 Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants