github.com/netdata/go.d.plugin@v0.58.1/modules/windows/collect_adcs.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 package windows 4 5 import ( 6 "strings" 7 8 "github.com/netdata/go.d.plugin/pkg/prometheus" 9 ) 10 11 const ( 12 metricADCSRequestsTotal = "windows_adcs_requests_total" 13 metricADCSFailedRequestsTotal = "windows_adcs_failed_requests_total" 14 metricADCSIssuedRequestsTotal = "windows_adcs_issued_requests_total" 15 metricADCSPendingRequestsTotal = "windows_adcs_pending_requests_total" 16 metricADCSRequestProcessingTime = "windows_adcs_request_processing_time_seconds" 17 metricADCSRetrievalsTotal = "windows_adcs_retrievals_total" 18 metricADCSRetrievalsProcessingTime = "windows_adcs_retrievals_processing_time_seconds" 19 metricADCSRequestCryptoSigningTime = "windows_adcs_request_cryptographic_signing_time_seconds" 20 metricADCSRequestPolicyModuleProcessingTime = "windows_adcs_request_policy_module_processing_time_seconds" 21 metricADCSChallengeResponseResponsesTotal = "windows_adcs_challenge_responses_total" 22 metricADCSChallengeResponseProcessingTime = "windows_adcs_challenge_response_processing_time_seconds" 23 metricADCSSignedCertTimestampListsTotal = "windows_adcs_signed_certificate_timestamp_lists_total" 24 metricADCSSignedCertTimestampListProcessingTime = "windows_adcs_signed_certificate_timestamp_list_processing_time_seconds" 25 ) 26 27 func (w *Windows) collectADCS(mx map[string]int64, pms prometheus.Series) { 28 pms = pms.FindByNames( 29 metricADCSRequestsTotal, 30 metricADCSFailedRequestsTotal, 31 metricADCSIssuedRequestsTotal, 32 metricADCSPendingRequestsTotal, 33 metricADCSRequestProcessingTime, 34 metricADCSRetrievalsTotal, 35 metricADCSRetrievalsProcessingTime, 36 metricADCSRequestCryptoSigningTime, 37 metricADCSRequestPolicyModuleProcessingTime, 38 metricADCSChallengeResponseResponsesTotal, 39 metricADCSChallengeResponseProcessingTime, 40 metricADCSSignedCertTimestampListsTotal, 41 metricADCSSignedCertTimestampListProcessingTime, 42 ) 43 44 seen := make(map[string]bool) 45 46 for _, pm := range pms { 47 if tmpl := pm.Labels.Get("cert_template"); tmpl != "" && tmpl != "_Total" { 48 seen[tmpl] = true 49 name := strings.TrimPrefix(pm.Name(), "windows_adcs_") 50 v := pm.Value 51 if strings.HasSuffix(pm.Name(), "_seconds") { 52 v *= precision 53 } 54 mx["adcs_cert_template_"+tmpl+"_"+name] += int64(v) 55 } 56 } 57 58 for template := range seen { 59 if !w.cache.adcs[template] { 60 w.cache.adcs[template] = true 61 w.addCertificateTemplateCharts(template) 62 } 63 } 64 for template := range w.cache.adcs { 65 if !seen[template] { 66 delete(w.cache.adcs, template) 67 w.removeCertificateTemplateCharts(template) 68 } 69 } 70 }