@cryptotaxi247 / netdata-1 / commits / f6125f31b

Adjust content api/v1/info (Windows) (#18656)

* address_collection: Fix os version * address_collection: Cleanup code * address_collection: Add install type * address_collection: Address kernel version * address_collection: Adjust variables for Microsoft

thiagoftsm committed Oct 3, 2024 at 14:23 UTC f6125f31b4b0c7b723a94a57b202f10462878039
3 files changed +34 -19
packaging/windows/resources/netdata.manifest.in
+14 -1
@@ -5,7 +5,20 @@
5 name="netdata"
6 type="win32"/>
7 <description>Netdata is a high-performance, cloud-native, and on-premises observability platform designed to monitor metrics and logs with unparalleled efficiency.</description>
8 - <!-- Identify the application security requirements. -->
8 + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
9 + <application>
10 + <!-- Windows 10 and Windows 11 -->
11 + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
12 + <!-- Windows 8.1 -->
13 + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
14 + <!-- Windows 8 -->
15 + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
16 + <!-- Windows 7 -->
17 + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
18 + <!-- Windows Vista -->
19 + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
20 + </application>
21 + </compatibility>
22 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
23 <security>
24 <requestedPrivileges>
src/daemon/buildinfo.c
+4
@@ -1332,6 +1332,7 @@ char *get_value_from_key(char *buffer, char *key) {
1332 }
1333
1334 void get_install_type(char **install_type, char **prebuilt_arch, char **prebuilt_dist) {
1335 +#ifndef OS_WINDOWS
1336 char *install_type_filename;
1337
1338 int install_type_filename_len = (strlen(netdata_configured_user_config_dir) + strlen(".install-type") + 3);
@@ -1354,6 +1355,9 @@ void get_install_type(char **install_type, char **prebuilt_arch, char **prebuilt
1355 fclose(fp);
1356 }
1357 freez(install_type_filename);
1358 +#else
1359 + *install_type = strdupz("netdata_installer.exe");
1360 +#endif
1361 }
1362
1363 static struct {
src/daemon/win_system-info.c
+16 -18
@@ -221,32 +221,25 @@ static void netdata_windows_discover_os_version(char *os, size_t length, DWORD b
221 }
222 // We are not testing older, because it is not supported anymore by Microsoft
223
224 - (void)snprintf(os, length, "Microsoft Windows Version %s, Build %d (Name: Windows %s)", versionName, build, version);
224 + (void)snprintf(os, length, "Microsoft Windows Version %s, Build %d", version, build);
225 }
226
227 -static void netdata_windows_os_version(char *out, DWORD length)
227 +static void netdata_windows_os_kernel_version(char *out, DWORD length, DWORD build)
228 {
229 - if (netdata_registry_get_string(out,
230 - length,
229 + DWORD major, minor;
230 + if (!netdata_registry_get_dword(&major,
231 HKEY_LOCAL_MACHINE,
232 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
233 - "ProductName"))
234 - return;
233 + "CurrentMajorVersionNumber"))
234 + major = 0;
235
236 - (void)snprintf(out, length, "%s", NETDATA_DEFAULT_SYSTEM_INFO_VALUE_UNKNOWN);
237 -}
238 -
239 -static void netdata_windows_os_kernel_version(char *out, DWORD length, DWORD build)
240 -{
241 - char version[8];
242 - if (!netdata_registry_get_string(version,
243 - 7,
236 + if (!netdata_registry_get_dword(&minor,
237 HKEY_LOCAL_MACHINE,
238 "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
246 - "CurrentVersion"))
247 - version[0] = '\0';
239 + "CurrentMinorVersionNumber"))
240 + minor = 0;
241
249 - (void)snprintf(out, length, "%s (build: %u)", version, build);
242 + (void)snprintf(out, length, "Windows %u.%u.%u Build: %u", major, minor, build, build);
243 }
244
245 static void netdata_windows_host(struct rrdhost_system_info *systemInfo)
@@ -262,7 +255,6 @@ static void netdata_windows_host(struct rrdhost_system_info *systemInfo)
255 (void)rrdhost_set_system_info_variable(
256 systemInfo, "NETDATA_HOST_OS_ID_LIKE", NETDATA_DEFAULT_SYSTEM_INFO_VALUE_UNKNOWN);
257
265 - netdata_windows_os_version(osVersion, 4095);
258 (void)rrdhost_set_system_info_variable(systemInfo, "NETDATA_HOST_OS_VERSION", osVersion);
259 (void)rrdhost_set_system_info_variable(systemInfo, "NETDATA_HOST_OS_VERSION_ID", osVersion);
260
@@ -307,6 +299,11 @@ static void netdata_windows_container(struct rrdhost_system_info *systemInfo)
299 systemInfo, "NETDATA_CONTAINER_IS_OFFICIAL_IMAGE", NETDATA_DEFAULT_SYSTEM_INFO_VALUE_FALSE);
300 }
301
302 +static void netdata_windows_install_type(struct rrdhost_system_info *systemInfo)
303 +{
304 + (void)rrdhost_set_system_info_variable(systemInfo, "NETDATA_INSTALL_TYPE", "netdata-installer.exe");
305 +}
306 +
307 void netdata_windows_get_system_info(struct rrdhost_system_info *systemInfo)
308 {
309 netdata_windows_cloud(systemInfo);
@@ -315,5 +312,6 @@ void netdata_windows_get_system_info(struct rrdhost_system_info *systemInfo)
312 netdata_windows_get_cpu(systemInfo);
313 netdata_windows_get_mem(systemInfo);
314 netdata_windows_get_total_disk_size(systemInfo);
315 + netdata_windows_install_type(systemInfo);
316 }
317 #endif