@cryptotaxi247 / netdata-1 / commits / 3df95546e

New Windows Metrics (CPU and Memory) (#20277)

thiagoftsm committed May 14, 2025 at 19:26 UTC 3df95546e78db8772ce16f661d0dd7b0202a0f5e
4 files changed +84
src/collectors/all.h
+2
@@ -33,6 +33,7 @@
33 #define NETDATA_CHART_PRIO_SYSTEM_ACTIVE_PROCESSES 750
34 #define NETDATA_CHART_PRIO_SYSTEM_CTXT 800
35 #define NETDATA_CHART_PRIO_SYSTEM_IDLEJITTER 800
36 +#define NETDATA_CHART_PRIO_SYSTEM_THREAD_QUEUE 801 // Windows only
37 #define NETDATA_CHART_PRIO_SYSTEM_INTR 900
38 #define NETDATA_CHART_PRIO_SYSTEM_SOFTIRQS 950
39 #define NETDATA_CHART_PRIO_SYSTEM_SOFTNET_STAT 955
@@ -127,6 +128,7 @@
128 #define NETDATA_CHART_PRIO_MEM_SWAP_PAGES 1037 // Windows only
129 #define NETDATA_CHART_PRIO_MEM_SWAPIO 1038
130 #define NETDATA_CHART_PRIO_MEM_SYSTEM_POOL 1039 // Windows only
131 +#define NETDATA_CHART_PRIO_MEM_FREE_SYSTEM_PAGE 1040 // Windows only
132 #define NETDATA_CHART_PRIO_MEM_ZSWAP 1036
133 #define NETDATA_CHART_PRIO_MEM_ZSWAPIO 1037
134 #define NETDATA_CHART_PRIO_MEM_ZSWAP_COMPRESS_RATIO 1038
src/collectors/windows.plugin/metadata.yaml
+12
@@ -203,6 +203,12 @@ modules:
203 dimensions:
204 - name: paged
205 - name: pool-paged
206 + - name: mem.system_page_table_entries
207 + description: Unused page table entries.
208 + unit: "pages"
209 + chart_type: line
210 + dimensions:
211 + - name: free
212 - meta:
213 plugin_name: windows.plugin
214 module_name: PerflibProcesses
@@ -298,6 +304,12 @@ modules:
304 chart_type: line
305 dimensions:
306 - name: switches
307 + - name: system.processor_queue_length
308 + description: The number of threads in the processor queue.
309 + unit: "threads"
310 + chart_type: line
311 + dimensions:
312 + - name: threads
313 - meta:
314 plugin_name: windows.plugin
315 module_name: PerflibStorage
src/collectors/windows.plugin/perflib-memory.c
+37
@@ -27,8 +27,12 @@ struct system_pool {
27 RRDDIM *rd_paged;
28 RRDDIM *rd_nonpaged;
29
30 + RRDSET *freeSystemPageTableEntries;
31 + RRDDIM *rd_free_system_page_table_entries;
32 +
33 COUNTER_DATA pagedData;
34 COUNTER_DATA nonPagedData;
35 + COUNTER_DATA pageTableEntries;
36 };
37
38 struct swap localSwap = {0};
@@ -49,6 +53,7 @@ void initialize_pool_keys(struct system_pool *p)
53 {
54 p->pagedData.key = "Pool Paged Bytes";
55 p->nonPagedData.key = "Pool Nonpaged Bytes";
56 + p->pageTableEntries.key = "Free System Page Table Entries";
57 }
58
59 static void initialize(void)
@@ -153,6 +158,37 @@ static void do_memory_system_pool(PERF_DATA_BLOCK *pDataBlock, PERF_OBJECT_TYPE
158 rrdset_done(localPool.pool);
159 }
160
161 +static void do_memory_page_table_entries(PERF_DATA_BLOCK *pDataBlock, PERF_OBJECT_TYPE *pObjectType, int update_every)
162 +{
163 + perflibGetObjectCounter(pDataBlock, pObjectType, &localPool.pageTableEntries);
164 +
165 + if (!localPool.freeSystemPageTableEntries) {
166 + localPool.freeSystemPageTableEntries = rrdset_create_localhost(
167 + "mem",
168 + "free_system_page_table_entries",
169 + NULL,
170 + "mem",
171 + "mem.system_page_table_entries",
172 + "Unused page table entries.",
173 + "pages",
174 + PLUGIN_WINDOWS_NAME,
175 + "PerflibMemory",
176 + NETDATA_CHART_PRIO_MEM_FREE_SYSTEM_PAGE,
177 + update_every,
178 + RRDSET_TYPE_LINE);
179 +
180 + localPool.rd_free_system_page_table_entries =
181 + rrddim_add(localPool.freeSystemPageTableEntries, "free", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
182 + }
183 +
184 + rrddim_set_by_pointer(
185 + localPool.freeSystemPageTableEntries,
186 + localPool.rd_free_system_page_table_entries,
187 + (collected_number)localPool.pageTableEntries.current.Data);
188 +
189 + rrdset_done(localPool.freeSystemPageTableEntries);
190 +}
191 +
192 static bool do_memory(PERF_DATA_BLOCK *pDataBlock, int update_every)
193 {
194 PERF_OBJECT_TYPE *pObjectType = perflibFindObjectTypeByName(pDataBlock, "Memory");
@@ -187,6 +223,7 @@ static bool do_memory(PERF_DATA_BLOCK *pDataBlock, int update_every)
223 do_memory_swap(pDataBlock, pObjectType, update_every);
224
225 do_memory_system_pool(pDataBlock, pObjectType, update_every);
226 + do_memory_page_table_entries(pDataBlock, pObjectType, update_every);
227
228 return true;
229 }
src/collectors/windows.plugin/perflib-processes.c
+33
@@ -12,6 +12,37 @@ static void initialize(void)
12 ;
13 }
14
15 +static void do_processor_queue(PERF_DATA_BLOCK *pDataBlock, PERF_OBJECT_TYPE *pObjectType, int update_every)
16 +{
17 + static RRDSET *st_queue = NULL;
18 + static RRDDIM *rd_queue = NULL;
19 + static COUNTER_DATA processorQueue = {.key = "Processor Queue Length"};
20 + if (!perflibGetObjectCounter(pDataBlock, pObjectType, &processorQueue))
21 + return;
22 +
23 + if (!st_queue) {
24 + st_queue = rrdset_create_localhost(
25 + "system",
26 + "processor_queue",
27 + NULL,
28 + "system",
29 + "system.processor_queue_length",
30 + "The number of threads in the processor queue.",
31 + "threads",
32 + _COMMON_PLUGIN_NAME,
33 + _COMMON_PLUGIN_MODULE_NAME,
34 + NETDATA_CHART_PRIO_SYSTEM_THREAD_QUEUE,
35 + update_every,
36 + RRDSET_TYPE_LINE);
37 +
38 + rd_queue = rrddim_add(st_queue, "threads", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
39 + }
40 +
41 + rrddim_set_by_pointer(st_queue, rd_queue, (collected_number)processorQueue.current.Data);
42 +
43 + rrdset_done(st_queue);
44 +}
45 +
46 static bool do_processes(PERF_DATA_BLOCK *pDataBlock, int update_every)
47 {
48 PERF_OBJECT_TYPE *pObjectType = perflibFindObjectTypeByName(pDataBlock, "System");
@@ -36,6 +67,8 @@ static bool do_processes(PERF_DATA_BLOCK *pDataBlock, int update_every)
67 ULONGLONG totalThreads = threads.current.Data;
68 common_system_threads(totalThreads, update_every);
69 }
70 +
71 + do_processor_queue(pDataBlock, pObjectType, update_every);
72 return true;
73 }
74