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

Windows Support Phase 1 #17497

Merged
merged 158 commits into from May 16, 2024
Merged

Windows Support Phase 1 #17497

merged 158 commits into from May 16, 2024

Conversation

ktsaou
Copy link
Member

@ktsaou ktsaou commented Apr 23, 2024

Implements partially #92


  • CYGWIN support
  • MSYS2 support (compile with profile MSYSTEM=MSYS)
  • Clion support on Windows (builds with MSYSTEM=MSYS and CYGWIN)
  • HKEY_PERFORMANCE_DATA (known as Performance Counters, or perflib) library for accessing any raw low-level windows performance data. This has been implemented in the netdata way, for fast access to these counters.
  • Basic plugins for collecting CPU, Memory, Network, Disks and Volumes metrics.

Global changes in Netdata:

  • O/S abstractions are kepts in src/libnetdata/os.
  • Only the UUID generations are used from libuuid. All the other calls are now implemented in libnetdata/uuid. On Windows native windows calls are used to generate UUIDs.
  • uuid_t has been renamed to nd_uuid_t because it conflicts with windows definitions.
  • detached threads are now implemented using joinable threads. Cleanup is automatic. Every time a new thread is created exited threads are joined and memory is freed.
  • replaced calls to netdata_thread_cleanup_push() and netdata_thread_cleanup_pop() with __attribute__((cleanup(...))). This was problematic on windows (calling the destructor multiple times) and it also helps us achieve pthreads independence.
  • phtread_cancel() has been eliminated from the code base. It has been replaced with a new mechanism to signal the threads which check for such cancellation signals without blocking on I/O (reads, writes, connections, sleep, etc).
  • enable/disable cancelability has been removed from the code base (since now threads can only voluntarily exit).

Issues remaining

  • Netdata can only be compiled with the POSIX compatibility on (MSYS2 profile MSYSTEM=MSYS, or under CYGWIN). Some features have been ported natively to windows APIs, but POSIX is still required.
  • Netdata has git symlinks (especially for src/web/gui/v0) which are not supported by windows (they could be supported by enabling windows developer mode and setting git config core.symlinks true, but this leads to typechange issues of all symlink files making difficult to commit changes back).
  • Netdata has filenames with colon in them :. These files cannot be checked out to Windows filesystems.

@ktsaou
Copy link
Member Author

ktsaou commented Apr 23, 2024

Guys, this compiles and runs (passes unit tests and the daemon works, the dashboard works, etc) on Windows, using either CYGWIN or MSYS2.

MSYS2 is without emulation. So, everything is quite faster. Also, it supports cross compilation, so that it can be integrated to our CI.

@ktsaou
Copy link
Member Author

ktsaou commented Apr 23, 2024

@vkalintiris please fix the protobuf in cmake. This is mergeable!

@ktsaou ktsaou changed the title Windows Support Windows Support Phase 1 Apr 23, 2024
@ktsaou ktsaou marked this pull request as ready for review April 23, 2024 20:27
@ktsaou
Copy link
Member Author

ktsaou commented Apr 23, 2024

Most of the work is re-structuring.

I added some native Windows functions (Windows API) to get the number of processors, and similar. I also emulated waitid() with waitpid() to get plugins running.

The changes are a lot, because I had to rename a lot of things and create an abstraction layer that is easier to manage.

But all this code is only running on Windows. On all other systems there shouldn't be any code changes.

@ktsaou
Copy link
Member Author

ktsaou commented Apr 23, 2024

@ilyam8 please test that macos compilation works. There may be some includes missing here or there.

@stelfrag stelfrag self-requested a review May 13, 2024 20:07
vkalintiris and others added 4 commits May 15, 2024 15:34
The installer will install everything
under C:\netdata by default.

It will:
  - Install msys2 at C:\netdata
  - Install netdata dependencies with pacman
  - Install the agent itself under C:\netdata\opt

You can start the agent by running an MSYS
shell with C:\netdata\msys2_shell.cmd and
then start the agent normally with:

/opt/netdata/usr/sbin/netdata -D

There are a more couple things to work on:

  - Verify publisher.
  - Install all deps not just libuv & protobuf.
  - Figure out how we want to auto-start the agent as a service.
  - Check how to uninstall things.
@stelfrag stelfrag self-requested a review May 15, 2024 18:40
stelfrag
stelfrag previously approved these changes May 16, 2024
@ktsaou ktsaou merged commit fe06e84 into netdata:master May 16, 2024
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants