Windows Pluging (Freedom to update every) (#20580)
thiagoftsm committed
Jul 13, 2025 at 19:07 UTC
1336ba958230cd2e31733c3cf1cf0bd9e3e43343
5 files changed
+223
-85
src/collectors/windows.plugin/README.md
+24
@@ -32,6 +32,30 @@ To change a setting, remove the comment symbol (`#`) from the beginning of the l
32
# PerflibADCS = yes
33
# PerflibADFS = yes
34
# PerflibExchange = yes
35
+ # PerflibNUMA = yes
36
+```
37
+
38
+## Update Every per Thread
39
+
40
+When the plugin is running, most threads will collect data using Netdata’s default update `every interval`. However,
41
+to avoid overloading the host, Netdata uses different `update every` intervals for specific threads, as shown below:
42
+
43
+| Period (seconds) | Threads |
44
+|------------------|----------------------------------------------------------------------------------|
45
+| 5 | `PerflibHyperV`, `PerflibThermalZone` |
46
+| 10 | `PerflibMSSQL`, `PerflibAD`, `PerflibADCS`, `PerflibADFS`, and `PerflibExchange` |
47
+| 30 | `PerflibServices` |
48
+
49
+To customize the update interval for a specific thread, you can set the update every value within the corresponding
50
+thread configuration in your `netdata.conf` file. For example, to modify the intervals for the `Object`
51
+and `HyperV` threads:
52
+
53
+```text
54
+[plugin:windows:PerflibObjects]
55
+ #update every = 10s
56
+
57
+[plugin:windows:PerflibHyperV]
58
+ #update every = 15s
59
```
60
61
## Microsoft SQL Server Integration
src/collectors/windows.plugin/metadata.yaml
+72
-68
@@ -46,7 +46,7 @@ modules:
46
configuration:
47
file:
48
name: "netdata.conf"
49
- section_name: "[plugin:windows]"
49
+ section_name: "[plugin:windows:PerflibProcessor]"
50
description: "The Netdata main configuration file"
51
options:
52
description: ""
@@ -54,9 +54,9 @@ modules:
54
title: "Config option"
55
enabled: false
56
list:
57
- - name: PerflibProcessor
58
- description: An option to enable or disable the data collection.
59
- default_value: yes
57
+ - name: update every
58
+ description: Data collection frequency.
59
+ default_value: 1
60
required: false
61
examples:
62
folding:
@@ -150,7 +150,7 @@ modules:
150
configuration:
151
file:
152
name: "netdata.conf"
153
- section_name: "[plugin:windows]"
153
+ section_name: "[plugin:windows:PerflibMemory]"
154
description: "The Netdata main configuration file"
155
options:
156
description: ""
@@ -158,9 +158,9 @@ modules:
158
title: "Config option"
159
enabled: false
160
list:
161
- - name: PerflibMemory
162
- description: An option to enable or disable the data collection.
163
- default_value: yes
161
+ - name: update every
162
+ description: Data collection frequency.
163
+ default_value: 1
164
required: false
165
examples:
166
folding:
@@ -254,7 +254,7 @@ modules:
254
configuration:
255
file:
256
name: "netdata.conf"
257
- section_name: "[plugin:windows]"
257
+ section_name: "[plugin:windows:PerflibProcesses]"
258
description: "The Netdata main configuration file"
259
options:
260
description: ""
@@ -262,9 +262,9 @@ modules:
262
title: "Config option"
263
enabled: false
264
list:
265
- - name: PerflibProcesses
266
- description: An option to enable or disable the data collection.
267
- default_value: yes
265
+ - name: update every
266
+ description: Data collection frequency.
267
+ default_value: 1
268
required: false
269
examples:
270
folding:
@@ -358,7 +358,7 @@ modules:
358
configuration:
359
file:
360
name: "netdata.conf"
361
- section_name: "[plugin:windows]"
361
+ section_name: "[plugin:windows:PerflibStorage]"
362
description: "The Netdata main configuration file"
363
options:
364
description: ""
@@ -366,9 +366,9 @@ modules:
366
title: "Config option"
367
enabled: false
368
list:
369
- - name: PerflibStorage
370
- description: An option to enable or disable the data collection.
371
- default_value: yes
369
+ - name: update every
370
+ description: Data collection frequency.
371
+ default_value: 1
372
required: false
373
examples:
374
folding:
@@ -541,7 +541,7 @@ modules:
541
configuration:
542
file:
543
name: "netdata.conf"
544
- section_name: "[plugin:windows]"
544
+ section_name: "[plugin:windows:PerflibNetwork]"
545
description: "The Netdata main configuration file"
546
options:
547
description: ""
@@ -549,9 +549,9 @@ modules:
549
title: "Config option"
550
enabled: false
551
list:
552
- - name: PerflibNetwork
553
- description: An option to enable or disable the data collection.
554
- default_value: yes
552
+ - name: update every
553
+ description: Data collection frequency.
554
+ default_value: 1
555
required: false
556
examples:
557
folding:
@@ -865,7 +865,7 @@ modules:
865
configuration:
866
file:
867
name: "netdata.conf"
868
- section_name: "[plugin:windows]"
868
+ section_name: "[plugin:windows:PerflibObjects]"
869
description: "The Netdata main configuration file"
870
options:
871
description: ""
@@ -873,9 +873,9 @@ modules:
873
title: "Config option"
874
enabled: false
875
list:
876
- - name: PerflibObjects
877
- description: An option to enable or disable the data collection.
878
- default_value: yes
876
+ - name: update every
877
+ description: Data collection frequency.
878
+ default_value: 1
879
required: false
880
examples:
881
folding:
@@ -946,7 +946,7 @@ modules:
946
list: []
947
configuration:
948
file:
949
- section_name: "[plugin:windows]"
949
+ section_name: "[plugin:windows:PerflibThermalZone]"
950
name: "netdata.conf"
951
description: "The Netdata main configuration file."
952
options:
@@ -955,9 +955,9 @@ modules:
955
title: "Config Option"
956
enabled: false
957
list:
958
- - name: PerflibThermalZone
959
- description: An option to enable or disable the data collection.
960
- default_value: yes
958
+ - name: update every
959
+ description: Data collection frequency.
960
+ default_value: 5
961
required: false
962
examples:
963
folding:
@@ -1027,7 +1027,7 @@ modules:
1027
list: []
1028
configuration:
1029
file:
1030
- section_name: "[plugin:windows]"
1030
+ section_name: "[plugin:windows:GetPowerSupply]"
1031
name: "netdata.conf"
1032
description: "The Netdata main configuration file."
1033
options:
@@ -1036,9 +1036,9 @@ modules:
1036
title: "Config Option"
1037
enabled: false
1038
list:
1039
- - name: GetPowerSupply
1040
- description: An option to enable or disable the data collection.
1041
- default_value: yes
1039
+ - name: update every
1040
+ description: Data collection frequency.
1041
+ default_value: 1
1042
required: false
1043
examples:
1044
folding:
@@ -1123,7 +1123,7 @@ modules:
1123
configuration:
1124
file:
1125
name: "netdata.conf"
1126
- section_name: "[plugin:windows]"
1126
+ section_name: "[plugin:windows:PerflibWebService]"
1127
description: "The Netdata main configuration file"
1128
options:
1129
description: ""
@@ -1131,9 +1131,9 @@ modules:
1131
title: "Config option"
1132
enabled: false
1133
list:
1134
- - name: PerflibWebService
1135
- description: An option to enable or disable the data collection.
1136
- default_value: yes
1134
+ - name: update every
1135
+ description: Data collection frequency.
1136
+ default_value: 1
1137
required: false
1138
examples:
1139
folding:
@@ -1442,7 +1442,7 @@ modules:
1442
configuration:
1443
file:
1444
name: "netdata.conf"
1445
- section_name: "[plugin:windows]"
1445
+ section_name: "[plugin:windows:PerflibHyperV]"
1446
description: "The Netdata main configuration file"
1447
options:
1448
description: ""
@@ -1450,9 +1450,9 @@ modules:
1450
title: "Config option"
1451
enabled: false
1452
list:
1453
- - name: PerflibHyperV
1454
- description: An option to enable or disable the data collection.
1455
- default_value: yes
1453
+ - name: update every
1454
+ description: Data collection frequency.
1455
+ default_value: 5
1456
required: false
1457
examples:
1458
folding:
@@ -1883,6 +1883,10 @@ modules:
1883
title: "Config option"
1884
enabled: false
1885
list:
1886
+ - name: update every
1887
+ description: Data collection frequency.
1888
+ default_value: 10
1889
+ required: false
1890
- name: driver
1891
description: ODBC driver used to connect to the SQL Server.
1892
default_value: SQL Server
@@ -2242,7 +2246,7 @@ modules:
2246
configuration:
2247
file:
2248
name: "netdata.conf"
2245
- section_name: "[plugin:windows]"
2249
+ section_name: "[plugin:windows:PerflibNetFramework]"
2250
description: "The Netdata main configuration file"
2251
options:
2252
description: ""
@@ -2250,9 +2254,9 @@ modules:
2254
title: "Config option"
2255
enabled: false
2256
list:
2253
- - name: PerflibNetFramework
2254
- description: An option to enable or disable the data collection.
2255
- default_value: yes
2257
+ - name: update every
2258
+ description: Data collection frequency.
2259
+ default_value: 1
2260
required: false
2261
examples:
2262
folding:
@@ -2508,7 +2512,7 @@ modules:
2512
configuration:
2513
file:
2514
name: "netdata.conf"
2511
- section_name: "[plugin:windows]"
2515
+ section_name: "[plugin:windows:PerflibAD]"
2516
description: "The Netdata main configuration file"
2517
options:
2518
description: ""
@@ -2516,9 +2520,9 @@ modules:
2520
title: "Config option"
2521
enabled: false
2522
list:
2519
- - name: PerflibAD
2520
- description: An option to enable or disable the data collection.
2521
- default_value: yes
2523
+ - name: update every
2524
+ description: Data collection frequency.
2525
+ default_value: 10
2526
required: false
2527
examples:
2528
folding:
@@ -2687,7 +2691,7 @@ modules:
2691
configuration:
2692
file:
2693
name: "netdata.conf"
2690
- section_name: "[plugin:windows]"
2694
+ section_name: "[plugin:windows:PerflibADCS]"
2695
description: "The Netdata main configuration file"
2696
options:
2697
description: ""
@@ -2695,9 +2699,9 @@ modules:
2699
title: "Config option"
2700
enabled: false
2701
list:
2698
- - name: PerflibADCS
2699
- description: An option to enable or disable the data collection.
2700
- default_value: yes
2702
+ - name: update every
2703
+ description: Data collection frequency.
2704
+ default_value: 10
2705
required: false
2706
examples:
2707
folding:
@@ -2864,7 +2868,7 @@ modules:
2868
configuration:
2869
file:
2870
name: "netdata.conf"
2867
- section_name: "[plugin:windows]"
2871
+ section_name: "[plugin:windows:PerflibADFS]"
2872
description: "The Netdata main configuration file"
2873
options:
2874
description: ""
@@ -2872,9 +2876,9 @@ modules:
2876
title: "Config option"
2877
enabled: false
2878
list:
2875
- - name: PerflibADFS
2876
- description: An option to enable or disable the data collection.
2877
- default_value: yes
2879
+ - name: update every
2880
+ description: Data collection frequency.
2881
+ default_value: 10
2882
required: false
2883
examples:
2884
folding:
@@ -3140,7 +3144,7 @@ modules:
3144
configuration:
3145
file:
3146
name: "netdata.conf"
3143
- section_name: "[plugin:windows]"
3147
+ section_name: "[plugin:windows:PerflibServices]"
3148
description: "The Netdata main configuration file"
3149
options:
3150
description: ""
@@ -3148,9 +3152,9 @@ modules:
3152
title: "Config option"
3153
enabled: false
3154
list:
3151
- - name: PerflibServices
3152
- description: An option to enable or disable the data collection.
3153
- default_value: yes
3155
+ - name: update every
3156
+ description: Data collection frequency.
3157
+ default_value: 30
3158
required: false
3159
examples:
3160
folding:
@@ -3233,7 +3237,7 @@ modules:
3237
configuration:
3238
file:
3239
name: "netdata.conf"
3236
- section_name: "[plugin:windows]"
3240
+ section_name: "[plugin:windows:PerflibExchange]"
3241
description: "The Netdata main configuration file"
3242
options:
3243
description: ""
@@ -3241,9 +3245,9 @@ modules:
3245
title: "Config option"
3246
enabled: false
3247
list:
3244
- - name: PerflibExchange
3245
- description: An option to enable or disable the data collection.
3246
- default_value: yes
3248
+ - name: update every
3249
+ description: Data collection frequency.
3250
+ default_value: 10
3251
required: false
3252
examples:
3253
folding:
@@ -3497,7 +3501,7 @@ modules:
3501
configuration:
3502
file:
3503
name: "netdata.conf"
3500
- section_name: "[plugin:windows]"
3504
+ section_name: "[plugin:windows:PerflibNUMA]"
3505
description: "The Netdata main configuration file"
3506
options:
3507
description: ""
@@ -3505,9 +3509,9 @@ modules:
3509
title: "Config option"
3510
enabled: false
3511
list:
3508
- - name: PerflibNUMA
3509
- description: An option to enable or disable the data collection.
3510
- default_value: yes
3512
+ - name: update every
3513
+ description: Data collection frequency.
3514
+ default_value: 1
3515
required: false
3516
examples:
3517
folding:
src/collectors/windows.plugin/perflib-mssql.c
+3
-5
@@ -18,7 +18,6 @@
18
#define NETDATA_MSSQL_NEXT_TRY (60)
19
20
BOOL is_sqlexpress = FALSE;
21
-ND_THREAD *mssql_query_thread = NULL;
21
22
struct netdata_mssql_conn {
23
const char *driver;
@@ -1128,8 +1127,8 @@ int dict_mssql_query_cb(const DICTIONARY_ITEM *item __maybe_unused, void *value,
1127
void *netdata_mssql_queries(void *ptr __maybe_unused)
1128
{
1129
heartbeat_t hb;
1131
- int update_every = *((int *)ptr);
1132
- heartbeat_init(&hb, update_every * USEC_PER_SEC);
1130
+ heartbeat_init(&hb, USEC_PER_SEC);
1131
+ int update_every = UPDATE_EVERY_MIN;
1132
1133
while (service_running(SERVICE_COLLECTORS)) {
1134
(void)heartbeat_next(&hb);
@@ -1156,8 +1155,7 @@ static int initialize(int update_every)
1155
}
1156
1157
if (create_thread)
1159
- mssql_query_thread =
1160
- nd_thread_create("mssql_queries", NETDATA_THREAD_OPTION_DEFAULT, netdata_mssql_queries, &update_every);
1158
+ nd_thread_create("mssql_queries", NETDATA_THREAD_OPTION_DEFAULT, netdata_mssql_queries, &update_every);
1159
1160
return 0;
1161
}
src/collectors/windows.plugin/windows_plugin.c
+41
-9
@@ -67,13 +67,13 @@ static struct proc_module {
67
{.name = "PerflibHyperV",
68
.dim = "PerflibHyperV",
69
.enabled = CONFIG_BOOLEAN_YES,
70
- .update_every = UPDATE_EVERY_MIN,
70
+ .update_every = 5 * UPDATE_EVERY_MIN,
71
.func = do_PerflibHyperV},
72
73
{.name = "PerflibThermalZone",
74
.dim = "PerflibThermalZone",
75
.enabled = CONFIG_BOOLEAN_NO,
76
- .update_every = UPDATE_EVERY_MIN,
76
+ .update_every = 5*UPDATE_EVERY_MIN,
77
.func = do_PerflibThermalZone},
78
79
{.name = "PerflibWebService",
@@ -81,7 +81,11 @@ static struct proc_module {
81
.enabled = CONFIG_BOOLEAN_YES,
82
.update_every = UPDATE_EVERY_MIN,
83
.func = do_PerflibWebService},
84
- {.name = "PerflibMSSQL", .dim = "PerflibMSSQL", .enabled = CONFIG_BOOLEAN_YES, .func = do_PerflibMSSQL},
84
+ {.name = "PerflibMSSQL",
85
+ .dim = "PerflibMSSQL",
86
+ .enabled = CONFIG_BOOLEAN_YES,
87
+ .update_every = 10 * UPDATE_EVERY_MIN,
88
+ .func = do_PerflibMSSQL},
89
90
{.name = "PerflibNetFramework",
91
.dim = "PerflibNetFramework",
@@ -91,19 +95,19 @@ static struct proc_module {
95
{.name = "PerflibAD",
96
.dim = "PerflibAD",
97
.enabled = CONFIG_BOOLEAN_YES,
94
- .update_every = UPDATE_EVERY_MIN,
98
+ .update_every = 10 * UPDATE_EVERY_MIN,
99
.func = do_PerflibAD},
100
101
{.name = "PerflibADCS",
102
.dim = "PerflibADCS",
103
.enabled = CONFIG_BOOLEAN_YES,
100
- .update_every = UPDATE_EVERY_MIN,
104
+ .update_every = 10 * UPDATE_EVERY_MIN,
105
.func = do_PerflibADCS},
106
107
{.name = "PerflibADFS",
108
.dim = "PerflibADFS",
109
.enabled = CONFIG_BOOLEAN_YES,
106
- .update_every = UPDATE_EVERY_MIN,
110
+ .update_every = 10 * UPDATE_EVERY_MIN,
111
.func = do_PerflibADFS},
112
113
{.name = "PerflibServices",
@@ -115,7 +119,7 @@ static struct proc_module {
119
{.name = "PerflibExchange",
120
.dim = "PerflibExchange",
121
.enabled = CONFIG_BOOLEAN_YES,
118
- .update_every = UPDATE_EVERY_MIN,
122
+ .update_every = 10 * UPDATE_EVERY_MIN,
123
.func = do_PerflibExchange},
124
125
{.name = "PerflibNUMA",
@@ -161,6 +165,25 @@ static bool log_windows_module(BUFFER *wb, void *data)
165
return true;
166
}
167
168
+static void *windows_plugin_thread_worker(void *ptr __maybe_unused)
169
+{
170
+ struct proc_module *mod = ptr;
171
+ heartbeat_t hb;
172
+ int update_every = mod->update_every;
173
+ heartbeat_init(&hb, update_every * USEC_PER_SEC);
174
+
175
+ while (service_running(SERVICE_COLLECTORS)) {
176
+ usec_t hb_dt = heartbeat_next(&hb);
177
+
178
+ if (unlikely(!service_running(SERVICE_COLLECTORS)))
179
+ break;
180
+
181
+ mod->func(update_every, hb_dt);
182
+ }
183
+
184
+ return NULL;
185
+}
186
+
187
void *win_plugin_main(void *ptr)
188
{
189
worker_register("WIN");
@@ -173,6 +196,7 @@ void *win_plugin_main(void *ptr)
196
// check the enabled status for each module
197
int i;
198
char buf[CONFIG_MAX_NAME + 1];
199
+ int update_every = localhost->rrd_update_every;
200
for (i = 0; win_modules[i].name; i++) {
201
struct proc_module *pm = &win_modules[i];
202
@@ -181,8 +205,13 @@ void *win_plugin_main(void *ptr)
205
pm->enabled = inicfg_get_boolean(&netdata_config, "plugin:windows", pm->name, pm->enabled);
206
pm->rd = NULL;
207
184
- pm->update_every =
185
- (int)inicfg_get_duration_seconds(&netdata_config, buf, "update every", localhost->rrd_update_every);
208
+ pm->update_every = (int)inicfg_get_duration_seconds(&netdata_config, buf, "update every", (update_every != pm->update_every)? pm->update_every: update_every);
209
+
210
+ if (pm->enabled && unlikely(update_every != pm->update_every)) {
211
+ char tag_name[ND_THREAD_TAG_MAX];
212
+ snprintfz(tag_name, ND_THREAD_TAG_MAX - 1, "WIN_PLUGIN[%d]", i);
213
+ nd_thread_create(tag_name, NETDATA_THREAD_OPTION_DEFAULT, windows_plugin_thread_worker, pm);
214
+ }
215
216
worker_register_job_name(i, win_modules[i].dim);
217
}
@@ -212,6 +241,9 @@ void *win_plugin_main(void *ptr)
241
break;
242
243
struct proc_module *pm = &win_modules[i];
244
+ if (unlikely(update_every != win_modules[i].update_every))
245
+ continue;
246
+
247
if (unlikely(!pm->enabled))
248
continue;
249
src/daemon/analytics.c
+83
-3
@@ -723,16 +723,96 @@ void set_late_analytics_variables(struct rrdhost_system_info *system_info)
723
analytics_get_install_type(system_info);
724
}
725
726
+#ifdef OS_WINDOWS
727
+static void get_timezone_win_id(char *win_id, DWORD win_size)
728
+{
729
+ win_id[0] = '\0';
730
+ HKEY hKey;
731
+ LSTATUS ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
732
+ "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation",
733
+ 0,
734
+ KEY_READ,
735
+ &hKey);
736
+ if (ret != ERROR_SUCCESS)
737
+ return;
738
+
739
+ DWORD valueType;
740
+ RegQueryValueExA(hKey, "TimeZoneKeyName", NULL, &valueType, (LPBYTE)win_id, &win_size);
741
+
742
+ RegCloseKey(hKey);
743
+}
744
+
745
+static void get_win_geoiso(char *geo_name, int length) {
746
+ GEOID id = GetUserGeoID(GEOCLASS_NATION);
747
+ int res = GetGeoInfoA(id, GEO_ISO2, geo_name, length, 0);
748
+ if (!res)
749
+ geo_name[0] = '\0';
750
+}
751
+
752
+static int map_windows_tz_to_ioanna(char *out, char *win_id, char *geo_name) {
753
+ if (*win_id == '\0')
754
+ return -1;
755
+
756
+ FILE *fp = fopen("c:\\Windows\\Globalization\\Time Zone\\TimezoneMapping.xml", "r");
757
+ if (!fp)
758
+ return -1;
759
+
760
+ char buffer[CONFIG_FILE_LINE_MAX + 1];
761
+ bool copied = 0;
762
+ while (fgets(buffer, CONFIG_FILE_LINE_MAX, fp) != NULL) {
763
+ buffer[CONFIG_FILE_LINE_MAX] = '\0';
764
+
765
+ char *s = strstr(buffer, win_id);
766
+ if (!s) {
767
+ if (!copied)
768
+ continue;
769
+ else // Country codes do not match, but we found the zone
770
+ break;
771
+ }
772
+
773
+ //Escape:' <MapTZ TZID="'
774
+ s = &buffer[15];
775
+ char *end = strchr(s, '"');
776
+ if (!end)
777
+ continue;
778
+
779
+ *end = '\0';
780
+
781
+ strncpyz(out, s, strlen(s));
782
+
783
+ //Escape:" Region="
784
+ char *cmpregion = end+ 10;
785
+ if (!strncmp(cmpregion, geo_name, 2))
786
+ break;
787
+
788
+ copied = 1;
789
+ }
790
+
791
+ fclose(fp);
792
+ return 0;
793
+}
794
+#endif
795
+
796
void get_system_timezone(void)
797
{
798
+ char buffer[FILENAME_MAX + 1] = "";
799
+ const char *timezone = NULL;
800
+ const char *tz = NULL;
801
+#ifdef OS_WINDOWS
802
+ char geo_name[128];
803
+ char win_zone[256];
804
+ get_timezone_win_id(win_zone, 256);
805
+ get_win_geoiso(geo_name, 128);
806
+ if (!map_windows_tz_to_ioanna(buffer, win_zone, geo_name))
807
+ timezone = buffer;
808
+#else
809
// avoid flood calls to stat(/etc/localtime)
810
// http://stackoverflow.com/questions/4554271/how-to-avoid-excessive-stat-etc-localtime-calls-in-strftime-on-linux
730
- const char *tz = getenv("TZ");
811
+ tz = getenv("TZ");
812
if (!tz || !*tz)
813
setenv("TZ", inicfg_get(&netdata_config, CONFIG_SECTION_ENV_VARS, "TZ", ":/etc/localtime"), 0);
814
+#endif
815
734
- char buffer[FILENAME_MAX + 1] = "";
735
- const char *timezone = NULL;
816
ssize_t ret;
817
818
// use the TZ variable