@cryptotaxi247 / netdata-1 / commits / 77d0c65c6

windows.plugin (IIS) (#18566)

thiagoftsm committed Oct 3, 2024 at 12:04 UTC 77d0c65c617012178945dab813aac401be32d964
4 files changed +595
CMakeLists.txt
+1
@@ -1444,6 +1444,7 @@ set(WINDOWS_PLUGIN_FILES
1444 src/collectors/windows.plugin/perflib-network.c
1445 src/collectors/windows.plugin/perflib-memory.c
1446 src/collectors/windows.plugin/perflib-processes.c
1447 + src/collectors/windows.plugin/perflib-web-service.c
1448 )
1449
1450 set(PROC_PLUGIN_FILES
src/collectors/windows.plugin/perflib-web-service.c new
+576
@@ -0,0 +1,576 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 +
3 +#include "windows_plugin.h"
4 +#include "windows-internals.h"
5 +
6 +struct web_service {
7 + RRDSET *st_traffic;
8 + RRDDIM *rd_traffic_received;
9 + RRDDIM *rd_traffic_sent;
10 +
11 + RRDSET *st_file_transfer;
12 + RRDDIM *rd_files_received;
13 + RRDDIM *rd_files_sent;
14 +
15 + RRDSET *st_curr_connections;
16 + RRDDIM *rd_curr_connections;
17 +
18 + RRDSET *st_connections_attemps;
19 + RRDDIM *rd_connections_attemps;
20 +
21 + RRDSET *st_user_count;
22 + RRDDIM *rd_user_anonymous;
23 + RRDDIM *rd_user_nonanonymous;
24 +
25 + RRDSET *st_isapi_extension_request_count;
26 + RRDDIM *rd_isapi_extension_request_count;
27 +
28 + RRDSET *st_isapi_extension_request_rate;
29 + RRDDIM *rd_isapi_extension_request_rate;
30 +
31 + RRDSET *st_error_rate;
32 + RRDDIM *rd_error_rate_locked;
33 + RRDDIM *rd_error_rate_not_found;
34 +
35 + RRDSET *st_logon_attemps;
36 + RRDDIM *rd_logon_attemps;
37 +
38 + RRDSET *st_service_uptime;
39 + RRDDIM *rd_service_uptime;
40 +
41 + RRDSET *st_request_rate;
42 + RRDDIM *rd_request_rate;
43 +
44 + COUNTER_DATA IISCurrentAnonymousUser;
45 + COUNTER_DATA IISCurrentNonAnonymousUsers;
46 + COUNTER_DATA IISCurrentConnections;
47 + COUNTER_DATA IISCurrentISAPIExtRequests;
48 + COUNTER_DATA IISUptime;
49 +
50 + COUNTER_DATA IISReceivedBytesTotal;
51 + COUNTER_DATA IISSentBytesTotal;
52 + COUNTER_DATA IISIPAPIExtRequestsTotal;
53 + COUNTER_DATA IISConnAttemptsAllInstancesTotal;
54 + COUNTER_DATA IISFilesReceivedTotal;
55 + COUNTER_DATA IISFilesSentTotal;
56 + COUNTER_DATA IISLogonAttemptsTotal;
57 + COUNTER_DATA IISLockedErrorsTotal;
58 + COUNTER_DATA IISNotFoundErrorsTotal;
59 +
60 + COUNTER_DATA IISRequestsOptions;
61 + COUNTER_DATA IISRequestsGet;
62 + COUNTER_DATA IISRequestsPost;
63 + COUNTER_DATA IISRequestsHead;
64 + COUNTER_DATA IISRequestsPut;
65 + COUNTER_DATA IISRequestsDelete;
66 + COUNTER_DATA IISRequestsTrace;
67 + COUNTER_DATA IISRequestsMove;
68 + COUNTER_DATA IISRequestsCopy;
69 + COUNTER_DATA IISRequestsMkcol;
70 + COUNTER_DATA IISRequestsPropfind;
71 + COUNTER_DATA IISRequestsProppatch;
72 + COUNTER_DATA IISRequestsSearch;
73 + COUNTER_DATA IISRequestsLock;
74 + COUNTER_DATA IISRequestsUnlock;
75 + COUNTER_DATA IISRequestsOther;
76 +};
77 +
78 +static inline void initialize_web_service_keys(struct web_service *p) {
79 + p->IISCurrentAnonymousUser.key = "Current Anonymous Users";
80 + p->IISCurrentNonAnonymousUsers.key = "Current NonAnonymous Users";
81 + p->IISCurrentConnections.key = "Current Connections";
82 + p->IISCurrentISAPIExtRequests.key = "Current ISAPI Extension Requests";
83 + p->IISUptime.key = "Service Uptime";
84 +
85 + p->IISReceivedBytesTotal.key = "Total Bytes Received";
86 + p->IISSentBytesTotal.key = "Total Bytes Sent";
87 + p->IISIPAPIExtRequestsTotal.key = "Total ISAPI Extension Requests";
88 + p->IISConnAttemptsAllInstancesTotal.key = "Total Connection Attempts (all instances)";
89 + p->IISFilesReceivedTotal.key = "Total Files Received";
90 + p->IISFilesSentTotal.key = "Total Files Sent";
91 + p->IISLogonAttemptsTotal.key = "Total Logon Attempts";
92 + p->IISLockedErrorsTotal.key = "Total Locked Errors";
93 + p->IISNotFoundErrorsTotal.key = "Total Not Found Errors";
94 +
95 + p->IISRequestsOptions.key = "Options Requests/sec";
96 + p->IISRequestsGet.key = "Get Requests/sec";
97 + p->IISRequestsPost.key = "Post Requests/sec";
98 + p->IISRequestsHead.key = "Head Requests/sec";
99 + p->IISRequestsPut.key = "Put Requests/sec";
100 + p->IISRequestsDelete.key = "Delete Requests/sec";
101 + p->IISRequestsTrace.key = "Trace Requests/sec";
102 + p->IISRequestsMove.key = "Move Requests/sec";
103 + p->IISRequestsCopy.key = "Copy Requests/sec";
104 + p->IISRequestsMkcol.key = "Mkcol Requests/sec";
105 + p->IISRequestsPropfind.key = "Propfind Requests/sec";
106 + p->IISRequestsProppatch.key = "Proppatch Requests/sec";
107 + p->IISRequestsSearch.key = "Search Requests/sec";
108 + p->IISRequestsLock.key = "Lock Requests/sec";
109 + p->IISRequestsUnlock.key = "Unlock Requests/sec";
110 + p->IISRequestsOther.key = "Other Request Methods/sec";
111 +}
112 +
113 +void dict_web_service_insert_cb(const DICTIONARY_ITEM *item __maybe_unused, void *value, void *data __maybe_unused) {
114 + struct web_service *p = value;
115 + initialize_web_service_keys(p);
116 +}
117 +
118 +static DICTIONARY *web_services = NULL;
119 +
120 +static void initialize(void) {
121 + web_services = dictionary_create_advanced(DICT_OPTION_DONT_OVERWRITE_VALUE |
122 + DICT_OPTION_FIXED_SIZE, NULL, sizeof(struct web_service));
123 +
124 + dictionary_register_insert_callback(web_services, dict_web_service_insert_cb, NULL);
125 +}
126 +
127 +static bool do_web_services(PERF_DATA_BLOCK *pDataBlock, int update_every) {
128 + char id[RRD_ID_LENGTH_MAX + 1];
129 + PERF_OBJECT_TYPE *pObjectType = perflibFindObjectTypeByName(pDataBlock, "Web Service");
130 + if(!pObjectType) return false;
131 +
132 + PERF_INSTANCE_DEFINITION *pi = NULL;
133 + for(LONG i = 0; i < pObjectType->NumInstances ; i++) {
134 + pi = perflibForEachInstance(pDataBlock, pObjectType, pi);
135 + if(!pi) break;
136 +
137 + if(!getInstanceName(pDataBlock, pObjectType, pi, windows_shared_buffer, sizeof(windows_shared_buffer)))
138 + strncpyz(windows_shared_buffer, "[unknown]", sizeof(windows_shared_buffer) - 1);
139 +
140 + // We are not ploting _Total here, because cloud will group the sites
141 + if(strcasecmp(windows_shared_buffer, "_Total") == 0) {
142 + continue;
143 + }
144 +
145 + netdata_fix_chart_name(windows_shared_buffer);
146 + struct web_service *p = dictionary_set(web_services, windows_shared_buffer, NULL, sizeof(*p));
147 +
148 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISReceivedBytesTotal) &&
149 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISSentBytesTotal)) {
150 + if (!p->st_traffic) {
151 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_traffic", windows_shared_buffer);
152 + p->st_traffic = rrdset_create_localhost("iis"
153 + , id, NULL
154 + , "traffic"
155 + , "iis.website_traffic"
156 + , "Website traffic"
157 + , "bytes/s"
158 + , PLUGIN_WINDOWS_NAME
159 + , "PerflibWebService"
160 + , PRIO_WEBSITE_IIS_TRAFFIC
161 + , update_every
162 + , RRDSET_TYPE_AREA
163 + );
164 +
165 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_received_bytes_total", windows_shared_buffer);
166 + p->rd_traffic_received = rrddim_add(p->st_traffic,
167 + id,
168 + "received",
169 + 1,
170 + 1,
171 + RRD_ALGORITHM_INCREMENTAL);
172 +
173 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_sent_bytes_total", windows_shared_buffer);
174 + p->rd_traffic_sent = rrddim_add(p->st_traffic,
175 + id,
176 + "sent",
177 + -1,
178 + 1,
179 + RRD_ALGORITHM_INCREMENTAL);
180 +
181 + rrdlabels_add(p->st_traffic->rrdlabels, "website", windows_shared_buffer, RRDLABEL_SRC_AUTO);
182 + }
183 +
184 + rrddim_set_by_pointer(p->st_traffic,
185 + p->rd_traffic_received,
186 + (collected_number)p->IISReceivedBytesTotal.current.Data);
187 +
188 + rrddim_set_by_pointer(p->st_traffic,
189 + p->rd_traffic_sent,
190 + (collected_number)p->IISSentBytesTotal.current.Data);
191 +
192 + rrdset_done(p->st_traffic);
193 + }
194 +
195 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISFilesReceivedTotal) &&
196 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISFilesSentTotal)) {
197 + if (!p->st_file_transfer) {
198 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_ftp_file_transfer_rate", windows_shared_buffer);
199 + p->st_file_transfer = rrdset_create_localhost("iis"
200 + , id, NULL
201 + , "traffic"
202 + , "iis.website_ftp_file_transfer_rate"
203 + , "Website FTP file transfer rate"
204 + , "files/s"
205 + , PLUGIN_WINDOWS_NAME
206 + , "PerflibWebService"
207 + , PRIO_WEBSITE_IIS_FTP_FILE_TRANSFER_RATE
208 + , update_every
209 + , RRDSET_TYPE_LINE
210 + );
211 +
212 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_files_received_total", windows_shared_buffer);
213 + p->rd_files_received = rrddim_add(p->st_file_transfer, id, "received",
214 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
215 +
216 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_files_sent_total", windows_shared_buffer);
217 + p->rd_files_sent = rrddim_add(p->st_file_transfer, id, "sent",
218 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
219 +
220 + rrdlabels_add(p->st_file_transfer->rrdlabels, "website",
221 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
222 + }
223 +
224 + rrddim_set_by_pointer(p->st_file_transfer,
225 + p->rd_files_received,
226 + (collected_number)p->IISFilesReceivedTotal.current.Data);
227 +
228 + rrddim_set_by_pointer(p->st_file_transfer,
229 + p->rd_files_sent,
230 + (collected_number)p->IISFilesSentTotal.current.Data);
231 +
232 + rrdset_done(p->st_file_transfer);
233 + }
234 +
235 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISCurrentConnections)) {
236 + if (!p->st_curr_connections) {
237 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_active_connections_count", windows_shared_buffer);
238 + p->st_curr_connections = rrdset_create_localhost("iis"
239 + , id, NULL
240 + , "connections"
241 + , "iis.website_active_connections_count"
242 + , "Website active connections"
243 + , "connections"
244 + , PLUGIN_WINDOWS_NAME
245 + , "PerflibWebService1"
246 + , PRIO_WEBSITE_IIS_ACTIVE_CONNECTIONS_COUNT
247 + , update_every
248 + , RRDSET_TYPE_LINE
249 + );
250 +
251 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_current_connections", windows_shared_buffer);
252 + p->rd_curr_connections = rrddim_add(p->st_curr_connections, id, "active",
253 + 1, 1, RRD_ALGORITHM_ABSOLUTE);
254 +
255 + rrdlabels_add(p->st_curr_connections->rrdlabels, "website", windows_shared_buffer, RRDLABEL_SRC_AUTO);
256 + }
257 +
258 + rrddim_set_by_pointer(p->st_curr_connections,
259 + p->rd_curr_connections,
260 + (collected_number)p->IISCurrentConnections.current.Data);
261 +
262 + rrdset_done(p->st_curr_connections);
263 + }
264 +
265 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISConnAttemptsAllInstancesTotal)) {
266 + if (!p->st_connections_attemps) {
267 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_connection_attempts_rate", windows_shared_buffer);
268 + netdata_fix_chart_name(id);
269 + p->st_connections_attemps = rrdset_create_localhost("iis"
270 + , id, NULL
271 + , "connections"
272 + , "iis.website_connection_attempts_rate"
273 + , "Website connections attempts"
274 + , "attempts/s"
275 + , PLUGIN_WINDOWS_NAME
276 + , "PerflibWebService"
277 + , PRIO_WEBSITE_IIS_CONNECTIONS_ATTEMP
278 + , update_every
279 + , RRDSET_TYPE_LINE
280 + );
281 +
282 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_connection_attempts_all_instances_total", windows_shared_buffer);
283 + p->rd_connections_attemps = rrddim_add(p->st_connections_attemps, id, "connection",
284 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
285 +
286 + rrdlabels_add(p->st_connections_attemps->rrdlabels, "website",
287 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
288 + }
289 +
290 + rrddim_set_by_pointer(p->st_connections_attemps,
291 + p->rd_connections_attemps,
292 + (collected_number)p->IISCurrentConnections.current.Data);
293 +
294 + rrdset_done(p->st_connections_attemps);
295 + }
296 +
297 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISCurrentAnonymousUser) &&
298 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISCurrentNonAnonymousUsers)) {
299 + if (!p->st_user_count) {
300 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_users_count", windows_shared_buffer);
301 + p->st_user_count = rrdset_create_localhost("iis",
302 + id, NULL
303 + ,"requests"
304 + , "iis.website_users_count"
305 + , "Website users with pending requests"
306 + , "users"
307 + , PLUGIN_WINDOWS_NAME
308 + , "PerflibWebService"
309 + , PRIO_WEBSITE_IIS_USERS
310 + , update_every
311 + , RRDSET_TYPE_STACKED
312 + );
313 +
314 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_current_anonymous_users", windows_shared_buffer);
315 + p->rd_user_anonymous = rrddim_add(p->st_user_count, id, "anonymous",
316 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
317 +
318 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_current_non_anonymous_users", windows_shared_buffer);
319 + p->rd_user_nonanonymous = rrddim_add(p->st_user_count, id, "non_anonymous",
320 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
321 +
322 + rrdlabels_add(p->st_user_count->rrdlabels, "website", windows_shared_buffer, RRDLABEL_SRC_AUTO);
323 + }
324 +
325 + rrddim_set_by_pointer(p->st_user_count,
326 + p->rd_user_anonymous,
327 + (collected_number)p->IISCurrentAnonymousUser.current.Data);
328 +
329 + rrddim_set_by_pointer(p->st_user_count,
330 + p->rd_user_nonanonymous,
331 + (collected_number)p->IISCurrentNonAnonymousUsers.current.Data);
332 +
333 + rrdset_done(p->st_user_count);
334 + }
335 +
336 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISCurrentISAPIExtRequests)) {
337 + if (!p->st_isapi_extension_request_count) {
338 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_isapi_extension_requests_count", windows_shared_buffer);
339 + p->st_isapi_extension_request_count = rrdset_create_localhost("iis"
340 + , id, NULL
341 + , "requests"
342 + , "iis.website_isapi_extension_requests_count"
343 + , "ISAPI extension requests"
344 + , "requests"
345 + , PLUGIN_WINDOWS_NAME
346 + , "PerflibWebService"
347 + , PRIO_WEBSITE_IIS_ISAPI_EXT_REQUEST_COUNT
348 + , update_every
349 + , RRDSET_TYPE_LINE
350 + );
351 +
352 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_current_isapi_extension_requests", windows_shared_buffer);
353 + p->rd_isapi_extension_request_count = rrddim_add(p->st_isapi_extension_request_count, id, "isapi",
354 + 1, 1, RRD_ALGORITHM_ABSOLUTE);
355 +
356 + rrdlabels_add(p->st_isapi_extension_request_count->rrdlabels, "website",
357 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
358 + }
359 +
360 + rrddim_set_by_pointer(p->st_isapi_extension_request_count,
361 + p->rd_isapi_extension_request_count,
362 + (collected_number)p->IISCurrentISAPIExtRequests.current.Data);
363 +
364 + rrdset_done(p->st_isapi_extension_request_count);
365 + }
366 +
367 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISIPAPIExtRequestsTotal)) {
368 + if (!p->st_isapi_extension_request_rate) {
369 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_isapi_extension_requests_rate", windows_shared_buffer);
370 + p->st_isapi_extension_request_rate = rrdset_create_localhost("iis"
371 + , id, NULL
372 + , "requests"
373 + , "iis.website_isapi_extension_requests_rate"
374 + , "Website extensions request"
375 + , "requests/s"
376 + , PLUGIN_WINDOWS_NAME
377 + , "PerflibWebService"
378 + , PRIO_WEBSITE_IIS_ISAPI_EXT_REQUEST_RATE
379 + , update_every
380 + , RRDSET_TYPE_LINE
381 + );
382 +
383 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_isapi_extension_requests_total", windows_shared_buffer);
384 + p->rd_isapi_extension_request_rate = rrddim_add(p->st_isapi_extension_request_rate, id, "isapi",
385 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
386 +
387 + rrdlabels_add(p->st_isapi_extension_request_rate->rrdlabels, "website",
388 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
389 + }
390 +
391 + rrddim_set_by_pointer(p->st_isapi_extension_request_rate,
392 + p->rd_isapi_extension_request_rate,
393 + (collected_number)p->IISIPAPIExtRequestsTotal.current.Data);
394 +
395 + rrdset_done(p->st_isapi_extension_request_rate);
396 + }
397 +
398 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISLockedErrorsTotal) &&
399 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISNotFoundErrorsTotal)) {
400 + if (!p->st_error_rate) {
401 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_errors_rate", windows_shared_buffer);
402 + p->st_error_rate = rrdset_create_localhost("iis",
403 + id, NULL
404 + ,"requests"
405 + , "iis.website_errors_rate"
406 + , "Website errors"
407 + , "errors/s"
408 + , PLUGIN_WINDOWS_NAME
409 + , "PerflibWebService"
410 + , PRIO_WEBSITE_IIS_USERS
411 + , update_every
412 + , RRDSET_TYPE_STACKED
413 + );
414 +
415 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_locked_errors_total", windows_shared_buffer);
416 + p->rd_error_rate_locked = rrddim_add(p->st_error_rate, id, "document_locked",
417 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
418 +
419 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_not_found_errors_total", windows_shared_buffer);
420 + p->rd_error_rate_not_found = rrddim_add(p->st_error_rate, id, "document_not_found",
421 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
422 +
423 + rrdlabels_add(p->st_error_rate->rrdlabels, "website", windows_shared_buffer, RRDLABEL_SRC_AUTO);
424 + }
425 +
426 + rrddim_set_by_pointer(p->st_error_rate,
427 + p->rd_error_rate_locked,
428 + (collected_number)p->IISLockedErrorsTotal.current.Data);
429 +
430 + rrddim_set_by_pointer(p->st_error_rate,
431 + p->rd_error_rate_not_found,
432 + (collected_number)p->IISNotFoundErrorsTotal.current.Data);
433 +
434 + rrdset_done(p->st_error_rate);
435 + }
436 +
437 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISLogonAttemptsTotal)) {
438 + if (!p->st_logon_attemps) {
439 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_logon_attempts_rate", windows_shared_buffer);
440 + p->st_logon_attemps = rrdset_create_localhost("iis"
441 + , id, NULL
442 + , "logon"
443 + , "iis.website_logon_attempts_rate"
444 + , "Website logon attempts"
445 + , "attempts/s"
446 + , PLUGIN_WINDOWS_NAME
447 + , "PerflibWebService"
448 + , PRIO_WEBSITE_IIS_LOGON_ATTEMPTS
449 + , update_every
450 + , RRDSET_TYPE_LINE
451 + );
452 +
453 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_logon_attempts_total", windows_shared_buffer);
454 + p->rd_logon_attemps = rrddim_add(p->st_logon_attemps, id, "logon",
455 + 1, 1, RRD_ALGORITHM_INCREMENTAL);
456 +
457 + rrdlabels_add(p->st_logon_attemps->rrdlabels, "website",
458 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
459 + }
460 +
461 + rrddim_set_by_pointer(p->st_logon_attemps,
462 + p->rd_logon_attemps,
463 + (collected_number)p->IISLogonAttemptsTotal.current.Data);
464 +
465 + rrdset_done(p->st_logon_attemps);
466 + }
467 +
468 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISUptime)) {
469 + if (!p->st_service_uptime) {
470 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_uptime", windows_shared_buffer);
471 + p->st_service_uptime = rrdset_create_localhost("iis"
472 + , id, NULL
473 + , "uptime"
474 + , "iis.website_uptime"
475 + , "Website uptime"
476 + , "seconds"
477 + , PLUGIN_WINDOWS_NAME
478 + , "PerflibWebService"
479 + , PRIO_WEBSITE_IIS_UPTIME
480 + , update_every
481 + , RRDSET_TYPE_LINE
482 + );
483 +
484 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_service_uptime", windows_shared_buffer);
485 + p->rd_service_uptime = rrddim_add(p->st_service_uptime, id, "uptime",
486 + 1, 1, RRD_ALGORITHM_ABSOLUTE);
487 +
488 + rrdlabels_add(p->st_service_uptime->rrdlabels, "website",
489 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
490 + }
491 +
492 + rrddim_set_by_pointer(p->st_service_uptime,
493 + p->rd_service_uptime,
494 + (collected_number)p->IISUptime.current.Data);
495 +
496 + rrdset_done(p->st_service_uptime);
497 + }
498 +
499 + if (perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsOptions) &&
500 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsGet) &&
501 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsPost) &&
502 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsHead) &&
503 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsPut) &&
504 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsDelete) &&
505 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsTrace) &&
506 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsMove) &&
507 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsCopy) &&
508 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsMkcol) &&
509 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsPropfind) &&
510 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsProppatch) &&
511 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsSearch) &&
512 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsLock) &&
513 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsUnlock) &&
514 + perflibGetInstanceCounter(pDataBlock, pObjectType, pi, &p->IISRequestsOther)) {
515 + if (!p->st_request_rate) {
516 + snprintfz(id, RRD_ID_LENGTH_MAX, "website_%s_requests_rate", windows_shared_buffer);
517 + p->st_request_rate = rrdset_create_localhost("iis"
518 + , id, NULL
519 + , "requests"
520 + , "iis.website_requests_rate"
521 + , "Website requests rate"
522 + , "requests/s"
523 + , PLUGIN_WINDOWS_NAME
524 + , "PerflibWebService"
525 + , PRIO_WEBSITE_IIS_REQUESTS_RATE
526 + , update_every
527 + , RRDSET_TYPE_LINE
528 + );
529 +
530 + snprintfz(id, RRD_ID_LENGTH_MAX, "iis_website_%s_requests_total", windows_shared_buffer);
531 + p->rd_request_rate = rrddim_add(p->st_request_rate, id, "requests",
532 + 1, 1, RRD_ALGORITHM_ABSOLUTE);
533 +
534 + rrdlabels_add(p->st_request_rate->rrdlabels, "website",
535 + windows_shared_buffer, RRDLABEL_SRC_AUTO);
536 + }
537 +
538 + uint64_t requests = p->IISRequestsOptions.current.Data + p->IISRequestsGet.current.Data +
539 + p->IISRequestsPost.current.Data + p->IISRequestsHead.current.Data +
540 + p->IISRequestsPut.current.Data + p->IISRequestsDelete.current.Data +
541 + p->IISRequestsTrace.current.Data + p->IISRequestsMove.current.Data +
542 + p->IISRequestsCopy.current.Data + p->IISRequestsMkcol.current.Data +
543 + p->IISRequestsPropfind.current.Data + p->IISRequestsProppatch.current.Data +
544 + p->IISRequestsSearch.current.Data + p->IISRequestsLock.current.Data +
545 + p->IISRequestsUnlock.current.Data + p->IISRequestsOther.current.Data;
546 +
547 + rrddim_set_by_pointer(p->st_request_rate,
548 + p->rd_request_rate,
549 + (collected_number)requests);
550 +
551 + rrdset_done(p->st_request_rate);
552 + }
553 + }
554 +
555 + return true;
556 +}
557 +
558 +int do_PerflibWebService(int update_every, usec_t dt __maybe_unused) {
559 + static bool initialized = false;
560 +
561 + if(unlikely(!initialized)) {
562 + initialize();
563 + initialized = true;
564 + }
565 +
566 + DWORD id = RegistryFindIDByName("Web Service");
567 + if(id == PERFLIB_REGISTRY_NAME_NOT_FOUND)
568 + return -1;
569 +
570 + PERF_DATA_BLOCK *pDataBlock = perflibGetPerformanceData(id);
571 + if(!pDataBlock) return -1;
572 +
573 + do_web_services(pDataBlock, update_every);
574 +
575 + return 0;
576 +}
src/collectors/windows.plugin/windows_plugin.c
+2
@@ -28,6 +28,8 @@ static struct proc_module {
28
29 {.name = "PerflibThermalZone", .dim = "PerflibThermalZone", .enabled = CONFIG_BOOLEAN_NO, .func = do_PerflibThermalZone},
30
31 + {.name = "PerflibWebService", .dim = "PerflibWebService", .enabled = CONFIG_BOOLEAN_YES, .func = do_PerflibWebService},
32 +
33 // the terminator of this array
34 {.name = NULL, .dim = NULL, .func = NULL}
35 };
src/collectors/windows.plugin/windows_plugin.h
+16
@@ -25,5 +25,21 @@ int do_PerflibProcessor(int update_every, usec_t dt);
25 int do_PerflibMemory(int update_every, usec_t dt);
26 int do_PerflibObjects(int update_every, usec_t dt);
27 int do_PerflibThermalZone(int update_every, usec_t dt);
28 +int do_PerflibWebService(int update_every, usec_t dt);
29 +
30 +enum PERFLIB_PRIO {
31 + PRIO_WEBSITE_IIS_TRAFFIC = 21000, // PRIO selected, because APPS is using 20YYY
32 + PRIO_WEBSITE_IIS_FTP_FILE_TRANSFER_RATE,
33 + PRIO_WEBSITE_IIS_ACTIVE_CONNECTIONS_COUNT,
34 + PRIO_WEBSITE_IIS_REQUESTS_RATE,
35 + PRIO_WEBSITE_IIS_CONNECTIONS_ATTEMP,
36 + PRIO_WEBSITE_IIS_USERS,
37 + PRIO_WEBSITE_IIS_ISAPI_EXT_REQUEST_COUNT,
38 + PRIO_WEBSITE_IIS_ISAPI_EXT_REQUEST_RATE,
39 + PRIO_WEBSITE_IIS_ERRORS_RATE,
40 + PRIO_WEBSITE_IIS_LOGON_ATTEMPTS,
41 + PRIO_WEBSITE_IIS_UPTIME
42 +};
43
44 #endif //NETDATA_WINDOWS_PLUGIN_H
45 +