master
c 713 lines 25.5 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include "windows_plugin.h"
4 #include "windows-internals.h"
5
6 struct adcs_certificate {
7 char *name;
8
9 RRDSET *st_adcs_requests_total;
10 RRDDIM *rd_adcs_requests_total;
11
12 RRDSET *st_adcs_failed_requests_total;
13 RRDDIM *rd_adcs_failed_requests_total;
14
15 RRDSET *st_adcs_issued_requests_total;
16 RRDDIM *rd_adcs_issued_requests_total;
17
18 RRDSET *st_adcs_pending_requests_total;
19 RRDDIM *rd_adcs_pending_requests_total;
20
21 RRDSET *st_adcs_request_processing_time_seconds;
22 RRDDIM *rd_adcs_request_processing_time_seconds;
23
24 RRDSET *st_adcs_retrievals_total;
25 RRDDIM *rd_adcs_retrievals_total;
26
27 RRDSET *st_adcs_retrievals_processing_time_seconds;
28 RRDDIM *rd_adcs_retrievals_processing_time_seconds;
29
30 RRDSET *st_adcs_request_cryptographic_signing_time_seconds;
31 RRDDIM *rd_adcs_request_cryptographic_signing_time_seconds;
32
33 RRDSET *st_adcs_request_policy_module_processing_time_seconds;
34 RRDDIM *rd_adcs_request_policy_module_processing_time_seconds;
35
36 RRDSET *st_adcs_challenge_responses_total;
37 RRDDIM *rd_adcs_challenge_responses_total;
38
39 RRDSET *st_adcs_challenge_response_processing_time_seconds;
40 RRDDIM *rd_adcs_challenge_response_processing_time_seconds;
41
42 RRDSET *st_adcs_signed_certificate_timestamp_lists_total;
43 RRDDIM *rd_adcs_signed_certificate_timestamp_lists_total;
44
45 RRDSET *st_adcs_signed_certificate_timestamp_list_processing_time_seconds;
46 RRDDIM *rd_adcs_signed_certificate_timestamp_list_processing_time_seconds;
47
48 COUNTER_DATA ADCSRequestsTotal;
49 COUNTER_DATA ADCSFailedRequestsTotal;
50 COUNTER_DATA ADCSIssuedRequestsTotal;
51 COUNTER_DATA ADCSPendingRequestsTotal;
52 COUNTER_DATA ADCSRequestProcessingTime;
53 COUNTER_DATA ADCSRetrievalsTotal;
54 COUNTER_DATA ADCSRetrievalsProcessingTime;
55 COUNTER_DATA ADCSRequestCryptoSigningTime;
56 COUNTER_DATA ADCSRequestPolicyModuleProcessingTime;
57 COUNTER_DATA ADCSChallengeResponseResponsesTotal;
58 COUNTER_DATA ADCSChallengeResponseProcessingTime;
59 COUNTER_DATA ADCSSignedCertTimestampListsTotal;
60 COUNTER_DATA ADCSSignedCertTimestampListProcessingTime;
61 };
62
63 static DICTIONARY *adcs_certificates = NULL;
64
65 void dict_adcs_insert_certificate_cb(const DICTIONARY_ITEM *item __maybe_unused, void *value, void *data __maybe_unused)
66 {
67 struct adcs_certificate *ptr = value;
68 const char *name = dictionary_acquired_item_name((DICTIONARY_ITEM *)item);
69
70 ptr->name = strdupz(name);
71
72 ptr->ADCSRequestsTotal.key = "Requests/sec";
73 ptr->ADCSFailedRequestsTotal.key = "Failed Requests/sec";
74 ptr->ADCSIssuedRequestsTotal.key = "Issued Requests/sec";
75 ptr->ADCSPendingRequestsTotal.key = "Pending Requests/sec";
76 ptr->ADCSRequestProcessingTime.key = "Request processing time (ms)";
77 ptr->ADCSRetrievalsTotal.key = "Retrievals/sec";
78 ptr->ADCSRetrievalsProcessingTime.key = "Retrieval processing time (ms)";
79 ptr->ADCSRequestCryptoSigningTime.key = "Request cryptographic signing time (ms)";
80 ptr->ADCSRequestPolicyModuleProcessingTime.key = "Request policy module processing time (ms)";
81 ptr->ADCSChallengeResponseResponsesTotal.key = "Challenge Responses/sec";
82 ptr->ADCSChallengeResponseProcessingTime.key = "Challenge Response processing time (ms)";
83 ptr->ADCSSignedCertTimestampListsTotal.key = "Signed Certificate Timestamp Lists/sec";
84 ptr->ADCSSignedCertTimestampListProcessingTime.key = "Signed Certificate Timestamp List processing time (ms)";
85 }
86
87 static void initialize(void)
88 {
89 adcs_certificates = dictionary_create_advanced(
90 DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_FIXED_SIZE, NULL, sizeof(struct adcs_certificate));
91
92 dictionary_register_insert_callback(adcs_certificates, dict_adcs_insert_certificate_cb, NULL);
93 }
94
95 static void netdata_adcs_requests(
96 struct adcs_certificate *ac,
97 PERF_DATA_BLOCK *pDataBlock,
98 PERF_OBJECT_TYPE *pObjectType,
99 int update_every)
100 {
101 char id[RRD_ID_LENGTH_MAX + 1];
102 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRequestsTotal)) {
103 return;
104 }
105
106 if (!ac->st_adcs_requests_total) {
107 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_requests", ac->name);
108 ac->st_adcs_requests_total = rrdset_create_localhost(
109 "adcs",
110 id,
111 NULL,
112 "requests",
113 "adcs.cert_requests",
114 "Certificate requests processed",
115 "requests/s",
116 PLUGIN_WINDOWS_NAME,
117 "PerflibADCS",
118 PRIO_ADCS_CERT_REQUESTS_TOTAL,
119 update_every,
120 RRDSET_TYPE_LINE);
121
122 ac->rd_adcs_requests_total =
123 rrddim_add(ac->st_adcs_requests_total, "requests", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
124
125 rrdlabels_add(ac->st_adcs_requests_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
126 }
127
128 rrddim_set_by_pointer(
129 ac->st_adcs_requests_total, ac->rd_adcs_requests_total, (collected_number)ac->ADCSRequestsTotal.current.Data);
130 rrdset_done(ac->st_adcs_requests_total);
131 }
132
133 static void netdata_adcs_requests_processing_time(
134 struct adcs_certificate *ac,
135 PERF_DATA_BLOCK *pDataBlock,
136 PERF_OBJECT_TYPE *pObjectType,
137 int update_every)
138 {
139 char id[RRD_ID_LENGTH_MAX + 1];
140 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRequestProcessingTime)) {
141 return;
142 }
143
144 if (!ac->st_adcs_request_processing_time_seconds) {
145 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_request_processing_time", ac->name);
146 ac->st_adcs_request_processing_time_seconds = rrdset_create_localhost(
147 "adcs",
148 id,
149 NULL,
150 "requests",
151 "adcs.cert_request_processing_time",
152 "Certificate last request processing time",
153 "seconds",
154 PLUGIN_WINDOWS_NAME,
155 "PerflibADCS",
156 PRIO_ADCS_CERT_REQUESTS_PROCESSING_TIME,
157 update_every,
158 RRDSET_TYPE_LINE);
159
160 ac->rd_adcs_request_processing_time_seconds = rrddim_add(
161 ac->st_adcs_request_processing_time_seconds, "processing_time", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
162
163 rrdlabels_add(ac->st_adcs_request_processing_time_seconds->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
164 }
165
166 rrddim_set_by_pointer(
167 ac->st_adcs_request_processing_time_seconds,
168 ac->rd_adcs_request_processing_time_seconds,
169 (collected_number)ac->ADCSRequestProcessingTime.current.Data);
170 rrdset_done(ac->st_adcs_request_processing_time_seconds);
171 }
172
173 static void netdata_adcs_retrievals(
174 struct adcs_certificate *ac,
175 PERF_DATA_BLOCK *pDataBlock,
176 PERF_OBJECT_TYPE *pObjectType,
177 int update_every)
178 {
179 char id[RRD_ID_LENGTH_MAX + 1];
180 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRetrievalsTotal)) {
181 return;
182 }
183
184 if (!ac->st_adcs_retrievals_total) {
185 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_retrievals", ac->name);
186 ac->st_adcs_retrievals_total = rrdset_create_localhost(
187 "adcs",
188 id,
189 NULL,
190 "retrievals",
191 "adcs.cert_retrievals",
192 "Total of certificate retrievals",
193 "retrievals/s",
194 PLUGIN_WINDOWS_NAME,
195 "PerflibADCS",
196 PRIO_ADCS_CERT_RETRIVALS,
197 update_every,
198 RRDSET_TYPE_LINE);
199
200 ac->rd_adcs_retrievals_total =
201 rrddim_add(ac->st_adcs_retrievals_total, "retrievals", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
202
203 rrdlabels_add(ac->st_adcs_retrievals_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
204 }
205
206 rrddim_set_by_pointer(
207 ac->st_adcs_retrievals_total,
208 ac->rd_adcs_retrievals_total,
209 (collected_number)ac->ADCSRetrievalsTotal.current.Data);
210 rrdset_done(ac->st_adcs_retrievals_total);
211 }
212
213 static void netdata_adcs_failed_requests(
214 struct adcs_certificate *ac,
215 PERF_DATA_BLOCK *pDataBlock,
216 PERF_OBJECT_TYPE *pObjectType,
217 int update_every)
218 {
219 char id[RRD_ID_LENGTH_MAX + 1];
220 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSFailedRequestsTotal)) {
221 return;
222 }
223
224 if (!ac->st_adcs_failed_requests_total) {
225 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_failed_requests", ac->name);
226 ac->st_adcs_failed_requests_total = rrdset_create_localhost(
227 "adcs",
228 id,
229 NULL,
230 "requests",
231 "adcs.cert_failed_requests",
232 "Certificate failed requests processed",
233 "requests/s",
234 PLUGIN_WINDOWS_NAME,
235 "PerflibADCS",
236 PRIO_ADCS_CERT_FAILED_REQUESTS,
237 update_every,
238 RRDSET_TYPE_LINE);
239
240 ac->rd_adcs_failed_requests_total =
241 rrddim_add(ac->st_adcs_failed_requests_total, "failed", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
242
243 rrdlabels_add(ac->st_adcs_failed_requests_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
244 }
245
246 rrddim_set_by_pointer(
247 ac->st_adcs_failed_requests_total,
248 ac->rd_adcs_failed_requests_total,
249 (collected_number)ac->ADCSFailedRequestsTotal.current.Data);
250 rrdset_done(ac->st_adcs_failed_requests_total);
251 }
252
253 static void netdata_adcs_issued_requests(
254 struct adcs_certificate *ac,
255 PERF_DATA_BLOCK *pDataBlock,
256 PERF_OBJECT_TYPE *pObjectType,
257 int update_every)
258 {
259 char id[RRD_ID_LENGTH_MAX + 1];
260 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSIssuedRequestsTotal)) {
261 return;
262 }
263
264 if (!ac->st_adcs_issued_requests_total) {
265 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_issued_requests", ac->name);
266 ac->st_adcs_issued_requests_total = rrdset_create_localhost(
267 "adcs",
268 id,
269 NULL,
270 "requests",
271 "adcs.cert_issued_requests",
272 "Certificate issued requests processed",
273 "requests/s",
274 PLUGIN_WINDOWS_NAME,
275 "PerflibADCS",
276 PRIO_ADCS_CERT_ISSUED_REQUESTS,
277 update_every,
278 RRDSET_TYPE_LINE);
279
280 ac->rd_adcs_issued_requests_total =
281 rrddim_add(ac->st_adcs_issued_requests_total, "issued", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
282
283 rrdlabels_add(ac->st_adcs_issued_requests_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
284 }
285
286 rrddim_set_by_pointer(
287 ac->st_adcs_issued_requests_total,
288 ac->rd_adcs_issued_requests_total,
289 (collected_number)ac->ADCSIssuedRequestsTotal.current.Data);
290 rrdset_done(ac->st_adcs_issued_requests_total);
291 }
292
293 static void netdata_adcs_pending_requests(
294 struct adcs_certificate *ac,
295 PERF_DATA_BLOCK *pDataBlock,
296 PERF_OBJECT_TYPE *pObjectType,
297 int update_every)
298 {
299 char id[RRD_ID_LENGTH_MAX + 1];
300 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSPendingRequestsTotal)) {
301 return;
302 }
303
304 if (!ac->st_adcs_pending_requests_total) {
305 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_pending_requests", ac->name);
306 ac->st_adcs_pending_requests_total = rrdset_create_localhost(
307 "adcs",
308 id,
309 NULL,
310 "requests",
311 "adcs.cert_pending_requests",
312 "Certificate pending requests processed",
313 "requests/s",
314 PLUGIN_WINDOWS_NAME,
315 "PerflibADCS",
316 PRIO_ADCS_CERT_PENDING_REQUESTS,
317 update_every,
318 RRDSET_TYPE_LINE);
319
320 ac->rd_adcs_pending_requests_total =
321 rrddim_add(ac->st_adcs_pending_requests_total, "pending", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
322
323 rrdlabels_add(ac->st_adcs_pending_requests_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
324 }
325
326 rrddim_set_by_pointer(
327 ac->st_adcs_pending_requests_total,
328 ac->rd_adcs_pending_requests_total,
329 (collected_number)ac->ADCSPendingRequestsTotal.current.Data);
330 rrdset_done(ac->st_adcs_pending_requests_total);
331 }
332
333 static void netdata_adcs_challenge_response(
334 struct adcs_certificate *ac,
335 PERF_DATA_BLOCK *pDataBlock,
336 PERF_OBJECT_TYPE *pObjectType,
337 int update_every)
338 {
339 char id[RRD_ID_LENGTH_MAX + 1];
340 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSChallengeResponseResponsesTotal)) {
341 return;
342 }
343
344 if (!ac->st_adcs_challenge_responses_total) {
345 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_challenge_responses", ac->name);
346 ac->st_adcs_challenge_responses_total = rrdset_create_localhost(
347 "adcs",
348 id,
349 NULL,
350 "responses",
351 "adcs.cert_challenge_responses",
352 "Certificate challenge responses",
353 "responses/s",
354 PLUGIN_WINDOWS_NAME,
355 "PerflibADCS",
356 PRIO_ADCS_CERT_CHALLENGE_RESPONSES,
357 update_every,
358 RRDSET_TYPE_LINE);
359
360 ac->rd_adcs_challenge_responses_total =
361 rrddim_add(ac->st_adcs_challenge_responses_total, "challenge", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
362
363 rrdlabels_add(ac->st_adcs_challenge_responses_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
364 }
365
366 rrddim_set_by_pointer(
367 ac->st_adcs_challenge_responses_total,
368 ac->rd_adcs_challenge_responses_total,
369 (collected_number)ac->ADCSChallengeResponseResponsesTotal.current.Data);
370 rrdset_done(ac->st_adcs_challenge_responses_total);
371 }
372
373 static void netdata_adcs_retrieval_processing(
374 struct adcs_certificate *ac,
375 PERF_DATA_BLOCK *pDataBlock,
376 PERF_OBJECT_TYPE *pObjectType,
377 int update_every)
378 {
379 char id[RRD_ID_LENGTH_MAX + 1];
380 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRetrievalsProcessingTime)) {
381 return;
382 }
383
384 if (!ac->st_adcs_retrievals_processing_time_seconds) {
385 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_retrievals_processing_time", ac->name);
386 ac->st_adcs_retrievals_processing_time_seconds = rrdset_create_localhost(
387 "adcs",
388 id,
389 NULL,
390 "retrievals",
391 "adcs.cert_retrieval_processing_time",
392 "Certificate last retrieval processing time",
393 "seconds",
394 PLUGIN_WINDOWS_NAME,
395 "PerflibADCS",
396 PRIO_ADCS_CERT_RETRIEVAL_PROCESSING_TIME,
397 update_every,
398 RRDSET_TYPE_LINE);
399
400 ac->rd_adcs_retrievals_processing_time_seconds = rrddim_add(
401 ac->st_adcs_retrievals_processing_time_seconds, "processing_time", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
402
403 rrdlabels_add(ac->st_adcs_retrievals_processing_time_seconds->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
404 }
405
406 rrddim_set_by_pointer(
407 ac->st_adcs_retrievals_processing_time_seconds,
408 ac->rd_adcs_retrievals_processing_time_seconds,
409 (collected_number)ac->ADCSRetrievalsProcessingTime.current.Data);
410 rrdset_done(ac->st_adcs_retrievals_processing_time_seconds);
411 }
412
413 static void netdata_adcs_crypto_signing_time(
414 struct adcs_certificate *ac,
415 PERF_DATA_BLOCK *pDataBlock,
416 PERF_OBJECT_TYPE *pObjectType,
417 int update_every)
418 {
419 char id[RRD_ID_LENGTH_MAX + 1];
420 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRequestCryptoSigningTime)) {
421 return;
422 }
423
424 if (!ac->st_adcs_request_cryptographic_signing_time_seconds) {
425 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_request_cryptographic_signing_time", ac->name);
426 ac->st_adcs_request_cryptographic_signing_time_seconds = rrdset_create_localhost(
427 "adcs",
428 id,
429 NULL,
430 "timings",
431 "adcs.cert_request_cryptographic_signing_time",
432 "Certificate last signing operation request time",
433 "seconds",
434 PLUGIN_WINDOWS_NAME,
435 "PerflibADCS",
436 PRIO_ADCS_CERT_REQ_CRYPTO_SIGNING_TIME,
437 update_every,
438 RRDSET_TYPE_LINE);
439
440 ac->rd_adcs_request_cryptographic_signing_time_seconds = rrddim_add(
441 ac->st_adcs_request_cryptographic_signing_time_seconds,
442 "signing_time",
443 NULL,
444 1,
445 1000,
446 RRD_ALGORITHM_ABSOLUTE);
447
448 rrdlabels_add(
449 ac->st_adcs_request_cryptographic_signing_time_seconds->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
450 }
451
452 rrddim_set_by_pointer(
453 ac->st_adcs_request_cryptographic_signing_time_seconds,
454 ac->rd_adcs_request_cryptographic_signing_time_seconds,
455 (collected_number)ac->ADCSRequestCryptoSigningTime.current.Data);
456 rrdset_done(ac->st_adcs_request_cryptographic_signing_time_seconds);
457 }
458
459 static void netdata_adcs_policy_mod_processing_time(
460 struct adcs_certificate *ac,
461 PERF_DATA_BLOCK *pDataBlock,
462 PERF_OBJECT_TYPE *pObjectType,
463 int update_every)
464 {
465 char id[RRD_ID_LENGTH_MAX + 1];
466 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSRequestPolicyModuleProcessingTime)) {
467 return;
468 }
469
470 if (!ac->st_adcs_request_policy_module_processing_time_seconds) {
471 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_request_policy_module_processing_time", ac->name);
472 ac->st_adcs_request_policy_module_processing_time_seconds = rrdset_create_localhost(
473 "adcs",
474 id,
475 NULL,
476 "timings",
477 "adcs.cert_request_policy_module_processing",
478 "Certificate last policy module processing request time",
479 "seconds",
480 PLUGIN_WINDOWS_NAME,
481 "PerflibADCS",
482 PRIO_ADCS_CERT_REQ_POLICY_MODULE_PROCESS_TIME,
483 update_every,
484 RRDSET_TYPE_LINE);
485
486 ac->rd_adcs_request_policy_module_processing_time_seconds = rrddim_add(
487 ac->st_adcs_request_policy_module_processing_time_seconds,
488 "processing_time",
489 NULL,
490 1,
491 1000,
492 RRD_ALGORITHM_ABSOLUTE);
493
494 rrdlabels_add(
495 ac->st_adcs_request_policy_module_processing_time_seconds->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
496 }
497
498 rrddim_set_by_pointer(
499 ac->st_adcs_request_policy_module_processing_time_seconds,
500 ac->rd_adcs_request_policy_module_processing_time_seconds,
501 (collected_number)ac->ADCSRequestPolicyModuleProcessingTime.current.Data);
502 rrdset_done(ac->st_adcs_request_policy_module_processing_time_seconds);
503 }
504
505 static void netdata_adcs_challenge_response_processing_time(
506 struct adcs_certificate *ac,
507 PERF_DATA_BLOCK *pDataBlock,
508 PERF_OBJECT_TYPE *pObjectType,
509 int update_every)
510 {
511 char id[RRD_ID_LENGTH_MAX + 1];
512 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSChallengeResponseProcessingTime)) {
513 return;
514 }
515
516 if (!ac->st_adcs_challenge_response_processing_time_seconds) {
517 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_challenge_response_processing_time", ac->name);
518 ac->st_adcs_challenge_response_processing_time_seconds = rrdset_create_localhost(
519 "adcs",
520 id,
521 NULL,
522 "timings",
523 "adcs.cert_challenge_response_processing_time",
524 "Certificate last challenge response time",
525 "seconds",
526 PLUGIN_WINDOWS_NAME,
527 "PerflibADCS",
528 PRIO_ADCS_CERT_CHALLENGE_RESP_PROCESSING_TIME,
529 update_every,
530 RRDSET_TYPE_LINE);
531
532 ac->rd_adcs_challenge_response_processing_time_seconds = rrddim_add(
533 ac->st_adcs_challenge_response_processing_time_seconds,
534 "processing_time",
535 NULL,
536 1,
537 1000,
538 RRD_ALGORITHM_ABSOLUTE);
539
540 rrdlabels_add(
541 ac->st_adcs_challenge_response_processing_time_seconds->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
542 }
543
544 rrddim_set_by_pointer(
545 ac->st_adcs_challenge_response_processing_time_seconds,
546 ac->rd_adcs_challenge_response_processing_time_seconds,
547 (collected_number)ac->ADCSChallengeResponseProcessingTime.current.Data);
548 rrdset_done(ac->st_adcs_challenge_response_processing_time_seconds);
549 }
550
551 static void netdata_adcs_signed_certificate_timestamp_list(
552 struct adcs_certificate *ac,
553 PERF_DATA_BLOCK *pDataBlock,
554 PERF_OBJECT_TYPE *pObjectType,
555 int update_every)
556 {
557 char id[RRD_ID_LENGTH_MAX + 1];
558 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSSignedCertTimestampListsTotal)) {
559 return;
560 }
561
562 if (!ac->st_adcs_signed_certificate_timestamp_lists_total) {
563 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_signed_certificate_timestamp_lists", ac->name);
564 ac->st_adcs_signed_certificate_timestamp_lists_total = rrdset_create_localhost(
565 "adcs",
566 id,
567 NULL,
568 "timings",
569 "adcs.cert_signed_certificate_timestamp_lists",
570 "Certificate Signed Certificate Timestamp Lists processed",
571 "lists/s",
572 PLUGIN_WINDOWS_NAME,
573 "PerflibADCS",
574 PRIO_ADCS_CERT_SIGNED_CERTIFICATE_TIMESTAMP_LIST,
575 update_every,
576 RRDSET_TYPE_LINE);
577
578 ac->rd_adcs_signed_certificate_timestamp_lists_total = rrddim_add(
579 ac->st_adcs_signed_certificate_timestamp_lists_total,
580 "signed_timestamp_list",
581 NULL,
582 1,
583 1,
584 RRD_ALGORITHM_INCREMENTAL);
585
586 rrdlabels_add(
587 ac->st_adcs_signed_certificate_timestamp_lists_total->rrdlabels, "cert", ac->name, RRDLABEL_SRC_AUTO);
588 }
589
590 rrddim_set_by_pointer(
591 ac->st_adcs_signed_certificate_timestamp_lists_total,
592 ac->rd_adcs_signed_certificate_timestamp_lists_total,
593 (collected_number)ac->ADCSSignedCertTimestampListsTotal.current.Data);
594 rrdset_done(ac->st_adcs_signed_certificate_timestamp_lists_total);
595 }
596
597 static void netdata_adcs_signed_certificate_timestamp_list_processing(
598 struct adcs_certificate *ac,
599 PERF_DATA_BLOCK *pDataBlock,
600 PERF_OBJECT_TYPE *pObjectType,
601 int update_every)
602 {
603 char id[RRD_ID_LENGTH_MAX + 1];
604 if (!perflibGetObjectCounter(pDataBlock, pObjectType, &ac->ADCSSignedCertTimestampListProcessingTime)) {
605 return;
606 }
607
608 if (!ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds) {
609 snprintfz(id, RRD_ID_LENGTH_MAX, "cert_%s_signed_certificate_timestamp_list_processing_time", ac->name);
610 ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds = rrdset_create_localhost(
611 "adcs",
612 id,
613 NULL,
614 "timings",
615 "adcs.cert_signed_certificate_timestamp_list_processing_time",
616 "Certificate last Signed Certificate Timestamp List process time",
617 "seconds",
618 PLUGIN_WINDOWS_NAME,
619 "PerflibADCS",
620 PRIO_ADCS_CERT_SIGNED_CERTIFICATE_TIMESTAMP_PROC_TIME_LIST,
621 update_every,
622 RRDSET_TYPE_LINE);
623
624 ac->rd_adcs_signed_certificate_timestamp_list_processing_time_seconds = rrddim_add(
625 ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds,
626 "list",
627 NULL,
628 1,
629 1000,
630 RRD_ALGORITHM_ABSOLUTE);
631
632 rrdlabels_add(
633 ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds->rrdlabels,
634 "cert",
635 ac->name,
636 RRDLABEL_SRC_AUTO);
637 }
638
639 rrddim_set_by_pointer(
640 ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds,
641 ac->rd_adcs_signed_certificate_timestamp_list_processing_time_seconds,
642 (collected_number)ac->ADCSSignedCertTimestampListProcessingTime.current.Data);
643 rrdset_done(ac->st_adcs_signed_certificate_timestamp_list_processing_time_seconds);
644 }
645
646 #define CERTIFICATION_AUTHORITY "Certification Authority"
647 static bool do_ADCS(PERF_DATA_BLOCK *pDataBlock, int update_every)
648 {
649 PERF_OBJECT_TYPE *pObjectType = perflibFindObjectTypeByName(pDataBlock, CERTIFICATION_AUTHORITY);
650 if (!pObjectType)
651 return false;
652
653 static void (*doADCS[])(struct adcs_certificate *, PERF_DATA_BLOCK *, PERF_OBJECT_TYPE *, int) = {
654 netdata_adcs_requests,
655 netdata_adcs_requests_processing_time,
656 netdata_adcs_retrievals,
657 netdata_adcs_failed_requests,
658 netdata_adcs_issued_requests,
659 netdata_adcs_pending_requests,
660 netdata_adcs_challenge_response,
661 netdata_adcs_retrieval_processing,
662 netdata_adcs_crypto_signing_time,
663 netdata_adcs_policy_mod_processing_time,
664 netdata_adcs_challenge_response_processing_time,
665 netdata_adcs_signed_certificate_timestamp_list,
666 netdata_adcs_signed_certificate_timestamp_list_processing,
667
668 // This must be the end
669 NULL};
670
671 PERF_INSTANCE_DEFINITION *pi = NULL;
672 for (LONG i = 0; i < pObjectType->NumInstances; i++) {
673 pi = perflibForEachInstance(pDataBlock, pObjectType, pi);
674 if (!pi)
675 break;
676
677 if (!getInstanceName(pDataBlock, pObjectType, pi, windows_shared_buffer, sizeof(windows_shared_buffer)))
678 strncpyz(windows_shared_buffer, "[unknown]", sizeof(windows_shared_buffer) - 1);
679
680 if (strcasecmp(windows_shared_buffer, "_Total") == 0)
681 continue;
682
683 struct adcs_certificate *ptr = dictionary_set(adcs_certificates, windows_shared_buffer, NULL, sizeof(*ptr));
684
685 for (int j = 0; doADCS[j]; j++)
686 doADCS[j](ptr, pDataBlock, pObjectType, update_every);
687 }
688
689 return true;
690 }
691
692 int do_PerflibADCS(int update_every, usec_t dt __maybe_unused)
693 {
694 static bool initialized = false;
695
696 if (unlikely(!initialized)) {
697 initialize();
698 initialized = true;
699 }
700
701 DWORD id = RegistryFindIDByName(CERTIFICATION_AUTHORITY);
702 if (id == PERFLIB_REGISTRY_NAME_NOT_FOUND)
703 return -1;
704
705 PERF_DATA_BLOCK *pDataBlock = perflibGetPerformanceData(id);
706 if (!pDataBlock)
707 return -1;
708
709 if (!do_ADCS(pDataBlock, update_every))
710 return -1;
711
712 return 0;
713 }