diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2024-02-13 06:56:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-13 06:56:20 -0500 |
commit | 3a29b66132f561c910d827e8c7ae82997f7c1f30 (patch) | |
tree | a9306156631b6b188de8877f7c1dbdbe8b067804 /src/go/collectors/go.d.plugin/modules/windows/collect_iis.go | |
parent | 57eec3da0e51baa400037ccc4b547cb839ab6ffa (diff) |
Include Go plugin sources in main repository. (#16997)
* Include Go plugin sources in main repository.
* Fix CI issues.
* Rename source tree.
Diffstat (limited to 'src/go/collectors/go.d.plugin/modules/windows/collect_iis.go')
-rw-r--r-- | src/go/collectors/go.d.plugin/modules/windows/collect_iis.go | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/src/go/collectors/go.d.plugin/modules/windows/collect_iis.go b/src/go/collectors/go.d.plugin/modules/windows/collect_iis.go new file mode 100644 index 0000000000..5e9cd03f16 --- /dev/null +++ b/src/go/collectors/go.d.plugin/modules/windows/collect_iis.go @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package windows + +import ( + "strings" + + "github.com/netdata/go.d.plugin/pkg/prometheus" +) + +const ( + metricIISCurrentAnonymousUsers = "windows_iis_current_anonymous_users" + metricIISCurrentNonAnonymousUsers = "windows_iis_current_non_anonymous_users" + metricIISCurrentConnections = "windows_iis_current_connections" + metricIICurrentISAPIExtRequests = "windows_iis_current_isapi_extension_requests" + metricIISUptime = "windows_iis_service_uptime" + + metricIISReceivedBytesTotal = "windows_iis_received_bytes_total" + metricIISSentBytesTotal = "windows_iis_sent_bytes_total" + metricIISRequestsTotal = "windows_iis_requests_total" + metricIISIPAPIExtRequestsTotal = "windows_iis_ipapi_extension_requests_total" + metricIISConnAttemptsAllInstancesTotal = "windows_iis_connection_attempts_all_instances_total" + metricIISFilesReceivedTotal = "windows_iis_files_received_total" + metricIISFilesSentTotal = "windows_iis_files_sent_total" + metricIISLogonAttemptsTotal = "windows_iis_logon_attempts_total" + metricIISLockedErrorsTotal = "windows_iis_locked_errors_total" + metricIISNotFoundErrorsTotal = "windows_iis_not_found_errors_total" +) + +func (w *Windows) collectIIS(mx map[string]int64, pms prometheus.Series) { + seen := make(map[string]bool) + px := "iis_website_" + for _, pm := range pms.FindByName(metricIISCurrentAnonymousUsers) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_current_anonymous_users"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISCurrentNonAnonymousUsers) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_current_non_anonymous_users"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISCurrentConnections) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_current_connections"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIICurrentISAPIExtRequests) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_current_isapi_extension_requests"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISUptime) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_service_uptime"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISReceivedBytesTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_received_bytes_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISSentBytesTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_sent_bytes_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISRequestsTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_requests_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISConnAttemptsAllInstancesTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_connection_attempts_all_instances_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISFilesReceivedTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_files_received_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISFilesSentTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_files_sent_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISIPAPIExtRequestsTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_isapi_extension_requests_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISLogonAttemptsTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_logon_attempts_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISLockedErrorsTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_locked_errors_total"] += int64(pm.Value) + } + } + for _, pm := range pms.FindByName(metricIISNotFoundErrorsTotal) { + if name := cleanWebsiteName(pm.Labels.Get("site")); name != "" { + seen[name] = true + mx[px+name+"_not_found_errors_total"] += int64(pm.Value) + } + } + + for site := range seen { + if !w.cache.iis[site] { + w.cache.iis[site] = true + w.addIISWebsiteCharts(site) + } + } + for site := range w.cache.iis { + if !seen[site] { + delete(w.cache.iis, site) + w.removeIIWebsiteSCharts(site) + } + } +} + +func cleanWebsiteName(name string) string { + return strings.ReplaceAll(name, " ", "_") +} |