mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-19 03:06:37 +00:00
Compare commits
15 Commits
v0.30.0-rc
...
v0.30.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86e6d12518 | ||
|
|
4cd9627ebf | ||
|
|
81ea4c6223 | ||
|
|
78386557d4 | ||
|
|
a9f8b3b722 | ||
|
|
39c929eefe | ||
|
|
eea5a50d5c | ||
|
|
a9698e27bf | ||
|
|
fac83b3c74 | ||
|
|
0fc926c0b0 | ||
|
|
57a3e84cec | ||
|
|
2aebd5c2da | ||
|
|
109c34f572 | ||
|
|
0ad8e01e0e | ||
|
|
3a3b50f898 |
@@ -2,7 +2,7 @@
|
|||||||
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
|
<configuration default="false" name="all" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="run">
|
||||||
<module name="windows_exporter" />
|
<module name="windows_exporter" />
|
||||||
<working_directory value="$PROJECT_DIR$" />
|
<working_directory value="$PROJECT_DIR$" />
|
||||||
<parameters value="--web.listen-address=127.0.0.1:9182 --log.level=info --collectors.enabled=ad,adcs,adfs,cache,container,cpu,cpu_info,cs,dfsr,dhcp,diskdrive,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,logon,memory,mscluster,msmq,mssql,net,netframework,nps,os,pagefile,performancecounter,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware --debug.enabled" />
|
<parameters value="--web.listen-address=127.0.0.1:9182 --log.level=info --collectors.enabled=ad,adcs,adfs,cache,container,cpu,cpu_info,cs,dfsr,dhcp,diskdrive,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,logon,memory,mscluster,msmq,mssql,net,netframework,nps,os,pagefile,performancecounter,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware,performancecounter --debug.enabled --collector.performancecounter.objects='[{ "name": "memory", "type": "formatted", "object": "Memory", "counters": [{ "name":"Cache Faults/sec", "type":"counter" }]}]'" />
|
||||||
<sudo value="true" />
|
<sudo value="true" />
|
||||||
<kind value="PACKAGE" />
|
<kind value="PACKAGE" />
|
||||||
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
|
<package value="github.com/prometheus-community/windows_exporter/cmd/windows_exporter" />
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"os/user"
|
"os/user"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -66,6 +67,7 @@ func main() {
|
|||||||
|
|
||||||
func run() int {
|
func run() int {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
|
app := kingpin.New("windows_exporter", "A metrics collector for Windows.")
|
||||||
|
|
||||||
@@ -103,6 +105,10 @@ func run() int {
|
|||||||
"process.priority",
|
"process.priority",
|
||||||
"Priority of the exporter process. Higher priorities may improve exporter responsiveness during periods of system load. Can be one of [\"realtime\", \"high\", \"abovenormal\", \"normal\", \"belownormal\", \"low\"]",
|
"Priority of the exporter process. Higher priorities may improve exporter responsiveness during periods of system load. Can be one of [\"realtime\", \"high\", \"abovenormal\", \"normal\", \"belownormal\", \"low\"]",
|
||||||
).Default("normal").String()
|
).Default("normal").String()
|
||||||
|
memoryLimit = app.Flag(
|
||||||
|
"process.memory-limit",
|
||||||
|
"Limit memory usage in bytes. This is a soft-limit and not guaranteed. 0 means no limit. Read more at https://pkg.go.dev/runtime/debug#SetMemoryLimit .",
|
||||||
|
).Default("200000000").Int64()
|
||||||
)
|
)
|
||||||
|
|
||||||
logFile := &log.AllowedFile{}
|
logFile := &log.AllowedFile{}
|
||||||
@@ -132,6 +138,8 @@ func run() int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug.SetMemoryLimit(*memoryLimit)
|
||||||
|
|
||||||
logger, err := log.New(logConfig)
|
logger, err := log.New(logConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//nolint:sloglint // we do not have an logger yet
|
//nolint:sloglint // we do not have an logger yet
|
||||||
@@ -143,7 +151,7 @@ func run() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *configFile != "" {
|
if *configFile != "" {
|
||||||
resolver, err := config.NewResolver(*configFile, logger, *insecureSkipVerify)
|
resolver, err := config.NewResolver(ctx, *configFile, logger, *insecureSkipVerify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("could not load config file",
|
logger.Error("could not load config file",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
@@ -153,7 +161,7 @@ func run() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err = resolver.Bind(app, os.Args[1:]); err != nil {
|
if err = resolver.Bind(app, os.Args[1:]); err != nil {
|
||||||
logger.Error("Failed to bind configuration",
|
logger.ErrorContext(ctx, "failed to bind configuration",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -167,7 +175,7 @@ func run() int {
|
|||||||
|
|
||||||
// Parse flags once more to include those discovered in configuration file(s).
|
// Parse flags once more to include those discovered in configuration file(s).
|
||||||
if _, err = app.Parse(os.Args[1:]); err != nil {
|
if _, err = app.Parse(os.Args[1:]); err != nil {
|
||||||
logger.Error("Failed to parse CLI args from YAML file",
|
logger.ErrorContext(ctx, "failed to parse CLI args from YAML file",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -185,7 +193,7 @@ func run() int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("Logging has Started")
|
logger.LogAttrs(ctx, slog.LevelDebug, "logging has Started")
|
||||||
|
|
||||||
if err = setPriorityWindows(logger, os.Getpid(), *processPriority); err != nil {
|
if err = setPriorityWindows(logger, os.Getpid(), *processPriority); err != nil {
|
||||||
logger.Error("failed to set process priority",
|
logger.Error("failed to set process priority",
|
||||||
@@ -207,15 +215,17 @@ func run() int {
|
|||||||
// Initialize collectors before loading
|
// Initialize collectors before loading
|
||||||
if err = collectors.Build(logger); err != nil {
|
if err = collectors.Build(logger); err != nil {
|
||||||
for _, err := range utils.SplitError(err) {
|
for _, err := range utils.SplitError(err) {
|
||||||
logger.Warn("couldn't initialize collector",
|
logger.Error("couldn't initialize collector",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logCurrentUser(logger)
|
logCurrentUser(logger)
|
||||||
|
|
||||||
logger.Info("Enabled collectors: " + strings.Join(enabledCollectorList, ", "))
|
logger.InfoContext(ctx, "Enabled collectors: "+strings.Join(enabledCollectorList, ", "))
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("GET /health", httphandler.NewHealthHandler())
|
mux.Handle("GET /health", httphandler.NewHealthHandler())
|
||||||
@@ -233,7 +243,7 @@ func run() int {
|
|||||||
mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
|
mux.HandleFunc("GET /debug/pprof/trace", pprof.Trace)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info(fmt.Sprintf("starting windows_exporter in %s", time.Since(startTime)),
|
logger.LogAttrs(ctx, slog.LevelInfo, fmt.Sprintf("starting windows_exporter in %s", time.Since(startTime)),
|
||||||
slog.String("version", version.Version),
|
slog.String("version", version.Version),
|
||||||
slog.String("branch", version.Branch),
|
slog.String("branch", version.Branch),
|
||||||
slog.String("revision", version.GetRevision()),
|
slog.String("revision", version.GetRevision()),
|
||||||
@@ -260,7 +270,7 @@ func run() int {
|
|||||||
close(errCh)
|
close(errCh)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
|
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, os.Kill)
|
||||||
defer stop()
|
defer stop()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
@@ -270,7 +280,7 @@ func run() int {
|
|||||||
logger.Info("Shutting down windows_exporter via service control")
|
logger.Info("Shutting down windows_exporter via service control")
|
||||||
case err := <-errCh:
|
case err := <-errCh:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to start windows_exporter",
|
logger.ErrorContext(ctx, "Failed to start windows_exporter",
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -283,7 +293,7 @@ func run() int {
|
|||||||
|
|
||||||
_ = server.Shutdown(ctx)
|
_ = server.Shutdown(ctx)
|
||||||
|
|
||||||
logger.Info("windows_exporter has shut down")
|
logger.InfoContext(ctx, "windows_exporter has shut down")
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -324,7 +334,7 @@ func setPriorityWindows(logger *slog.Logger, pid int, priority string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("setting process priority to " + priority)
|
logger.LogAttrs(context.Background(), slog.LevelDebug, "setting process priority to "+priority)
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
// https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
||||||
handle, err := windows.OpenProcess(
|
handle, err := windows.OpenProcess(
|
||||||
|
|||||||
16
config.yaml
16
config.yaml
@@ -1,9 +1,23 @@
|
|||||||
# example configuration file for windows_exporter
|
# example configuration file for windows_exporter
|
||||||
|
|
||||||
collectors:
|
collectors:
|
||||||
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
enabled: cpu,cpu_info,exchange,iis,logical_disk,logon,memory,net,os,performancecounter,process,remote_fx,service,system,tcp,time,terminal_services,textfile
|
||||||
collector:
|
collector:
|
||||||
service:
|
service:
|
||||||
include: "windows_exporter"
|
include: "windows_exporter"
|
||||||
|
performancecounter:
|
||||||
|
objects: |-
|
||||||
|
- name: photon_udp
|
||||||
|
object: "Photon Socket Server: UDP"
|
||||||
|
instances: ["*"]
|
||||||
|
counters:
|
||||||
|
- name: "UDP: Datagrams in"
|
||||||
|
metric: "photon_udp_datagrams"
|
||||||
|
labels:
|
||||||
|
direction: "in"
|
||||||
|
- name: "UDP: Datagrams out"
|
||||||
|
metric: "photon_udp_datagrams"
|
||||||
|
labels:
|
||||||
|
direction: "out"
|
||||||
log:
|
log:
|
||||||
level: warn
|
level: warn
|
||||||
|
|||||||
@@ -18,15 +18,10 @@ Comma-separated list of MSSQL WMI classes to use. Supported values are `accessme
|
|||||||
|
|
||||||
If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.fman`, `databases`, `dbreplica`, `genstats`, `locks`, `memmgr`, `sqlstats`, `sqlerrors`, `transactions`, and `waitstats`.
|
If true, print available mssql WMI classes and exit. Only displays if the mssql collector is enabled.fman`, `databases`, `dbreplica`, `genstats`, `locks`, `memmgr`, `sqlstats`, `sqlerrors`, `transactions`, and `waitstats`.
|
||||||
|
|
||||||
### `--collector.mssql.port`
|
|
||||||
|
|
||||||
Port of MSSQL server used for `windows_mssql_info` metric. Default is `1433`.
|
|
||||||
|
|
||||||
## Metrics
|
## Metrics
|
||||||
|
|
||||||
| Name | Description | Type | Labels |
|
| Name | Description | Type | Labels |
|
||||||
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------|
|
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|-------------------------------|
|
||||||
| `windows_mssql_info` | Returns information about the MSSQL server running on port 1433 | gauge | `version` |
|
|
||||||
| `windows_mssql_collector_duration_seconds` | The time taken for each sub-collector to return | gauge | `collector`, `mssql_instance` |
|
| `windows_mssql_collector_duration_seconds` | The time taken for each sub-collector to return | gauge | `collector`, `mssql_instance` |
|
||||||
| `windows_mssql_collector_success` | 1 if sub-collector succeeded, 0 otherwise | gauge | `collector`, `mssql_instance` |
|
| `windows_mssql_collector_success` | 1 if sub-collector succeeded, 0 otherwise | gauge | `collector`, `mssql_instance` |
|
||||||
| `windows_mssql_accessmethods_au_batch_cleanups` | The total number of batches that were completed successfully by the background task that cleans up deferred dropped allocation units | counter | `mssql_instance` |
|
| `windows_mssql_accessmethods_au_batch_cleanups` | The total number of batches that were completed successfully by the background task that cleans up deferred dropped allocation units | counter | `mssql_instance` |
|
||||||
@@ -197,6 +192,7 @@ Port of MSSQL server used for `windows_mssql_info` metric. Default is `1433`.
|
|||||||
| `windows_mssql_genstats_trace_event_notification_queue_size` | Number of trace event notification instances waiting in the internal queue to be sent through Service Broker | gauge | `mssql_instance` |
|
| `windows_mssql_genstats_trace_event_notification_queue_size` | Number of trace event notification instances waiting in the internal queue to be sent through Service Broker | gauge | `mssql_instance` |
|
||||||
| `windows_mssql_genstats_transactions` | Number of transaction enlistments (local, DTC, bound all combined) | gauge | `mssql_instance` |
|
| `windows_mssql_genstats_transactions` | Number of transaction enlistments (local, DTC, bound all combined) | gauge | `mssql_instance` |
|
||||||
| `windows_mssql_genstats_user_connections` | Counts the number of users currently connected to SQL Server | gauge | `mssql_instance` |
|
| `windows_mssql_genstats_user_connections` | Counts the number of users currently connected to SQL Server | gauge | `mssql_instance` |
|
||||||
|
| `windows_mssql_instance_info ` | Returns information about the MSSQL server running on port 1433 | gauge | `version` |
|
||||||
| `windows_mssql_locks_average_wait_seconds` | Average amount of wait time (in milliseconds) for each lock request that resulted in a wait | gauge | `mssql_instance`, `resource` |
|
| `windows_mssql_locks_average_wait_seconds` | Average amount of wait time (in milliseconds) for each lock request that resulted in a wait | gauge | `mssql_instance`, `resource` |
|
||||||
| `windows_mssql_locks_lock_requests` | Number of new locks and lock conversions per second requested from the lock manager | counter | `mssql_instance`, `resource` |
|
| `windows_mssql_locks_lock_requests` | Number of new locks and lock conversions per second requested from the lock manager | counter | `mssql_instance`, `resource` |
|
||||||
| `windows_mssql_locks_lock_timeouts` | Number of lock requests per second that timed out, including requests for NOWAIT locks | counter | `mssql_instance`, `resource` |
|
| `windows_mssql_locks_lock_timeouts` | Number of lock requests per second that timed out, including requests for NOWAIT locks | counter | `mssql_instance`, `resource` |
|
||||||
|
|||||||
@@ -13,9 +13,28 @@ The performancecounter collector exposes any configured metric.
|
|||||||
|
|
||||||
### `--collector.performancecounter.objects`
|
### `--collector.performancecounter.objects`
|
||||||
|
|
||||||
Objects is a list of objects to collect metrics from. The value takes the form of a JSON array of strings. YAML is also supported.
|
Objects is a list of objects to collect metrics from. The value takes the form of a JSON array of strings.
|
||||||
|
YAML is supported.
|
||||||
|
|
||||||
The collector supports only english named counter. Localized counter-names are not supported.
|
The collector supports only English-named counter. Localized counter-names aren’t supported.
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> If you are using a configuration file, the value must be kept as a string.
|
||||||
|
>
|
||||||
|
> Use a `|-` to keep the value as a string.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
collector:
|
||||||
|
performancecounter:
|
||||||
|
objects: |-
|
||||||
|
- name: memory
|
||||||
|
object: "Memory"
|
||||||
|
counters:
|
||||||
|
- name: "Cache Faults/sec"
|
||||||
|
type: "counter" # optional
|
||||||
|
```
|
||||||
|
|
||||||
#### Schema
|
#### Schema
|
||||||
|
|
||||||
@@ -25,7 +44,8 @@ YAML:
|
|||||||
<summary>Click to expand YAML schema</summary>
|
<summary>Click to expand YAML schema</summary>
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- object: "Processor Information"
|
- name: cpu # free text name
|
||||||
|
object: "Processor Information" # Performance counter object name
|
||||||
instances: ["*"]
|
instances: ["*"]
|
||||||
instance_label: "core"
|
instance_label: "core"
|
||||||
counters:
|
counters:
|
||||||
@@ -37,7 +57,9 @@ YAML:
|
|||||||
metric: windows_performancecounter_processor_information_processor_time # optional
|
metric: windows_performancecounter_processor_information_processor_time # optional
|
||||||
labels:
|
labels:
|
||||||
state: idle
|
state: idle
|
||||||
- object: "Memory"
|
- name: memory
|
||||||
|
object: "Memory"
|
||||||
|
type: "formatted"
|
||||||
counters:
|
counters:
|
||||||
- name: "Cache Faults/sec"
|
- name: "Cache Faults/sec"
|
||||||
type: "counter" # optional
|
type: "counter" # optional
|
||||||
@@ -51,6 +73,7 @@ YAML:
|
|||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"name": "cpu",
|
||||||
"object": "Processor Information",
|
"object": "Processor Information",
|
||||||
"instances": [
|
"instances": [
|
||||||
"*"
|
"*"
|
||||||
@@ -74,7 +97,9 @@ YAML:
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"name": "memory",
|
||||||
"object": "Memory",
|
"object": "Memory",
|
||||||
|
"type": "formatted",
|
||||||
"counters": [
|
"counters": [
|
||||||
{
|
{
|
||||||
"name": "Cache Faults/sec",
|
"name": "Cache Faults/sec",
|
||||||
@@ -84,13 +109,46 @@ YAML:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
#### name
|
#### name
|
||||||
|
|
||||||
|
The name is used to identify the object in the logs and metrics.
|
||||||
|
Must unique across all objects.
|
||||||
|
|
||||||
|
#### object
|
||||||
|
|
||||||
ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar.
|
ObjectName is the Object to query for, like Processor, DirectoryServices, LogicalDisk or similar.
|
||||||
|
|
||||||
The collector supports only english named counter. Localized counter-names are not supported.
|
The collector supports only english named counter. Localized counter-names are not supported.
|
||||||
|
|
||||||
|
#### type
|
||||||
|
|
||||||
|
The counter-type. The value can be `raw` or `formatted`. Optional and defaults to `raw`.
|
||||||
|
|
||||||
|
- `raw` returns the raw value of the counter. This is the default.
|
||||||
|
- `formatted` returns the formatted value of the counter. This is useful for counters like `Processor Information` where the value is a percentage.
|
||||||
|
|
||||||
|
The difference between a raw Windows Performance Counter and a formatted Windows Performance Counter is about how the data is presented and processed:
|
||||||
|
|
||||||
|
1. Raw Windows Performance Counter:
|
||||||
|
|
||||||
|
This provides the counter's data in its basic, unprocessed form.
|
||||||
|
The values may represent cumulative counts, time intervals, or other uncalibrated metrics.
|
||||||
|
Interpreting these values often requires more calculations or context, such as calculating deltas or normalizing values over time.
|
||||||
|
|
||||||
|
2. Formatted Windows Performance Counter:
|
||||||
|
|
||||||
|
This presents data that has already been processed and interpreted according to the counter type (e.g., rates per second, averages, percentages).
|
||||||
|
Formatted counters are easier to understand directly since the necessary calculations have been applied.
|
||||||
|
These are often what monitoring tools display to users because they are meaningful at a glance.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
* A raw counter for CPU time might give the total number of clock ticks used since the system started.
|
||||||
|
* A formatted counter would convert this into a percentage of CPU utilization over a specific time interval.
|
||||||
|
|
||||||
|
|
||||||
#### instances
|
#### instances
|
||||||
|
|
||||||
The instances key (this is an array) declares the instances of a counter you would like returned, it can be one or more values.
|
The instances key (this is an array) declares the instances of a counter you would like returned, it can be one or more values.
|
||||||
@@ -185,6 +243,17 @@ windows_performancecounter_processor_information_processor_time{core="0,8",state
|
|||||||
windows_performancecounter_processor_information_processor_time{core="0,9",state="active"} 1.0059484375e+11
|
windows_performancecounter_processor_information_processor_time{core="0,9",state="active"} 1.0059484375e+11
|
||||||
windows_performancecounter_processor_information_processor_time{core="0,9",state="idle"} 10059.484375
|
windows_performancecounter_processor_information_processor_time{core="0,9",state="idle"} 10059.484375
|
||||||
```
|
```
|
||||||
|
> [!NOTE]
|
||||||
|
> If you are using a configuration file, the value must be keep as string.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
collector:
|
||||||
|
performancecounter:
|
||||||
|
objects: |
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Metrics
|
## Metrics
|
||||||
|
|
||||||
|
|||||||
32
go.mod
32
go.mod
@@ -3,7 +3,6 @@ module github.com/prometheus-community/windows_exporter
|
|||||||
go 1.23
|
go 1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Microsoft/go-winio v0.6.2
|
|
||||||
github.com/Microsoft/hcsshim v0.12.9
|
github.com/Microsoft/hcsshim v0.12.9
|
||||||
github.com/alecthomas/kingpin/v2 v2.4.0
|
github.com/alecthomas/kingpin/v2 v2.4.0
|
||||||
github.com/bmatcuk/doublestar/v4 v4.7.1
|
github.com/bmatcuk/doublestar/v4 v4.7.1
|
||||||
@@ -12,25 +11,26 @@ require (
|
|||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/prometheus/client_golang v1.20.5
|
github.com/prometheus/client_golang v1.20.5
|
||||||
github.com/prometheus/client_model v0.6.1
|
github.com/prometheus/client_model v0.6.1
|
||||||
github.com/prometheus/common v0.60.1
|
github.com/prometheus/common v0.61.0
|
||||||
github.com/prometheus/exporter-toolkit v0.13.1
|
github.com/prometheus/exporter-toolkit v0.13.2
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/stretchr/testify v1.10.0
|
||||||
golang.org/x/sys v0.27.0
|
golang.org/x/sys v0.29.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||||
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
|
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/containerd/cgroups/v3 v3.0.3 // indirect
|
github.com/containerd/cgroups/v3 v3.0.4 // indirect
|
||||||
github.com/containerd/errdefs v0.3.0 // indirect
|
github.com/containerd/errdefs v1.0.0 // indirect
|
||||||
github.com/containerd/errdefs/pkg v0.3.0 // indirect
|
github.com/containerd/errdefs/pkg v0.3.0 // indirect
|
||||||
github.com/containerd/typeurl/v2 v2.2.0 // indirect
|
github.com/containerd/typeurl/v2 v2.2.3 // indirect
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||||
github.com/jpillora/backoff v1.0.0 // indirect
|
github.com/jpillora/backoff v1.0.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
github.com/klauspost/compress v1.17.11 // indirect
|
||||||
github.com/mdlayher/socket v0.5.1 // indirect
|
github.com/mdlayher/socket v0.5.1 // indirect
|
||||||
@@ -43,13 +43,13 @@ require (
|
|||||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||||
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
golang.org/x/crypto v0.28.0 // indirect
|
golang.org/x/crypto v0.31.0 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/net v0.32.0 // indirect
|
||||||
golang.org/x/oauth2 v0.23.0 // indirect
|
golang.org/x/oauth2 v0.24.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
golang.org/x/sync v0.10.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 // indirect
|
||||||
google.golang.org/grpc v1.67.1 // indirect
|
google.golang.org/grpc v1.68.0 // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // indirect
|
google.golang.org/protobuf v1.35.2 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
62
go.sum
62
go.sum
@@ -17,14 +17,14 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
|
|||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
|
github.com/containerd/cgroups/v3 v3.0.4 h1:2fs7l3P0Qxb1nKWuJNFiwhp2CqiKzho71DQkDrHJIo4=
|
||||||
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=
|
github.com/containerd/cgroups/v3 v3.0.4/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins=
|
||||||
github.com/containerd/errdefs v0.3.0 h1:FSZgGOeK4yuT/+DnF07/Olde/q4KBoMsaamhXxIMDp4=
|
github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI=
|
||||||
github.com/containerd/errdefs v0.3.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
|
github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M=
|
||||||
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
|
github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE=
|
||||||
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
|
github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk=
|
||||||
github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso=
|
github.com/containerd/typeurl/v2 v2.2.3 h1:yNA/94zxWdvYACdYO8zofhrTVuQY73fFU1y++dYSw40=
|
||||||
github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g=
|
github.com/containerd/typeurl/v2 v2.2.3/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -43,8 +43,8 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
|||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@@ -55,6 +55,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
|||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
@@ -95,10 +97,10 @@ github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/j
|
|||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
|
||||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
|
||||||
github.com/prometheus/exporter-toolkit v0.13.1 h1:Evsh0gWQo2bdOHlnz9+0Nm7/OFfIwhE2Ws4A2jIlR04=
|
github.com/prometheus/exporter-toolkit v0.13.2 h1:Z02fYtbqTMy2i/f+xZ+UK5jy/bl1Ex3ndzh06T/Q9DQ=
|
||||||
github.com/prometheus/exporter-toolkit v0.13.1/go.mod h1:ujdv2YIOxtdFxxqtloLpbqmxd5J0Le6IITUvIRSWjj0=
|
github.com/prometheus/exporter-toolkit v0.13.2/go.mod h1:tCqnfx21q6qN1KA4U3Bfb8uWzXfijIrJz3/kTIqMV7g=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
@@ -126,8 +128,8 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
@@ -143,30 +145,30 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
|
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
||||||
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
@@ -184,15 +186,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697 h1:LWZqQOEjDyONlF1H6afSWpAL/znlREo2tHfLoe+8LMA=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241118233622-e639e219e697/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
|
||||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
@@ -202,8 +204,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
|
|||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -36,7 +36,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
addressBookClientSessions *prometheus.Desc
|
addressBookClientSessions *prometheus.Desc
|
||||||
addressBookOperationsTotal *prometheus.Desc
|
addressBookOperationsTotal *prometheus.Desc
|
||||||
@@ -129,156 +130,9 @@ func (c *Collector) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
counters := []string{
|
|
||||||
abANRPerSec,
|
|
||||||
abBrowsesPerSec,
|
|
||||||
abClientSessions,
|
|
||||||
abMatchesPerSec,
|
|
||||||
abPropertyReadsPerSec,
|
|
||||||
abProxyLookupsPerSec,
|
|
||||||
abSearchesPerSec,
|
|
||||||
approximateHighestDNT,
|
|
||||||
atqEstimatedQueueDelay,
|
|
||||||
atqOutstandingQueuedRequests,
|
|
||||||
atqRequestLatency,
|
|
||||||
atqThreadsLDAP,
|
|
||||||
atqThreadsOther,
|
|
||||||
atqThreadsTotal,
|
|
||||||
baseSearchesPerSec,
|
|
||||||
databaseAddsPerSec,
|
|
||||||
databaseDeletesPerSec,
|
|
||||||
databaseModifiesPerSec,
|
|
||||||
databaseRecyclesPerSec,
|
|
||||||
digestBindsPerSec,
|
|
||||||
draHighestUSNCommittedHighPart,
|
|
||||||
draHighestUSNCommittedLowPart,
|
|
||||||
draHighestUSNIssuedHighPart,
|
|
||||||
draHighestUSNIssuedLowPart,
|
|
||||||
draInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot,
|
|
||||||
draInboundBytesCompressedBetweenSitesAfterCompressionPerSec,
|
|
||||||
draInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot,
|
|
||||||
draInboundBytesCompressedBetweenSitesBeforeCompressionPerSec,
|
|
||||||
draInboundBytesNotCompressedWithinSiteSinceBoot,
|
|
||||||
draInboundBytesNotCompressedWithinSitePerSec,
|
|
||||||
draInboundBytesTotalSinceBoot,
|
|
||||||
draInboundBytesTotalPerSec,
|
|
||||||
draInboundFullSyncObjectsRemaining,
|
|
||||||
draInboundLinkValueUpdatesRemainingInPacket,
|
|
||||||
draInboundObjectUpdatesRemainingInPacket,
|
|
||||||
draInboundObjectsAppliedPerSec,
|
|
||||||
draInboundObjectsFilteredPerSec,
|
|
||||||
draInboundObjectsPerSec,
|
|
||||||
draInboundPropertiesAppliedPerSec,
|
|
||||||
draInboundPropertiesFilteredPerSec,
|
|
||||||
draInboundPropertiesTotalPerSec,
|
|
||||||
draInboundTotalUpdatesRemainingInPacket,
|
|
||||||
draInboundValuesDNsOnlyPerSec,
|
|
||||||
draInboundValuesTotalPerSec,
|
|
||||||
draOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot,
|
|
||||||
draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec,
|
|
||||||
draOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot,
|
|
||||||
draOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec,
|
|
||||||
draOutboundBytesNotCompressedWithinSiteSinceBoot,
|
|
||||||
draOutboundBytesNotCompressedWithinSitePerSec,
|
|
||||||
draOutboundBytesTotalSinceBoot,
|
|
||||||
draOutboundBytesTotalPerSec,
|
|
||||||
draOutboundObjectsFilteredPerSec,
|
|
||||||
draOutboundObjectsPerSec,
|
|
||||||
draOutboundPropertiesPerSec,
|
|
||||||
draOutboundValuesDNsOnlyPerSec,
|
|
||||||
draOutboundValuesTotalPerSec,
|
|
||||||
draPendingReplicationOperations,
|
|
||||||
draPendingReplicationSynchronizations,
|
|
||||||
draSyncFailuresOnSchemaMismatch,
|
|
||||||
draSyncRequestsMade,
|
|
||||||
draSyncRequestsSuccessful,
|
|
||||||
draThreadsGettingNCChanges,
|
|
||||||
draThreadsGettingNCChangesHoldingSemaphore,
|
|
||||||
dsPercentReadsFromDRA,
|
|
||||||
dsPercentReadsFromKCC,
|
|
||||||
dsPercentReadsFromLSA,
|
|
||||||
dsPercentReadsFromNSPI,
|
|
||||||
dsPercentReadsFromNTDSAPI,
|
|
||||||
dsPercentReadsFromSAM,
|
|
||||||
dsPercentReadsOther,
|
|
||||||
dsPercentSearchesFromDRA,
|
|
||||||
dsPercentSearchesFromKCC,
|
|
||||||
dsPercentSearchesFromLDAP,
|
|
||||||
dsPercentSearchesFromLSA,
|
|
||||||
dsPercentSearchesFromNSPI,
|
|
||||||
dsPercentSearchesFromNTDSAPI,
|
|
||||||
dsPercentSearchesFromSAM,
|
|
||||||
dsPercentSearchesOther,
|
|
||||||
dsPercentWritesFromDRA,
|
|
||||||
dsPercentWritesFromKCC,
|
|
||||||
dsPercentWritesFromLDAP,
|
|
||||||
dsPercentWritesFromLSA,
|
|
||||||
dsPercentWritesFromNSPI,
|
|
||||||
dsPercentWritesFromNTDSAPI,
|
|
||||||
dsPercentWritesFromSAM,
|
|
||||||
dsPercentWritesOther,
|
|
||||||
dsClientBindsPerSec,
|
|
||||||
dsClientNameTranslationsPerSec,
|
|
||||||
dsDirectoryReadsPerSec,
|
|
||||||
dsDirectorySearchesPerSec,
|
|
||||||
dsDirectoryWritesPerSec,
|
|
||||||
dsMonitorListSize,
|
|
||||||
dsNameCacheHitRate,
|
|
||||||
dsNotifyQueueSize,
|
|
||||||
dsSearchSubOperationsPerSec,
|
|
||||||
dsSecurityDescriptorPropagationsEvents,
|
|
||||||
dsSecurityDescriptorPropagatorAverageExclusionTime,
|
|
||||||
dsSecurityDescriptorPropagatorRuntimeQueue,
|
|
||||||
dsSecurityDescriptorSubOperationsPerSec,
|
|
||||||
dsServerBindsPerSec,
|
|
||||||
dsServerNameTranslationsPerSec,
|
|
||||||
dsThreadsInUse,
|
|
||||||
externalBindsPerSec,
|
|
||||||
fastBindsPerSec,
|
|
||||||
ldapActiveThreads,
|
|
||||||
ldapBindTime,
|
|
||||||
ldapClientSessions,
|
|
||||||
ldapClosedConnectionsPerSec,
|
|
||||||
ldapNewConnectionsPerSec,
|
|
||||||
ldapNewSSLConnectionsPerSec,
|
|
||||||
ldapSearchesPerSec,
|
|
||||||
ldapSuccessfulBindsPerSec,
|
|
||||||
ldapUDPOperationsPerSec,
|
|
||||||
ldapWritesPerSec,
|
|
||||||
linkValuesCleanedPerSec,
|
|
||||||
negotiatedBindsPerSec,
|
|
||||||
ntlmBindsPerSec,
|
|
||||||
oneLevelSearchesPerSec,
|
|
||||||
phantomsCleanedPerSec,
|
|
||||||
phantomsVisitedPerSec,
|
|
||||||
samAccountGroupEvaluationLatency,
|
|
||||||
samDisplayInformationQueriesPerSec,
|
|
||||||
samDomainLocalGroupMembershipEvaluationsPerSec,
|
|
||||||
samEnumerationsPerSec,
|
|
||||||
samGCEvaluationsPerSec,
|
|
||||||
samGlobalGroupMembershipEvaluationsPerSec,
|
|
||||||
samMachineCreationAttemptsPerSec,
|
|
||||||
samMembershipChangesPerSec,
|
|
||||||
samNonTransitiveMembershipEvaluationsPerSec,
|
|
||||||
samPasswordChangesPerSec,
|
|
||||||
samResourceGroupEvaluationLatency,
|
|
||||||
samSuccessfulComputerCreationsPerSecIncludesAllRequests,
|
|
||||||
samSuccessfulUserCreationsPerSec,
|
|
||||||
samTransitiveMembershipEvaluationsPerSec,
|
|
||||||
samUniversalGroupMembershipEvaluationsPerSec,
|
|
||||||
samUserCreationAttemptsPerSec,
|
|
||||||
simpleBindsPerSec,
|
|
||||||
subtreeSearchesPerSec,
|
|
||||||
tombstonesGarbageCollectedPerSec,
|
|
||||||
tombstonesVisitedPerSec,
|
|
||||||
transitiveOperationsMillisecondsRun,
|
|
||||||
transitiveOperationsPerSec,
|
|
||||||
transitiveSubOperationsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("DirectoryServices", perfdata.InstancesAll, counters)
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DirectoryServices", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DirectoryServices collector: %w", err)
|
return fmt.Errorf("failed to create DirectoryServices collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -663,210 +517,204 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
// Collect sends the metric values for each metric
|
// Collect sends the metric values for each metric
|
||||||
// to the provided prometheus Metric channel.
|
// to the provided prometheus Metric channel.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", err)
|
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData["NTDS"]
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect DirectoryServices (AD) metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abANRPerSec].FirstValue,
|
c.perfDataObject[0].AbANRPerSec,
|
||||||
"ambiguous_name_resolution",
|
"ambiguous_name_resolution",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abBrowsesPerSec].FirstValue,
|
c.perfDataObject[0].AbBrowsesPerSec,
|
||||||
"browse",
|
"browse",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abMatchesPerSec].FirstValue,
|
c.perfDataObject[0].AbMatchesPerSec,
|
||||||
"find",
|
"find",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abPropertyReadsPerSec].FirstValue,
|
c.perfDataObject[0].AbPropertyReadsPerSec,
|
||||||
"property_read",
|
"property_read",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abSearchesPerSec].FirstValue,
|
c.perfDataObject[0].AbSearchesPerSec,
|
||||||
"search",
|
"search",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookOperationsTotal,
|
c.addressBookOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[abProxyLookupsPerSec].FirstValue,
|
c.perfDataObject[0].AbProxyLookupsPerSec,
|
||||||
"proxy_search",
|
"proxy_search",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.addressBookClientSessions,
|
c.addressBookClientSessions,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[abClientSessions].FirstValue,
|
c.perfDataObject[0].AbClientSessions,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.approximateHighestDistinguishedNameTag,
|
c.approximateHighestDistinguishedNameTag,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[approximateHighestDNT].FirstValue,
|
c.perfDataObject[0].ApproximateHighestDNT,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqEstimatedDelaySeconds,
|
c.atqEstimatedDelaySeconds,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[atqEstimatedQueueDelay].FirstValue/1000,
|
c.perfDataObject[0].AtqEstimatedQueueDelay/1000,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqOutstandingRequests,
|
c.atqOutstandingRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[atqOutstandingQueuedRequests].FirstValue,
|
c.perfDataObject[0].AtqOutstandingQueuedRequests,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqAverageRequestLatency,
|
c.atqAverageRequestLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[atqRequestLatency].FirstValue,
|
c.perfDataObject[0].AtqRequestLatency,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqCurrentThreads,
|
c.atqCurrentThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[atqThreadsLDAP].FirstValue,
|
c.perfDataObject[0].AtqThreadsLDAP,
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.atqCurrentThreads,
|
c.atqCurrentThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[atqThreadsOther].FirstValue,
|
c.perfDataObject[0].AtqThreadsOther,
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.searchesTotal,
|
c.searchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[baseSearchesPerSec].FirstValue,
|
c.perfDataObject[0].BaseSearchesPerSec,
|
||||||
"base",
|
"base",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.searchesTotal,
|
c.searchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[subtreeSearchesPerSec].FirstValue,
|
c.perfDataObject[0].SubtreeSearchesPerSec,
|
||||||
"subtree",
|
"subtree",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.searchesTotal,
|
c.searchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[oneLevelSearchesPerSec].FirstValue,
|
c.perfDataObject[0].OneLevelSearchesPerSec,
|
||||||
"one_level",
|
"one_level",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databaseAddsPerSec].FirstValue,
|
c.perfDataObject[0].DatabaseAddsPerSec,
|
||||||
"add",
|
"add",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databaseDeletesPerSec].FirstValue,
|
c.perfDataObject[0].DatabaseDeletesPerSec,
|
||||||
"delete",
|
"delete",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databaseModifiesPerSec].FirstValue,
|
c.perfDataObject[0].DatabaseModifiesPerSec,
|
||||||
"modify",
|
"modify",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databaseOperationsTotal,
|
c.databaseOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databaseRecyclesPerSec].FirstValue,
|
c.perfDataObject[0].DatabaseRecyclesPerSec,
|
||||||
"recycle",
|
"recycle",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[digestBindsPerSec].FirstValue,
|
c.perfDataObject[0].DigestBindsPerSec,
|
||||||
"digest",
|
"digest",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsClientBindsPerSec].FirstValue,
|
c.perfDataObject[0].DsClientBindsPerSec,
|
||||||
"ds_client",
|
"ds_client",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsServerBindsPerSec].FirstValue,
|
c.perfDataObject[0].DsServerBindsPerSec,
|
||||||
"ds_server",
|
"ds_server",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[externalBindsPerSec].FirstValue,
|
c.perfDataObject[0].ExternalBindsPerSec,
|
||||||
"external",
|
"external",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[fastBindsPerSec].FirstValue,
|
c.perfDataObject[0].FastBindsPerSec,
|
||||||
"fast",
|
"fast",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[negotiatedBindsPerSec].FirstValue,
|
c.perfDataObject[0].NegotiatedBindsPerSec,
|
||||||
"negotiate",
|
"negotiate",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ntlmBindsPerSec].FirstValue,
|
c.perfDataObject[0].NTLMBindsPerSec,
|
||||||
"ntlm",
|
"ntlm",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[simpleBindsPerSec].FirstValue,
|
c.perfDataObject[0].SimpleBindsPerSec,
|
||||||
"simple",
|
"simple",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bindsTotal,
|
c.bindsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapSuccessfulBindsPerSec].FirstValue,
|
c.perfDataObject[0].LdapSuccessfulBindsPerSec,
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationHighestUsn,
|
c.replicationHighestUsn,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(uint64(data[draHighestUSNCommittedHighPart].FirstValue)<<32)+data[draHighestUSNCommittedLowPart].FirstValue,
|
float64(uint64(c.perfDataObject[0].DRAHighestUSNCommittedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNCommittedLowPart,
|
||||||
"committed",
|
"committed",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationHighestUsn,
|
c.replicationHighestUsn,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(uint64(data[draHighestUSNIssuedHighPart].FirstValue)<<32)+data[draHighestUSNIssuedLowPart].FirstValue,
|
float64(uint64(c.perfDataObject[0].DRAHighestUSNIssuedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNIssuedLowPart,
|
||||||
"issued",
|
"issued",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.interSiteReplicationDataBytesTotal,
|
c.interSiteReplicationDataBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundBytesCompressedBetweenSitesAfterCompressionPerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundBytesCompressedBetweenSitesAfterCompressionPerSec,
|
||||||
"inbound",
|
"inbound",
|
||||||
)
|
)
|
||||||
// The pre-compression perfData size seems to have little value? Skipping for now
|
// The pre-compression perfData size seems to have little value? Skipping for now
|
||||||
@@ -879,7 +727,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.interSiteReplicationDataBytesTotal,
|
c.interSiteReplicationDataBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec].FirstValue,
|
c.perfDataObject[0].DRAOutboundBytesCompressedBetweenSitesAfterCompressionPerSec,
|
||||||
"outbound",
|
"outbound",
|
||||||
)
|
)
|
||||||
// ch <- prometheus.MustNewConstMetric(
|
// ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -891,270 +739,270 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.intraSiteReplicationDataBytesTotal,
|
c.intraSiteReplicationDataBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundBytesNotCompressedWithinSitePerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec,
|
||||||
"inbound",
|
"inbound",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.intraSiteReplicationDataBytesTotal,
|
c.intraSiteReplicationDataBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draOutboundBytesNotCompressedWithinSitePerSec].FirstValue,
|
c.perfDataObject[0].DRAOutboundBytesNotCompressedWithinSitePerSec,
|
||||||
"outbound",
|
"outbound",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundSyncObjectsRemaining,
|
c.replicationInboundSyncObjectsRemaining,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[draInboundFullSyncObjectsRemaining].FirstValue,
|
c.perfDataObject[0].DRAInboundFullSyncObjectsRemaining,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundLinkValueUpdatesRemaining,
|
c.replicationInboundLinkValueUpdatesRemaining,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[draInboundLinkValueUpdatesRemainingInPacket].FirstValue,
|
c.perfDataObject[0].DRAInboundLinkValueUpdatesRemainingInPacket,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundObjectsUpdatedTotal,
|
c.replicationInboundObjectsUpdatedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundObjectsAppliedPerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundObjectsAppliedPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundObjectsFilteredTotal,
|
c.replicationInboundObjectsFilteredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundObjectsFilteredPerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundObjectsFilteredPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundPropertiesUpdatedTotal,
|
c.replicationInboundPropertiesUpdatedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundPropertiesAppliedPerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationInboundPropertiesFilteredTotal,
|
c.replicationInboundPropertiesFilteredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draInboundPropertiesFilteredPerSec].FirstValue,
|
c.perfDataObject[0].DRAInboundPropertiesFilteredPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationPendingOperations,
|
c.replicationPendingOperations,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[draPendingReplicationOperations].FirstValue,
|
c.perfDataObject[0].DRAPendingReplicationOperations,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationPendingSynchronizations,
|
c.replicationPendingSynchronizations,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[draPendingReplicationSynchronizations].FirstValue,
|
c.perfDataObject[0].DRAPendingReplicationSynchronizations,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationSyncRequestsTotal,
|
c.replicationSyncRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draSyncRequestsMade].FirstValue,
|
c.perfDataObject[0].DRASyncRequestsMade,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationSyncRequestsSuccessTotal,
|
c.replicationSyncRequestsSuccessTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draSyncRequestsSuccessful].FirstValue,
|
c.perfDataObject[0].DRASyncRequestsSuccessful,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.replicationSyncRequestsSchemaMismatchFailureTotal,
|
c.replicationSyncRequestsSchemaMismatchFailureTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[draSyncFailuresOnSchemaMismatch].FirstValue,
|
c.perfDataObject[0].DRASyncFailuresOnSchemaMismatch,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameTranslationsTotal,
|
c.nameTranslationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsClientNameTranslationsPerSec].FirstValue,
|
c.perfDataObject[0].DsClientNameTranslationsPerSec,
|
||||||
"client",
|
"client",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameTranslationsTotal,
|
c.nameTranslationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsServerNameTranslationsPerSec].FirstValue,
|
c.perfDataObject[0].DsServerNameTranslationsPerSec,
|
||||||
"server",
|
"server",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.changeMonitorsRegistered,
|
c.changeMonitorsRegistered,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dsMonitorListSize].FirstValue,
|
c.perfDataObject[0].DsMonitorListSize,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.changeMonitorUpdatesPending,
|
c.changeMonitorUpdatesPending,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dsNotifyQueueSize].FirstValue,
|
c.perfDataObject[0].DsNotifyQueueSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameCacheHitsTotal,
|
c.nameCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsNameCacheHitRate].FirstValue,
|
c.perfDataObject[0].DsNameCacheHitRate,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nameCacheLookupsTotal,
|
c.nameCacheLookupsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsNameCacheHitRate].SecondValue,
|
c.perfDataObject[0].DsNameCacheHitRateSecondValue,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromDRA].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromDRA,
|
||||||
"read",
|
"read",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromKCC].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromKCC,
|
||||||
"read",
|
"read",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromLSA].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromLSA,
|
||||||
"read",
|
"read",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromNSPI].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromNSPI,
|
||||||
"read",
|
"read",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromNTDSAPI].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromNTDSAPI,
|
||||||
"read",
|
"read",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsFromSAM].FirstValue,
|
c.perfDataObject[0].DsPercentReadsFromSAM,
|
||||||
"read",
|
"read",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentReadsOther].FirstValue,
|
c.perfDataObject[0].DsPercentReadsOther,
|
||||||
"read",
|
"read",
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromDRA].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromDRA,
|
||||||
"search",
|
"search",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromKCC].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromKCC,
|
||||||
"search",
|
"search",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromLDAP].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromLDAP,
|
||||||
"search",
|
"search",
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromLSA].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromLSA,
|
||||||
"search",
|
"search",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromNSPI].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromNSPI,
|
||||||
"search",
|
"search",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromNTDSAPI].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromNTDSAPI,
|
||||||
"search",
|
"search",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromSAM].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromSAM,
|
||||||
"search",
|
"search",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesOther].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesOther,
|
||||||
"search",
|
"search",
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromDRA].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromDRA,
|
||||||
"write",
|
"write",
|
||||||
"replication_agent",
|
"replication_agent",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromKCC].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromKCC,
|
||||||
"write",
|
"write",
|
||||||
"knowledge_consistency_checker",
|
"knowledge_consistency_checker",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromLDAP].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromLDAP,
|
||||||
"write",
|
"write",
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentSearchesFromLSA].FirstValue,
|
c.perfDataObject[0].DsPercentSearchesFromLSA,
|
||||||
"write",
|
"write",
|
||||||
"local_security_authority",
|
"local_security_authority",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromNSPI].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromNSPI,
|
||||||
"write",
|
"write",
|
||||||
"name_service_provider_interface",
|
"name_service_provider_interface",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromNTDSAPI].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromNTDSAPI,
|
||||||
"write",
|
"write",
|
||||||
"directory_service_api",
|
"directory_service_api",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesFromSAM].FirstValue,
|
c.perfDataObject[0].DsPercentWritesFromSAM,
|
||||||
"write",
|
"write",
|
||||||
"security_account_manager",
|
"security_account_manager",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryOperationsTotal,
|
c.directoryOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsPercentWritesOther].FirstValue,
|
c.perfDataObject[0].DsPercentWritesOther,
|
||||||
"write",
|
"write",
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
@@ -1162,207 +1010,207 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directorySearchSubOperationsTotal,
|
c.directorySearchSubOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsSearchSubOperationsPerSec].FirstValue,
|
c.perfDataObject[0].DsSearchSubOperationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationEventsTotal,
|
c.securityDescriptorPropagationEventsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsSecurityDescriptorSubOperationsPerSec].FirstValue,
|
c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationEventsQueued,
|
c.securityDescriptorPropagationEventsQueued,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dsSecurityDescriptorPropagationsEvents].FirstValue,
|
c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationAccessWaitTotalSeconds,
|
c.securityDescriptorPropagationAccessWaitTotalSeconds,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dsSecurityDescriptorPropagatorAverageExclusionTime].FirstValue,
|
c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.securityDescriptorPropagationItemsQueuedTotal,
|
c.securityDescriptorPropagationItemsQueuedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dsSecurityDescriptorPropagatorRuntimeQueue].FirstValue,
|
c.perfDataObject[0].DsSecurityDescriptorPropagatorRuntimeQueue,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.directoryServiceThreads,
|
c.directoryServiceThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dsThreadsInUse].FirstValue,
|
c.perfDataObject[0].DsThreadsInUse,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapClosedConnectionsTotal,
|
c.ldapClosedConnectionsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapClosedConnectionsPerSec].FirstValue,
|
c.perfDataObject[0].LdapClosedConnectionsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapOpenedConnectionsTotal,
|
c.ldapOpenedConnectionsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapNewConnectionsPerSec].FirstValue,
|
c.perfDataObject[0].LdapNewConnectionsPerSec,
|
||||||
"ldap",
|
"ldap",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapOpenedConnectionsTotal,
|
c.ldapOpenedConnectionsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapNewSSLConnectionsPerSec].FirstValue,
|
c.perfDataObject[0].LdapNewSSLConnectionsPerSec,
|
||||||
"ldaps",
|
"ldaps",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapActiveThreads,
|
c.ldapActiveThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[ldapActiveThreads].FirstValue,
|
c.perfDataObject[0].LdapActiveThreads,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapLastBindTimeSeconds,
|
c.ldapLastBindTimeSeconds,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[ldapBindTime].FirstValue/1000,
|
c.perfDataObject[0].LdapBindTime/1000,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapSearchesTotal,
|
c.ldapSearchesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapSearchesPerSec].FirstValue,
|
c.perfDataObject[0].LdapSearchesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapUdpOperationsTotal,
|
c.ldapUdpOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapUDPOperationsPerSec].FirstValue,
|
c.perfDataObject[0].LdapUDPOperationsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapWritesTotal,
|
c.ldapWritesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapWritesPerSec].FirstValue,
|
c.perfDataObject[0].LdapWritesPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapClientSessions,
|
c.ldapClientSessions,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[ldapClientSessions].FirstValue,
|
c.perfDataObject[0].LdapClientSessions,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.linkValuesCleanedTotal,
|
c.linkValuesCleanedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[linkValuesCleanedPerSec].FirstValue,
|
c.perfDataObject[0].LinkValuesCleanedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.phantomObjectsCleanedTotal,
|
c.phantomObjectsCleanedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[phantomsCleanedPerSec].FirstValue,
|
c.perfDataObject[0].PhantomsCleanedPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.phantomObjectsVisitedTotal,
|
c.phantomObjectsVisitedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[phantomsVisitedPerSec].FirstValue,
|
c.perfDataObject[0].PhantomsVisitedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTotal,
|
c.samGroupMembershipEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samGlobalGroupMembershipEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec,
|
||||||
"global",
|
"global",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTotal,
|
c.samGroupMembershipEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samDomainLocalGroupMembershipEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec,
|
||||||
"domain_local",
|
"domain_local",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTotal,
|
c.samGroupMembershipEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samUniversalGroupMembershipEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec,
|
||||||
"universal",
|
"universal",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
|
c.samGroupMembershipGlobalCatalogEvaluationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samGCEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamGCEvaluationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsNonTransitiveTotal,
|
c.samGroupMembershipEvaluationsNonTransitiveTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samNonTransitiveMembershipEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupMembershipEvaluationsTransitiveTotal,
|
c.samGroupMembershipEvaluationsTransitiveTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samTransitiveMembershipEvaluationsPerSec].FirstValue,
|
c.perfDataObject[0].SamTransitiveMembershipEvaluationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupEvaluationLatency,
|
c.samGroupEvaluationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[samAccountGroupEvaluationLatency].FirstValue,
|
c.perfDataObject[0].SamAccountGroupEvaluationLatency,
|
||||||
"account_group",
|
"account_group",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samGroupEvaluationLatency,
|
c.samGroupEvaluationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[samResourceGroupEvaluationLatency].FirstValue,
|
c.perfDataObject[0].SamResourceGroupEvaluationLatency,
|
||||||
"resource_group",
|
"resource_group",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samComputerCreationRequestsTotal,
|
c.samComputerCreationRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samSuccessfulComputerCreationsPerSecIncludesAllRequests].FirstValue,
|
c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samComputerCreationSuccessfulRequestsTotal,
|
c.samComputerCreationSuccessfulRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samMachineCreationAttemptsPerSec].FirstValue,
|
c.perfDataObject[0].SamMachineCreationAttemptsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samUserCreationRequestsTotal,
|
c.samUserCreationRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samUserCreationAttemptsPerSec].FirstValue,
|
c.perfDataObject[0].SamUserCreationAttemptsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samUserCreationSuccessfulRequestsTotal,
|
c.samUserCreationSuccessfulRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samSuccessfulUserCreationsPerSec].FirstValue,
|
c.perfDataObject[0].SamSuccessfulUserCreationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samQueryDisplayRequestsTotal,
|
c.samQueryDisplayRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samDisplayInformationQueriesPerSec].FirstValue,
|
c.perfDataObject[0].SamDisplayInformationQueriesPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samEnumerationsTotal,
|
c.samEnumerationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samEnumerationsPerSec].FirstValue,
|
c.perfDataObject[0].SamEnumerationsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samMembershipChangesTotal,
|
c.samMembershipChangesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samMembershipChangesPerSec].FirstValue,
|
c.perfDataObject[0].SamMembershipChangesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samPasswordChangesTotal,
|
c.samPasswordChangesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[samPasswordChangesPerSec].FirstValue,
|
c.perfDataObject[0].SamPasswordChangesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.tombstonesObjectsCollectedTotal,
|
c.tombstonesObjectsCollectedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[tombstonesGarbageCollectedPerSec].FirstValue,
|
c.perfDataObject[0].TombstonesGarbageCollectedPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.tombstonesObjectsVisitedTotal,
|
c.tombstonesObjectsVisitedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[tombstonesVisitedPerSec].FirstValue,
|
c.perfDataObject[0].TombstonesVisitedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, ad.Name, ad.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, ad.Name, ad.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, ad.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,222 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package ad
|
|
||||||
|
|
||||||
const (
|
|
||||||
abANRPerSec = "AB ANR/sec"
|
|
||||||
abBrowsesPerSec = "AB Browses/sec"
|
|
||||||
abClientSessions = "AB Client Sessions"
|
|
||||||
abMatchesPerSec = "AB Matches/sec"
|
|
||||||
abPropertyReadsPerSec = "AB Property Reads/sec"
|
|
||||||
abProxyLookupsPerSec = "AB Proxy Lookups/sec"
|
|
||||||
abSearchesPerSec = "AB Searches/sec"
|
|
||||||
approximateHighestDNT = "Approximate highest DNT"
|
|
||||||
atqEstimatedQueueDelay = "ATQ Estimated Queue Delay"
|
|
||||||
atqOutstandingQueuedRequests = "ATQ Outstanding Queued Requests"
|
|
||||||
_ = "ATQ Queue Latency"
|
|
||||||
atqRequestLatency = "ATQ Request Latency"
|
|
||||||
atqThreadsLDAP = "ATQ Threads LDAP"
|
|
||||||
atqThreadsOther = "ATQ Threads Other"
|
|
||||||
atqThreadsTotal = "ATQ Threads Total"
|
|
||||||
baseSearchesPerSec = "Base searches/sec"
|
|
||||||
databaseAddsPerSec = "Database adds/sec"
|
|
||||||
databaseDeletesPerSec = "Database deletes/sec"
|
|
||||||
databaseModifiesPerSec = "Database modifys/sec"
|
|
||||||
databaseRecyclesPerSec = "Database recycles/sec"
|
|
||||||
digestBindsPerSec = "Digest Binds/sec"
|
|
||||||
_ = "DirSync session throttling rate"
|
|
||||||
_ = "DirSync sessions in progress"
|
|
||||||
draHighestUSNCommittedHighPart = "DRA Highest USN Committed (High part)"
|
|
||||||
draHighestUSNCommittedLowPart = "DRA Highest USN Committed (Low part)"
|
|
||||||
draHighestUSNIssuedHighPart = "DRA Highest USN Issued (High part)"
|
|
||||||
draHighestUSNIssuedLowPart = "DRA Highest USN Issued (Low part)"
|
|
||||||
draInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot = "DRA Inbound Bytes Compressed (Between Sites, After Compression) Since Boot"
|
|
||||||
draInboundBytesCompressedBetweenSitesAfterCompressionPerSec = "DRA Inbound Bytes Compressed (Between Sites, After Compression)/sec"
|
|
||||||
draInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot = "DRA Inbound Bytes Compressed (Between Sites, Before Compression) Since Boot"
|
|
||||||
draInboundBytesCompressedBetweenSitesBeforeCompressionPerSec = "DRA Inbound Bytes Compressed (Between Sites, Before Compression)/sec"
|
|
||||||
draInboundBytesNotCompressedWithinSiteSinceBoot = "DRA Inbound Bytes Not Compressed (Within Site) Since Boot"
|
|
||||||
draInboundBytesNotCompressedWithinSitePerSec = "DRA Inbound Bytes Not Compressed (Within Site)/sec"
|
|
||||||
draInboundBytesTotalSinceBoot = "DRA Inbound Bytes Total Since Boot"
|
|
||||||
draInboundBytesTotalPerSec = "DRA Inbound Bytes Total/sec"
|
|
||||||
draInboundFullSyncObjectsRemaining = "DRA Inbound Full Sync Objects Remaining"
|
|
||||||
draInboundLinkValueUpdatesRemainingInPacket = "DRA Inbound Link Value Updates Remaining in Packet"
|
|
||||||
_ = "DRA Inbound Link Values/sec"
|
|
||||||
draInboundObjectUpdatesRemainingInPacket = "DRA Inbound Object Updates Remaining in Packet"
|
|
||||||
draInboundObjectsAppliedPerSec = "DRA Inbound Objects Applied/sec"
|
|
||||||
draInboundObjectsFilteredPerSec = "DRA Inbound Objects Filtered/sec"
|
|
||||||
draInboundObjectsPerSec = "DRA Inbound Objects/sec"
|
|
||||||
draInboundPropertiesAppliedPerSec = "DRA Inbound Properties Applied/sec"
|
|
||||||
draInboundPropertiesFilteredPerSec = "DRA Inbound Properties Filtered/sec"
|
|
||||||
draInboundPropertiesTotalPerSec = "DRA Inbound Properties Total/sec"
|
|
||||||
_ = "DRA Inbound Sync Link Deletion/sec"
|
|
||||||
draInboundTotalUpdatesRemainingInPacket = "DRA Inbound Total Updates Remaining in Packet"
|
|
||||||
draInboundValuesDNsOnlyPerSec = "DRA Inbound Values (DNs only)/sec"
|
|
||||||
draInboundValuesTotalPerSec = "DRA Inbound Values Total/sec"
|
|
||||||
_ = "DRA number of NC replication calls since boot"
|
|
||||||
_ = "DRA number of successful NC replication calls since boot"
|
|
||||||
draOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot = "DRA Outbound Bytes Compressed (Between Sites, After Compression) Since Boot"
|
|
||||||
draOutboundBytesCompressedBetweenSitesAfterCompressionPerSec = "DRA Outbound Bytes Compressed (Between Sites, After Compression)/sec"
|
|
||||||
draOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot = "DRA Outbound Bytes Compressed (Between Sites, Before Compression) Since Boot"
|
|
||||||
draOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec = "DRA Outbound Bytes Compressed (Between Sites, Before Compression)/sec"
|
|
||||||
draOutboundBytesNotCompressedWithinSiteSinceBoot = "DRA Outbound Bytes Not Compressed (Within Site) Since Boot"
|
|
||||||
draOutboundBytesNotCompressedWithinSitePerSec = "DRA Outbound Bytes Not Compressed (Within Site)/sec"
|
|
||||||
draOutboundBytesTotalSinceBoot = "DRA Outbound Bytes Total Since Boot"
|
|
||||||
draOutboundBytesTotalPerSec = "DRA Outbound Bytes Total/sec"
|
|
||||||
draOutboundObjectsFilteredPerSec = "DRA Outbound Objects Filtered/sec"
|
|
||||||
draOutboundObjectsPerSec = "DRA Outbound Objects/sec"
|
|
||||||
draOutboundPropertiesPerSec = "DRA Outbound Properties/sec"
|
|
||||||
draOutboundValuesDNsOnlyPerSec = "DRA Outbound Values (DNs only)/sec"
|
|
||||||
draOutboundValuesTotalPerSec = "DRA Outbound Values Total/sec"
|
|
||||||
draPendingReplicationOperations = "DRA Pending Replication Operations"
|
|
||||||
draPendingReplicationSynchronizations = "DRA Pending Replication Synchronizations"
|
|
||||||
draSyncFailuresOnSchemaMismatch = "DRA Sync Failures on Schema Mismatch"
|
|
||||||
draSyncRequestsMade = "DRA Sync Requests Made"
|
|
||||||
draSyncRequestsSuccessful = "DRA Sync Requests Successful"
|
|
||||||
draThreadsGettingNCChanges = "DRA Threads Getting NC Changes"
|
|
||||||
draThreadsGettingNCChangesHoldingSemaphore = "DRA Threads Getting NC Changes Holding Semaphore"
|
|
||||||
_ = "DRA total number of Busy failures since boot"
|
|
||||||
_ = "DRA total number of MissingParent failures since boot"
|
|
||||||
_ = "DRA total number of NotEnoughAttrs/MissingObject failures since boot"
|
|
||||||
_ = "DRA total number of Preempted failures since boot"
|
|
||||||
_ = "DRA total time of applying replication package since boot"
|
|
||||||
_ = "DRA total time of NC replication calls since boot"
|
|
||||||
_ = "DRA total time of successful NC replication calls since boot"
|
|
||||||
_ = "DRA total time of successfully applying replication package since boot"
|
|
||||||
_ = "DRA total time on waiting async replication packages since boot"
|
|
||||||
_ = "DRA total time on waiting sync replication packages since boot"
|
|
||||||
dsPercentReadsFromDRA = "DS % Reads from DRA"
|
|
||||||
dsPercentReadsFromKCC = "DS % Reads from KCC"
|
|
||||||
dsPercentReadsFromLSA = "DS % Reads from LSA"
|
|
||||||
dsPercentReadsFromNSPI = "DS % Reads from NSPI"
|
|
||||||
dsPercentReadsFromNTDSAPI = "DS % Reads from NTDSAPI"
|
|
||||||
dsPercentReadsFromSAM = "DS % Reads from SAM"
|
|
||||||
dsPercentReadsOther = "DS % Reads Other"
|
|
||||||
dsPercentSearchesFromDRA = "DS % Searches from DRA"
|
|
||||||
dsPercentSearchesFromKCC = "DS % Searches from KCC"
|
|
||||||
dsPercentSearchesFromLDAP = "DS % Searches from LDAP"
|
|
||||||
dsPercentSearchesFromLSA = "DS % Searches from LSA"
|
|
||||||
dsPercentSearchesFromNSPI = "DS % Searches from NSPI"
|
|
||||||
dsPercentSearchesFromNTDSAPI = "DS % Searches from NTDSAPI"
|
|
||||||
dsPercentSearchesFromSAM = "DS % Searches from SAM"
|
|
||||||
dsPercentSearchesOther = "DS % Searches Other"
|
|
||||||
dsPercentWritesFromDRA = "DS % Writes from DRA"
|
|
||||||
dsPercentWritesFromKCC = "DS % Writes from KCC"
|
|
||||||
dsPercentWritesFromLDAP = "DS % Writes from LDAP"
|
|
||||||
dsPercentWritesFromLSA = "DS % Writes from LSA"
|
|
||||||
dsPercentWritesFromNSPI = "DS % Writes from NSPI"
|
|
||||||
dsPercentWritesFromNTDSAPI = "DS % Writes from NTDSAPI"
|
|
||||||
dsPercentWritesFromSAM = "DS % Writes from SAM"
|
|
||||||
dsPercentWritesOther = "DS % Writes Other"
|
|
||||||
dsClientBindsPerSec = "DS Client Binds/sec"
|
|
||||||
dsClientNameTranslationsPerSec = "DS Client Name Translations/sec"
|
|
||||||
dsDirectoryReadsPerSec = "DS Directory Reads/sec"
|
|
||||||
dsDirectorySearchesPerSec = "DS Directory Searches/sec"
|
|
||||||
dsDirectoryWritesPerSec = "DS Directory Writes/sec"
|
|
||||||
dsMonitorListSize = "DS Monitor List Size"
|
|
||||||
dsNameCacheHitRate = "DS Name Cache hit rate"
|
|
||||||
dsNotifyQueueSize = "DS Notify Queue Size"
|
|
||||||
dsSearchSubOperationsPerSec = "DS Search sub-operations/sec"
|
|
||||||
dsSecurityDescriptorPropagationsEvents = "DS Security Descriptor Propagations Events"
|
|
||||||
dsSecurityDescriptorPropagatorAverageExclusionTime = "DS Security Descriptor Propagator Average Exclusion Time"
|
|
||||||
dsSecurityDescriptorPropagatorRuntimeQueue = "DS Security Descriptor Propagator Runtime Queue"
|
|
||||||
dsSecurityDescriptorSubOperationsPerSec = "DS Security Descriptor sub-operations/sec"
|
|
||||||
dsServerBindsPerSec = "DS Server Binds/sec"
|
|
||||||
dsServerNameTranslationsPerSec = "DS Server Name Translations/sec"
|
|
||||||
dsThreadsInUse = "DS Threads in Use"
|
|
||||||
_ = "Error eventlogs since boot"
|
|
||||||
_ = "Error events since boot"
|
|
||||||
externalBindsPerSec = "External Binds/sec"
|
|
||||||
fastBindsPerSec = "Fast Binds/sec"
|
|
||||||
_ = "Fatal events since boot"
|
|
||||||
_ = "Info eventlogs since boot"
|
|
||||||
ldapActiveThreads = "LDAP Active Threads"
|
|
||||||
_ = "LDAP Add Operations"
|
|
||||||
_ = "LDAP Add Operations/sec"
|
|
||||||
_ = "LDAP batch slots available"
|
|
||||||
ldapBindTime = "LDAP Bind Time"
|
|
||||||
_ = "LDAP busy retries"
|
|
||||||
_ = "LDAP busy retries/sec"
|
|
||||||
ldapClientSessions = "LDAP Client Sessions"
|
|
||||||
ldapClosedConnectionsPerSec = "LDAP Closed Connections/sec"
|
|
||||||
_ = "LDAP Delete Operations"
|
|
||||||
_ = "LDAP Delete Operations/sec"
|
|
||||||
_ = "LDAP Modify DN Operations"
|
|
||||||
_ = "LDAP Modify DN Operations/sec"
|
|
||||||
_ = "LDAP Modify Operations"
|
|
||||||
_ = "LDAP Modify Operations/sec"
|
|
||||||
ldapNewConnectionsPerSec = "LDAP New Connections/sec"
|
|
||||||
ldapNewSSLConnectionsPerSec = "LDAP New SSL Connections/sec"
|
|
||||||
_ = "LDAP Outbound Bytes"
|
|
||||||
_ = "LDAP Outbound Bytes/sec"
|
|
||||||
_ = "LDAP Page Search Cache entries count"
|
|
||||||
_ = "LDAP Page Search Cache size"
|
|
||||||
ldapSearchesPerSec = "LDAP Searches/sec"
|
|
||||||
ldapSuccessfulBindsPerSec = "LDAP Successful Binds/sec"
|
|
||||||
_ = "LDAP Threads Sleeping on BUSY"
|
|
||||||
ldapUDPOperationsPerSec = "LDAP UDP operations/sec"
|
|
||||||
ldapWritesPerSec = "LDAP Writes/sec"
|
|
||||||
linkValuesCleanedPerSec = "Link Values Cleaned/sec"
|
|
||||||
_ = "Links added"
|
|
||||||
_ = "Links added/sec"
|
|
||||||
_ = "Links visited"
|
|
||||||
_ = "Links visited/sec"
|
|
||||||
_ = "Logical link deletes"
|
|
||||||
_ = "Logical link deletes/sec"
|
|
||||||
negotiatedBindsPerSec = "Negotiated Binds/sec"
|
|
||||||
ntlmBindsPerSec = "NTLM Binds/sec"
|
|
||||||
_ = "Objects returned"
|
|
||||||
_ = "Objects returned/sec"
|
|
||||||
_ = "Objects visited"
|
|
||||||
_ = "Objects visited/sec"
|
|
||||||
oneLevelSearchesPerSec = "Onelevel searches/sec"
|
|
||||||
_ = "PDC failed password update notifications"
|
|
||||||
_ = "PDC password update notifications/sec"
|
|
||||||
_ = "PDC successful password update notifications"
|
|
||||||
phantomsCleanedPerSec = "Phantoms Cleaned/sec"
|
|
||||||
phantomsVisitedPerSec = "Phantoms Visited/sec"
|
|
||||||
_ = "Physical link deletes"
|
|
||||||
_ = "Physical link deletes/sec"
|
|
||||||
_ = "Replicate Single Object operations"
|
|
||||||
_ = "Replicate Single Object operations/sec"
|
|
||||||
_ = "RID Pool invalidations since boot"
|
|
||||||
_ = "RID Pool request failures since boot"
|
|
||||||
_ = "RID Pool request successes since boot"
|
|
||||||
samAccountGroupEvaluationLatency = "SAM Account Group Evaluation Latency"
|
|
||||||
samDisplayInformationQueriesPerSec = "SAM Display Information Queries/sec"
|
|
||||||
samDomainLocalGroupMembershipEvaluationsPerSec = "SAM Domain Local Group Membership Evaluations/sec"
|
|
||||||
samEnumerationsPerSec = "SAM Enumerations/sec"
|
|
||||||
samGCEvaluationsPerSec = "SAM GC Evaluations/sec"
|
|
||||||
samGlobalGroupMembershipEvaluationsPerSec = "SAM Global Group Membership Evaluations/sec"
|
|
||||||
samMachineCreationAttemptsPerSec = "SAM Machine Creation Attempts/sec"
|
|
||||||
samMembershipChangesPerSec = "SAM Membership Changes/sec"
|
|
||||||
samNonTransitiveMembershipEvaluationsPerSec = "SAM Non-Transitive Membership Evaluations/sec"
|
|
||||||
samPasswordChangesPerSec = "SAM Password Changes/sec"
|
|
||||||
samResourceGroupEvaluationLatency = "SAM Resource Group Evaluation Latency"
|
|
||||||
samSuccessfulComputerCreationsPerSecIncludesAllRequests = "SAM Successful Computer Creations/sec: Includes all requests"
|
|
||||||
samSuccessfulUserCreationsPerSec = "SAM Successful User Creations/sec"
|
|
||||||
samTransitiveMembershipEvaluationsPerSec = "SAM Transitive Membership Evaluations/sec"
|
|
||||||
samUniversalGroupMembershipEvaluationsPerSec = "SAM Universal Group Membership Evaluations/sec"
|
|
||||||
samUserCreationAttemptsPerSec = "SAM User Creation Attempts/sec"
|
|
||||||
simpleBindsPerSec = "Simple Binds/sec"
|
|
||||||
subtreeSearchesPerSec = "Subtree searches/sec"
|
|
||||||
tombstonesGarbageCollectedPerSec = "Tombstones Garbage Collected/sec"
|
|
||||||
tombstonesVisitedPerSec = "Tombstones Visited/sec"
|
|
||||||
transitiveOperationsMillisecondsRun = "Transitive operations milliseconds run"
|
|
||||||
transitiveOperationsPerSec = "Transitive operations/sec"
|
|
||||||
transitiveSubOperationsPerSec = "Transitive suboperations/sec"
|
|
||||||
_ = "Warning eventlogs since boot"
|
|
||||||
_ = "Warning events since boot"
|
|
||||||
)
|
|
||||||
223
internal/collector/ad/types.go
Normal file
223
internal/collector/ad/types.go
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package ad
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
AbANRPerSec float64 `perfdata:"AB ANR/sec"`
|
||||||
|
AbBrowsesPerSec float64 `perfdata:"AB Browses/sec"`
|
||||||
|
AbClientSessions float64 `perfdata:"AB Client Sessions"`
|
||||||
|
AbMatchesPerSec float64 `perfdata:"AB Matches/sec"`
|
||||||
|
AbPropertyReadsPerSec float64 `perfdata:"AB Property Reads/sec"`
|
||||||
|
AbProxyLookupsPerSec float64 `perfdata:"AB Proxy Lookups/sec"`
|
||||||
|
AbSearchesPerSec float64 `perfdata:"AB Searches/sec"`
|
||||||
|
ApproximateHighestDNT float64 `perfdata:"Approximate highest DNT"`
|
||||||
|
AtqEstimatedQueueDelay float64 `perfdata:"ATQ Estimated Queue Delay"`
|
||||||
|
AtqOutstandingQueuedRequests float64 `perfdata:"ATQ Outstanding Queued Requests"`
|
||||||
|
_ float64 `perfdata:"ATQ Queue Latency"`
|
||||||
|
AtqRequestLatency float64 `perfdata:"ATQ Request Latency"`
|
||||||
|
AtqThreadsLDAP float64 `perfdata:"ATQ Threads LDAP"`
|
||||||
|
AtqThreadsOther float64 `perfdata:"ATQ Threads Other"`
|
||||||
|
AtqThreadsTotal float64 `perfdata:"ATQ Threads Total"`
|
||||||
|
BaseSearchesPerSec float64 `perfdata:"Base searches/sec"`
|
||||||
|
DatabaseAddsPerSec float64 `perfdata:"Database adds/sec"`
|
||||||
|
DatabaseDeletesPerSec float64 `perfdata:"Database deletes/sec"`
|
||||||
|
DatabaseModifiesPerSec float64 `perfdata:"Database modifys/sec"`
|
||||||
|
DatabaseRecyclesPerSec float64 `perfdata:"Database recycles/sec"`
|
||||||
|
DigestBindsPerSec float64 `perfdata:"Digest Binds/sec"`
|
||||||
|
_ float64 `perfdata:"DirSync session throttling rate"`
|
||||||
|
_ float64 `perfdata:"DirSync sessions in progress"`
|
||||||
|
DRAHighestUSNCommittedHighPart float64 `perfdata:"DRA Highest USN Committed (High part)"`
|
||||||
|
DRAHighestUSNCommittedLowPart float64 `perfdata:"DRA Highest USN Committed (Low part)"`
|
||||||
|
DRAHighestUSNIssuedHighPart float64 `perfdata:"DRA Highest USN Issued (High part)"`
|
||||||
|
DRAHighestUSNIssuedLowPart float64 `perfdata:"DRA Highest USN Issued (Low part)"`
|
||||||
|
DRAInboundBytesCompressedBetweenSitesAfterCompressionSinceBoot float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, After Compression) Since Boot"`
|
||||||
|
DRAInboundBytesCompressedBetweenSitesAfterCompressionPerSec float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, After Compression)/sec"`
|
||||||
|
DRAInboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, Before Compression) Since Boot"`
|
||||||
|
DRAInboundBytesCompressedBetweenSitesBeforeCompressionPerSec float64 `perfdata:"DRA Inbound Bytes Compressed (Between Sites, Before Compression)/sec"`
|
||||||
|
DRAInboundBytesNotCompressedWithinSiteSinceBoot float64 `perfdata:"DRA Inbound Bytes Not Compressed (Within Site) Since Boot"`
|
||||||
|
DRAInboundBytesNotCompressedWithinSitePerSec float64 `perfdata:"DRA Inbound Bytes Not Compressed (Within Site)/sec"`
|
||||||
|
DRAInboundBytesTotalSinceBoot float64 `perfdata:"DRA Inbound Bytes Total Since Boot"`
|
||||||
|
DRAInboundBytesTotalPerSec float64 `perfdata:"DRA Inbound Bytes Total/sec"`
|
||||||
|
DRAInboundFullSyncObjectsRemaining float64 `perfdata:"DRA Inbound Full Sync Objects Remaining"`
|
||||||
|
DRAInboundLinkValueUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Link Value Updates Remaining in Packet"`
|
||||||
|
_ float64 `perfdata:"DRA Inbound Link Values/sec"`
|
||||||
|
DRAInboundObjectUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Object Updates Remaining in Packet"`
|
||||||
|
DRAInboundObjectsAppliedPerSec float64 `perfdata:"DRA Inbound Objects Applied/sec"`
|
||||||
|
DRAInboundObjectsFilteredPerSec float64 `perfdata:"DRA Inbound Objects Filtered/sec"`
|
||||||
|
DRAInboundObjectsPerSec float64 `perfdata:"DRA Inbound Objects/sec"`
|
||||||
|
DRAInboundPropertiesAppliedPerSec float64 `perfdata:"DRA Inbound Properties Applied/sec"`
|
||||||
|
DRAInboundPropertiesFilteredPerSec float64 `perfdata:"DRA Inbound Properties Filtered/sec"`
|
||||||
|
DRAInboundPropertiesTotalPerSec float64 `perfdata:"DRA Inbound Properties Total/sec"`
|
||||||
|
_ float64 `perfdata:"DRA Inbound Sync Link Deletion/sec"`
|
||||||
|
DRAInboundTotalUpdatesRemainingInPacket float64 `perfdata:"DRA Inbound Total Updates Remaining in Packet"`
|
||||||
|
DRAInboundValuesDNsOnlyPerSec float64 `perfdata:"DRA Inbound Values (DNs only)/sec"`
|
||||||
|
DRAInboundValuesTotalPerSec float64 `perfdata:"DRA Inbound Values Total/sec"`
|
||||||
|
_ float64 `perfdata:"DRA number of NC replication calls since boot"`
|
||||||
|
_ float64 `perfdata:"DRA number of successful NC replication calls since boot"`
|
||||||
|
DRAOutboundBytesCompressedBetweenSitesAfterCompressionSinceBoot float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, After Compression) Since Boot"`
|
||||||
|
DRAOutboundBytesCompressedBetweenSitesAfterCompressionPerSec float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, After Compression)/sec"`
|
||||||
|
DRAOutboundBytesCompressedBetweenSitesBeforeCompressionSinceBoot float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, Before Compression) Since Boot"`
|
||||||
|
DRAOutboundBytesCompressedBetweenSitesBeforeCompressionPerSec float64 `perfdata:"DRA Outbound Bytes Compressed (Between Sites, Before Compression)/sec"`
|
||||||
|
DRAOutboundBytesNotCompressedWithinSiteSinceBoot float64 `perfdata:"DRA Outbound Bytes Not Compressed (Within Site) Since Boot"`
|
||||||
|
DRAOutboundBytesNotCompressedWithinSitePerSec float64 `perfdata:"DRA Outbound Bytes Not Compressed (Within Site)/sec"`
|
||||||
|
DRAOutboundBytesTotalSinceBoot float64 `perfdata:"DRA Outbound Bytes Total Since Boot"`
|
||||||
|
DRAOutboundBytesTotalPerSec float64 `perfdata:"DRA Outbound Bytes Total/sec"`
|
||||||
|
DRAOutboundObjectsFilteredPerSec float64 `perfdata:"DRA Outbound Objects Filtered/sec"`
|
||||||
|
DRAOutboundObjectsPerSec float64 `perfdata:"DRA Outbound Objects/sec"`
|
||||||
|
DRAOutboundPropertiesPerSec float64 `perfdata:"DRA Outbound Properties/sec"`
|
||||||
|
DRAOutboundValuesDNsOnlyPerSec float64 `perfdata:"DRA Outbound Values (DNs only)/sec"`
|
||||||
|
DRAOutboundValuesTotalPerSec float64 `perfdata:"DRA Outbound Values Total/sec"`
|
||||||
|
DRAPendingReplicationOperations float64 `perfdata:"DRA Pending Replication Operations"`
|
||||||
|
DRAPendingReplicationSynchronizations float64 `perfdata:"DRA Pending Replication Synchronizations"`
|
||||||
|
DRASyncFailuresOnSchemaMismatch float64 `perfdata:"DRA Sync Failures on Schema Mismatch"`
|
||||||
|
DRASyncRequestsMade float64 `perfdata:"DRA Sync Requests Made"`
|
||||||
|
DRASyncRequestsSuccessful float64 `perfdata:"DRA Sync Requests Successful"`
|
||||||
|
DRAThreadsGettingNCChanges float64 `perfdata:"DRA Threads Getting NC Changes"`
|
||||||
|
DRAThreadsGettingNCChangesHoldingSemaphore float64 `perfdata:"DRA Threads Getting NC Changes Holding Semaphore"`
|
||||||
|
_ float64 `perfdata:"DRA total number of Busy failures since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total number of MissingParent failures since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total number of NotEnoughAttrs/MissingObject failures since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total number of Preempted failures since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time of applying replication package since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time of NC replication calls since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time of successful NC replication calls since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time of successfully applying replication package since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time on waiting async replication packages since boot"`
|
||||||
|
_ float64 `perfdata:"DRA total time on waiting sync replication packages since boot"`
|
||||||
|
DsPercentReadsFromDRA float64 `perfdata:"DS % Reads from DRA"`
|
||||||
|
DsPercentReadsFromKCC float64 `perfdata:"DS % Reads from KCC"`
|
||||||
|
DsPercentReadsFromLSA float64 `perfdata:"DS % Reads from LSA"`
|
||||||
|
DsPercentReadsFromNSPI float64 `perfdata:"DS % Reads from NSPI"`
|
||||||
|
DsPercentReadsFromNTDSAPI float64 `perfdata:"DS % Reads from NTDSAPI"`
|
||||||
|
DsPercentReadsFromSAM float64 `perfdata:"DS % Reads from SAM"`
|
||||||
|
DsPercentReadsOther float64 `perfdata:"DS % Reads Other"`
|
||||||
|
DsPercentSearchesFromDRA float64 `perfdata:"DS % Searches from DRA"`
|
||||||
|
DsPercentSearchesFromKCC float64 `perfdata:"DS % Searches from KCC"`
|
||||||
|
DsPercentSearchesFromLDAP float64 `perfdata:"DS % Searches from LDAP"`
|
||||||
|
DsPercentSearchesFromLSA float64 `perfdata:"DS % Searches from LSA"`
|
||||||
|
DsPercentSearchesFromNSPI float64 `perfdata:"DS % Searches from NSPI"`
|
||||||
|
DsPercentSearchesFromNTDSAPI float64 `perfdata:"DS % Searches from NTDSAPI"`
|
||||||
|
DsPercentSearchesFromSAM float64 `perfdata:"DS % Searches from SAM"`
|
||||||
|
DsPercentSearchesOther float64 `perfdata:"DS % Searches Other"`
|
||||||
|
DsPercentWritesFromDRA float64 `perfdata:"DS % Writes from DRA"`
|
||||||
|
DsPercentWritesFromKCC float64 `perfdata:"DS % Writes from KCC"`
|
||||||
|
DsPercentWritesFromLDAP float64 `perfdata:"DS % Writes from LDAP"`
|
||||||
|
DsPercentWritesFromLSA float64 `perfdata:"DS % Writes from LSA"`
|
||||||
|
DsPercentWritesFromNSPI float64 `perfdata:"DS % Writes from NSPI"`
|
||||||
|
DsPercentWritesFromNTDSAPI float64 `perfdata:"DS % Writes from NTDSAPI"`
|
||||||
|
DsPercentWritesFromSAM float64 `perfdata:"DS % Writes from SAM"`
|
||||||
|
DsPercentWritesOther float64 `perfdata:"DS % Writes Other"`
|
||||||
|
DsClientBindsPerSec float64 `perfdata:"DS Client Binds/sec"`
|
||||||
|
DsClientNameTranslationsPerSec float64 `perfdata:"DS Client Name Translations/sec"`
|
||||||
|
DsDirectoryReadsPerSec float64 `perfdata:"DS Directory Reads/sec"`
|
||||||
|
DsDirectorySearchesPerSec float64 `perfdata:"DS Directory Searches/sec"`
|
||||||
|
DsDirectoryWritesPerSec float64 `perfdata:"DS Directory Writes/sec"`
|
||||||
|
DsMonitorListSize float64 `perfdata:"DS Monitor List Size"`
|
||||||
|
DsNameCacheHitRate float64 `perfdata:"DS Name Cache hit rate"`
|
||||||
|
DsNameCacheHitRateSecondValue float64 `perfdata:"DS Name Cache hit rate,secondvalue"`
|
||||||
|
DsNotifyQueueSize float64 `perfdata:"DS Notify Queue Size"`
|
||||||
|
DsSearchSubOperationsPerSec float64 `perfdata:"DS Search sub-operations/sec"`
|
||||||
|
DsSecurityDescriptorPropagationsEvents float64 `perfdata:"DS Security Descriptor Propagations Events"`
|
||||||
|
DsSecurityDescriptorPropagatorAverageExclusionTime float64 `perfdata:"DS Security Descriptor Propagator Average Exclusion Time"`
|
||||||
|
DsSecurityDescriptorPropagatorRuntimeQueue float64 `perfdata:"DS Security Descriptor Propagator Runtime Queue"`
|
||||||
|
DsSecurityDescriptorSubOperationsPerSec float64 `perfdata:"DS Security Descriptor sub-operations/sec"`
|
||||||
|
DsServerBindsPerSec float64 `perfdata:"DS Server Binds/sec"`
|
||||||
|
DsServerNameTranslationsPerSec float64 `perfdata:"DS Server Name Translations/sec"`
|
||||||
|
DsThreadsInUse float64 `perfdata:"DS Threads in Use"`
|
||||||
|
_ float64 `perfdata:"Error eventlogs since boot"`
|
||||||
|
_ float64 `perfdata:"Error events since boot"`
|
||||||
|
ExternalBindsPerSec float64 `perfdata:"External Binds/sec"`
|
||||||
|
FastBindsPerSec float64 `perfdata:"Fast Binds/sec"`
|
||||||
|
_ float64 `perfdata:"Fatal events since boot"`
|
||||||
|
_ float64 `perfdata:"Info eventlogs since boot"`
|
||||||
|
LdapActiveThreads float64 `perfdata:"LDAP Active Threads"`
|
||||||
|
_ float64 `perfdata:"LDAP Add Operations"`
|
||||||
|
_ float64 `perfdata:"LDAP Add Operations/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP batch slots available"`
|
||||||
|
LdapBindTime float64 `perfdata:"LDAP Bind Time"`
|
||||||
|
_ float64 `perfdata:"LDAP busy retries"`
|
||||||
|
_ float64 `perfdata:"LDAP busy retries/sec"`
|
||||||
|
LdapClientSessions float64 `perfdata:"LDAP Client Sessions"`
|
||||||
|
LdapClosedConnectionsPerSec float64 `perfdata:"LDAP Closed Connections/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Delete Operations"`
|
||||||
|
_ float64 `perfdata:"LDAP Delete Operations/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Modify DN Operations"`
|
||||||
|
_ float64 `perfdata:"LDAP Modify DN Operations/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Modify Operations"`
|
||||||
|
_ float64 `perfdata:"LDAP Modify Operations/sec"`
|
||||||
|
LdapNewConnectionsPerSec float64 `perfdata:"LDAP New Connections/sec"`
|
||||||
|
LdapNewSSLConnectionsPerSec float64 `perfdata:"LDAP New SSL Connections/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Outbound Bytes"`
|
||||||
|
_ float64 `perfdata:"LDAP Outbound Bytes/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Page Search Cache entries count"`
|
||||||
|
_ float64 `perfdata:"LDAP Page Search Cache size"`
|
||||||
|
LdapSearchesPerSec float64 `perfdata:"LDAP Searches/sec"`
|
||||||
|
LdapSuccessfulBindsPerSec float64 `perfdata:"LDAP Successful Binds/sec"`
|
||||||
|
_ float64 `perfdata:"LDAP Threads Sleeping on BUSY"`
|
||||||
|
LdapUDPOperationsPerSec float64 `perfdata:"LDAP UDP operations/sec"`
|
||||||
|
LdapWritesPerSec float64 `perfdata:"LDAP Writes/sec"`
|
||||||
|
LinkValuesCleanedPerSec float64 `perfdata:"Link Values Cleaned/sec"`
|
||||||
|
_ float64 `perfdata:"Links added"`
|
||||||
|
_ float64 `perfdata:"Links added/sec"`
|
||||||
|
_ float64 `perfdata:"Links visited"`
|
||||||
|
_ float64 `perfdata:"Links visited/sec"`
|
||||||
|
_ float64 `perfdata:"Logical link deletes"`
|
||||||
|
_ float64 `perfdata:"Logical link deletes/sec"`
|
||||||
|
NegotiatedBindsPerSec float64 `perfdata:"Negotiated Binds/sec"`
|
||||||
|
NTLMBindsPerSec float64 `perfdata:"NTLM Binds/sec"`
|
||||||
|
_ float64 `perfdata:"Objects returned"`
|
||||||
|
_ float64 `perfdata:"Objects returned/sec"`
|
||||||
|
_ float64 `perfdata:"Objects visited"`
|
||||||
|
_ float64 `perfdata:"Objects visited/sec"`
|
||||||
|
OneLevelSearchesPerSec float64 `perfdata:"Onelevel searches/sec"`
|
||||||
|
_ float64 `perfdata:"PDC failed password update notifications"`
|
||||||
|
_ float64 `perfdata:"PDC password update notifications/sec"`
|
||||||
|
_ float64 `perfdata:"PDC successful password update notifications"`
|
||||||
|
PhantomsCleanedPerSec float64 `perfdata:"Phantoms Cleaned/sec"`
|
||||||
|
PhantomsVisitedPerSec float64 `perfdata:"Phantoms Visited/sec"`
|
||||||
|
_ float64 `perfdata:"Physical link deletes"`
|
||||||
|
_ float64 `perfdata:"Physical link deletes/sec"`
|
||||||
|
_ float64 `perfdata:"Replicate Single Object operations"`
|
||||||
|
_ float64 `perfdata:"Replicate Single Object operations/sec"`
|
||||||
|
_ float64 `perfdata:"RID Pool invalidations since boot"`
|
||||||
|
_ float64 `perfdata:"RID Pool request failures since boot"`
|
||||||
|
_ float64 `perfdata:"RID Pool request successes since boot"`
|
||||||
|
SamAccountGroupEvaluationLatency float64 `perfdata:"SAM Account Group Evaluation Latency"`
|
||||||
|
SamDisplayInformationQueriesPerSec float64 `perfdata:"SAM Display Information Queries/sec"`
|
||||||
|
SamDomainLocalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Domain Local Group Membership Evaluations/sec"`
|
||||||
|
SamEnumerationsPerSec float64 `perfdata:"SAM Enumerations/sec"`
|
||||||
|
SamGCEvaluationsPerSec float64 `perfdata:"SAM GC Evaluations/sec"`
|
||||||
|
SamGlobalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Global Group Membership Evaluations/sec"`
|
||||||
|
SamMachineCreationAttemptsPerSec float64 `perfdata:"SAM Machine Creation Attempts/sec"`
|
||||||
|
SamMembershipChangesPerSec float64 `perfdata:"SAM Membership Changes/sec"`
|
||||||
|
SamNonTransitiveMembershipEvaluationsPerSec float64 `perfdata:"SAM Non-Transitive Membership Evaluations/sec"`
|
||||||
|
SamPasswordChangesPerSec float64 `perfdata:"SAM Password Changes/sec"`
|
||||||
|
SamResourceGroupEvaluationLatency float64 `perfdata:"SAM Resource Group Evaluation Latency"`
|
||||||
|
SamSuccessfulComputerCreationsPerSecIncludesAllRequests float64 `perfdata:"SAM Successful Computer Creations/sec: Includes all requests"`
|
||||||
|
SamSuccessfulUserCreationsPerSec float64 `perfdata:"SAM Successful User Creations/sec"`
|
||||||
|
SamTransitiveMembershipEvaluationsPerSec float64 `perfdata:"SAM Transitive Membership Evaluations/sec"`
|
||||||
|
SamUniversalGroupMembershipEvaluationsPerSec float64 `perfdata:"SAM Universal Group Membership Evaluations/sec"`
|
||||||
|
SamUserCreationAttemptsPerSec float64 `perfdata:"SAM User Creation Attempts/sec"`
|
||||||
|
SimpleBindsPerSec float64 `perfdata:"Simple Binds/sec"`
|
||||||
|
SubtreeSearchesPerSec float64 `perfdata:"Subtree searches/sec"`
|
||||||
|
TombstonesGarbageCollectedPerSec float64 `perfdata:"Tombstones Garbage Collected/sec"`
|
||||||
|
TombstonesVisitedPerSec float64 `perfdata:"Tombstones Visited/sec"`
|
||||||
|
TransitiveOperationsMillisecondsRun float64 `perfdata:"Transitive operations milliseconds run"`
|
||||||
|
TransitiveOperationsPerSec float64 `perfdata:"Transitive operations/sec"`
|
||||||
|
TransitiveSubOperationsPerSec float64 `perfdata:"Transitive suboperations/sec"`
|
||||||
|
_ float64 `perfdata:"Warning eventlogs since boot"`
|
||||||
|
_ float64 `perfdata:"Warning events since boot"`
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
challengeResponseProcessingTime *prometheus.Desc
|
challengeResponseProcessingTime *prometheus.Desc
|
||||||
challengeResponsesPerSecond *prometheus.Desc
|
challengeResponsesPerSecond *prometheus.Desc
|
||||||
@@ -83,21 +84,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("Certification Authority", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Certification Authority", pdh.InstancesAll)
|
||||||
requestsPerSecond,
|
|
||||||
requestProcessingTime,
|
|
||||||
retrievalsPerSecond,
|
|
||||||
retrievalProcessingTime,
|
|
||||||
failedRequestsPerSecond,
|
|
||||||
issuedRequestsPerSecond,
|
|
||||||
pendingRequestsPerSecond,
|
|
||||||
requestCryptographicSigningTime,
|
|
||||||
requestPolicyModuleProcessingTime,
|
|
||||||
challengeResponsesPerSecond,
|
|
||||||
challengeResponseProcessingTime,
|
|
||||||
signedCertificateTimestampListsPerSecond,
|
|
||||||
signedCertificateTimestampListProcessingTime,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
|
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -185,93 +172,89 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", err)
|
return fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObject {
|
||||||
return fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestsPerSecond,
|
c.requestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsPerSecond].FirstValue,
|
data.RequestsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestProcessingTime,
|
c.requestProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[requestProcessingTime].FirstValue),
|
utils.MilliSecToSec(data.RequestProcessingTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalsPerSecond,
|
c.retrievalsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[retrievalsPerSecond].FirstValue,
|
data.RetrievalsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalProcessingTime,
|
c.retrievalProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[retrievalProcessingTime].FirstValue),
|
utils.MilliSecToSec(data.RetrievalProcessingTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failedRequestsPerSecond,
|
c.failedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failedRequestsPerSecond].FirstValue,
|
data.FailedRequestsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.issuedRequestsPerSecond,
|
c.issuedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[issuedRequestsPerSecond].FirstValue,
|
data.IssuedRequestsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pendingRequestsPerSecond,
|
c.pendingRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pendingRequestsPerSecond].FirstValue,
|
data.PendingRequestsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestCryptographicSigningTime,
|
c.requestCryptographicSigningTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[requestCryptographicSigningTime].FirstValue),
|
utils.MilliSecToSec(data.RequestCryptographicSigningTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestPolicyModuleProcessingTime,
|
c.requestPolicyModuleProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[requestPolicyModuleProcessingTime].FirstValue),
|
utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponsesPerSecond,
|
c.challengeResponsesPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[challengeResponsesPerSecond].FirstValue,
|
data.ChallengeResponsesPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponseProcessingTime,
|
c.challengeResponseProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[challengeResponseProcessingTime].FirstValue),
|
utils.MilliSecToSec(data.ChallengeResponseProcessingTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListsPerSecond,
|
c.signedCertificateTimestampListsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[signedCertificateTimestampListsPerSecond].FirstValue,
|
data.SignedCertificateTimestampListsPerSecond,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListProcessingTime,
|
c.signedCertificateTimestampListProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(data[signedCertificateTimestampListProcessingTime].FirstValue),
|
utils.MilliSecToSec(data.SignedCertificateTimestampListProcessingTime),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, adcs.Name, adcs.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, adcs.Name, adcs.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, adcs.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package adcs
|
|
||||||
|
|
||||||
const (
|
|
||||||
challengeResponseProcessingTime = "Challenge Response processing time (ms)"
|
|
||||||
challengeResponsesPerSecond = "Challenge Responses/sec"
|
|
||||||
failedRequestsPerSecond = "Failed Requests/sec"
|
|
||||||
issuedRequestsPerSecond = "Issued Requests/sec"
|
|
||||||
pendingRequestsPerSecond = "Pending Requests/sec"
|
|
||||||
requestCryptographicSigningTime = "Request cryptographic signing time (ms)"
|
|
||||||
requestPolicyModuleProcessingTime = "Request policy module processing time (ms)"
|
|
||||||
requestProcessingTime = "Request processing time (ms)"
|
|
||||||
requestsPerSecond = "Requests/sec"
|
|
||||||
retrievalProcessingTime = "Retrieval processing time (ms)"
|
|
||||||
retrievalsPerSecond = "Retrievals/sec"
|
|
||||||
signedCertificateTimestampListProcessingTime = "Signed Certificate Timestamp List processing time (ms)"
|
|
||||||
signedCertificateTimestampListsPerSecond = "Signed Certificate Timestamp Lists/sec"
|
|
||||||
)
|
|
||||||
34
internal/collector/adcs/types.go
Normal file
34
internal/collector/adcs/types.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package adcs
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
ChallengeResponseProcessingTime float64 `perfdata:"Challenge Response processing time (ms)"`
|
||||||
|
ChallengeResponsesPerSecond float64 `perfdata:"Challenge Responses/sec"`
|
||||||
|
FailedRequestsPerSecond float64 `perfdata:"Failed Requests/sec"`
|
||||||
|
IssuedRequestsPerSecond float64 `perfdata:"Issued Requests/sec"`
|
||||||
|
PendingRequestsPerSecond float64 `perfdata:"Pending Requests/sec"`
|
||||||
|
RequestCryptographicSigningTime float64 `perfdata:"Request cryptographic signing time (ms)"`
|
||||||
|
RequestPolicyModuleProcessingTime float64 `perfdata:"Request policy module processing time (ms)"`
|
||||||
|
RequestProcessingTime float64 `perfdata:"Request processing time (ms)"`
|
||||||
|
RequestsPerSecond float64 `perfdata:"Requests/sec"`
|
||||||
|
RetrievalProcessingTime float64 `perfdata:"Retrieval processing time (ms)"`
|
||||||
|
RetrievalsPerSecond float64 `perfdata:"Retrievals/sec"`
|
||||||
|
SignedCertificateTimestampListProcessingTime float64 `perfdata:"Signed Certificate Timestamp List processing time (ms)"`
|
||||||
|
SignedCertificateTimestampListsPerSecond float64 `perfdata:"Signed Certificate Timestamp Lists/sec"`
|
||||||
|
}
|
||||||
@@ -18,13 +18,11 @@ package adfs
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"maps"
|
|
||||||
"math"
|
"math"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -39,7 +37,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
adLoginConnectionFailures *prometheus.Desc
|
adLoginConnectionFailures *prometheus.Desc
|
||||||
artifactDBFailures *prometheus.Desc
|
artifactDBFailures *prometheus.Desc
|
||||||
@@ -115,51 +114,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("AD FS", nil, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "AD FS", nil)
|
||||||
adLoginConnectionFailures,
|
|
||||||
certificateAuthentications,
|
|
||||||
deviceAuthentications,
|
|
||||||
extranetAccountLockouts,
|
|
||||||
federatedAuthentications,
|
|
||||||
passportAuthentications,
|
|
||||||
passiveRequests,
|
|
||||||
passwordChangeFailed,
|
|
||||||
passwordChangeSucceeded,
|
|
||||||
tokenRequests,
|
|
||||||
windowsIntegratedAuthentications,
|
|
||||||
oAuthAuthZRequests,
|
|
||||||
oAuthClientAuthentications,
|
|
||||||
oAuthClientAuthenticationFailures,
|
|
||||||
oAuthClientCredentialRequestFailures,
|
|
||||||
oAuthClientCredentialRequests,
|
|
||||||
oAuthClientPrivateKeyJWTAuthenticationFailures,
|
|
||||||
oAuthClientPrivateKeyJWTAuthentications,
|
|
||||||
oAuthClientBasicAuthenticationFailures,
|
|
||||||
oAuthClientBasicAuthentications,
|
|
||||||
oAuthClientSecretPostAuthenticationFailures,
|
|
||||||
oAuthClientSecretPostAuthentications,
|
|
||||||
oAuthClientWindowsAuthenticationFailures,
|
|
||||||
oAuthClientWindowsAuthentications,
|
|
||||||
oAuthLogonCertRequestFailures,
|
|
||||||
oAuthLogonCertTokenRequests,
|
|
||||||
oAuthPasswordGrantRequestFailures,
|
|
||||||
oAuthPasswordGrantRequests,
|
|
||||||
oAuthTokenRequests,
|
|
||||||
samlPTokenRequests,
|
|
||||||
ssoAuthenticationFailures,
|
|
||||||
ssoAuthentications,
|
|
||||||
wsFedTokenRequests,
|
|
||||||
wsTrustTokenRequests,
|
|
||||||
usernamePasswordAuthenticationFailures,
|
|
||||||
usernamePasswordAuthentications,
|
|
||||||
externalAuthentications,
|
|
||||||
externalAuthNFailures,
|
|
||||||
artifactDBFailures,
|
|
||||||
avgArtifactDBQueryTime,
|
|
||||||
configDBFailures,
|
|
||||||
avgConfigDBQueryTime,
|
|
||||||
federationMetadataRequests,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create AD FS collector: %w", err)
|
return fmt.Errorf("failed to create AD FS collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -427,279 +382,267 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect ADFS metrics: %w", err)
|
return fmt.Errorf("failed to collect ADFS metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
instanceKey := slices.Collect(maps.Keys(data))
|
|
||||||
|
|
||||||
if len(instanceKey) == 0 {
|
|
||||||
return fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
adfsData, ok := data[instanceKey[0]]
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect ADFS metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.adLoginConnectionFailures,
|
c.adLoginConnectionFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[adLoginConnectionFailures].FirstValue,
|
c.perfDataObject[0].AdLoginConnectionFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.certificateAuthentications,
|
c.certificateAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[certificateAuthentications].FirstValue,
|
c.perfDataObject[0].CertificateAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.deviceAuthentications,
|
c.deviceAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[deviceAuthentications].FirstValue,
|
c.perfDataObject[0].DeviceAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.extranetAccountLockouts,
|
c.extranetAccountLockouts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[extranetAccountLockouts].FirstValue,
|
c.perfDataObject[0].ExtranetAccountLockouts,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.federatedAuthentications,
|
c.federatedAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[federatedAuthentications].FirstValue,
|
c.perfDataObject[0].FederatedAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.passportAuthentications,
|
c.passportAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[passportAuthentications].FirstValue,
|
c.perfDataObject[0].PassportAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.passiveRequests,
|
c.passiveRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[passiveRequests].FirstValue,
|
c.perfDataObject[0].PassiveRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.passwordChangeFailed,
|
c.passwordChangeFailed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[passwordChangeFailed].FirstValue,
|
c.perfDataObject[0].PasswordChangeFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.passwordChangeSucceeded,
|
c.passwordChangeSucceeded,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[passwordChangeSucceeded].FirstValue,
|
c.perfDataObject[0].PasswordChangeSucceeded,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.tokenRequests,
|
c.tokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[tokenRequests].FirstValue,
|
c.perfDataObject[0].TokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.windowsIntegratedAuthentications,
|
c.windowsIntegratedAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[windowsIntegratedAuthentications].FirstValue,
|
c.perfDataObject[0].WindowsIntegratedAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthAuthZRequests,
|
c.oAuthAuthZRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthAuthZRequests].FirstValue,
|
c.perfDataObject[0].OAuthAuthZRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientAuthentications,
|
c.oAuthClientAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientAuthentications].FirstValue,
|
c.perfDataObject[0].OAuthClientAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientAuthenticationsFailures,
|
c.oAuthClientAuthenticationsFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientCredentialsRequestFailures,
|
c.oAuthClientCredentialsRequestFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientCredentialRequestFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientCredentialRequestFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientCredentialsRequests,
|
c.oAuthClientCredentialsRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientCredentialRequests].FirstValue,
|
c.perfDataObject[0].OAuthClientCredentialRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientPrivateKeyJwtAuthenticationFailures,
|
c.oAuthClientPrivateKeyJwtAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientPrivateKeyJWTAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientPrivateKeyJWTAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientPrivateKeyJwtAuthentications,
|
c.oAuthClientPrivateKeyJwtAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientPrivateKeyJWTAuthentications].FirstValue,
|
c.perfDataObject[0].OAuthClientPrivateKeyJWTAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientSecretBasicAuthenticationFailures,
|
c.oAuthClientSecretBasicAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientBasicAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientBasicAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientSecretBasicAuthentications,
|
c.oAuthClientSecretBasicAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientBasicAuthentications].FirstValue,
|
c.perfDataObject[0].OAuthClientBasicAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientSecretPostAuthenticationFailures,
|
c.oAuthClientSecretPostAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientSecretPostAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientSecretPostAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientSecretPostAuthentications,
|
c.oAuthClientSecretPostAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientSecretPostAuthentications].FirstValue,
|
c.perfDataObject[0].OAuthClientSecretPostAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientWindowsIntegratedAuthenticationFailures,
|
c.oAuthClientWindowsIntegratedAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientWindowsAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].OAuthClientWindowsAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthClientWindowsIntegratedAuthentications,
|
c.oAuthClientWindowsIntegratedAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthClientWindowsAuthentications].FirstValue,
|
c.perfDataObject[0].OAuthClientWindowsAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthLogonCertificateRequestFailures,
|
c.oAuthLogonCertificateRequestFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthLogonCertRequestFailures].FirstValue,
|
c.perfDataObject[0].OAuthLogonCertRequestFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthLogonCertificateTokenRequests,
|
c.oAuthLogonCertificateTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthLogonCertTokenRequests].FirstValue,
|
c.perfDataObject[0].OAuthLogonCertTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthPasswordGrantRequestFailures,
|
c.oAuthPasswordGrantRequestFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthPasswordGrantRequestFailures].FirstValue,
|
c.perfDataObject[0].OAuthPasswordGrantRequestFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthPasswordGrantRequests,
|
c.oAuthPasswordGrantRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthPasswordGrantRequests].FirstValue,
|
c.perfDataObject[0].OAuthPasswordGrantRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.oAuthTokenRequests,
|
c.oAuthTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[oAuthTokenRequests].FirstValue,
|
c.perfDataObject[0].OAuthTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.samlPTokenRequests,
|
c.samlPTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[samlPTokenRequests].FirstValue,
|
c.perfDataObject[0].SamlPTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ssoAuthenticationFailures,
|
c.ssoAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[ssoAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].SsoAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ssoAuthentications,
|
c.ssoAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[ssoAuthentications].FirstValue,
|
c.perfDataObject[0].SsoAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.wsFedTokenRequests,
|
c.wsFedTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[wsFedTokenRequests].FirstValue,
|
c.perfDataObject[0].WsFedTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.wsTrustTokenRequests,
|
c.wsTrustTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[wsTrustTokenRequests].FirstValue,
|
c.perfDataObject[0].WsTrustTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.upAuthenticationFailures,
|
c.upAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[usernamePasswordAuthenticationFailures].FirstValue,
|
c.perfDataObject[0].UsernamePasswordAuthenticationFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.upAuthentications,
|
c.upAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[usernamePasswordAuthentications].FirstValue,
|
c.perfDataObject[0].UsernamePasswordAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.externalAuthenticationFailures,
|
c.externalAuthenticationFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[externalAuthNFailures].FirstValue,
|
c.perfDataObject[0].ExternalAuthNFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.externalAuthentications,
|
c.externalAuthentications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[externalAuthentications].FirstValue,
|
c.perfDataObject[0].ExternalAuthentications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.artifactDBFailures,
|
c.artifactDBFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[artifactDBFailures].FirstValue,
|
c.perfDataObject[0].ArtifactDBFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgArtifactDBQueryTime,
|
c.avgArtifactDBQueryTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[avgArtifactDBQueryTime].FirstValue*math.Pow(10, -8),
|
c.perfDataObject[0].AvgArtifactDBQueryTime*math.Pow(10, -8),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.configDBFailures,
|
c.configDBFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[configDBFailures].FirstValue,
|
c.perfDataObject[0].ConfigDBFailures,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgConfigDBQueryTime,
|
c.avgConfigDBQueryTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[avgConfigDBQueryTime].FirstValue*math.Pow(10, -8),
|
c.perfDataObject[0].AvgConfigDBQueryTime*math.Pow(10, -8),
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.federationMetadataRequests,
|
c.federationMetadataRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[federationMetadataRequests].FirstValue,
|
c.perfDataObject[0].FederationMetadataRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, adfs.Name, adfs.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, adfs.Name, adfs.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, adfs.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package adfs
|
|
||||||
|
|
||||||
const (
|
|
||||||
adLoginConnectionFailures = "AD Login Connection Failures"
|
|
||||||
artifactDBFailures = "Artifact Database Connection Failures"
|
|
||||||
avgArtifactDBQueryTime = "Average Artifact Database Query Time"
|
|
||||||
avgConfigDBQueryTime = "Average Config Database Query Time"
|
|
||||||
certificateAuthentications = "Certificate Authentications"
|
|
||||||
configDBFailures = "Configuration Database Connection Failures"
|
|
||||||
deviceAuthentications = "Device Authentications"
|
|
||||||
externalAuthentications = "External Authentications"
|
|
||||||
externalAuthNFailures = "External Authentication Failures"
|
|
||||||
extranetAccountLockouts = "Extranet Account Lockouts"
|
|
||||||
federatedAuthentications = "Federated Authentications"
|
|
||||||
federationMetadataRequests = "Federation Metadata Requests"
|
|
||||||
oAuthAuthZRequests = "OAuth AuthZ Requests"
|
|
||||||
oAuthClientAuthenticationFailures = "OAuth Client Authentications Failures"
|
|
||||||
oAuthClientAuthentications = "OAuth Client Authentications"
|
|
||||||
oAuthClientBasicAuthenticationFailures = "OAuth Client Secret Basic Authentication Failures"
|
|
||||||
oAuthClientBasicAuthentications = "OAuth Client Secret Basic Authentications"
|
|
||||||
oAuthClientCredentialRequestFailures = "OAuth Client Credentials Request Failures"
|
|
||||||
oAuthClientCredentialRequests = "OAuth Client Credentials Requests"
|
|
||||||
oAuthClientPrivateKeyJWTAuthenticationFailures = "OAuth Client Private Key Jwt Authentication Failures"
|
|
||||||
oAuthClientPrivateKeyJWTAuthentications = "OAuth Client Private Key Jwt Authentications"
|
|
||||||
oAuthClientSecretPostAuthenticationFailures = "OAuth Client Secret Post Authentication Failures"
|
|
||||||
oAuthClientSecretPostAuthentications = "OAuth Client Secret Post Authentications"
|
|
||||||
oAuthClientWindowsAuthenticationFailures = "OAuth Client Windows Integrated Authentication Failures"
|
|
||||||
oAuthClientWindowsAuthentications = "OAuth Client Windows Integrated Authentications"
|
|
||||||
oAuthLogonCertRequestFailures = "OAuth Logon Certificate Request Failures"
|
|
||||||
oAuthLogonCertTokenRequests = "OAuth Logon Certificate Token Requests"
|
|
||||||
oAuthPasswordGrantRequestFailures = "OAuth Password Grant Request Failures"
|
|
||||||
oAuthPasswordGrantRequests = "OAuth Password Grant Requests"
|
|
||||||
oAuthTokenRequests = "OAuth Token Requests"
|
|
||||||
passiveRequests = "Passive Requests"
|
|
||||||
passportAuthentications = "Microsoft Passport Authentications"
|
|
||||||
passwordChangeFailed = "Password Change Failed Requests"
|
|
||||||
passwordChangeSucceeded = "Password Change Successful Requests"
|
|
||||||
samlPTokenRequests = "SAML-P Token Requests"
|
|
||||||
ssoAuthenticationFailures = "SSO Authentication Failures"
|
|
||||||
ssoAuthentications = "SSO Authentications"
|
|
||||||
tokenRequests = "Token Requests"
|
|
||||||
usernamePasswordAuthenticationFailures = "U/P Authentication Failures"
|
|
||||||
usernamePasswordAuthentications = "U/P Authentications"
|
|
||||||
windowsIntegratedAuthentications = "Windows Integrated Authentications"
|
|
||||||
wsFedTokenRequests = "WS-Fed Token Requests"
|
|
||||||
wsTrustTokenRequests = "WS-Trust Token Requests"
|
|
||||||
)
|
|
||||||
62
internal/collector/adfs/types.go
Normal file
62
internal/collector/adfs/types.go
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package adfs
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
AdLoginConnectionFailures float64 `perfdata:"AD Login Connection Failures"`
|
||||||
|
ArtifactDBFailures float64 `perfdata:"Artifact Database Connection Failures"`
|
||||||
|
AvgArtifactDBQueryTime float64 `perfdata:"Average Artifact Database Query Time"`
|
||||||
|
AvgConfigDBQueryTime float64 `perfdata:"Average Config Database Query Time"`
|
||||||
|
CertificateAuthentications float64 `perfdata:"Certificate Authentications"`
|
||||||
|
ConfigDBFailures float64 `perfdata:"Configuration Database Connection Failures"`
|
||||||
|
DeviceAuthentications float64 `perfdata:"Device Authentications"`
|
||||||
|
ExternalAuthentications float64 `perfdata:"External Authentications"`
|
||||||
|
ExternalAuthNFailures float64 `perfdata:"External Authentication Failures"`
|
||||||
|
ExtranetAccountLockouts float64 `perfdata:"Extranet Account Lockouts"`
|
||||||
|
FederatedAuthentications float64 `perfdata:"Federated Authentications"`
|
||||||
|
FederationMetadataRequests float64 `perfdata:"Federation Metadata Requests"`
|
||||||
|
OAuthAuthZRequests float64 `perfdata:"OAuth AuthZ Requests"`
|
||||||
|
OAuthClientAuthenticationFailures float64 `perfdata:"OAuth Client Authentications Failures"`
|
||||||
|
OAuthClientAuthentications float64 `perfdata:"OAuth Client Authentications"`
|
||||||
|
OAuthClientBasicAuthenticationFailures float64 `perfdata:"OAuth Client Secret Basic Authentication Failures"`
|
||||||
|
OAuthClientBasicAuthentications float64 `perfdata:"OAuth Client Secret Basic Authentications"`
|
||||||
|
OAuthClientCredentialRequestFailures float64 `perfdata:"OAuth Client Credentials Request Failures"`
|
||||||
|
OAuthClientCredentialRequests float64 `perfdata:"OAuth Client Credentials Requests"`
|
||||||
|
OAuthClientPrivateKeyJWTAuthenticationFailures float64 `perfdata:"OAuth Client Private Key Jwt Authentication Failures"`
|
||||||
|
OAuthClientPrivateKeyJWTAuthentications float64 `perfdata:"OAuth Client Private Key Jwt Authentications"`
|
||||||
|
OAuthClientSecretPostAuthenticationFailures float64 `perfdata:"OAuth Client Secret Post Authentication Failures"`
|
||||||
|
OAuthClientSecretPostAuthentications float64 `perfdata:"OAuth Client Secret Post Authentications"`
|
||||||
|
OAuthClientWindowsAuthenticationFailures float64 `perfdata:"OAuth Client Windows Integrated Authentication Failures"`
|
||||||
|
OAuthClientWindowsAuthentications float64 `perfdata:"OAuth Client Windows Integrated Authentications"`
|
||||||
|
OAuthLogonCertRequestFailures float64 `perfdata:"OAuth Logon Certificate Request Failures"`
|
||||||
|
OAuthLogonCertTokenRequests float64 `perfdata:"OAuth Logon Certificate Token Requests"`
|
||||||
|
OAuthPasswordGrantRequestFailures float64 `perfdata:"OAuth Password Grant Request Failures"`
|
||||||
|
OAuthPasswordGrantRequests float64 `perfdata:"OAuth Password Grant Requests"`
|
||||||
|
OAuthTokenRequests float64 `perfdata:"OAuth Token Requests"`
|
||||||
|
PassiveRequests float64 `perfdata:"Passive Requests"`
|
||||||
|
PassportAuthentications float64 `perfdata:"Microsoft Passport Authentications"`
|
||||||
|
PasswordChangeFailed float64 `perfdata:"Password Change Failed Requests"`
|
||||||
|
PasswordChangeSucceeded float64 `perfdata:"Password Change Successful Requests"`
|
||||||
|
SamlPTokenRequests float64 `perfdata:"SAML-P Token Requests"`
|
||||||
|
SsoAuthenticationFailures float64 `perfdata:"SSO Authentication Failures"`
|
||||||
|
SsoAuthentications float64 `perfdata:"SSO Authentications"`
|
||||||
|
TokenRequests float64 `perfdata:"Token Requests"`
|
||||||
|
UsernamePasswordAuthenticationFailures float64 `perfdata:"U/P Authentication Failures"`
|
||||||
|
UsernamePasswordAuthentications float64 `perfdata:"U/P Authentications"`
|
||||||
|
WindowsIntegratedAuthentications float64 `perfdata:"Windows Integrated Authentications"`
|
||||||
|
WsFedTokenRequests float64 `perfdata:"WS-Fed Token Requests"`
|
||||||
|
WsTrustTokenRequests float64 `perfdata:"WS-Trust Token Requests"`
|
||||||
|
}
|
||||||
103
internal/collector/cache/cache.go
vendored
103
internal/collector/cache/cache.go
vendored
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
asyncCopyReadsTotal *prometheus.Desc
|
asyncCopyReadsTotal *prometheus.Desc
|
||||||
asyncDataMapsTotal *prometheus.Desc
|
asyncDataMapsTotal *prometheus.Desc
|
||||||
@@ -99,37 +100,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Cache", pdh.InstancesAll)
|
||||||
asyncCopyReadsTotal,
|
|
||||||
asyncDataMapsTotal,
|
|
||||||
asyncFastReadsTotal,
|
|
||||||
asyncMDLReadsTotal,
|
|
||||||
asyncPinReadsTotal,
|
|
||||||
copyReadHitsTotal,
|
|
||||||
copyReadsTotal,
|
|
||||||
dataFlushesTotal,
|
|
||||||
dataFlushPagesTotal,
|
|
||||||
dataMapHitsPercent,
|
|
||||||
dataMapPinsTotal,
|
|
||||||
dataMapsTotal,
|
|
||||||
dirtyPages,
|
|
||||||
dirtyPageThreshold,
|
|
||||||
fastReadNotPossiblesTotal,
|
|
||||||
fastReadResourceMissesTotal,
|
|
||||||
fastReadsTotal,
|
|
||||||
lazyWriteFlushesTotal,
|
|
||||||
lazyWritePagesTotal,
|
|
||||||
mdlReadHitsTotal,
|
|
||||||
mdlReadsTotal,
|
|
||||||
pinReadHitsTotal,
|
|
||||||
pinReadsTotal,
|
|
||||||
readAheadsTotal,
|
|
||||||
syncCopyReadsTotal,
|
|
||||||
syncDataMapsTotal,
|
|
||||||
syncFastReadsTotal,
|
|
||||||
syncMDLReadsTotal,
|
|
||||||
syncPinReadsTotal,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Cache collector: %w", err)
|
return fmt.Errorf("failed to create Cache collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -314,189 +285,183 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
|
|
||||||
// Collect implements the Collector interface.
|
// Collect implements the Collector interface.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Cache metrics: %w", err)
|
return fmt.Errorf("failed to collect Cache metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheData, ok := data[perfdata.InstanceEmpty]
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect Cache metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.asyncCopyReadsTotal,
|
c.asyncCopyReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[asyncCopyReadsTotal].FirstValue,
|
c.perfDataObject[0].AsyncCopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.asyncDataMapsTotal,
|
c.asyncDataMapsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[asyncDataMapsTotal].FirstValue,
|
c.perfDataObject[0].AsyncDataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.asyncFastReadsTotal,
|
c.asyncFastReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[asyncFastReadsTotal].FirstValue,
|
c.perfDataObject[0].AsyncFastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.asyncMDLReadsTotal,
|
c.asyncMDLReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[asyncMDLReadsTotal].FirstValue,
|
c.perfDataObject[0].AsyncMDLReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.asyncPinReadsTotal,
|
c.asyncPinReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[asyncPinReadsTotal].FirstValue,
|
c.perfDataObject[0].AsyncPinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.copyReadHitsTotal,
|
c.copyReadHitsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
cacheData[copyReadHitsTotal].FirstValue,
|
c.perfDataObject[0].CopyReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.copyReadsTotal,
|
c.copyReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[copyReadsTotal].FirstValue,
|
c.perfDataObject[0].CopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataFlushesTotal,
|
c.dataFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[dataFlushesTotal].FirstValue,
|
c.perfDataObject[0].DataFlushesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataFlushPagesTotal,
|
c.dataFlushPagesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[dataFlushPagesTotal].FirstValue,
|
c.perfDataObject[0].DataFlushPagesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataMapHitsPercent,
|
c.dataMapHitsPercent,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
cacheData[dataMapHitsPercent].FirstValue,
|
c.perfDataObject[0].DataMapHitsPercent,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataMapPinsTotal,
|
c.dataMapPinsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[dataMapPinsTotal].FirstValue,
|
c.perfDataObject[0].DataMapPinsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataMapsTotal,
|
c.dataMapsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[dataMapsTotal].FirstValue,
|
c.perfDataObject[0].DataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dirtyPages,
|
c.dirtyPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
cacheData[dirtyPages].FirstValue,
|
c.perfDataObject[0].DirtyPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dirtyPageThreshold,
|
c.dirtyPageThreshold,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
cacheData[dirtyPageThreshold].FirstValue,
|
c.perfDataObject[0].DirtyPageThreshold,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.fastReadNotPossiblesTotal,
|
c.fastReadNotPossiblesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[fastReadNotPossiblesTotal].FirstValue,
|
c.perfDataObject[0].FastReadNotPossiblesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.fastReadResourceMissesTotal,
|
c.fastReadResourceMissesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[fastReadResourceMissesTotal].FirstValue,
|
c.perfDataObject[0].FastReadResourceMissesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.fastReadsTotal,
|
c.fastReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[fastReadsTotal].FirstValue,
|
c.perfDataObject[0].FastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.lazyWriteFlushesTotal,
|
c.lazyWriteFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[lazyWriteFlushesTotal].FirstValue,
|
c.perfDataObject[0].LazyWriteFlushesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.lazyWritePagesTotal,
|
c.lazyWritePagesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[lazyWritePagesTotal].FirstValue,
|
c.perfDataObject[0].LazyWritePagesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mdlReadHitsTotal,
|
c.mdlReadHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[mdlReadHitsTotal].FirstValue,
|
c.perfDataObject[0].MdlReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mdlReadsTotal,
|
c.mdlReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[mdlReadsTotal].FirstValue,
|
c.perfDataObject[0].MdlReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pinReadHitsTotal,
|
c.pinReadHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[pinReadHitsTotal].FirstValue,
|
c.perfDataObject[0].PinReadHitsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pinReadsTotal,
|
c.pinReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[pinReadsTotal].FirstValue,
|
c.perfDataObject[0].PinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readAheadsTotal,
|
c.readAheadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[readAheadsTotal].FirstValue,
|
c.perfDataObject[0].ReadAheadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncCopyReadsTotal,
|
c.syncCopyReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[syncCopyReadsTotal].FirstValue,
|
c.perfDataObject[0].SyncCopyReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncDataMapsTotal,
|
c.syncDataMapsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[syncDataMapsTotal].FirstValue,
|
c.perfDataObject[0].SyncDataMapsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncFastReadsTotal,
|
c.syncFastReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[syncFastReadsTotal].FirstValue,
|
c.perfDataObject[0].SyncFastReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncMDLReadsTotal,
|
c.syncMDLReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[syncMDLReadsTotal].FirstValue,
|
c.perfDataObject[0].SyncMDLReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncPinReadsTotal,
|
c.syncPinReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
cacheData[syncPinReadsTotal].FirstValue,
|
c.perfDataObject[0].SyncPinReadsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
4
internal/collector/cache/cache_test.go
vendored
4
internal/collector/cache/cache_test.go
vendored
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, cache.Name, cache.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, cache.Name, cache.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, cache.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
50
internal/collector/cache/const.go
vendored
50
internal/collector/cache/const.go
vendored
@@ -1,50 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package cache
|
|
||||||
|
|
||||||
// Perflib "Cache":
|
|
||||||
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
|
|
||||||
const (
|
|
||||||
asyncCopyReadsTotal = "Async Copy Reads/sec"
|
|
||||||
asyncDataMapsTotal = "Async Data Maps/sec"
|
|
||||||
asyncFastReadsTotal = "Async Fast Reads/sec"
|
|
||||||
asyncMDLReadsTotal = "Async MDL Reads/sec"
|
|
||||||
asyncPinReadsTotal = "Async Pin Reads/sec"
|
|
||||||
copyReadHitsTotal = "Copy Read Hits %"
|
|
||||||
copyReadsTotal = "Copy Reads/sec"
|
|
||||||
dataFlushesTotal = "Data Flushes/sec"
|
|
||||||
dataFlushPagesTotal = "Data Flush Pages/sec"
|
|
||||||
dataMapHitsPercent = "Data Map Hits %"
|
|
||||||
dataMapPinsTotal = "Data Map Pins/sec"
|
|
||||||
dataMapsTotal = "Data Maps/sec"
|
|
||||||
dirtyPages = "Dirty Pages"
|
|
||||||
dirtyPageThreshold = "Dirty Page Threshold"
|
|
||||||
fastReadNotPossiblesTotal = "Fast Read Not Possibles/sec"
|
|
||||||
fastReadResourceMissesTotal = "Fast Read Resource Misses/sec"
|
|
||||||
fastReadsTotal = "Fast Reads/sec"
|
|
||||||
lazyWriteFlushesTotal = "Lazy Write Flushes/sec"
|
|
||||||
lazyWritePagesTotal = "Lazy Write Pages/sec"
|
|
||||||
mdlReadHitsTotal = "MDL Read Hits %"
|
|
||||||
mdlReadsTotal = "MDL Reads/sec"
|
|
||||||
pinReadHitsTotal = "Pin Read Hits %"
|
|
||||||
pinReadsTotal = "Pin Reads/sec"
|
|
||||||
readAheadsTotal = "Read Aheads/sec"
|
|
||||||
syncCopyReadsTotal = "Sync Copy Reads/sec"
|
|
||||||
syncDataMapsTotal = "Sync Data Maps/sec"
|
|
||||||
syncFastReadsTotal = "Sync Fast Reads/sec"
|
|
||||||
syncMDLReadsTotal = "Sync MDL Reads/sec"
|
|
||||||
syncPinReadsTotal = "Sync Pin Reads/sec"
|
|
||||||
)
|
|
||||||
50
internal/collector/cache/types.go
vendored
Normal file
50
internal/collector/cache/types.go
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package cache
|
||||||
|
|
||||||
|
// Perflib "Cache":
|
||||||
|
// - https://docs.microsoft.com/en-us/previous-versions/aa394267(v=vs.85)
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
AsyncCopyReadsTotal float64 `perfdata:"Async Copy Reads/sec"`
|
||||||
|
AsyncDataMapsTotal float64 `perfdata:"Async Data Maps/sec"`
|
||||||
|
AsyncFastReadsTotal float64 `perfdata:"Async Fast Reads/sec"`
|
||||||
|
AsyncMDLReadsTotal float64 `perfdata:"Async MDL Reads/sec"`
|
||||||
|
AsyncPinReadsTotal float64 `perfdata:"Async Pin Reads/sec"`
|
||||||
|
CopyReadHitsTotal float64 `perfdata:"Copy Read Hits %"`
|
||||||
|
CopyReadsTotal float64 `perfdata:"Copy Reads/sec"`
|
||||||
|
DataFlushesTotal float64 `perfdata:"Data Flushes/sec"`
|
||||||
|
DataFlushPagesTotal float64 `perfdata:"Data Flush Pages/sec"`
|
||||||
|
DataMapHitsPercent float64 `perfdata:"Data Map Hits %"`
|
||||||
|
DataMapPinsTotal float64 `perfdata:"Data Map Pins/sec"`
|
||||||
|
DataMapsTotal float64 `perfdata:"Data Maps/sec"`
|
||||||
|
DirtyPages float64 `perfdata:"Dirty Pages"`
|
||||||
|
DirtyPageThreshold float64 `perfdata:"Dirty Page Threshold"`
|
||||||
|
FastReadNotPossiblesTotal float64 `perfdata:"Fast Read Not Possibles/sec"`
|
||||||
|
FastReadResourceMissesTotal float64 `perfdata:"Fast Read Resource Misses/sec"`
|
||||||
|
FastReadsTotal float64 `perfdata:"Fast Reads/sec"`
|
||||||
|
LazyWriteFlushesTotal float64 `perfdata:"Lazy Write Flushes/sec"`
|
||||||
|
LazyWritePagesTotal float64 `perfdata:"Lazy Write Pages/sec"`
|
||||||
|
MdlReadHitsTotal float64 `perfdata:"MDL Read Hits %"`
|
||||||
|
MdlReadsTotal float64 `perfdata:"MDL Reads/sec"`
|
||||||
|
PinReadHitsTotal float64 `perfdata:"Pin Read Hits %"`
|
||||||
|
PinReadsTotal float64 `perfdata:"Pin Reads/sec"`
|
||||||
|
ReadAheadsTotal float64 `perfdata:"Read Aheads/sec"`
|
||||||
|
SyncCopyReadsTotal float64 `perfdata:"Sync Copy Reads/sec"`
|
||||||
|
SyncDataMapsTotal float64 `perfdata:"Sync Data Maps/sec"`
|
||||||
|
SyncFastReadsTotal float64 `perfdata:"Sync Fast Reads/sec"`
|
||||||
|
SyncMDLReadsTotal float64 `perfdata:"Sync MDL Reads/sec"`
|
||||||
|
SyncPinReadsTotal float64 `perfdata:"Sync Pin Reads/sec"`
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/Microsoft/hcsshim"
|
"github.com/Microsoft/hcsshim"
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -322,19 +322,19 @@ func (c *Collector) collectContainer(ch chan<- prometheus.Metric, containerDetai
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeTotal,
|
c.runtimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(containerStats.Processor.TotalRuntime100ns)*perfdata.TicksToSecondScaleFactor,
|
float64(containerStats.Processor.TotalRuntime100ns)*pdh.TicksToSecondScaleFactor,
|
||||||
containerIdWithPrefix,
|
containerIdWithPrefix,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeUser,
|
c.runtimeUser,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(containerStats.Processor.RuntimeUser100ns)*perfdata.TicksToSecondScaleFactor,
|
float64(containerStats.Processor.RuntimeUser100ns)*pdh.TicksToSecondScaleFactor,
|
||||||
containerIdWithPrefix,
|
containerIdWithPrefix,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.runtimeKernel,
|
c.runtimeKernel,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
float64(containerStats.Processor.RuntimeKernel100ns)*perfdata.TicksToSecondScaleFactor,
|
float64(containerStats.Processor.RuntimeKernel100ns)*pdh.TicksToSecondScaleFactor,
|
||||||
containerIdWithPrefix,
|
containerIdWithPrefix,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, container.Name, container.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, container.Name, container.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, container.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package cpu
|
|
||||||
|
|
||||||
// Processor performance counters.
|
|
||||||
const (
|
|
||||||
c1TimeSeconds = "% C1 Time"
|
|
||||||
c2TimeSeconds = "% C2 Time"
|
|
||||||
c3TimeSeconds = "% C3 Time"
|
|
||||||
c1TransitionsTotal = "C1 Transitions/sec"
|
|
||||||
c2TransitionsTotal = "C2 Transitions/sec"
|
|
||||||
c3TransitionsTotal = "C3 Transitions/sec"
|
|
||||||
clockInterruptsTotal = "Clock Interrupts/sec"
|
|
||||||
dpcQueuedPerSecond = "DPCs Queued/sec"
|
|
||||||
dpcTimeSeconds = "% DPC Time"
|
|
||||||
idleBreakEventsTotal = "Idle Break Events/sec"
|
|
||||||
idleTimeSeconds = "% Idle Time"
|
|
||||||
interruptsTotal = "Interrupts/sec"
|
|
||||||
interruptTimeSeconds = "% Interrupt Time"
|
|
||||||
parkingStatus = "Parking Status"
|
|
||||||
performanceLimitPercent = "% Performance Limit"
|
|
||||||
priorityTimeSeconds = "% Priority Time"
|
|
||||||
privilegedTimeSeconds = "% Privileged Time"
|
|
||||||
privilegedUtilitySeconds = "% Privileged Utility"
|
|
||||||
processorFrequencyMHz = "Processor Frequency"
|
|
||||||
processorPerformance = "% Processor Performance"
|
|
||||||
processorTimeSeconds = "% Processor Time"
|
|
||||||
processorUtilityRate = "% Processor Utility"
|
|
||||||
userTimeSeconds = "% User Time"
|
|
||||||
)
|
|
||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -38,7 +38,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
|
||||||
@@ -92,31 +93,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
|
|
||||||
c.mu = sync.Mutex{}
|
c.mu = sync.Mutex{}
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Processor Information", pdh.InstancesAll)
|
||||||
c1TimeSeconds,
|
|
||||||
c2TimeSeconds,
|
|
||||||
c3TimeSeconds,
|
|
||||||
c1TransitionsTotal,
|
|
||||||
c2TransitionsTotal,
|
|
||||||
c3TransitionsTotal,
|
|
||||||
clockInterruptsTotal,
|
|
||||||
dpcQueuedPerSecond,
|
|
||||||
dpcTimeSeconds,
|
|
||||||
idleBreakEventsTotal,
|
|
||||||
idleTimeSeconds,
|
|
||||||
interruptsTotal,
|
|
||||||
interruptTimeSeconds,
|
|
||||||
parkingStatus,
|
|
||||||
performanceLimitPercent,
|
|
||||||
priorityTimeSeconds,
|
|
||||||
privilegedTimeSeconds,
|
|
||||||
privilegedUtilitySeconds,
|
|
||||||
processorFrequencyMHz,
|
|
||||||
processorPerformance,
|
|
||||||
processorTimeSeconds,
|
|
||||||
processorUtilityRate,
|
|
||||||
userTimeSeconds,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Processor Information collector: %w", err)
|
return fmt.Errorf("failed to create Processor Information collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -216,14 +193,15 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
c.mu.Lock() // Lock is needed to prevent concurrent map access to c.processorRTCValues
|
c.mu.Lock() // Lock is needed to prevent concurrent map access to c.processorRTCValues
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
|
||||||
data, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Processor Information metrics: %w", err)
|
return fmt.Errorf("failed to collect Processor Information metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreCount float64
|
var coreCount float64
|
||||||
|
|
||||||
for core, coreData := range data {
|
for _, coreData := range c.perfDataObject {
|
||||||
|
core := coreData.Name
|
||||||
coreCount++
|
coreCount++
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -233,17 +211,17 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if counterProcessorRTCValues, ok = c.processorRTCValues[core]; ok {
|
if counterProcessorRTCValues, ok = c.processorRTCValues[core]; ok {
|
||||||
counterProcessorRTCValues.AddValue(uint32(coreData[processorUtilityRate].SecondValue))
|
counterProcessorRTCValues.AddValue(uint32(coreData.ProcessorUtilityRateSecondValue))
|
||||||
} else {
|
} else {
|
||||||
counterProcessorRTCValues = utils.NewCounter(uint32(coreData[privilegedUtilitySeconds].SecondValue))
|
counterProcessorRTCValues = utils.NewCounter(uint32(coreData.ProcessorUtilityRateSecondValue))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.processorRTCValues[core] = counterProcessorRTCValues
|
c.processorRTCValues[core] = counterProcessorRTCValues
|
||||||
|
|
||||||
if counterProcessorMPerfValues, ok = c.processorMPerfValues[core]; ok {
|
if counterProcessorMPerfValues, ok = c.processorMPerfValues[core]; ok {
|
||||||
counterProcessorMPerfValues.AddValue(uint32(coreData[processorPerformance].SecondValue))
|
counterProcessorMPerfValues.AddValue(uint32(coreData.ProcessorPerformanceSecondValue))
|
||||||
} else {
|
} else {
|
||||||
counterProcessorMPerfValues = utils.NewCounter(uint32(coreData[processorPerformance].SecondValue))
|
counterProcessorMPerfValues = utils.NewCounter(uint32(coreData.ProcessorPerformanceSecondValue))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.processorMPerfValues[core] = counterProcessorMPerfValues
|
c.processorMPerfValues[core] = counterProcessorMPerfValues
|
||||||
@@ -251,95 +229,95 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[c1TimeSeconds].FirstValue,
|
coreData.C1TimeSeconds,
|
||||||
core, "c1",
|
core, "c1",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[c2TimeSeconds].FirstValue,
|
coreData.C2TimeSeconds,
|
||||||
core, "c2",
|
core, "c2",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[c3TimeSeconds].FirstValue,
|
coreData.C3TimeSeconds,
|
||||||
core, "c3",
|
core, "c3",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[idleTimeSeconds].FirstValue,
|
coreData.IdleTimeSeconds,
|
||||||
core, "idle",
|
core, "idle",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[interruptTimeSeconds].FirstValue,
|
coreData.InterruptTimeSeconds,
|
||||||
core, "interrupt",
|
core, "interrupt",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[dpcTimeSeconds].FirstValue,
|
coreData.DpcTimeSeconds,
|
||||||
core, "dpc",
|
core, "dpc",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[privilegedTimeSeconds].FirstValue,
|
coreData.PrivilegedTimeSeconds,
|
||||||
core, "privileged",
|
core, "privileged",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[userTimeSeconds].FirstValue,
|
coreData.UserTimeSeconds,
|
||||||
core, "user",
|
core, "user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.interruptsTotal,
|
c.interruptsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[interruptsTotal].FirstValue,
|
coreData.InterruptsTotal,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dpcsTotal,
|
c.dpcsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[dpcQueuedPerSecond].FirstValue,
|
coreData.DpcQueuedPerSecond,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.clockInterruptsTotal,
|
c.clockInterruptsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[clockInterruptsTotal].FirstValue,
|
coreData.ClockInterruptsTotal,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.idleBreakEventsTotal,
|
c.idleBreakEventsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[idleBreakEventsTotal].FirstValue,
|
coreData.IdleBreakEventsTotal,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.parkingStatus,
|
c.parkingStatus,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
coreData[parkingStatus].FirstValue,
|
coreData.ParkingStatus,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorFrequencyMHz,
|
c.processorFrequencyMHz,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
coreData[processorFrequencyMHz].FirstValue,
|
coreData.ProcessorFrequencyMHz,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPerformance,
|
c.processorPerformance,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[processorPerformance].FirstValue,
|
coreData.ProcessorPerformance,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -357,13 +335,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorUtility,
|
c.processorUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[processorUtilityRate].FirstValue,
|
coreData.ProcessorUtilityRate,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPrivilegedUtility,
|
c.processorPrivilegedUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[privilegedUtilitySeconds].FirstValue,
|
coreData.PrivilegedUtilitySeconds,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
47
internal/collector/cpu/types.go
Normal file
47
internal/collector/cpu/types.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// Processor performance counters.
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
C1TimeSeconds float64 `perfdata:"% C1 Time"`
|
||||||
|
C2TimeSeconds float64 `perfdata:"% C2 Time"`
|
||||||
|
C3TimeSeconds float64 `perfdata:"% C3 Time"`
|
||||||
|
C1TransitionsTotal float64 `perfdata:"C1 Transitions/sec"`
|
||||||
|
C2TransitionsTotal float64 `perfdata:"C2 Transitions/sec"`
|
||||||
|
C3TransitionsTotal float64 `perfdata:"C3 Transitions/sec"`
|
||||||
|
ClockInterruptsTotal float64 `perfdata:"Clock Interrupts/sec"`
|
||||||
|
DpcQueuedPerSecond float64 `perfdata:"DPCs Queued/sec"`
|
||||||
|
DpcTimeSeconds float64 `perfdata:"% DPC Time"`
|
||||||
|
IdleBreakEventsTotal float64 `perfdata:"Idle Break Events/sec"`
|
||||||
|
IdleTimeSeconds float64 `perfdata:"% Idle Time"`
|
||||||
|
InterruptsTotal float64 `perfdata:"Interrupts/sec"`
|
||||||
|
InterruptTimeSeconds float64 `perfdata:"% Interrupt Time"`
|
||||||
|
ParkingStatus float64 `perfdata:"Parking Status"`
|
||||||
|
PerformanceLimitPercent float64 `perfdata:"% Performance Limit"`
|
||||||
|
PriorityTimeSeconds float64 `perfdata:"% Priority Time"`
|
||||||
|
PrivilegedTimeSeconds float64 `perfdata:"% Privileged Time"`
|
||||||
|
PrivilegedUtilitySeconds float64 `perfdata:"% Privileged Utility"`
|
||||||
|
ProcessorFrequencyMHz float64 `perfdata:"Processor Frequency"`
|
||||||
|
ProcessorPerformance float64 `perfdata:"% Processor Performance"`
|
||||||
|
ProcessorPerformanceSecondValue float64 `perfdata:"% Processor Performance,secondvalue"`
|
||||||
|
ProcessorTimeSeconds float64 `perfdata:"% Processor Time"`
|
||||||
|
ProcessorUtilityRate float64 `perfdata:"% Processor Utility"`
|
||||||
|
ProcessorUtilityRateSecondValue float64 `perfdata:"% Processor Utility,secondvalue"`
|
||||||
|
UserTimeSeconds float64 `perfdata:"% User Time"`
|
||||||
|
}
|
||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, cs.Name, cs.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, cs.Name, cs.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, cs.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package dfsr
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Connection Perflib: "DFS Replication Service Connections".
|
|
||||||
bytesReceivedTotal = "Total Bytes Received"
|
|
||||||
|
|
||||||
// Folder Perflib: "DFS Replicated Folder".
|
|
||||||
bandwidthSavingsUsingDFSReplicationTotal = "Bandwidth Savings Using DFS Replication"
|
|
||||||
compressedSizeOfFilesReceivedTotal = "Compressed Size of Files Received"
|
|
||||||
conflictBytesCleanedUpTotal = "Conflict Bytes Cleaned Up"
|
|
||||||
conflictBytesGeneratedTotal = "Conflict Bytes Generated"
|
|
||||||
conflictFilesCleanedUpTotal = "Conflict Files Cleaned Up"
|
|
||||||
conflictFilesGeneratedTotal = "Conflict Files Generated"
|
|
||||||
conflictFolderCleanupsCompletedTotal = "Conflict folder Cleanups Completed"
|
|
||||||
conflictSpaceInUse = "Conflict Space In Use"
|
|
||||||
deletedSpaceInUse = "Deleted Space In Use"
|
|
||||||
deletedBytesCleanedUpTotal = "Deleted Bytes Cleaned Up"
|
|
||||||
deletedBytesGeneratedTotal = "Deleted Bytes Generated"
|
|
||||||
deletedFilesCleanedUpTotal = "Deleted Files Cleaned Up"
|
|
||||||
deletedFilesGeneratedTotal = "Deleted Files Generated"
|
|
||||||
fileInstallsRetriedTotal = "File Installs Retried"
|
|
||||||
fileInstallsSucceededTotal = "File Installs Succeeded"
|
|
||||||
filesReceivedTotal = "Total Files Received"
|
|
||||||
rdcBytesReceivedTotal = "RDC Bytes Received"
|
|
||||||
rdcCompressedSizeOfFilesReceivedTotal = "RDC Compressed Size of Files Received"
|
|
||||||
rdcNumberOfFilesReceivedTotal = "RDC Number of Files Received"
|
|
||||||
rdcSizeOfFilesReceivedTotal = "RDC Size of Files Received"
|
|
||||||
sizeOfFilesReceivedTotal = "Size of Files Received"
|
|
||||||
stagingSpaceInUse = "Staging Space In Use"
|
|
||||||
stagingBytesCleanedUpTotal = "Staging Bytes Cleaned Up"
|
|
||||||
stagingBytesGeneratedTotal = "Staging Bytes Generated"
|
|
||||||
stagingFilesCleanedUpTotal = "Staging Files Cleaned Up"
|
|
||||||
stagingFilesGeneratedTotal = "Staging Files Generated"
|
|
||||||
updatesDroppedTotal = "Updates Dropped"
|
|
||||||
|
|
||||||
// Volume Perflib: "DFS Replication Service Volumes".
|
|
||||||
databaseCommitsTotal = "Database Commits"
|
|
||||||
databaseLookupsTotal = "Database Lookups"
|
|
||||||
usnJournalRecordsReadTotal = "USN Journal Records Read"
|
|
||||||
usnJournalRecordsAcceptedTotal = "USN Journal Records Accepted"
|
|
||||||
usnJournalUnreadPercentage = "USN Journal Unread Percentage"
|
|
||||||
)
|
|
||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -44,9 +44,12 @@ var ConfigDefaults = Config{
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollectorConnection *perfdata.Collector
|
perfDataCollectorConnection *pdh.Collector
|
||||||
perfDataCollectorFolder *perfdata.Collector
|
perfDataCollectorFolder *pdh.Collector
|
||||||
perfDataCollectorVolume *perfdata.Collector
|
perfDataCollectorVolume *pdh.Collector
|
||||||
|
perfDataObjectConnection []perfDataCounterValuesConnection
|
||||||
|
perfDataObjectFolder []perfDataCounterValuesFolder
|
||||||
|
perfDataObjectVolume []perfDataCounterValuesVolume
|
||||||
|
|
||||||
// connection source
|
// connection source
|
||||||
connectionBandwidthSavingsUsingDFSReplicationTotal *prometheus.Desc
|
connectionBandwidthSavingsUsingDFSReplicationTotal *prometheus.Desc
|
||||||
@@ -160,69 +163,26 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if slices.Contains(c.config.CollectorsEnabled, "connection") {
|
if slices.Contains(c.config.CollectorsEnabled, "connection") {
|
||||||
c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstancesAll, []string{
|
c.perfDataCollectorConnection, err = pdh.NewCollector[perfDataCounterValuesConnection](pdh.CounterTypeRaw, "DFS Replication Connections", pdh.InstancesAll)
|
||||||
bandwidthSavingsUsingDFSReplicationTotal,
|
|
||||||
bytesReceivedTotal,
|
|
||||||
compressedSizeOfFilesReceivedTotal,
|
|
||||||
filesReceivedTotal,
|
|
||||||
rdcBytesReceivedTotal,
|
|
||||||
rdcCompressedSizeOfFilesReceivedTotal,
|
|
||||||
rdcNumberOfFilesReceivedTotal,
|
|
||||||
rdcSizeOfFilesReceivedTotal,
|
|
||||||
sizeOfFilesReceivedTotal,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DFS Replication Connections collector: %w", err)
|
return fmt.Errorf("failed to create DFS Replication Connections collector: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if slices.Contains(c.config.CollectorsEnabled, "folder") {
|
if slices.Contains(c.config.CollectorsEnabled, "folder") {
|
||||||
c.perfDataCollectorFolder, err = perfdata.NewCollector("DFS Replicated Folders", perfdata.InstancesAll, []string{
|
c.perfDataCollectorFolder, err = pdh.NewCollector[perfDataCounterValuesFolder](pdh.CounterTypeRaw, "DFS Replicated Folders", pdh.InstancesAll)
|
||||||
bandwidthSavingsUsingDFSReplicationTotal,
|
|
||||||
compressedSizeOfFilesReceivedTotal,
|
|
||||||
conflictBytesCleanedUpTotal,
|
|
||||||
conflictBytesGeneratedTotal,
|
|
||||||
conflictFilesCleanedUpTotal,
|
|
||||||
conflictFilesGeneratedTotal,
|
|
||||||
conflictFolderCleanupsCompletedTotal,
|
|
||||||
conflictSpaceInUse,
|
|
||||||
deletedSpaceInUse,
|
|
||||||
deletedBytesCleanedUpTotal,
|
|
||||||
deletedBytesGeneratedTotal,
|
|
||||||
deletedFilesCleanedUpTotal,
|
|
||||||
deletedFilesGeneratedTotal,
|
|
||||||
fileInstallsRetriedTotal,
|
|
||||||
fileInstallsSucceededTotal,
|
|
||||||
filesReceivedTotal,
|
|
||||||
rdcBytesReceivedTotal,
|
|
||||||
rdcCompressedSizeOfFilesReceivedTotal,
|
|
||||||
rdcNumberOfFilesReceivedTotal,
|
|
||||||
rdcSizeOfFilesReceivedTotal,
|
|
||||||
sizeOfFilesReceivedTotal,
|
|
||||||
stagingSpaceInUse,
|
|
||||||
stagingBytesCleanedUpTotal,
|
|
||||||
stagingBytesGeneratedTotal,
|
|
||||||
stagingFilesCleanedUpTotal,
|
|
||||||
stagingFilesGeneratedTotal,
|
|
||||||
updatesDroppedTotal,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DFS Replicated Folders collector: %w", err)
|
return fmt.Errorf("failed to create DFS Replicated Folders collector: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if slices.Contains(c.config.CollectorsEnabled, "volume") {
|
if slices.Contains(c.config.CollectorsEnabled, "volume") {
|
||||||
c.perfDataCollectorVolume, err = perfdata.NewCollector("DFS Replication Service Volumes", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVolume, err = pdh.NewCollector[perfDataCounterValuesVolume](pdh.CounterTypeRaw, "DFS Replication Service Volumes", pdh.InstancesAll)
|
||||||
databaseCommitsTotal,
|
|
||||||
databaseLookupsTotal,
|
|
||||||
usnJournalRecordsReadTotal,
|
|
||||||
usnJournalRecordsAcceptedTotal,
|
|
||||||
usnJournalUnreadPercentage,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DFS Replication Service Volumes collector: %w", err)
|
return fmt.Errorf("failed to create DFS Replication Service Volumes collector: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection
|
// connection
|
||||||
c.connectionBandwidthSavingsUsingDFSReplicationTotal = prometheus.NewDesc(
|
c.connectionBandwidthSavingsUsingDFSReplicationTotal = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "connection_bandwidth_savings_using_dfs_replication_bytes_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "connection_bandwidth_savings_using_dfs_replication_bytes_total"),
|
||||||
@@ -537,76 +497,74 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectPDHConnection(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectPDHConnection(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorConnection.Collect()
|
err := c.perfDataCollectorConnection.Collect(&c.perfDataObjectConnection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DFS Replication Connections metrics: %w", err)
|
return fmt.Errorf("failed to collect DFS Replication Connections metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, connection := range c.perfDataObjectConnection {
|
||||||
return fmt.Errorf("failed to collect DFS Replication Connections metrics: %w", types.ErrNoData)
|
name := connection.Name
|
||||||
}
|
|
||||||
|
|
||||||
for name, connection := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionBandwidthSavingsUsingDFSReplicationTotal,
|
c.connectionBandwidthSavingsUsingDFSReplicationTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[bandwidthSavingsUsingDFSReplicationTotal].FirstValue,
|
connection.BandwidthSavingsUsingDFSReplicationTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionBytesReceivedTotal,
|
c.connectionBytesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[bytesReceivedTotal].FirstValue,
|
connection.BytesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionCompressedSizeOfFilesReceivedTotal,
|
c.connectionCompressedSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[compressedSizeOfFilesReceivedTotal].FirstValue,
|
connection.CompressedSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionFilesReceivedTotal,
|
c.connectionFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[filesReceivedTotal].FirstValue,
|
connection.FilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionRDCBytesReceivedTotal,
|
c.connectionRDCBytesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[rdcBytesReceivedTotal].FirstValue,
|
connection.RdcBytesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionRDCCompressedSizeOfFilesReceivedTotal,
|
c.connectionRDCCompressedSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[rdcCompressedSizeOfFilesReceivedTotal].FirstValue,
|
connection.RdcCompressedSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionRDCSizeOfFilesReceivedTotal,
|
c.connectionRDCSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[rdcSizeOfFilesReceivedTotal].FirstValue,
|
connection.RdcSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionRDCNumberOfFilesReceivedTotal,
|
c.connectionRDCNumberOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[rdcNumberOfFilesReceivedTotal].FirstValue,
|
connection.RdcNumberOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionSizeOfFilesReceivedTotal,
|
c.connectionSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
connection[sizeOfFilesReceivedTotal].FirstValue,
|
connection.SizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -615,202 +573,200 @@ func (c *Collector) collectPDHConnection(ch chan<- prometheus.Metric) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectPDHFolder(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectPDHFolder(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorFolder.Collect()
|
err := c.perfDataCollectorFolder.Collect(&c.perfDataObjectFolder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DFS Replicated Folders metrics: %w", err)
|
return fmt.Errorf("failed to collect DFS Replicated Folders metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, folder := range c.perfDataObjectFolder {
|
||||||
return fmt.Errorf("failed to collect DFS Replicated Folders metrics: %w", types.ErrNoData)
|
name := folder.Name
|
||||||
}
|
|
||||||
|
|
||||||
for name, folder := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderBandwidthSavingsUsingDFSReplicationTotal,
|
c.folderBandwidthSavingsUsingDFSReplicationTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[bandwidthSavingsUsingDFSReplicationTotal].FirstValue,
|
folder.BandwidthSavingsUsingDFSReplicationTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderCompressedSizeOfFilesReceivedTotal,
|
c.folderCompressedSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[compressedSizeOfFilesReceivedTotal].FirstValue,
|
folder.CompressedSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictBytesCleanedUpTotal,
|
c.folderConflictBytesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[conflictBytesCleanedUpTotal].FirstValue,
|
folder.ConflictBytesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictBytesGeneratedTotal,
|
c.folderConflictBytesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[conflictBytesGeneratedTotal].FirstValue,
|
folder.ConflictBytesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictFilesCleanedUpTotal,
|
c.folderConflictFilesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[conflictFilesCleanedUpTotal].FirstValue,
|
folder.ConflictFilesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictFilesGeneratedTotal,
|
c.folderConflictFilesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[conflictFilesGeneratedTotal].FirstValue,
|
folder.ConflictFilesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictFolderCleanupsCompletedTotal,
|
c.folderConflictFolderCleanupsCompletedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[conflictFolderCleanupsCompletedTotal].FirstValue,
|
folder.ConflictFolderCleanupsCompletedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderConflictSpaceInUse,
|
c.folderConflictSpaceInUse,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
folder[conflictSpaceInUse].FirstValue,
|
folder.ConflictSpaceInUse,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderDeletedSpaceInUse,
|
c.folderDeletedSpaceInUse,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
folder[deletedSpaceInUse].FirstValue,
|
folder.DeletedSpaceInUse,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderDeletedBytesCleanedUpTotal,
|
c.folderDeletedBytesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[deletedBytesCleanedUpTotal].FirstValue,
|
folder.DeletedBytesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderDeletedBytesGeneratedTotal,
|
c.folderDeletedBytesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[deletedBytesGeneratedTotal].FirstValue,
|
folder.DeletedBytesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderDeletedFilesCleanedUpTotal,
|
c.folderDeletedFilesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[deletedFilesCleanedUpTotal].FirstValue,
|
folder.DeletedFilesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderDeletedFilesGeneratedTotal,
|
c.folderDeletedFilesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[deletedFilesGeneratedTotal].FirstValue,
|
folder.DeletedFilesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderFileInstallsRetriedTotal,
|
c.folderFileInstallsRetriedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[fileInstallsRetriedTotal].FirstValue,
|
folder.FileInstallsRetriedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderFileInstallsSucceededTotal,
|
c.folderFileInstallsSucceededTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[fileInstallsSucceededTotal].FirstValue,
|
folder.FileInstallsSucceededTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderFilesReceivedTotal,
|
c.folderFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[filesReceivedTotal].FirstValue,
|
folder.FilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderRDCBytesReceivedTotal,
|
c.folderRDCBytesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[rdcBytesReceivedTotal].FirstValue,
|
folder.RdcBytesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderRDCCompressedSizeOfFilesReceivedTotal,
|
c.folderRDCCompressedSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[rdcCompressedSizeOfFilesReceivedTotal].FirstValue,
|
folder.RdcCompressedSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderRDCNumberOfFilesReceivedTotal,
|
c.folderRDCNumberOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[rdcNumberOfFilesReceivedTotal].FirstValue,
|
folder.RdcNumberOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderRDCSizeOfFilesReceivedTotal,
|
c.folderRDCSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[rdcSizeOfFilesReceivedTotal].FirstValue,
|
folder.RdcSizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderSizeOfFilesReceivedTotal,
|
c.folderSizeOfFilesReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[sizeOfFilesReceivedTotal].FirstValue,
|
folder.SizeOfFilesReceivedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderStagingSpaceInUse,
|
c.folderStagingSpaceInUse,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
folder[stagingSpaceInUse].FirstValue,
|
folder.StagingSpaceInUse,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderStagingBytesCleanedUpTotal,
|
c.folderStagingBytesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[stagingBytesCleanedUpTotal].FirstValue,
|
folder.StagingBytesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderStagingBytesGeneratedTotal,
|
c.folderStagingBytesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[stagingBytesGeneratedTotal].FirstValue,
|
folder.StagingBytesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderStagingFilesCleanedUpTotal,
|
c.folderStagingFilesCleanedUpTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[stagingFilesCleanedUpTotal].FirstValue,
|
folder.StagingFilesCleanedUpTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderStagingFilesGeneratedTotal,
|
c.folderStagingFilesGeneratedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[stagingFilesGeneratedTotal].FirstValue,
|
folder.StagingFilesGeneratedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.folderUpdatesDroppedTotal,
|
c.folderUpdatesDroppedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
folder[updatesDroppedTotal].FirstValue,
|
folder.UpdatesDroppedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -819,48 +775,45 @@ func (c *Collector) collectPDHFolder(ch chan<- prometheus.Metric) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectPDHVolume(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectPDHVolume(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorVolume.Collect()
|
err := c.perfDataCollectorVolume.Collect(&c.perfDataObjectVolume)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DFS Replication Volumes metrics: %w", err)
|
return fmt.Errorf("failed to collect DFS Replication Volumes metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, volume := range c.perfDataObjectVolume {
|
||||||
return fmt.Errorf("failed to collect DFS Replication Volumes metrics: %w", types.ErrNoData)
|
name := volume.Name
|
||||||
}
|
|
||||||
|
|
||||||
for name, volume := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.volumeDatabaseLookupsTotal,
|
c.volumeDatabaseLookupsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[databaseLookupsTotal].FirstValue,
|
volume.DatabaseLookupsTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.volumeDatabaseCommitsTotal,
|
c.volumeDatabaseCommitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[databaseCommitsTotal].FirstValue,
|
volume.DatabaseCommitsTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.volumeUSNJournalRecordsAcceptedTotal,
|
c.volumeUSNJournalRecordsAcceptedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[usnJournalRecordsAcceptedTotal].FirstValue,
|
volume.UsnJournalRecordsAcceptedTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.volumeUSNJournalRecordsReadTotal,
|
c.volumeUSNJournalRecordsReadTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[usnJournalRecordsReadTotal].FirstValue,
|
volume.UsnJournalRecordsReadTotal,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.volumeUSNJournalUnreadPercentage,
|
c.volumeUSNJournalUnreadPercentage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[usnJournalUnreadPercentage].FirstValue,
|
volume.UsnJournalUnreadPercentage,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, dfsr.Name, dfsr.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, dfsr.Name, dfsr.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, dfsr.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
75
internal/collector/dfsr/types.go
Normal file
75
internal/collector/dfsr/types.go
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package dfsr
|
||||||
|
|
||||||
|
// Connection Perflib: "DFS Replication Service Connections".
|
||||||
|
type perfDataCounterValuesConnection struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
BandwidthSavingsUsingDFSReplicationTotal float64 `perfdata:"Bandwidth Savings Using DFS Replication"`
|
||||||
|
BytesReceivedTotal float64 `perfdata:"Total Bytes Received"`
|
||||||
|
CompressedSizeOfFilesReceivedTotal float64 `perfdata:"Compressed Size of Files Received"`
|
||||||
|
FilesReceivedTotal float64 `perfdata:"Total Files Received"`
|
||||||
|
RdcBytesReceivedTotal float64 `perfdata:"RDC Bytes Received"`
|
||||||
|
RdcCompressedSizeOfFilesReceivedTotal float64 `perfdata:"RDC Compressed Size of Files Received"`
|
||||||
|
RdcNumberOfFilesReceivedTotal float64 `perfdata:"RDC Number of Files Received"`
|
||||||
|
RdcSizeOfFilesReceivedTotal float64 `perfdata:"RDC Size of Files Received"`
|
||||||
|
SizeOfFilesReceivedTotal float64 `perfdata:"Size of Files Received"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Folder Perflib: "DFS Replicated Folder".
|
||||||
|
type perfDataCounterValuesFolder struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
BandwidthSavingsUsingDFSReplicationTotal float64 `perfdata:"Bandwidth Savings Using DFS Replication"`
|
||||||
|
CompressedSizeOfFilesReceivedTotal float64 `perfdata:"Compressed Size of Files Received"`
|
||||||
|
ConflictBytesCleanedUpTotal float64 `perfdata:"Conflict Bytes Cleaned Up"`
|
||||||
|
ConflictBytesGeneratedTotal float64 `perfdata:"Conflict Bytes Generated"`
|
||||||
|
ConflictFilesCleanedUpTotal float64 `perfdata:"Conflict Files Cleaned Up"`
|
||||||
|
ConflictFilesGeneratedTotal float64 `perfdata:"Conflict Files Generated"`
|
||||||
|
ConflictFolderCleanupsCompletedTotal float64 `perfdata:"Conflict folder Cleanups Completed"`
|
||||||
|
ConflictSpaceInUse float64 `perfdata:"Conflict Space In Use"`
|
||||||
|
DeletedSpaceInUse float64 `perfdata:"Deleted Space In Use"`
|
||||||
|
DeletedBytesCleanedUpTotal float64 `perfdata:"Deleted Bytes Cleaned Up"`
|
||||||
|
DeletedBytesGeneratedTotal float64 `perfdata:"Deleted Bytes Generated"`
|
||||||
|
DeletedFilesCleanedUpTotal float64 `perfdata:"Deleted Files Cleaned Up"`
|
||||||
|
DeletedFilesGeneratedTotal float64 `perfdata:"Deleted Files Generated"`
|
||||||
|
FileInstallsRetriedTotal float64 `perfdata:"File Installs Retried"`
|
||||||
|
FileInstallsSucceededTotal float64 `perfdata:"File Installs Succeeded"`
|
||||||
|
FilesReceivedTotal float64 `perfdata:"Total Files Received"`
|
||||||
|
RdcBytesReceivedTotal float64 `perfdata:"RDC Bytes Received"`
|
||||||
|
RdcCompressedSizeOfFilesReceivedTotal float64 `perfdata:"RDC Compressed Size of Files Received"`
|
||||||
|
RdcNumberOfFilesReceivedTotal float64 `perfdata:"RDC Number of Files Received"`
|
||||||
|
RdcSizeOfFilesReceivedTotal float64 `perfdata:"RDC Size of Files Received"`
|
||||||
|
SizeOfFilesReceivedTotal float64 `perfdata:"Size of Files Received"`
|
||||||
|
StagingSpaceInUse float64 `perfdata:"Staging Space In Use"`
|
||||||
|
StagingBytesCleanedUpTotal float64 `perfdata:"Staging Bytes Cleaned Up"`
|
||||||
|
StagingBytesGeneratedTotal float64 `perfdata:"Staging Bytes Generated"`
|
||||||
|
StagingFilesCleanedUpTotal float64 `perfdata:"Staging Files Cleaned Up"`
|
||||||
|
StagingFilesGeneratedTotal float64 `perfdata:"Staging Files Generated"`
|
||||||
|
UpdatesDroppedTotal float64 `perfdata:"Updates Dropped"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Volume Perflib: "DFS Replication Service Volumes".
|
||||||
|
type perfDataCounterValuesVolume struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
DatabaseCommitsTotal float64 `perfdata:"Database Commits"`
|
||||||
|
DatabaseLookupsTotal float64 `perfdata:"Database Lookups"`
|
||||||
|
UsnJournalRecordsReadTotal float64 `perfdata:"USN Journal Records Read"`
|
||||||
|
UsnJournalRecordsAcceptedTotal float64 `perfdata:"USN Journal Records Accepted"`
|
||||||
|
UsnJournalUnreadPercentage float64 `perfdata:"USN Journal Unread Percentage"`
|
||||||
|
}
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package dhcp
|
|
||||||
|
|
||||||
const (
|
|
||||||
acksTotal = "Acks/sec"
|
|
||||||
activeQueueLength = "Active Queue Length"
|
|
||||||
conflictCheckQueueLength = "Conflict Check Queue Length"
|
|
||||||
declinesTotal = "Declines/sec"
|
|
||||||
deniedDueToMatch = "Denied due to match."
|
|
||||||
deniedDueToNonMatch = "Denied due to match."
|
|
||||||
discoversTotal = "Discovers/sec"
|
|
||||||
duplicatesDroppedTotal = "Duplicates Dropped/sec"
|
|
||||||
failoverBndAckReceivedTotal = "Failover: BndAck received/sec."
|
|
||||||
failoverBndAckSentTotal = "Failover: BndAck sent/sec."
|
|
||||||
failoverBndUpdDropped = "Failover: BndUpd Dropped."
|
|
||||||
failoverBndUpdPendingOutboundQueue = "Failover: BndUpd pending in outbound queue."
|
|
||||||
failoverBndUpdReceivedTotal = "Failover: BndUpd received/sec."
|
|
||||||
failoverBndUpdSentTotal = "Failover: BndUpd sent/sec."
|
|
||||||
failoverTransitionsCommunicationInterruptedState = "Failover: Transitions to COMMUNICATION-INTERRUPTED state."
|
|
||||||
failoverTransitionsPartnerDownState = "Failover: Transitions to PARTNER-DOWN state."
|
|
||||||
failoverTransitionsRecoverState = "Failover: Transitions to RECOVER state."
|
|
||||||
informsTotal = "Informs/sec"
|
|
||||||
nacksTotal = "Nacks/sec"
|
|
||||||
offerQueueLength = "Offer Queue Length"
|
|
||||||
offersTotal = "Offers/sec"
|
|
||||||
packetsExpiredTotal = "Packets Expired/sec"
|
|
||||||
packetsReceivedTotal = "Packets Received/sec"
|
|
||||||
releasesTotal = "Releases/sec"
|
|
||||||
requestsTotal = "Requests/sec"
|
|
||||||
)
|
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
acksTotal *prometheus.Desc
|
acksTotal *prometheus.Desc
|
||||||
activeQueueLength *prometheus.Desc
|
activeQueueLength *prometheus.Desc
|
||||||
@@ -95,33 +96,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("DHCP Server", nil, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DHCP Server", nil)
|
||||||
acksTotal,
|
|
||||||
activeQueueLength,
|
|
||||||
conflictCheckQueueLength,
|
|
||||||
declinesTotal,
|
|
||||||
deniedDueToMatch,
|
|
||||||
deniedDueToNonMatch,
|
|
||||||
discoversTotal,
|
|
||||||
duplicatesDroppedTotal,
|
|
||||||
failoverBndAckReceivedTotal,
|
|
||||||
failoverBndAckSentTotal,
|
|
||||||
failoverBndUpdDropped,
|
|
||||||
failoverBndUpdPendingOutboundQueue,
|
|
||||||
failoverBndUpdReceivedTotal,
|
|
||||||
failoverBndUpdSentTotal,
|
|
||||||
failoverTransitionsCommunicationInterruptedState,
|
|
||||||
failoverTransitionsPartnerDownState,
|
|
||||||
failoverTransitionsRecoverState,
|
|
||||||
informsTotal,
|
|
||||||
nacksTotal,
|
|
||||||
offerQueueLength,
|
|
||||||
offersTotal,
|
|
||||||
packetsExpiredTotal,
|
|
||||||
packetsReceivedTotal,
|
|
||||||
releasesTotal,
|
|
||||||
requestsTotal,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
|
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -281,164 +256,159 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
|
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect DHCP Server metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsReceivedTotal,
|
c.packetsReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[packetsReceivedTotal].FirstValue,
|
c.perfDataObject[0].PacketsReceivedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.duplicatesDroppedTotal,
|
c.duplicatesDroppedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[duplicatesDroppedTotal].FirstValue,
|
c.perfDataObject[0].DuplicatesDroppedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.packetsExpiredTotal,
|
c.packetsExpiredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[packetsExpiredTotal].FirstValue,
|
c.perfDataObject[0].PacketsExpiredTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeQueueLength,
|
c.activeQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[activeQueueLength].FirstValue,
|
c.perfDataObject[0].ActiveQueueLength,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.conflictCheckQueueLength,
|
c.conflictCheckQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[conflictCheckQueueLength].FirstValue,
|
c.perfDataObject[0].ConflictCheckQueueLength,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.discoversTotal,
|
c.discoversTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[discoversTotal].FirstValue,
|
c.perfDataObject[0].DiscoversTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.offersTotal,
|
c.offersTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[offersTotal].FirstValue,
|
c.perfDataObject[0].OffersTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestsTotal,
|
c.requestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsTotal].FirstValue,
|
c.perfDataObject[0].RequestsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.informsTotal,
|
c.informsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[informsTotal].FirstValue,
|
c.perfDataObject[0].InformsTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.acksTotal,
|
c.acksTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[acksTotal].FirstValue,
|
c.perfDataObject[0].AcksTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.nACKsTotal,
|
c.nACKsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[nacksTotal].FirstValue,
|
c.perfDataObject[0].NacksTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.declinesTotal,
|
c.declinesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[declinesTotal].FirstValue,
|
c.perfDataObject[0].DeclinesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.releasesTotal,
|
c.releasesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[releasesTotal].FirstValue,
|
c.perfDataObject[0].ReleasesTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.offerQueueLength,
|
c.offerQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[offerQueueLength].FirstValue,
|
c.perfDataObject[0].OfferQueueLength,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.deniedDueToMatch,
|
c.deniedDueToMatch,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[deniedDueToMatch].FirstValue,
|
c.perfDataObject[0].DeniedDueToMatch,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.deniedDueToNonMatch,
|
c.deniedDueToNonMatch,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[deniedDueToNonMatch].FirstValue,
|
c.perfDataObject[0].DeniedDueToNonMatch,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndUpdSentTotal,
|
c.failoverBndUpdSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverBndUpdSentTotal].FirstValue,
|
c.perfDataObject[0].FailoverBndUpdSentTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndUpdReceivedTotal,
|
c.failoverBndUpdReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverBndUpdReceivedTotal].FirstValue,
|
c.perfDataObject[0].FailoverBndUpdReceivedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndAckSentTotal,
|
c.failoverBndAckSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverBndAckSentTotal].FirstValue,
|
c.perfDataObject[0].FailoverBndAckSentTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndAckReceivedTotal,
|
c.failoverBndAckReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverBndAckReceivedTotal].FirstValue,
|
c.perfDataObject[0].FailoverBndAckReceivedTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndUpdPendingOutboundQueue,
|
c.failoverBndUpdPendingOutboundQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[failoverBndUpdPendingOutboundQueue].FirstValue,
|
c.perfDataObject[0].FailoverBndUpdPendingOutboundQueue,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverTransitionsCommunicationInterruptedState,
|
c.failoverTransitionsCommunicationInterruptedState,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverTransitionsCommunicationInterruptedState].FirstValue,
|
c.perfDataObject[0].FailoverTransitionsCommunicationInterruptedState,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverTransitionsPartnerDownState,
|
c.failoverTransitionsPartnerDownState,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverTransitionsPartnerDownState].FirstValue,
|
c.perfDataObject[0].FailoverTransitionsPartnerDownState,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverTransitionsRecoverState,
|
c.failoverTransitionsRecoverState,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverTransitionsRecoverState].FirstValue,
|
c.perfDataObject[0].FailoverTransitionsRecoverState,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failoverBndUpdDropped,
|
c.failoverBndUpdDropped,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[failoverBndUpdDropped].FirstValue,
|
c.perfDataObject[0].FailoverBndUpdDropped,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, dhcp.Name, dhcp.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, dhcp.Name, dhcp.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, dhcp.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
44
internal/collector/dhcp/types.go
Normal file
44
internal/collector/dhcp/types.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package dhcp
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
AcksTotal float64 `perfdata:"Acks/sec"`
|
||||||
|
ActiveQueueLength float64 `perfdata:"Active Queue Length"`
|
||||||
|
ConflictCheckQueueLength float64 `perfdata:"Conflict Check Queue Length"`
|
||||||
|
DeclinesTotal float64 `perfdata:"Declines/sec"`
|
||||||
|
DeniedDueToMatch float64 `perfdata:"Denied due to match."`
|
||||||
|
DeniedDueToNonMatch float64 `perfdata:"Denied due to match."`
|
||||||
|
DiscoversTotal float64 `perfdata:"Discovers/sec"`
|
||||||
|
DuplicatesDroppedTotal float64 `perfdata:"Duplicates Dropped/sec"`
|
||||||
|
FailoverBndAckReceivedTotal float64 `perfdata:"Failover: BndAck received/sec."`
|
||||||
|
FailoverBndAckSentTotal float64 `perfdata:"Failover: BndAck sent/sec."`
|
||||||
|
FailoverBndUpdDropped float64 `perfdata:"Failover: BndUpd Dropped."`
|
||||||
|
FailoverBndUpdPendingOutboundQueue float64 `perfdata:"Failover: BndUpd pending in outbound queue."`
|
||||||
|
FailoverBndUpdReceivedTotal float64 `perfdata:"Failover: BndUpd received/sec."`
|
||||||
|
FailoverBndUpdSentTotal float64 `perfdata:"Failover: BndUpd sent/sec."`
|
||||||
|
FailoverTransitionsCommunicationInterruptedState float64 `perfdata:"Failover: Transitions to COMMUNICATION-INTERRUPTED state."`
|
||||||
|
FailoverTransitionsPartnerDownState float64 `perfdata:"Failover: Transitions to PARTNER-DOWN state."`
|
||||||
|
FailoverTransitionsRecoverState float64 `perfdata:"Failover: Transitions to RECOVER state."`
|
||||||
|
InformsTotal float64 `perfdata:"Informs/sec"`
|
||||||
|
NacksTotal float64 `perfdata:"Nacks/sec"`
|
||||||
|
OfferQueueLength float64 `perfdata:"Offer Queue Length"`
|
||||||
|
OffersTotal float64 `perfdata:"Offers/sec"`
|
||||||
|
PacketsExpiredTotal float64 `perfdata:"Packets Expired/sec"`
|
||||||
|
PacketsReceivedTotal float64 `perfdata:"Packets Received/sec"`
|
||||||
|
ReleasesTotal float64 `perfdata:"Releases/sec"`
|
||||||
|
RequestsTotal float64 `perfdata:"Requests/sec"`
|
||||||
|
}
|
||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, diskdrive.Name, diskdrive.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, diskdrive.Name, diskdrive.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, diskdrive.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package dns
|
|
||||||
|
|
||||||
const (
|
|
||||||
_ = "% User Time"
|
|
||||||
_ = "176"
|
|
||||||
_ = "Async Fast Reads/sec"
|
|
||||||
axfrRequestReceived = "AXFR Request Received"
|
|
||||||
axfrRequestSent = "AXFR Request Sent"
|
|
||||||
axfrResponseReceived = "AXFR Response Received"
|
|
||||||
axfrSuccessReceived = "AXFR Success Received"
|
|
||||||
axfrSuccessSent = "AXFR Success Sent"
|
|
||||||
cachingMemory = "Caching Memory"
|
|
||||||
_ = "Data Flush Pages/sec"
|
|
||||||
_ = "Data Flushes/sec"
|
|
||||||
databaseNodeMemory = "Database Node Memory"
|
|
||||||
dynamicUpdateNoOperation = "Dynamic Update NoOperation"
|
|
||||||
_ = "Dynamic Update NoOperation/sec"
|
|
||||||
dynamicUpdateQueued = "Dynamic Update Queued"
|
|
||||||
_ = "Dynamic Update Received"
|
|
||||||
_ = "Dynamic Update Received/sec"
|
|
||||||
dynamicUpdateRejected = "Dynamic Update Rejected"
|
|
||||||
dynamicUpdateTimeOuts = "Dynamic Update TimeOuts"
|
|
||||||
dynamicUpdateWrittenToDatabase = "Dynamic Update Written to Database"
|
|
||||||
_ = "Dynamic Update Written to Database/sec"
|
|
||||||
_ = "Enumerations Server/sec"
|
|
||||||
_ = "Fast Read Not Possibles/sec"
|
|
||||||
_ = "Fast Read Resource Misses/sec"
|
|
||||||
ixfrRequestReceived = "IXFR Request Received"
|
|
||||||
ixfrRequestSent = "IXFR Request Sent"
|
|
||||||
ixfrResponseReceived = "IXFR Response Received"
|
|
||||||
_ = "IXFR Success Received"
|
|
||||||
ixfrSuccessSent = "IXFR Success Sent"
|
|
||||||
ixfrTCPSuccessReceived = "IXFR TCP Success Received"
|
|
||||||
ixfrUDPSuccessReceived = "IXFR UDP Success Received"
|
|
||||||
_ = "Lazy Write Flushes/sec"
|
|
||||||
_ = "Lazy Write Pages/sec"
|
|
||||||
_ = "Level 2 TLB Fills/sec"
|
|
||||||
nbStatMemory = "Nbstat Memory"
|
|
||||||
notifyReceived = "Notify Received"
|
|
||||||
notifySent = "Notify Sent"
|
|
||||||
_ = "Query Dropped Bad Socket"
|
|
||||||
_ = "Query Dropped Bad Socket/sec"
|
|
||||||
_ = "Query Dropped By Policy"
|
|
||||||
_ = "Query Dropped By Policy/sec"
|
|
||||||
_ = "Query Dropped By Response Rate Limiting"
|
|
||||||
_ = "Query Dropped By Response Rate Limiting/sec"
|
|
||||||
_ = "Query Dropped Send"
|
|
||||||
_ = "Query Dropped Send/sec"
|
|
||||||
_ = "Query Dropped Total"
|
|
||||||
_ = "Query Dropped Total/sec"
|
|
||||||
recordFlowMemory = "Record Flow Memory"
|
|
||||||
recursiveQueries = "Recursive Queries"
|
|
||||||
_ = "Recursive Queries/sec"
|
|
||||||
recursiveQueryFailure = "Recursive Query Failure"
|
|
||||||
_ = "Recursive Query Failure/sec"
|
|
||||||
_ = "Recursive Send TimeOuts"
|
|
||||||
recursiveSendTimeOuts = "Recursive TimeOut/sec"
|
|
||||||
_ = "Responses Suppressed"
|
|
||||||
_ = "Responses Suppressed/sec"
|
|
||||||
secureUpdateFailure = "Secure Update Failure"
|
|
||||||
secureUpdateReceived = "Secure Update Received"
|
|
||||||
_ = "Secure Update Received/sec"
|
|
||||||
tcpMessageMemory = "TCP Message Memory"
|
|
||||||
tcpQueryReceived = "TCP Query Received"
|
|
||||||
_ = "TCP Query Received/sec"
|
|
||||||
tcpResponseSent = "TCP Response Sent"
|
|
||||||
_ = "TCP Response Sent/sec"
|
|
||||||
_ = "Total Query Received"
|
|
||||||
_ = "Total Query Received/sec"
|
|
||||||
_ = "Total Remote Inflight Queries"
|
|
||||||
_ = "Total Response Sent"
|
|
||||||
_ = "Total Response Sent/sec"
|
|
||||||
udpMessageMemory = "UDP Message Memory"
|
|
||||||
udpQueryReceived = "UDP Query Received"
|
|
||||||
_ = "UDP Query Received/sec"
|
|
||||||
udpResponseSent = "UDP Response Sent"
|
|
||||||
_ = "UDP Response Sent/sec"
|
|
||||||
unmatchedResponsesReceived = "Unmatched Responses Received"
|
|
||||||
_ = "Virtual Bytes"
|
|
||||||
winsLookupReceived = "WINS Lookup Received"
|
|
||||||
_ = "WINS Lookup Received/sec"
|
|
||||||
winsResponseSent = "WINS Response Sent"
|
|
||||||
_ = "WINS Response Sent/sec"
|
|
||||||
winsReverseLookupReceived = "WINS Reverse Lookup Received"
|
|
||||||
_ = "WINS Reverse Lookup Received/sec"
|
|
||||||
winsReverseResponseSent = "WINS Reverse Response Sent"
|
|
||||||
_ = "WINS Reverse Response Sent/sec"
|
|
||||||
zoneTransferFailure = "Zone Transfer Failure"
|
|
||||||
zoneTransferSOARequestSent = "Zone Transfer Request Received"
|
|
||||||
_ = "Zone Transfer SOA Request Sent"
|
|
||||||
_ = "Zone Transfer Success"
|
|
||||||
)
|
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -37,7 +37,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
dynamicUpdatesFailures *prometheus.Desc
|
dynamicUpdatesFailures *prometheus.Desc
|
||||||
dynamicUpdatesQueued *prometheus.Desc
|
dynamicUpdatesQueued *prometheus.Desc
|
||||||
@@ -92,48 +93,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "DNS", pdh.InstancesAll)
|
||||||
axfrRequestReceived,
|
|
||||||
axfrRequestSent,
|
|
||||||
axfrResponseReceived,
|
|
||||||
axfrSuccessReceived,
|
|
||||||
axfrSuccessSent,
|
|
||||||
cachingMemory,
|
|
||||||
databaseNodeMemory,
|
|
||||||
dynamicUpdateNoOperation,
|
|
||||||
dynamicUpdateQueued,
|
|
||||||
dynamicUpdateRejected,
|
|
||||||
dynamicUpdateTimeOuts,
|
|
||||||
dynamicUpdateWrittenToDatabase,
|
|
||||||
ixfrRequestReceived,
|
|
||||||
ixfrRequestSent,
|
|
||||||
ixfrResponseReceived,
|
|
||||||
ixfrSuccessSent,
|
|
||||||
ixfrTCPSuccessReceived,
|
|
||||||
ixfrUDPSuccessReceived,
|
|
||||||
nbStatMemory,
|
|
||||||
notifyReceived,
|
|
||||||
notifySent,
|
|
||||||
recordFlowMemory,
|
|
||||||
recursiveQueries,
|
|
||||||
recursiveQueryFailure,
|
|
||||||
recursiveSendTimeOuts,
|
|
||||||
secureUpdateFailure,
|
|
||||||
secureUpdateReceived,
|
|
||||||
tcpMessageMemory,
|
|
||||||
tcpQueryReceived,
|
|
||||||
tcpResponseSent,
|
|
||||||
udpMessageMemory,
|
|
||||||
udpQueryReceived,
|
|
||||||
udpResponseSent,
|
|
||||||
unmatchedResponsesReceived,
|
|
||||||
winsLookupReceived,
|
|
||||||
winsResponseSent,
|
|
||||||
winsReverseLookupReceived,
|
|
||||||
winsReverseResponseSent,
|
|
||||||
zoneTransferFailure,
|
|
||||||
zoneTransferSOARequestSent,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create DNS collector: %w", err)
|
return fmt.Errorf("failed to create DNS collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -277,79 +237,74 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
// Collect sends the metric values for each metric
|
// Collect sends the metric values for each metric
|
||||||
// to the provided prometheus Metric channel.
|
// to the provided prometheus Metric channel.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect DNS metrics: %w", err)
|
return fmt.Errorf("failed to collect DNS metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect DNS metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsReceived,
|
c.zoneTransferRequestsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[axfrRequestReceived].FirstValue,
|
c.perfDataObject[0].AxfrRequestReceived,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsReceived,
|
c.zoneTransferRequestsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrRequestReceived].FirstValue,
|
c.perfDataObject[0].IxfrRequestReceived,
|
||||||
"incremental",
|
"incremental",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsSent,
|
c.zoneTransferRequestsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[axfrRequestSent].FirstValue,
|
c.perfDataObject[0].AxfrRequestSent,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsSent,
|
c.zoneTransferRequestsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrRequestSent].FirstValue,
|
c.perfDataObject[0].IxfrRequestSent,
|
||||||
"incremental",
|
"incremental",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferRequestsSent,
|
c.zoneTransferRequestsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[zoneTransferSOARequestSent].FirstValue,
|
c.perfDataObject[0].ZoneTransferSOARequestSent,
|
||||||
"soa",
|
"soa",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferResponsesReceived,
|
c.zoneTransferResponsesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[axfrResponseReceived].FirstValue,
|
c.perfDataObject[0].AxfrResponseReceived,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferResponsesReceived,
|
c.zoneTransferResponsesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrResponseReceived].FirstValue,
|
c.perfDataObject[0].IxfrResponseReceived,
|
||||||
"incremental",
|
"incremental",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessReceived,
|
c.zoneTransferSuccessReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[axfrSuccessReceived].FirstValue,
|
c.perfDataObject[0].AxfrSuccessReceived,
|
||||||
"full",
|
"full",
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessReceived,
|
c.zoneTransferSuccessReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrTCPSuccessReceived].FirstValue,
|
c.perfDataObject[0].IxfrTCPSuccessReceived,
|
||||||
"incremental",
|
"incremental",
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessReceived,
|
c.zoneTransferSuccessReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrTCPSuccessReceived].FirstValue,
|
c.perfDataObject[0].IxfrTCPSuccessReceived,
|
||||||
"incremental",
|
"incremental",
|
||||||
"udp",
|
"udp",
|
||||||
)
|
)
|
||||||
@@ -357,183 +312,183 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessSent,
|
c.zoneTransferSuccessSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[axfrSuccessSent].FirstValue,
|
c.perfDataObject[0].AxfrSuccessSent,
|
||||||
"full",
|
"full",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferSuccessSent,
|
c.zoneTransferSuccessSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ixfrSuccessSent].FirstValue,
|
c.perfDataObject[0].IxfrSuccessSent,
|
||||||
"incremental",
|
"incremental",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.zoneTransferFailures,
|
c.zoneTransferFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[zoneTransferFailure].FirstValue,
|
c.perfDataObject[0].ZoneTransferFailure,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[cachingMemory].FirstValue,
|
c.perfDataObject[0].CachingMemory,
|
||||||
"caching",
|
"caching",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databaseNodeMemory].FirstValue,
|
c.perfDataObject[0].DatabaseNodeMemory,
|
||||||
"database_node",
|
"database_node",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[nbStatMemory].FirstValue,
|
c.perfDataObject[0].NbStatMemory,
|
||||||
"nbstat",
|
"nbstat",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[recordFlowMemory].FirstValue,
|
c.perfDataObject[0].RecordFlowMemory,
|
||||||
"record_flow",
|
"record_flow",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[tcpMessageMemory].FirstValue,
|
c.perfDataObject[0].TcpMessageMemory,
|
||||||
"tcp_message",
|
"tcp_message",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memoryUsedBytes,
|
c.memoryUsedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[udpMessageMemory].FirstValue,
|
c.perfDataObject[0].UdpMessageMemory,
|
||||||
"udp_message",
|
"udp_message",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesReceived,
|
c.dynamicUpdatesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dynamicUpdateNoOperation].FirstValue,
|
c.perfDataObject[0].DynamicUpdateNoOperation,
|
||||||
"noop",
|
"noop",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesReceived,
|
c.dynamicUpdatesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dynamicUpdateWrittenToDatabase].FirstValue,
|
c.perfDataObject[0].DynamicUpdateWrittenToDatabase,
|
||||||
"written",
|
"written",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesQueued,
|
c.dynamicUpdatesQueued,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dynamicUpdateQueued].FirstValue,
|
c.perfDataObject[0].DynamicUpdateQueued,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesFailures,
|
c.dynamicUpdatesFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dynamicUpdateRejected].FirstValue,
|
c.perfDataObject[0].DynamicUpdateRejected,
|
||||||
"rejected",
|
"rejected",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dynamicUpdatesFailures,
|
c.dynamicUpdatesFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dynamicUpdateTimeOuts].FirstValue,
|
c.perfDataObject[0].DynamicUpdateTimeOuts,
|
||||||
"timeout",
|
"timeout",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.notifyReceived,
|
c.notifyReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[notifyReceived].FirstValue,
|
c.perfDataObject[0].NotifyReceived,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.notifySent,
|
c.notifySent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[notifySent].FirstValue,
|
c.perfDataObject[0].NotifySent,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recursiveQueries,
|
c.recursiveQueries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[recursiveQueries].FirstValue,
|
c.perfDataObject[0].RecursiveQueries,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recursiveQueryFailures,
|
c.recursiveQueryFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[recursiveQueryFailure].FirstValue,
|
c.perfDataObject[0].RecursiveQueryFailure,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recursiveQuerySendTimeouts,
|
c.recursiveQuerySendTimeouts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[recursiveSendTimeOuts].FirstValue,
|
c.perfDataObject[0].RecursiveSendTimeOuts,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.queries,
|
c.queries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[tcpQueryReceived].FirstValue,
|
c.perfDataObject[0].TcpQueryReceived,
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.queries,
|
c.queries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[udpQueryReceived].FirstValue,
|
c.perfDataObject[0].UdpQueryReceived,
|
||||||
"udp",
|
"udp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.responses,
|
c.responses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[tcpResponseSent].FirstValue,
|
c.perfDataObject[0].TcpResponseSent,
|
||||||
"tcp",
|
"tcp",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.responses,
|
c.responses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[udpResponseSent].FirstValue,
|
c.perfDataObject[0].UdpResponseSent,
|
||||||
"udp",
|
"udp",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.unmatchedResponsesReceived,
|
c.unmatchedResponsesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[unmatchedResponsesReceived].FirstValue,
|
c.perfDataObject[0].UnmatchedResponsesReceived,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsQueries,
|
c.winsQueries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[winsLookupReceived].FirstValue,
|
c.perfDataObject[0].WinsLookupReceived,
|
||||||
"forward",
|
"forward",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsQueries,
|
c.winsQueries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[winsReverseLookupReceived].FirstValue,
|
c.perfDataObject[0].WinsReverseLookupReceived,
|
||||||
"reverse",
|
"reverse",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsResponses,
|
c.winsResponses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[winsResponseSent].FirstValue,
|
c.perfDataObject[0].WinsResponseSent,
|
||||||
"forward",
|
"forward",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.winsResponses,
|
c.winsResponses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[winsReverseResponseSent].FirstValue,
|
c.perfDataObject[0].WinsReverseResponseSent,
|
||||||
"reverse",
|
"reverse",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.secureUpdateFailures,
|
c.secureUpdateFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[secureUpdateFailure].FirstValue,
|
c.perfDataObject[0].SecureUpdateFailure,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.secureUpdateReceived,
|
c.secureUpdateReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[secureUpdateReceived].FirstValue,
|
c.perfDataObject[0].SecureUpdateReceived,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, dns.Name, dns.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, dns.Name, dns.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, dns.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
107
internal/collector/dns/types.go
Normal file
107
internal/collector/dns/types.go
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package dns
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
_ float64 `perfdata:"% User Time"`
|
||||||
|
_ float64 `perfdata:"176"`
|
||||||
|
_ float64 `perfdata:"Async Fast Reads/sec"`
|
||||||
|
AxfrRequestReceived float64 `perfdata:"AXFR Request Received"`
|
||||||
|
AxfrRequestSent float64 `perfdata:"AXFR Request Sent"`
|
||||||
|
AxfrResponseReceived float64 `perfdata:"AXFR Response Received"`
|
||||||
|
AxfrSuccessReceived float64 `perfdata:"AXFR Success Received"`
|
||||||
|
AxfrSuccessSent float64 `perfdata:"AXFR Success Sent"`
|
||||||
|
CachingMemory float64 `perfdata:"Caching Memory"`
|
||||||
|
_ float64 `perfdata:"Data Flush Pages/sec"`
|
||||||
|
_ float64 `perfdata:"Data Flushes/sec"`
|
||||||
|
DatabaseNodeMemory float64 `perfdata:"Database Node Memory"`
|
||||||
|
DynamicUpdateNoOperation float64 `perfdata:"Dynamic Update NoOperation"`
|
||||||
|
_ float64 `perfdata:"Dynamic Update NoOperation/sec"`
|
||||||
|
DynamicUpdateQueued float64 `perfdata:"Dynamic Update Queued"`
|
||||||
|
_ float64 `perfdata:"Dynamic Update Received"`
|
||||||
|
_ float64 `perfdata:"Dynamic Update Received/sec"`
|
||||||
|
DynamicUpdateRejected float64 `perfdata:"Dynamic Update Rejected"`
|
||||||
|
DynamicUpdateTimeOuts float64 `perfdata:"Dynamic Update TimeOuts"`
|
||||||
|
DynamicUpdateWrittenToDatabase float64 `perfdata:"Dynamic Update Written to Database"`
|
||||||
|
_ float64 `perfdata:"Dynamic Update Written to Database/sec"`
|
||||||
|
_ float64 `perfdata:"Enumerations Server/sec"`
|
||||||
|
_ float64 `perfdata:"Fast Read Not Possibles/sec"`
|
||||||
|
_ float64 `perfdata:"Fast Read Resource Misses/sec"`
|
||||||
|
IxfrRequestReceived float64 `perfdata:"IXFR Request Received"`
|
||||||
|
IxfrRequestSent float64 `perfdata:"IXFR Request Sent"`
|
||||||
|
IxfrResponseReceived float64 `perfdata:"IXFR Response Received"`
|
||||||
|
_ float64 `perfdata:"IXFR Success Received"`
|
||||||
|
IxfrSuccessSent float64 `perfdata:"IXFR Success Sent"`
|
||||||
|
IxfrTCPSuccessReceived float64 `perfdata:"IXFR TCP Success Received"`
|
||||||
|
IxfrUDPSuccessReceived float64 `perfdata:"IXFR UDP Success Received"`
|
||||||
|
_ float64 `perfdata:"Lazy Write Flushes/sec"`
|
||||||
|
_ float64 `perfdata:"Lazy Write Pages/sec"`
|
||||||
|
_ float64 `perfdata:"Level 2 TLB Fills/sec"`
|
||||||
|
NbStatMemory float64 `perfdata:"Nbstat Memory"`
|
||||||
|
NotifyReceived float64 `perfdata:"Notify Received"`
|
||||||
|
NotifySent float64 `perfdata:"Notify Sent"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Bad Socket"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Bad Socket/sec"`
|
||||||
|
_ float64 `perfdata:"Query Dropped By Policy"`
|
||||||
|
_ float64 `perfdata:"Query Dropped By Policy/sec"`
|
||||||
|
_ float64 `perfdata:"Query Dropped By Response Rate Limiting"`
|
||||||
|
_ float64 `perfdata:"Query Dropped By Response Rate Limiting/sec"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Send"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Send/sec"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Total"`
|
||||||
|
_ float64 `perfdata:"Query Dropped Total/sec"`
|
||||||
|
RecordFlowMemory float64 `perfdata:"Record Flow Memory"`
|
||||||
|
RecursiveQueries float64 `perfdata:"Recursive Queries"`
|
||||||
|
_ float64 `perfdata:"Recursive Queries/sec"`
|
||||||
|
RecursiveQueryFailure float64 `perfdata:"Recursive Query Failure"`
|
||||||
|
_ float64 `perfdata:"Recursive Query Failure/sec"`
|
||||||
|
_ float64 `perfdata:"Recursive Send TimeOuts"`
|
||||||
|
RecursiveSendTimeOuts float64 `perfdata:"Recursive TimeOut/sec"`
|
||||||
|
_ float64 `perfdata:"Responses Suppressed"`
|
||||||
|
_ float64 `perfdata:"Responses Suppressed/sec"`
|
||||||
|
SecureUpdateFailure float64 `perfdata:"Secure Update Failure"`
|
||||||
|
SecureUpdateReceived float64 `perfdata:"Secure Update Received"`
|
||||||
|
_ float64 `perfdata:"Secure Update Received/sec"`
|
||||||
|
TcpMessageMemory float64 `perfdata:"TCP Message Memory"`
|
||||||
|
TcpQueryReceived float64 `perfdata:"TCP Query Received"`
|
||||||
|
_ float64 `perfdata:"TCP Query Received/sec"`
|
||||||
|
TcpResponseSent float64 `perfdata:"TCP Response Sent"`
|
||||||
|
_ float64 `perfdata:"TCP Response Sent/sec"`
|
||||||
|
_ float64 `perfdata:"Total Query Received"`
|
||||||
|
_ float64 `perfdata:"Total Query Received/sec"`
|
||||||
|
_ float64 `perfdata:"Total Remote Inflight Queries"`
|
||||||
|
_ float64 `perfdata:"Total Response Sent"`
|
||||||
|
_ float64 `perfdata:"Total Response Sent/sec"`
|
||||||
|
UdpMessageMemory float64 `perfdata:"UDP Message Memory"`
|
||||||
|
UdpQueryReceived float64 `perfdata:"UDP Query Received"`
|
||||||
|
_ float64 `perfdata:"UDP Query Received/sec"`
|
||||||
|
UdpResponseSent float64 `perfdata:"UDP Response Sent"`
|
||||||
|
_ float64 `perfdata:"UDP Response Sent/sec"`
|
||||||
|
UnmatchedResponsesReceived float64 `perfdata:"Unmatched Responses Received"`
|
||||||
|
_ float64 `perfdata:"Virtual Bytes"`
|
||||||
|
WinsLookupReceived float64 `perfdata:"WINS Lookup Received"`
|
||||||
|
_ float64 `perfdata:"WINS Lookup Received/sec"`
|
||||||
|
WinsResponseSent float64 `perfdata:"WINS Response Sent"`
|
||||||
|
_ float64 `perfdata:"WINS Response Sent/sec"`
|
||||||
|
WinsReverseLookupReceived float64 `perfdata:"WINS Reverse Lookup Received"`
|
||||||
|
_ float64 `perfdata:"WINS Reverse Lookup Received/sec"`
|
||||||
|
WinsReverseResponseSent float64 `perfdata:"WINS Reverse Response Sent"`
|
||||||
|
_ float64 `perfdata:"WINS Reverse Response Sent/sec"`
|
||||||
|
ZoneTransferFailure float64 `perfdata:"Zone Transfer Failure"`
|
||||||
|
ZoneTransferSOARequestSent float64 `perfdata:"Zone Transfer Request Received"`
|
||||||
|
_ float64 `perfdata:"Zone Transfer SOA Request Sent"`
|
||||||
|
_ float64 `perfdata:"Zone Transfer Success"`
|
||||||
|
}
|
||||||
@@ -21,26 +21,26 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Name = "exchange"
|
const Name = "exchange"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
adAccessProcesses = "ADAccessProcesses"
|
subCollectorADAccessProcesses = "ADAccessProcesses"
|
||||||
transportQueues = "TransportQueues"
|
subCollectorTransportQueues = "TransportQueues"
|
||||||
httpProxy = "HttpProxy"
|
subCollectorHttpProxy = "HttpProxy"
|
||||||
activeSync = "ActiveSync"
|
subCollectorActiveSync = "ActiveSync"
|
||||||
availabilityService = "AvailabilityService"
|
subCollectorAvailabilityService = "AvailabilityService"
|
||||||
outlookWebAccess = "OutlookWebAccess"
|
subCollectorOutlookWebAccess = "OutlookWebAccess"
|
||||||
autoDiscover = "Autodiscover"
|
subCollectorAutoDiscover = "Autodiscover"
|
||||||
workloadManagement = "WorkloadManagement"
|
subCollectorWorkloadManagement = "WorkloadManagement"
|
||||||
rpcClientAccess = "RpcClientAccess"
|
subCollectorRpcClientAccess = "RpcClientAccess"
|
||||||
mapiHttpEmsmdb = "MapiHttpEmsmdb"
|
subCollectorMapiHttpEmsmdb = "MapiHttpEmsmdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -50,82 +50,35 @@ type Config struct {
|
|||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
var ConfigDefaults = Config{
|
var ConfigDefaults = Config{
|
||||||
CollectorsEnabled: []string{
|
CollectorsEnabled: []string{
|
||||||
adAccessProcesses,
|
subCollectorADAccessProcesses,
|
||||||
transportQueues,
|
subCollectorTransportQueues,
|
||||||
httpProxy,
|
subCollectorHttpProxy,
|
||||||
activeSync,
|
subCollectorActiveSync,
|
||||||
availabilityService,
|
subCollectorAvailabilityService,
|
||||||
outlookWebAccess,
|
subCollectorOutlookWebAccess,
|
||||||
autoDiscover,
|
subCollectorAutoDiscover,
|
||||||
workloadManagement,
|
subCollectorWorkloadManagement,
|
||||||
rpcClientAccess,
|
subCollectorRpcClientAccess,
|
||||||
mapiHttpEmsmdb,
|
subCollectorMapiHttpEmsmdb,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollectorADAccessProcesses *perfdata.Collector
|
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||||
perfDataCollectorTransportQueues *perfdata.Collector
|
closeFns []func()
|
||||||
perfDataCollectorHttpProxy *perfdata.Collector
|
|
||||||
perfDataCollectorActiveSync *perfdata.Collector
|
|
||||||
perfDataCollectorAvailabilityService *perfdata.Collector
|
|
||||||
perfDataCollectorOWA *perfdata.Collector
|
|
||||||
perfDataCollectorAutoDiscover *perfdata.Collector
|
|
||||||
perfDataCollectorWorkloadManagementWorkloads *perfdata.Collector
|
|
||||||
perfDataCollectorRpcClientAccess *perfdata.Collector
|
|
||||||
perfDataCollectorMapiHttpEmsmdb *perfdata.Collector
|
|
||||||
|
|
||||||
activeMailboxDeliveryQueueLength *prometheus.Desc
|
collectorADAccessProcesses
|
||||||
activeSyncRequestsPerSec *prometheus.Desc
|
collectorActiveSync
|
||||||
activeTasks *prometheus.Desc
|
collectorAutoDiscover
|
||||||
activeUserCount *prometheus.Desc
|
collectorAvailabilityService
|
||||||
activeUserCountMapiHttpEmsMDB *prometheus.Desc
|
collectorHTTPProxy
|
||||||
autoDiscoverRequestsPerSec *prometheus.Desc
|
collectorMapiHttpEmsmdb
|
||||||
availabilityRequestsSec *prometheus.Desc
|
collectorOWA
|
||||||
averageAuthenticationLatency *prometheus.Desc
|
collectorRpcClientAccess
|
||||||
averageCASProcessingLatency *prometheus.Desc
|
collectorTransportQueues
|
||||||
completedTasks *prometheus.Desc
|
collectorWorkloadManagementWorkloads
|
||||||
connectionCount *prometheus.Desc
|
|
||||||
currentUniqueUsers *prometheus.Desc
|
|
||||||
externalActiveRemoteDeliveryQueueLength *prometheus.Desc
|
|
||||||
externalLargestDeliveryQueueLength *prometheus.Desc
|
|
||||||
internalActiveRemoteDeliveryQueueLength *prometheus.Desc
|
|
||||||
internalLargestDeliveryQueueLength *prometheus.Desc
|
|
||||||
isActive *prometheus.Desc
|
|
||||||
ldapReadTime *prometheus.Desc
|
|
||||||
ldapSearchTime *prometheus.Desc
|
|
||||||
ldapTimeoutErrorsPerSec *prometheus.Desc
|
|
||||||
ldapWriteTime *prometheus.Desc
|
|
||||||
longRunningLDAPOperationsPerMin *prometheus.Desc
|
|
||||||
mailboxServerLocatorAverageLatency *prometheus.Desc
|
|
||||||
mailboxServerProxyFailureRate *prometheus.Desc
|
|
||||||
outstandingProxyRequests *prometheus.Desc
|
|
||||||
owaRequestsPerSec *prometheus.Desc
|
|
||||||
pingCommandsPending *prometheus.Desc
|
|
||||||
poisonQueueLength *prometheus.Desc
|
|
||||||
proxyRequestsPerSec *prometheus.Desc
|
|
||||||
queuedTasks *prometheus.Desc
|
|
||||||
retryMailboxDeliveryQueueLength *prometheus.Desc
|
|
||||||
rpcAveragedLatency *prometheus.Desc
|
|
||||||
rpcOperationsPerSec *prometheus.Desc
|
|
||||||
rpcRequests *prometheus.Desc
|
|
||||||
syncCommandsPerSec *prometheus.Desc
|
|
||||||
unreachableQueueLength *prometheus.Desc
|
|
||||||
userCount *prometheus.Desc
|
|
||||||
yieldedTasks *prometheus.Desc
|
|
||||||
messagesQueuedForDeliveryTotal *prometheus.Desc
|
|
||||||
messagesSubmittedTotal *prometheus.Desc
|
|
||||||
messagesDelayedTotal *prometheus.Desc
|
|
||||||
messagesCompletedDeliveryTotal *prometheus.Desc
|
|
||||||
shadowQueueLength *prometheus.Desc
|
|
||||||
submissionQueueLength *prometheus.Desc
|
|
||||||
delayQueueLength *prometheus.Desc
|
|
||||||
itemsCompletedDeliveryTotal *prometheus.Desc
|
|
||||||
itemsQueuedForDeliveryExpiredTotal *prometheus.Desc
|
|
||||||
itemsQueuedForDeliveryTotal *prometheus.Desc
|
|
||||||
itemsResubmittedTotal *prometheus.Desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
@@ -167,16 +120,16 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
app.PreAction(func(*kingpin.ParseContext) error {
|
app.PreAction(func(*kingpin.ParseContext) error {
|
||||||
if listAllCollectors {
|
if listAllCollectors {
|
||||||
collectorDesc := map[string]string{
|
collectorDesc := map[string]string{
|
||||||
adAccessProcesses: "[19108] MSExchange ADAccess Processes",
|
subCollectorADAccessProcesses: "[19108] MSExchange ADAccess Processes",
|
||||||
transportQueues: "[20524] MSExchangeTransport Queues",
|
subCollectorTransportQueues: "[20524] MSExchangeTransport Queues",
|
||||||
httpProxy: "[36934] MSExchange HttpProxy",
|
subCollectorHttpProxy: "[36934] MSExchange HttpProxy",
|
||||||
activeSync: "[25138] MSExchange ActiveSync",
|
subCollectorActiveSync: "[25138] MSExchange ActiveSync",
|
||||||
availabilityService: "[24914] MSExchange Availability Service",
|
subCollectorAvailabilityService: "[24914] MSExchange Availability Service",
|
||||||
outlookWebAccess: "[24618] MSExchange OWA",
|
subCollectorOutlookWebAccess: "[24618] MSExchange OWA",
|
||||||
autoDiscover: "[29240] MSExchange Autodiscover",
|
subCollectorAutoDiscover: "[29240] MSExchange Autodiscover",
|
||||||
workloadManagement: "[19430] MSExchange WorkloadManagement Workloads",
|
subCollectorWorkloadManagement: "[19430] MSExchange WorkloadManagement Workloads",
|
||||||
rpcClientAccess: "[29336] MSExchange RpcClientAccess",
|
subCollectorRpcClientAccess: "[29336] MSExchange RpcClientAccess",
|
||||||
mapiHttpEmsmdb: "[26463] MSExchange MapiHttp Emsmdb",
|
subCollectorMapiHttpEmsmdb: "[26463] MSExchange MapiHttp Emsmdb",
|
||||||
}
|
}
|
||||||
|
|
||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
@@ -208,51 +161,116 @@ func (c *Collector) GetName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Close() error {
|
func (c *Collector) Close() error {
|
||||||
|
for _, fn := range c.closeFns {
|
||||||
|
fn()
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
collectorFuncs := map[string]func() error{
|
subCollectors := map[string]struct {
|
||||||
adAccessProcesses: c.buildADAccessProcesses,
|
build func() error
|
||||||
transportQueues: c.buildTransportQueues,
|
collect func(ch chan<- prometheus.Metric) error
|
||||||
httpProxy: c.buildHTTPProxy,
|
close func()
|
||||||
activeSync: c.buildActiveSync,
|
}{
|
||||||
availabilityService: c.buildAvailabilityService,
|
subCollectorADAccessProcesses: {
|
||||||
outlookWebAccess: c.buildOWA,
|
build: c.buildADAccessProcesses,
|
||||||
autoDiscover: c.buildAutoDiscover,
|
collect: c.collectADAccessProcesses,
|
||||||
workloadManagement: c.buildWorkloadManagementWorkloads,
|
close: c.perfDataCollectorADAccessProcesses.Close,
|
||||||
rpcClientAccess: c.buildRPC,
|
},
|
||||||
mapiHttpEmsmdb: c.buildMapiHttpEmsmdb,
|
subCollectorTransportQueues: {
|
||||||
|
build: c.buildTransportQueues,
|
||||||
|
collect: c.collectTransportQueues,
|
||||||
|
close: c.perfDataCollectorTransportQueues.Close,
|
||||||
|
},
|
||||||
|
subCollectorHttpProxy: {
|
||||||
|
build: c.buildHTTPProxy,
|
||||||
|
collect: c.collectHTTPProxy,
|
||||||
|
close: c.perfDataCollectorHTTPProxy.Close,
|
||||||
|
},
|
||||||
|
subCollectorActiveSync: {
|
||||||
|
build: c.buildActiveSync,
|
||||||
|
collect: c.collectActiveSync,
|
||||||
|
close: c.perfDataCollectorActiveSync.Close,
|
||||||
|
},
|
||||||
|
subCollectorAvailabilityService: {
|
||||||
|
build: c.buildAvailabilityService,
|
||||||
|
collect: c.collectAvailabilityService,
|
||||||
|
close: c.perfDataCollectorAvailabilityService.Close,
|
||||||
|
},
|
||||||
|
subCollectorOutlookWebAccess: {
|
||||||
|
build: c.buildOWA,
|
||||||
|
collect: c.collectOWA,
|
||||||
|
close: c.perfDataCollectorOWA.Close,
|
||||||
|
},
|
||||||
|
subCollectorAutoDiscover: {
|
||||||
|
build: c.buildAutoDiscover,
|
||||||
|
collect: c.collectAutoDiscover,
|
||||||
|
close: c.perfDataCollectorAutoDiscover.Close,
|
||||||
|
},
|
||||||
|
subCollectorWorkloadManagement: {
|
||||||
|
build: c.buildWorkloadManagementWorkloads,
|
||||||
|
collect: c.collectWorkloadManagementWorkloads,
|
||||||
|
close: c.perfDataCollectorWorkloadManagementWorkloads.Close,
|
||||||
|
},
|
||||||
|
subCollectorRpcClientAccess: {
|
||||||
|
build: c.buildRpcClientAccess,
|
||||||
|
collect: c.collectRpcClientAccess,
|
||||||
|
close: c.perfDataCollectorRpcClientAccess.Close,
|
||||||
|
},
|
||||||
|
subCollectorMapiHttpEmsmdb: {
|
||||||
|
build: c.buildMapiHttpEmsmdb,
|
||||||
|
collect: c.collectMapiHttpEmsmdb,
|
||||||
|
close: c.perfDataCollectorMapiHttpEmsmdb.Close,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, collectorName := range c.config.CollectorsEnabled {
|
errs := make([]error, 0, len(c.config.CollectorsEnabled))
|
||||||
if err := collectorFuncs[collectorName](); err != nil {
|
|
||||||
return err
|
for _, name := range c.config.CollectorsEnabled {
|
||||||
|
if _, ok := subCollectors[name]; !ok {
|
||||||
|
return fmt.Errorf("unknown collector: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := subCollectors[name].build(); err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("failed to build %s collector: %w", name, err))
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
c.collectorFns = append(c.collectorFns, subCollectors[name].collect)
|
||||||
|
c.closeFns = append(c.closeFns, subCollectors[name].close)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect collects exchange metrics and sends them to prometheus.
|
// Collect collects exchange metrics and sends them to prometheus.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
collectorFuncs := map[string]func(ch chan<- prometheus.Metric) error{
|
errCh := make(chan error, len(c.collectorFns))
|
||||||
adAccessProcesses: c.collectADAccessProcesses,
|
errs := make([]error, 0, len(c.collectorFns))
|
||||||
transportQueues: c.collectTransportQueues,
|
|
||||||
httpProxy: c.collectHTTPProxy,
|
wg := sync.WaitGroup{}
|
||||||
activeSync: c.collectActiveSync,
|
|
||||||
availabilityService: c.collectAvailabilityService,
|
for _, fn := range c.collectorFns {
|
||||||
outlookWebAccess: c.collectOWA,
|
wg.Add(1)
|
||||||
autoDiscover: c.collectAutoDiscover,
|
|
||||||
workloadManagement: c.collectWorkloadManagementWorkloads,
|
go func(fn func(ch chan<- prometheus.Metric) error) {
|
||||||
rpcClientAccess: c.collectRPC,
|
defer wg.Done()
|
||||||
mapiHttpEmsmdb: c.collectMapiHttpEmsmdb,
|
|
||||||
|
if err := fn(ch); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
}
|
||||||
|
}(fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
errs := make([]error, len(c.config.CollectorsEnabled))
|
wg.Wait()
|
||||||
|
|
||||||
for i, collectorName := range c.config.CollectorsEnabled {
|
close(errCh)
|
||||||
errs[i] = collectorFuncs[collectorName](ch)
|
|
||||||
|
for err := range errCh {
|
||||||
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
@@ -265,8 +283,3 @@ func (c *Collector) toLabelName(name string) string {
|
|||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// msToSec converts from ms to seconds.
|
|
||||||
func (c *Collector) msToSec(t float64) float64 {
|
|
||||||
return t / 1000
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,27 +18,30 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorActiveSync struct {
|
||||||
requestsPerSec = "Requests/sec"
|
perfDataCollectorActiveSync *pdh.Collector
|
||||||
pingCommandsPending = "Ping Commands Pending"
|
perfDataObjectActiveSync []perfDataCounterValuesActiveSync
|
||||||
syncCommandsPerSec = "Sync Commands/sec"
|
|
||||||
)
|
activeSyncRequestsPerSec *prometheus.Desc
|
||||||
|
pingCommandsPending *prometheus.Desc
|
||||||
|
syncCommandsPerSec *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesActiveSync struct {
|
||||||
|
RequestsPerSec float64 `perfdata:"Requests/sec"`
|
||||||
|
PingCommandsPending float64 `perfdata:"Ping Commands Pending"`
|
||||||
|
SyncCommandsPerSec float64 `perfdata:"Sync Commands/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildActiveSync() error {
|
func (c *Collector) buildActiveSync() error {
|
||||||
counters := []string{
|
|
||||||
requestsPerSec,
|
|
||||||
pingCommandsPending,
|
|
||||||
syncCommandsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorActiveSync, err = perfdata.NewCollector("MSExchange ActiveSync", perfdata.InstancesAll, counters)
|
c.perfDataCollectorActiveSync, err = pdh.NewCollector[perfDataCounterValuesActiveSync](pdh.CounterTypeRaw, "MSExchange ActiveSync", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange ActiveSync collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange ActiveSync collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -66,30 +69,26 @@ func (c *Collector) buildActiveSync() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorActiveSync.Collect()
|
err := c.perfDataCollectorActiveSync.Collect(&c.perfDataObjectActiveSync)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange ActiveSync metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange ActiveSync metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectActiveSync {
|
||||||
return fmt.Errorf("failed to collect MSExchange ActiveSync metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeSyncRequestsPerSec,
|
c.activeSyncRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsPerSec].FirstValue,
|
data.RequestsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pingCommandsPending,
|
c.pingCommandsPending,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[pingCommandsPending].FirstValue,
|
data.PingCommandsPending,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.syncCommandsPerSec,
|
c.syncCommandsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[syncCommandsPerSec].FirstValue,
|
data.SyncCommandsPerSec,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,31 +18,37 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorADAccessProcesses struct {
|
||||||
ldapReadTime = "LDAP Read Time"
|
perfDataCollectorADAccessProcesses *pdh.Collector
|
||||||
ldapSearchTime = "LDAP Search Time"
|
perfDataObjectADAccessProcesses []perfDataCounterValuesADAccessProcesses
|
||||||
ldapWriteTime = "LDAP Write Time"
|
|
||||||
ldapTimeoutErrorsPerSec = "LDAP Timeout Errors/sec"
|
ldapReadTime *prometheus.Desc
|
||||||
longRunningLDAPOperationsPerMin = "Long Running LDAP Operations/min"
|
ldapSearchTime *prometheus.Desc
|
||||||
)
|
ldapTimeoutErrorsPerSec *prometheus.Desc
|
||||||
|
ldapWriteTime *prometheus.Desc
|
||||||
|
longRunningLDAPOperationsPerMin *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesADAccessProcesses struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
LdapReadTime float64 `perfdata:"LDAP Read Time"`
|
||||||
|
LdapSearchTime float64 `perfdata:"LDAP Search Time"`
|
||||||
|
LdapWriteTime float64 `perfdata:"LDAP Write Time"`
|
||||||
|
LdapTimeoutErrorsPerSec float64 `perfdata:"LDAP Timeout Errors/sec"`
|
||||||
|
LongRunningLDAPOperationsPerMin float64 `perfdata:"Long Running LDAP Operations/min"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildADAccessProcesses() error {
|
func (c *Collector) buildADAccessProcesses() error {
|
||||||
counters := []string{
|
|
||||||
ldapReadTime,
|
|
||||||
ldapSearchTime,
|
|
||||||
ldapWriteTime,
|
|
||||||
ldapTimeoutErrorsPerSec,
|
|
||||||
longRunningLDAPOperationsPerMin,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorADAccessProcesses, err = perfdata.NewCollector("MSExchange ADAccess Processes", perfdata.InstancesAll, counters)
|
c.perfDataCollectorADAccessProcesses, err = pdh.NewCollector[perfDataCounterValuesADAccessProcesses](pdh.CounterTypeRaw, "MSExchange ADAccess Processes", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange ADAccess Processes collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange ADAccess Processes collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -82,19 +88,15 @@ func (c *Collector) buildADAccessProcesses() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorADAccessProcesses.Collect()
|
err := c.perfDataCollectorADAccessProcesses.Collect(&c.perfDataObjectADAccessProcesses)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange ADAccess Processes metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange ADAccess Processes metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
|
||||||
return fmt.Errorf("failed to collect MSExchange ADAccess Processes metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
labelUseCount := make(map[string]int)
|
labelUseCount := make(map[string]int)
|
||||||
|
|
||||||
for name, data := range perfData {
|
for _, data := range c.perfDataObjectADAccessProcesses {
|
||||||
labelName := c.toLabelName(name)
|
labelName := c.toLabelName(data.Name)
|
||||||
|
|
||||||
// Since we're not including the PID suffix from the instance names in the label names, we get an occasional duplicate.
|
// Since we're not including the PID suffix from the instance names in the label names, we get an occasional duplicate.
|
||||||
// This seems to affect about 4 instances only of this object.
|
// This seems to affect about 4 instances only of this object.
|
||||||
@@ -106,31 +108,31 @@ func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapReadTime,
|
c.ldapReadTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.msToSec(data[ldapReadTime].FirstValue),
|
utils.MilliSecToSec(data.LdapReadTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapSearchTime,
|
c.ldapSearchTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.msToSec(data[ldapSearchTime].FirstValue),
|
utils.MilliSecToSec(data.LdapSearchTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapWriteTime,
|
c.ldapWriteTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.msToSec(data[ldapWriteTime].FirstValue),
|
utils.MilliSecToSec(data.LdapWriteTime),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.ldapTimeoutErrorsPerSec,
|
c.ldapTimeoutErrorsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[ldapTimeoutErrorsPerSec].FirstValue,
|
data.LdapTimeoutErrorsPerSec,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.longRunningLDAPOperationsPerMin,
|
c.longRunningLDAPOperationsPerMin,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[longRunningLDAPOperationsPerMin].FirstValue*60,
|
data.LongRunningLDAPOperationsPerMin*60,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,19 +18,26 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Collector) buildAutoDiscover() error {
|
type collectorAutoDiscover struct {
|
||||||
counters := []string{
|
perfDataCollectorAutoDiscover *pdh.Collector
|
||||||
requestsPerSec,
|
perfDataObjectAutoDiscover []perfDataCounterValuesAutoDiscover
|
||||||
}
|
|
||||||
|
|
||||||
|
autoDiscoverRequestsPerSec *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesAutoDiscover struct {
|
||||||
|
RequestsPerSec float64 `perfdata:"Requests/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) buildAutoDiscover() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorAutoDiscover, err = perfdata.NewCollector("MSExchange Autodiscover", perfdata.InstancesAll, counters)
|
c.perfDataCollectorAutoDiscover, err = pdh.NewCollector[perfDataCounterValuesAutoDiscover](pdh.CounterTypeRaw, "MSExchange Autodiscover", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange Autodiscover collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange Autodiscover collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -46,20 +53,16 @@ func (c *Collector) buildAutoDiscover() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectAutoDiscover(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectAutoDiscover(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorAutoDiscover.Collect()
|
err := c.perfDataCollectorAutoDiscover.Collect(&c.perfDataObjectAutoDiscover)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange Autodiscover metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange Autodiscover metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectAutoDiscover {
|
||||||
return fmt.Errorf("failed to collect MSExchange Autodiscover metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.autoDiscoverRequestsPerSec,
|
c.autoDiscoverRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsPerSec].FirstValue,
|
data.RequestsPerSec,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,19 +18,26 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Collector) buildAvailabilityService() error {
|
type collectorAvailabilityService struct {
|
||||||
counters := []string{
|
perfDataCollectorAvailabilityService *pdh.Collector
|
||||||
requestsPerSec,
|
perfDataObjectAvailabilityService []perfDataCounterValuesAvailabilityService
|
||||||
}
|
|
||||||
|
|
||||||
|
availabilityRequestsSec *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesAvailabilityService struct {
|
||||||
|
RequestsPerSec float64 `perfdata:"Requests/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) buildAvailabilityService() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorAvailabilityService, err = perfdata.NewCollector("MSExchange Availability Service", perfdata.InstancesAll, counters)
|
c.perfDataCollectorAvailabilityService, err = pdh.NewCollector[perfDataCounterValuesAvailabilityService](pdh.CounterTypeRaw, "MSExchange Availability Service", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange Availability Service collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange Availability Service collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -46,20 +53,16 @@ func (c *Collector) buildAvailabilityService() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectAvailabilityService(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectAvailabilityService(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorAvailabilityService.Collect()
|
err := c.perfDataCollectorAvailabilityService.Collect(&c.perfDataObjectAvailabilityService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectAvailabilityService {
|
||||||
return fmt.Errorf("failed to collect MSExchange Availability Service metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availabilityRequestsSec,
|
c.availabilityRequestsSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsPerSec].FirstValue,
|
data.RequestsPerSec,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,33 +18,39 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorHTTPProxy struct {
|
||||||
mailboxServerLocatorAverageLatency = "MailboxServerLocator Average Latency (Moving Average)"
|
perfDataCollectorHTTPProxy *pdh.Collector
|
||||||
averageAuthenticationLatency = "Average Authentication Latency"
|
perfDataObjectHTTPProxy []perfDataCounterValuesHTTPProxy
|
||||||
averageCASProcessingLatency = "Average ClientAccess Server Processing Latency"
|
|
||||||
mailboxServerProxyFailureRate = "Mailbox Server Proxy Failure Rate"
|
mailboxServerLocatorAverageLatency *prometheus.Desc
|
||||||
outstandingProxyRequests = "Outstanding Proxy Requests"
|
averageAuthenticationLatency *prometheus.Desc
|
||||||
proxyRequestsPerSec = "Proxy Requests/Sec"
|
outstandingProxyRequests *prometheus.Desc
|
||||||
)
|
proxyRequestsPerSec *prometheus.Desc
|
||||||
|
averageCASProcessingLatency *prometheus.Desc
|
||||||
|
mailboxServerProxyFailureRate *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesHTTPProxy struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
MailboxServerLocatorAverageLatency float64 `perfdata:"MailboxServerLocator Average Latency (Moving Average)"`
|
||||||
|
AverageAuthenticationLatency float64 `perfdata:"Average Authentication Latency"`
|
||||||
|
AverageCASProcessingLatency float64 `perfdata:"Average ClientAccess Server Processing Latency"`
|
||||||
|
MailboxServerProxyFailureRate float64 `perfdata:"Mailbox Server Proxy Failure Rate"`
|
||||||
|
OutstandingProxyRequests float64 `perfdata:"Outstanding Proxy Requests"`
|
||||||
|
ProxyRequestsPerSec float64 `perfdata:"Proxy Requests/Sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildHTTPProxy() error {
|
func (c *Collector) buildHTTPProxy() error {
|
||||||
counters := []string{
|
|
||||||
mailboxServerLocatorAverageLatency,
|
|
||||||
averageAuthenticationLatency,
|
|
||||||
averageCASProcessingLatency,
|
|
||||||
mailboxServerProxyFailureRate,
|
|
||||||
outstandingProxyRequests,
|
|
||||||
proxyRequestsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorHttpProxy, err = perfdata.NewCollector("MSExchange HttpProxy", perfdata.InstancesAll, counters)
|
c.perfDataCollectorHTTPProxy, err = pdh.NewCollector[perfDataCounterValuesHTTPProxy](pdh.CounterTypeRaw, "MSExchange HttpProxy", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange HttpProxy collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange HttpProxy collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -90,51 +96,47 @@ func (c *Collector) buildHTTPProxy() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorHttpProxy.Collect()
|
err := c.perfDataCollectorHTTPProxy.Collect(&c.perfDataObjectHTTPProxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange HttpProxy Service metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange HttpProxy Service metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectHTTPProxy {
|
||||||
return fmt.Errorf("failed to collect MSExchange HttpProxy Service metrics: %w", types.ErrNoData)
|
labelName := c.toLabelName(data.Name)
|
||||||
}
|
|
||||||
|
|
||||||
for name, data := range perfData {
|
|
||||||
labelName := c.toLabelName(name)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mailboxServerLocatorAverageLatency,
|
c.mailboxServerLocatorAverageLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.msToSec(data[mailboxServerLocatorAverageLatency].FirstValue),
|
utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.averageAuthenticationLatency,
|
c.averageAuthenticationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[averageAuthenticationLatency].FirstValue,
|
data.AverageAuthenticationLatency,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.averageCASProcessingLatency,
|
c.averageCASProcessingLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.msToSec(data[averageCASProcessingLatency].FirstValue),
|
utils.MilliSecToSec(data.AverageCASProcessingLatency),
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.mailboxServerProxyFailureRate,
|
c.mailboxServerProxyFailureRate,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[mailboxServerProxyFailureRate].FirstValue,
|
data.MailboxServerProxyFailureRate,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.outstandingProxyRequests,
|
c.outstandingProxyRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[outstandingProxyRequests].FirstValue,
|
data.OutstandingProxyRequests,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.proxyRequestsPerSec,
|
c.proxyRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[proxyRequestsPerSec].FirstValue,
|
data.ProxyRequestsPerSec,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,23 +18,26 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorMapiHttpEmsmdb struct {
|
||||||
activeUserCount = "Active User Count"
|
perfDataCollectorMapiHttpEmsmdb *pdh.Collector
|
||||||
)
|
perfDataObjectMapiHttpEmsmdb []perfDataCounterValuesMapiHttpEmsmdb
|
||||||
|
|
||||||
|
activeUserCountMapiHttpEmsMDB *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesMapiHttpEmsmdb struct {
|
||||||
|
ActiveUserCount float64 `perfdata:"Active User Count"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildMapiHttpEmsmdb() error {
|
func (c *Collector) buildMapiHttpEmsmdb() error {
|
||||||
counters := []string{
|
|
||||||
activeUserCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorMapiHttpEmsmdb, err = perfdata.NewCollector("MSExchange MapiHttp Emsmdb", perfdata.InstancesAll, counters)
|
c.perfDataCollectorMapiHttpEmsmdb, err = pdh.NewCollector[perfDataCounterValuesMapiHttpEmsmdb](pdh.CounterTypeRaw, "MSExchange MapiHttp Emsmdb", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange MapiHttp Emsmdb: %w", err)
|
return fmt.Errorf("failed to create MSExchange MapiHttp Emsmdb: %w", err)
|
||||||
}
|
}
|
||||||
@@ -50,20 +53,16 @@ func (c *Collector) buildMapiHttpEmsmdb() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectMapiHttpEmsmdb(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectMapiHttpEmsmdb(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorMapiHttpEmsmdb.Collect()
|
err := c.perfDataCollectorMapiHttpEmsmdb.Collect(&c.perfDataObjectMapiHttpEmsmdb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange MapiHttp Emsmdb metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange MapiHttp Emsmdb metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectMapiHttpEmsmdb {
|
||||||
return fmt.Errorf("failed to collect MSExchange MapiHttp Emsmdb metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeUserCountMapiHttpEmsMDB,
|
c.activeUserCountMapiHttpEmsMDB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[activeUserCount].FirstValue,
|
data.ActiveUserCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,25 +18,28 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorOWA struct {
|
||||||
currentUniqueUsers = "Current Unique Users"
|
perfDataCollectorOWA *pdh.Collector
|
||||||
// requestsPerSec = "Requests/sec"
|
perfDataObjectOWA []perfDataCounterValuesOWA
|
||||||
)
|
|
||||||
|
currentUniqueUsers *prometheus.Desc
|
||||||
|
owaRequestsPerSec *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesOWA struct {
|
||||||
|
CurrentUniqueUsers float64 `perfdata:"Current Unique Users"`
|
||||||
|
RequestsPerSec float64 `perfdata:"Requests/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildOWA() error {
|
func (c *Collector) buildOWA() error {
|
||||||
counters := []string{
|
|
||||||
currentUniqueUsers,
|
|
||||||
requestsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorOWA, err = perfdata.NewCollector("MSExchange OWA", perfdata.InstancesAll, counters)
|
c.perfDataCollectorOWA, err = pdh.NewCollector[perfDataCounterValuesOWA](pdh.CounterTypeRaw, "MSExchange OWA", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange OWA collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange OWA collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -58,25 +61,21 @@ func (c *Collector) buildOWA() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorOWA.Collect()
|
err := c.perfDataCollectorOWA.Collect(&c.perfDataObjectOWA)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange OWA metrics: %w", err)
|
return fmt.Errorf("failed to collect MSExchange OWA metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectOWA {
|
||||||
return fmt.Errorf("failed to collect MSExchange OWA metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentUniqueUsers,
|
c.currentUniqueUsers,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[currentUniqueUsers].FirstValue,
|
data.CurrentUniqueUsers,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.owaRequestsPerSec,
|
c.owaRequestsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[requestsPerSec].FirstValue,
|
data.RequestsPerSec,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,33 +18,37 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorRpcClientAccess struct {
|
||||||
rpcAveragedLatency = "RPC Averaged Latency"
|
perfDataCollectorRpcClientAccess *pdh.Collector
|
||||||
rpcRequests = "RPC Requests"
|
perfDataObjectRpcClientAccess []perfDataCounterValuesRpcClientAccess
|
||||||
// activeUserCount = "Active User Count"
|
|
||||||
connectionCount = "Connection Count"
|
|
||||||
rpcOperationsPerSec = "RPC Operations/sec"
|
|
||||||
userCount = "User Count"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Collector) buildRPC() error {
|
activeUserCount *prometheus.Desc
|
||||||
counters := []string{
|
connectionCount *prometheus.Desc
|
||||||
rpcAveragedLatency,
|
rpcAveragedLatency *prometheus.Desc
|
||||||
rpcRequests,
|
rpcOperationsPerSec *prometheus.Desc
|
||||||
activeUserCount,
|
rpcRequests *prometheus.Desc
|
||||||
connectionCount,
|
userCount *prometheus.Desc
|
||||||
rpcOperationsPerSec,
|
}
|
||||||
userCount,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
type perfDataCounterValuesRpcClientAccess struct {
|
||||||
|
RpcAveragedLatency float64 `perfdata:"RPC Averaged Latency"`
|
||||||
|
RpcRequests float64 `perfdata:"RPC Requests"`
|
||||||
|
ActiveUserCount float64 `perfdata:"Active User Count"`
|
||||||
|
ConnectionCount float64 `perfdata:"Connection Count"`
|
||||||
|
RpcOperationsPerSec float64 `perfdata:"RPC Operations/sec"`
|
||||||
|
UserCount float64 `perfdata:"User Count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) buildRpcClientAccess() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorRpcClientAccess, err = perfdata.NewCollector("MSExchange RpcClientAccess", perfdata.InstancesAll, counters)
|
c.perfDataCollectorRpcClientAccess, err = pdh.NewCollector[perfDataCounterValuesRpcClientAccess](pdh.CounterTypeRaw, "MSExchange RpcClientAccess", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange RpcClientAccess collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange RpcClientAccess collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -89,46 +93,42 @@ func (c *Collector) buildRPC() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectRPC(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectRpcClientAccess(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorRpcClientAccess.Collect()
|
err := c.perfDataCollectorRpcClientAccess.Collect(&c.perfDataObjectRpcClientAccess)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange RpcClientAccess: %w", err)
|
return fmt.Errorf("failed to collect MSExchange RpcClientAccess: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectRpcClientAccess {
|
||||||
return fmt.Errorf("failed to collect MSExchange RpcClientAccess metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range perfData {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.rpcAveragedLatency,
|
c.rpcAveragedLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
c.msToSec(data[rpcAveragedLatency].FirstValue),
|
utils.MilliSecToSec(data.RpcAveragedLatency),
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.rpcRequests,
|
c.rpcRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[rpcRequests].FirstValue,
|
data.RpcRequests,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeUserCount,
|
c.activeUserCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[activeUserCount].FirstValue,
|
data.ActiveUserCount,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionCount,
|
c.connectionCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[connectionCount].FirstValue,
|
data.ConnectionCount,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.rpcOperationsPerSec,
|
c.rpcOperationsPerSec,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[rpcOperationsPerSec].FirstValue,
|
data.RpcOperationsPerSec,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.userCount,
|
c.userCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[userCount].FirstValue,
|
data.UserCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, exchange.Name, exchange.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, exchange.Name, exchange.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, exchange.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,59 +18,64 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorTransportQueues struct {
|
||||||
externalActiveRemoteDeliveryQueueLength = "External Active Remote Delivery Queue Length"
|
perfDataCollectorTransportQueues *pdh.Collector
|
||||||
internalActiveRemoteDeliveryQueueLength = "Internal Active Remote Delivery Queue Length"
|
perfDataObjectTransportQueues []perfDataCounterValuesTransportQueues
|
||||||
activeMailboxDeliveryQueueLength = "Active Mailbox Delivery Queue Length"
|
|
||||||
retryMailboxDeliveryQueueLength = "Retry Mailbox Delivery Queue Length"
|
activeMailboxDeliveryQueueLength *prometheus.Desc
|
||||||
unreachableQueueLength = "Unreachable Queue Length"
|
externalActiveRemoteDeliveryQueueLength *prometheus.Desc
|
||||||
externalLargestDeliveryQueueLength = "External Largest Delivery Queue Length"
|
externalLargestDeliveryQueueLength *prometheus.Desc
|
||||||
internalLargestDeliveryQueueLength = "Internal Largest Delivery Queue Length"
|
internalActiveRemoteDeliveryQueueLength *prometheus.Desc
|
||||||
poisonQueueLength = "Poison Queue Length"
|
internalLargestDeliveryQueueLength *prometheus.Desc
|
||||||
messagesQueuedForDeliveryTotal = "Messages Queued For Delivery Total"
|
poisonQueueLength *prometheus.Desc
|
||||||
messagesSubmittedTotal = "Messages Submitted Total"
|
retryMailboxDeliveryQueueLength *prometheus.Desc
|
||||||
messagesDelayedTotal = "Messages Delayed Total"
|
unreachableQueueLength *prometheus.Desc
|
||||||
messagesCompletedDeliveryTotal = "Messages Completed Delivery Total"
|
messagesQueuedForDeliveryTotal *prometheus.Desc
|
||||||
shadowQueueLength = "Shadow Queue Length"
|
messagesSubmittedTotal *prometheus.Desc
|
||||||
submissionQueueLength = "Submission Queue Length"
|
messagesDelayedTotal *prometheus.Desc
|
||||||
delayQueueLength = "Delay Queue Length"
|
messagesCompletedDeliveryTotal *prometheus.Desc
|
||||||
itemsCompletedDeliveryTotal = "Items Completed Delivery Total"
|
shadowQueueLength *prometheus.Desc
|
||||||
itemsQueuedForDeliveryExpiredTotal = "Items Queued For Delivery Expired Total"
|
submissionQueueLength *prometheus.Desc
|
||||||
itemsQueuedForDeliveryTotal = "Items Queued For Delivery Total"
|
delayQueueLength *prometheus.Desc
|
||||||
itemsResubmittedTotal = "Items Resubmitted Total"
|
itemsCompletedDeliveryTotal *prometheus.Desc
|
||||||
)
|
itemsQueuedForDeliveryExpiredTotal *prometheus.Desc
|
||||||
|
itemsQueuedForDeliveryTotal *prometheus.Desc
|
||||||
|
itemsResubmittedTotal *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesTransportQueues struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
ExternalActiveRemoteDeliveryQueueLength float64 `perfdata:"External Active Remote Delivery Queue Length"`
|
||||||
|
InternalActiveRemoteDeliveryQueueLength float64 `perfdata:"Internal Active Remote Delivery Queue Length"`
|
||||||
|
ActiveMailboxDeliveryQueueLength float64 `perfdata:"Active Mailbox Delivery Queue Length"`
|
||||||
|
RetryMailboxDeliveryQueueLength float64 `perfdata:"Retry Mailbox Delivery Queue Length"`
|
||||||
|
UnreachableQueueLength float64 `perfdata:"Unreachable Queue Length"`
|
||||||
|
ExternalLargestDeliveryQueueLength float64 `perfdata:"External Largest Delivery Queue Length"`
|
||||||
|
InternalLargestDeliveryQueueLength float64 `perfdata:"Internal Largest Delivery Queue Length"`
|
||||||
|
PoisonQueueLength float64 `perfdata:"Poison Queue Length"`
|
||||||
|
MessagesQueuedForDeliveryTotal float64 `perfdata:"Messages Queued For Delivery Total"`
|
||||||
|
MessagesSubmittedTotal float64 `perfdata:"Messages Submitted Total"`
|
||||||
|
MessagesDelayedTotal float64 `perfdata:"Messages Delayed Total"`
|
||||||
|
MessagesCompletedDeliveryTotal float64 `perfdata:"Messages Completed Delivery Total"`
|
||||||
|
ShadowQueueLength float64 `perfdata:"Shadow Queue Length"`
|
||||||
|
SubmissionQueueLength float64 `perfdata:"Submission Queue Length"`
|
||||||
|
DelayQueueLength float64 `perfdata:"Delay Queue Length"`
|
||||||
|
ItemsCompletedDeliveryTotal float64 `perfdata:"Items Completed Delivery Total"`
|
||||||
|
ItemsQueuedForDeliveryExpiredTotal float64 `perfdata:"Items Queued For Delivery Expired Total"`
|
||||||
|
ItemsQueuedForDeliveryTotal float64 `perfdata:"Items Queued For Delivery Total"`
|
||||||
|
ItemsResubmittedTotal float64 `perfdata:"Items Resubmitted Total"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildTransportQueues() error {
|
func (c *Collector) buildTransportQueues() error {
|
||||||
counters := []string{
|
|
||||||
externalActiveRemoteDeliveryQueueLength,
|
|
||||||
internalActiveRemoteDeliveryQueueLength,
|
|
||||||
activeMailboxDeliveryQueueLength,
|
|
||||||
retryMailboxDeliveryQueueLength,
|
|
||||||
unreachableQueueLength,
|
|
||||||
externalLargestDeliveryQueueLength,
|
|
||||||
internalLargestDeliveryQueueLength,
|
|
||||||
poisonQueueLength,
|
|
||||||
messagesQueuedForDeliveryTotal,
|
|
||||||
messagesSubmittedTotal,
|
|
||||||
messagesDelayedTotal,
|
|
||||||
messagesCompletedDeliveryTotal,
|
|
||||||
shadowQueueLength,
|
|
||||||
submissionQueueLength,
|
|
||||||
delayQueueLength,
|
|
||||||
itemsCompletedDeliveryTotal,
|
|
||||||
itemsQueuedForDeliveryExpiredTotal,
|
|
||||||
itemsQueuedForDeliveryTotal,
|
|
||||||
itemsResubmittedTotal,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorTransportQueues, err = perfdata.NewCollector("MSExchangeTransport Queues", perfdata.InstancesAll, counters)
|
c.perfDataCollectorTransportQueues, err = pdh.NewCollector[perfDataCounterValuesTransportQueues](pdh.CounterTypeRaw, "MSExchangeTransport Queues", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchangeTransport Queues collector: %w", err)
|
return fmt.Errorf("failed to create MSExchangeTransport Queues collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -194,130 +199,126 @@ func (c *Collector) buildTransportQueues() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorTransportQueues.Collect()
|
err := c.perfDataCollectorTransportQueues.Collect(&c.perfDataObjectTransportQueues)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchangeTransport Queues: %w", err)
|
return fmt.Errorf("failed to collect MSExchangeTransport Queues: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectTransportQueues {
|
||||||
return fmt.Errorf("failed to collect MSExchangeTransport Queues metrics: %w", types.ErrNoData)
|
labelName := c.toLabelName(data.Name)
|
||||||
}
|
|
||||||
|
|
||||||
for name, data := range perfData {
|
|
||||||
labelName := c.toLabelName(name)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.externalActiveRemoteDeliveryQueueLength,
|
c.externalActiveRemoteDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[externalActiveRemoteDeliveryQueueLength].FirstValue,
|
data.ExternalActiveRemoteDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.internalActiveRemoteDeliveryQueueLength,
|
c.internalActiveRemoteDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[internalActiveRemoteDeliveryQueueLength].FirstValue,
|
data.InternalActiveRemoteDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeMailboxDeliveryQueueLength,
|
c.activeMailboxDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[activeMailboxDeliveryQueueLength].FirstValue,
|
data.ActiveMailboxDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retryMailboxDeliveryQueueLength,
|
c.retryMailboxDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[retryMailboxDeliveryQueueLength].FirstValue,
|
data.RetryMailboxDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.unreachableQueueLength,
|
c.unreachableQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[unreachableQueueLength].FirstValue,
|
data.UnreachableQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.externalLargestDeliveryQueueLength,
|
c.externalLargestDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[externalLargestDeliveryQueueLength].FirstValue,
|
data.ExternalLargestDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.internalLargestDeliveryQueueLength,
|
c.internalLargestDeliveryQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[internalLargestDeliveryQueueLength].FirstValue,
|
data.InternalLargestDeliveryQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poisonQueueLength,
|
c.poisonQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[poisonQueueLength].FirstValue,
|
data.PoisonQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesQueuedForDeliveryTotal,
|
c.messagesQueuedForDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[messagesQueuedForDeliveryTotal].FirstValue,
|
data.MessagesQueuedForDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesSubmittedTotal,
|
c.messagesSubmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[messagesSubmittedTotal].FirstValue,
|
data.MessagesSubmittedTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesDelayedTotal,
|
c.messagesDelayedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[messagesDelayedTotal].FirstValue,
|
data.MessagesDelayedTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesCompletedDeliveryTotal,
|
c.messagesCompletedDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[messagesCompletedDeliveryTotal].FirstValue,
|
data.MessagesCompletedDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.shadowQueueLength,
|
c.shadowQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[shadowQueueLength].FirstValue,
|
data.ShadowQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.submissionQueueLength,
|
c.submissionQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[submissionQueueLength].FirstValue,
|
data.SubmissionQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.delayQueueLength,
|
c.delayQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[delayQueueLength].FirstValue,
|
data.DelayQueueLength,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsCompletedDeliveryTotal,
|
c.itemsCompletedDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[itemsCompletedDeliveryTotal].FirstValue,
|
data.ItemsCompletedDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsQueuedForDeliveryExpiredTotal,
|
c.itemsQueuedForDeliveryExpiredTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[itemsQueuedForDeliveryExpiredTotal].FirstValue,
|
data.ItemsQueuedForDeliveryExpiredTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsQueuedForDeliveryTotal,
|
c.itemsQueuedForDeliveryTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[itemsQueuedForDeliveryTotal].FirstValue,
|
data.ItemsQueuedForDeliveryTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.itemsResubmittedTotal,
|
c.itemsResubmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[itemsResubmittedTotal].FirstValue,
|
data.ItemsResubmittedTotal,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,31 +18,36 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
type collectorWorkloadManagementWorkloads struct {
|
||||||
activeTasks = "ActiveTasks"
|
perfDataCollectorWorkloadManagementWorkloads *pdh.Collector
|
||||||
completedTasks = "CompletedTasks"
|
perfDataObjectWorkloadManagementWorkloads []perfDataCounterValuesWorkloadManagementWorkloads
|
||||||
queuedTasks = "QueuedTasks"
|
|
||||||
yieldedTasks = "YieldedTasks"
|
activeTasks *prometheus.Desc
|
||||||
isActive = "Active"
|
isActive *prometheus.Desc
|
||||||
)
|
completedTasks *prometheus.Desc
|
||||||
|
queuedTasks *prometheus.Desc
|
||||||
|
yieldedTasks *prometheus.Desc
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesWorkloadManagementWorkloads struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
ActiveTasks float64 `perfdata:"ActiveTasks"`
|
||||||
|
CompletedTasks float64 `perfdata:"CompletedTasks"`
|
||||||
|
QueuedTasks float64 `perfdata:"QueuedTasks"`
|
||||||
|
YieldedTasks float64 `perfdata:"YieldedTasks"`
|
||||||
|
IsActive float64 `perfdata:"Active"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildWorkloadManagementWorkloads() error {
|
func (c *Collector) buildWorkloadManagementWorkloads() error {
|
||||||
counters := []string{
|
|
||||||
activeTasks,
|
|
||||||
completedTasks,
|
|
||||||
queuedTasks,
|
|
||||||
yieldedTasks,
|
|
||||||
isActive,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorWorkloadManagementWorkloads, err = perfdata.NewCollector("MSExchange WorkloadManagement Workloads", perfdata.InstancesAll, counters)
|
c.perfDataCollectorWorkloadManagementWorkloads, err = pdh.NewCollector[perfDataCounterValuesWorkloadManagementWorkloads](pdh.CounterTypeRaw, "MSExchange WorkloadManagement Workloads", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSExchange WorkloadManagement Workloads collector: %w", err)
|
return fmt.Errorf("failed to create MSExchange WorkloadManagement Workloads collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -82,46 +87,42 @@ func (c *Collector) buildWorkloadManagementWorkloads() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorWorkloadManagementWorkloads.Collect()
|
err := c.perfDataCollectorWorkloadManagementWorkloads.Collect(&c.perfDataObjectWorkloadManagementWorkloads)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSExchange WorkloadManagement Workloads: %w", err)
|
return fmt.Errorf("failed to collect MSExchange WorkloadManagement Workloads: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(perfData) == 0 {
|
for _, data := range c.perfDataObjectWorkloadManagementWorkloads {
|
||||||
return fmt.Errorf("failed to collect MSExchange WorkloadManagement Workloads metrics: %w", types.ErrNoData)
|
labelName := c.toLabelName(data.Name)
|
||||||
}
|
|
||||||
|
|
||||||
for name, data := range perfData {
|
|
||||||
labelName := c.toLabelName(name)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.activeTasks,
|
c.activeTasks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[activeTasks].FirstValue,
|
data.ActiveTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.completedTasks,
|
c.completedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[completedTasks].FirstValue,
|
data.CompletedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.queuedTasks,
|
c.queuedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[queuedTasks].FirstValue,
|
data.QueuedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.yieldedTasks,
|
c.yieldedTasks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[yieldedTasks].FirstValue,
|
data.YieldedTasks,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.isActive,
|
c.isActive,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[isActive].FirstValue,
|
data.IsActive,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, fsrmquota.Name, fsrmquota.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, fsrmquota.Name, fsrmquota.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, fsrmquota.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorDataStore Hyper-V DataStore metrics
|
// collectorDataStore Hyper-V DataStore metrics
|
||||||
type collectorDataStore struct {
|
type collectorDataStore struct {
|
||||||
perfDataCollectorDataStore *perfdata.Collector
|
perfDataCollectorDataStore *pdh.Collector
|
||||||
|
perfDataObjectDataStore []perfDataCounterValuesDataStore
|
||||||
|
|
||||||
dataStoreFragmentationRatio *prometheus.Desc // \Hyper-V DataStore(*)\Fragmentation ratio
|
dataStoreFragmentationRatio *prometheus.Desc // \Hyper-V DataStore(*)\Fragmentation ratio
|
||||||
dataStoreSectorSize *prometheus.Desc // \Hyper-V DataStore(*)\Sector size
|
dataStoreSectorSize *prometheus.Desc // \Hyper-V DataStore(*)\Sector size
|
||||||
@@ -75,107 +76,61 @@ type collectorDataStore struct {
|
|||||||
dataStoreSetOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Set operation count
|
dataStoreSetOperationCount *prometheus.Desc // \Hyper-V DataStore(*)\Set operation count
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesDataStore struct {
|
||||||
|
Name string
|
||||||
// Hyper-V DataStore metrics
|
// Hyper-V DataStore metrics
|
||||||
dataStoreFragmentationRatio = "Fragmentation ratio"
|
DataStoreFragmentationRatio float64 `perfdata:"Fragmentation ratio"`
|
||||||
dataStoreSectorSize = "Sector size"
|
DataStoreSectorSize float64 `perfdata:"Sector size"`
|
||||||
dataStoreDataAlignment = "Data alignment"
|
DataStoreDataAlignment float64 `perfdata:"Data alignment"`
|
||||||
dataStoreCurrentReplayLogSize = "Current replay logSize"
|
DataStoreCurrentReplayLogSize float64 `perfdata:"Current replay logSize"`
|
||||||
dataStoreAvailableEntries = "Number of available entries inside object tables"
|
DataStoreAvailableEntries float64 `perfdata:"Number of available entries inside object tables"`
|
||||||
dataStoreEmptyEntries = "Number of empty entries inside object tables"
|
DataStoreEmptyEntries float64 `perfdata:"Number of empty entries inside object tables"`
|
||||||
dataStoreFreeBytes = "Number of free bytes inside key tables"
|
DataStoreFreeBytes float64 `perfdata:"Number of free bytes inside key tables"`
|
||||||
dataStoreDataEnd = "Data end"
|
DataStoreDataEnd float64 `perfdata:"Data end"`
|
||||||
dataStoreFileObjects = "Number of file objects"
|
DataStoreFileObjects float64 `perfdata:"Number of file objects"`
|
||||||
dataStoreObjectTables = "Number of object tables"
|
DataStoreObjectTables float64 `perfdata:"Number of object tables"`
|
||||||
dataStoreKeyTables = "Number of key tables"
|
DataStoreKeyTables float64 `perfdata:"Number of key tables"`
|
||||||
dataStoreFileDataSize = "File data size in bytes"
|
DataStoreFileDataSize float64 `perfdata:"File data size in bytes"`
|
||||||
dataStoreTableDataSize = "Table data size in bytes"
|
DataStoreTableDataSize float64 `perfdata:"Table data size in bytes"`
|
||||||
dataStoreNamesSize = "Names size in bytes"
|
DataStoreNamesSize float64 `perfdata:"Names size in bytes"`
|
||||||
dataStoreNumberOfKeys = "Number of keys"
|
DataStoreNumberOfKeys float64 `perfdata:"Number of keys"`
|
||||||
dataStoreReconnectLatencyMicro = "Reconnect latency microseconds"
|
DataStoreReconnectLatencyMicro float64 `perfdata:"Reconnect latency microseconds"`
|
||||||
dataStoreDisconnectCount = "Disconnect count"
|
DataStoreDisconnectCount float64 `perfdata:"Disconnect count"`
|
||||||
dataStoreWriteToFileByteLatency = "Write to file byte latency microseconds"
|
DataStoreWriteToFileByteLatency float64 `perfdata:"Write to file byte latency microseconds"`
|
||||||
dataStoreWriteToFileByteCount = "Write to file byte count"
|
DataStoreWriteToFileByteCount float64 `perfdata:"Write to file byte count"`
|
||||||
dataStoreWriteToFileCount = "Write to file count"
|
DataStoreWriteToFileCount float64 `perfdata:"Write to file count"`
|
||||||
dataStoreReadFromFileByteLatency = "Read from file byte latency microseconds"
|
DataStoreReadFromFileByteLatency float64 `perfdata:"Read from file byte latency microseconds"`
|
||||||
dataStoreReadFromFileByteCount = "Read from file byte count"
|
DataStoreReadFromFileByteCount float64 `perfdata:"Read from file byte count"`
|
||||||
dataStoreReadFromFileCount = "Read from file count"
|
DataStoreReadFromFileCount float64 `perfdata:"Read from file count"`
|
||||||
dataStoreWriteToStorageByteLatency = "Write to storage byte latency microseconds"
|
DataStoreWriteToStorageByteLatency float64 `perfdata:"Write to storage byte latency microseconds"`
|
||||||
dataStoreWriteToStorageByteCount = "Write to storage byte count"
|
DataStoreWriteToStorageByteCount float64 `perfdata:"Write to storage byte count"`
|
||||||
dataStoreWriteToStorageCount = "Write to storage count"
|
DataStoreWriteToStorageCount float64 `perfdata:"Write to storage count"`
|
||||||
dataStoreReadFromStorageByteLatency = "Read from storage byte latency microseconds"
|
DataStoreReadFromStorageByteLatency float64 `perfdata:"Read from storage byte latency microseconds"`
|
||||||
dataStoreReadFromStorageByteCount = "Read from storage byte count"
|
DataStoreReadFromStorageByteCount float64 `perfdata:"Read from storage byte count"`
|
||||||
dataStoreReadFromStorageCount = "Read from storage count"
|
DataStoreReadFromStorageCount float64 `perfdata:"Read from storage count"`
|
||||||
dataStoreCommitByteLatency = "Commit byte latency microseconds"
|
DataStoreCommitByteLatency float64 `perfdata:"Commit byte latency microseconds"`
|
||||||
dataStoreCommitByteCount = "Commit byte count"
|
DataStoreCommitByteCount float64 `perfdata:"Commit byte count"`
|
||||||
dataStoreCommitCount = "Commit count"
|
DataStoreCommitCount float64 `perfdata:"Commit count"`
|
||||||
dataStoreCacheUpdateOperationLatency = "Cache update operation latency microseconds"
|
DataStoreCacheUpdateOperationLatency float64 `perfdata:"Cache update operation latency microseconds"`
|
||||||
dataStoreCacheUpdateOperationCount = "Cache update operation count"
|
DataStoreCacheUpdateOperationCount float64 `perfdata:"Cache update operation count"`
|
||||||
dataStoreCommitOperationLatency = "Commit operation latency microseconds"
|
DataStoreCommitOperationLatency float64 `perfdata:"Commit operation latency microseconds"`
|
||||||
dataStoreCommitOperationCount = "Commit operation count"
|
DataStoreCommitOperationCount float64 `perfdata:"Commit operation count"`
|
||||||
dataStoreCompactOperationLatency = "Compact operation latency microseconds"
|
DataStoreCompactOperationLatency float64 `perfdata:"Compact operation latency microseconds"`
|
||||||
dataStoreCompactOperationCount = "Compact operation count"
|
DataStoreCompactOperationCount float64 `perfdata:"Compact operation count"`
|
||||||
dataStoreLoadFileOperationLatency = "Load file operation latency microseconds"
|
DataStoreLoadFileOperationLatency float64 `perfdata:"Load file operation latency microseconds"`
|
||||||
dataStoreLoadFileOperationCount = "Load file operation count"
|
DataStoreLoadFileOperationCount float64 `perfdata:"Load file operation count"`
|
||||||
dataStoreRemoveOperationLatency = "Remove operation latency microseconds"
|
DataStoreRemoveOperationLatency float64 `perfdata:"Remove operation latency microseconds"`
|
||||||
dataStoreRemoveOperationCount = "Remove operation count"
|
DataStoreRemoveOperationCount float64 `perfdata:"Remove operation count"`
|
||||||
dataStoreQuerySizeOperationLatency = "Query size operation latency microseconds"
|
DataStoreQuerySizeOperationLatency float64 `perfdata:"Query size operation latency microseconds"`
|
||||||
dataStoreQuerySizeOperationCount = "Query size operation count"
|
DataStoreQuerySizeOperationCount float64 `perfdata:"Query size operation count"`
|
||||||
dataStoreSetOperationLatencyMicro = "Set operation latency microseconds"
|
DataStoreSetOperationLatencyMicro float64 `perfdata:"Set operation latency microseconds"`
|
||||||
dataStoreSetOperationCount = "Set operation count"
|
DataStoreSetOperationCount float64 `perfdata:"Set operation count"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildDataStore() error {
|
func (c *Collector) buildDataStore() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorDataStore, err = perfdata.NewCollector("Hyper-V DataStore", perfdata.InstancesAll, []string{
|
c.perfDataCollectorDataStore, err = pdh.NewCollector[perfDataCounterValuesDataStore](pdh.CounterTypeRaw, "Hyper-V DataStore", pdh.InstancesAll)
|
||||||
dataStoreFragmentationRatio,
|
|
||||||
dataStoreSectorSize,
|
|
||||||
dataStoreDataAlignment,
|
|
||||||
dataStoreCurrentReplayLogSize,
|
|
||||||
dataStoreAvailableEntries,
|
|
||||||
dataStoreEmptyEntries,
|
|
||||||
dataStoreFreeBytes,
|
|
||||||
dataStoreDataEnd,
|
|
||||||
dataStoreFileObjects,
|
|
||||||
dataStoreObjectTables,
|
|
||||||
dataStoreKeyTables,
|
|
||||||
dataStoreFileDataSize,
|
|
||||||
dataStoreTableDataSize,
|
|
||||||
dataStoreNamesSize,
|
|
||||||
dataStoreNumberOfKeys,
|
|
||||||
dataStoreReconnectLatencyMicro,
|
|
||||||
dataStoreDisconnectCount,
|
|
||||||
dataStoreWriteToFileByteLatency,
|
|
||||||
dataStoreWriteToFileByteCount,
|
|
||||||
dataStoreWriteToFileCount,
|
|
||||||
dataStoreReadFromFileByteLatency,
|
|
||||||
dataStoreReadFromFileByteCount,
|
|
||||||
dataStoreReadFromFileCount,
|
|
||||||
dataStoreWriteToStorageByteLatency,
|
|
||||||
dataStoreWriteToStorageByteCount,
|
|
||||||
dataStoreWriteToStorageCount,
|
|
||||||
dataStoreReadFromStorageByteLatency,
|
|
||||||
dataStoreReadFromStorageByteCount,
|
|
||||||
dataStoreReadFromStorageCount,
|
|
||||||
dataStoreCommitByteLatency,
|
|
||||||
dataStoreCommitByteCount,
|
|
||||||
dataStoreCommitCount,
|
|
||||||
dataStoreCacheUpdateOperationLatency,
|
|
||||||
dataStoreCacheUpdateOperationCount,
|
|
||||||
dataStoreCommitOperationLatency,
|
|
||||||
dataStoreCommitOperationCount,
|
|
||||||
dataStoreCompactOperationLatency,
|
|
||||||
dataStoreCompactOperationCount,
|
|
||||||
dataStoreLoadFileOperationLatency,
|
|
||||||
dataStoreLoadFileOperationCount,
|
|
||||||
dataStoreRemoveOperationLatency,
|
|
||||||
dataStoreRemoveOperationCount,
|
|
||||||
dataStoreQuerySizeOperationLatency,
|
|
||||||
dataStoreQuerySizeOperationCount,
|
|
||||||
dataStoreSetOperationLatencyMicro,
|
|
||||||
dataStoreSetOperationCount,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V DataStore collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V DataStore collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -461,332 +416,332 @@ func (c *Collector) buildDataStore() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDataStore(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectDataStore(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorDataStore.Collect()
|
err := c.perfDataCollectorDataStore.Collect(&c.perfDataObjectDataStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V DataStore metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V DataStore metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, page := range data {
|
for _, data := range c.perfDataObjectDataStore {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreFragmentationRatio,
|
c.dataStoreFragmentationRatio,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreFragmentationRatio].FirstValue,
|
data.DataStoreFragmentationRatio,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreSectorSize,
|
c.dataStoreSectorSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreSectorSize].FirstValue,
|
data.DataStoreSectorSize,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreDataAlignment,
|
c.dataStoreDataAlignment,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreDataAlignment].FirstValue,
|
data.DataStoreDataAlignment,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCurrentReplayLogSize,
|
c.dataStoreCurrentReplayLogSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreCurrentReplayLogSize].FirstValue,
|
data.DataStoreCurrentReplayLogSize,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreAvailableEntries,
|
c.dataStoreAvailableEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreAvailableEntries].FirstValue,
|
data.DataStoreAvailableEntries,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreEmptyEntries,
|
c.dataStoreEmptyEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreEmptyEntries].FirstValue,
|
data.DataStoreEmptyEntries,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreFreeBytes,
|
c.dataStoreFreeBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreFreeBytes].FirstValue,
|
data.DataStoreFreeBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreDataEnd,
|
c.dataStoreDataEnd,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreDataEnd].FirstValue,
|
data.DataStoreDataEnd,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreFileObjects,
|
c.dataStoreFileObjects,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreFileObjects].FirstValue,
|
data.DataStoreFileObjects,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreObjectTables,
|
c.dataStoreObjectTables,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreObjectTables].FirstValue,
|
data.DataStoreObjectTables,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreKeyTables,
|
c.dataStoreKeyTables,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreKeyTables].FirstValue,
|
data.DataStoreKeyTables,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreFileDataSize,
|
c.dataStoreFileDataSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreFileDataSize].FirstValue,
|
data.DataStoreFileDataSize,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreTableDataSize,
|
c.dataStoreTableDataSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreTableDataSize].FirstValue,
|
data.DataStoreTableDataSize,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreNamesSize,
|
c.dataStoreNamesSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreNamesSize].FirstValue,
|
data.DataStoreNamesSize,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreNumberOfKeys,
|
c.dataStoreNumberOfKeys,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreNumberOfKeys].FirstValue,
|
data.DataStoreNumberOfKeys,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReconnectLatencyMicro,
|
c.dataStoreReconnectLatencyMicro,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreReconnectLatencyMicro].FirstValue,
|
data.DataStoreReconnectLatencyMicro,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreDisconnectCount,
|
c.dataStoreDisconnectCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreDisconnectCount].FirstValue,
|
data.DataStoreDisconnectCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToFileByteLatency,
|
c.dataStoreWriteToFileByteLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreWriteToFileByteLatency].FirstValue,
|
data.DataStoreWriteToFileByteLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToFileByteCount,
|
c.dataStoreWriteToFileByteCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreWriteToFileByteCount].FirstValue,
|
data.DataStoreWriteToFileByteCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToFileCount,
|
c.dataStoreWriteToFileCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreWriteToFileCount].FirstValue,
|
data.DataStoreWriteToFileCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromFileByteLatency,
|
c.dataStoreReadFromFileByteLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreReadFromFileByteLatency].FirstValue,
|
data.DataStoreReadFromFileByteLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromFileByteCount,
|
c.dataStoreReadFromFileByteCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreReadFromFileByteCount].FirstValue,
|
data.DataStoreReadFromFileByteCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromFileCount,
|
c.dataStoreReadFromFileCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreReadFromFileCount].FirstValue,
|
data.DataStoreReadFromFileCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToStorageByteLatency,
|
c.dataStoreWriteToStorageByteLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreWriteToStorageByteLatency].FirstValue,
|
data.DataStoreWriteToStorageByteLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToStorageByteCount,
|
c.dataStoreWriteToStorageByteCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreWriteToStorageByteCount].FirstValue,
|
data.DataStoreWriteToStorageByteCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreWriteToStorageCount,
|
c.dataStoreWriteToStorageCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreWriteToStorageCount].FirstValue,
|
data.DataStoreWriteToStorageCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromStorageByteLatency,
|
c.dataStoreReadFromStorageByteLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreReadFromStorageByteLatency].FirstValue,
|
data.DataStoreReadFromStorageByteLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromStorageByteCount,
|
c.dataStoreReadFromStorageByteCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreReadFromStorageByteCount].FirstValue,
|
data.DataStoreReadFromStorageByteCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreReadFromStorageCount,
|
c.dataStoreReadFromStorageCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreReadFromStorageCount].FirstValue,
|
data.DataStoreReadFromStorageCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCommitByteLatency,
|
c.dataStoreCommitByteLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreCommitByteLatency].FirstValue,
|
data.DataStoreCommitByteLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCommitByteCount,
|
c.dataStoreCommitByteCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreCommitByteCount].FirstValue,
|
data.DataStoreCommitByteCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCommitCount,
|
c.dataStoreCommitCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreCommitCount].FirstValue,
|
data.DataStoreCommitCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCacheUpdateOperationLatency,
|
c.dataStoreCacheUpdateOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreCacheUpdateOperationLatency].FirstValue,
|
data.DataStoreCacheUpdateOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCacheUpdateOperationCount,
|
c.dataStoreCacheUpdateOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreCacheUpdateOperationCount].FirstValue,
|
data.DataStoreCacheUpdateOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCommitOperationLatency,
|
c.dataStoreCommitOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreCommitOperationLatency].FirstValue,
|
data.DataStoreCommitOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCommitOperationCount,
|
c.dataStoreCommitOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreCommitOperationCount].FirstValue,
|
data.DataStoreCommitOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCompactOperationLatency,
|
c.dataStoreCompactOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreCompactOperationLatency].FirstValue,
|
data.DataStoreCompactOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreCompactOperationCount,
|
c.dataStoreCompactOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreCompactOperationCount].FirstValue,
|
data.DataStoreCompactOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreLoadFileOperationLatency,
|
c.dataStoreLoadFileOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreLoadFileOperationLatency].FirstValue,
|
data.DataStoreLoadFileOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreLoadFileOperationCount,
|
c.dataStoreLoadFileOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreLoadFileOperationCount].FirstValue,
|
data.DataStoreLoadFileOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreRemoveOperationLatency,
|
c.dataStoreRemoveOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreRemoveOperationLatency].FirstValue,
|
data.DataStoreRemoveOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreRemoveOperationCount,
|
c.dataStoreRemoveOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreRemoveOperationCount].FirstValue,
|
data.DataStoreRemoveOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreQuerySizeOperationLatency,
|
c.dataStoreQuerySizeOperationLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreQuerySizeOperationLatency].FirstValue,
|
data.DataStoreQuerySizeOperationLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreQuerySizeOperationCount,
|
c.dataStoreQuerySizeOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreQuerySizeOperationCount].FirstValue,
|
data.DataStoreQuerySizeOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreSetOperationLatencyMicro,
|
c.dataStoreSetOperationLatencyMicro,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[dataStoreSetOperationLatencyMicro].FirstValue,
|
data.DataStoreSetOperationLatencyMicro,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dataStoreSetOperationCount,
|
c.dataStoreSetOperationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
page[dataStoreSetOperationCount].FirstValue,
|
data.DataStoreSetOperationCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -26,31 +26,30 @@ import (
|
|||||||
|
|
||||||
// collectorDynamicMemoryBalancer Hyper-V Dynamic Memory Balancer metrics
|
// collectorDynamicMemoryBalancer Hyper-V Dynamic Memory Balancer metrics
|
||||||
type collectorDynamicMemoryBalancer struct {
|
type collectorDynamicMemoryBalancer struct {
|
||||||
perfDataCollectorDynamicMemoryBalancer *perfdata.Collector
|
perfDataCollectorDynamicMemoryBalancer *pdh.Collector
|
||||||
|
perfDataObjectDynamicMemoryBalancer []perfDataCounterValuesDynamicMemoryBalancer
|
||||||
|
|
||||||
vmDynamicMemoryBalancerAvailableMemoryForBalancing *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory For Balancing
|
vmDynamicMemoryBalancerAvailableMemoryForBalancing *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory For Balancing
|
||||||
vmDynamicMemoryBalancerSystemCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\System Current Pressure
|
vmDynamicMemoryBalancerSystemCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\System Current Pressure
|
||||||
vmDynamicMemoryBalancerAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory
|
vmDynamicMemoryBalancerAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Available Memory
|
||||||
vmDynamicMemoryBalancerAveragePressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Average Pressure
|
vmDynamicMemoryBalancerAveragePressure *prometheus.Desc // \Hyper-V Dynamic Memory Balancer(*)\Average Pressure
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesDynamicMemoryBalancer struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
// Hyper-V Dynamic Memory Balancer metrics
|
// Hyper-V Dynamic Memory Balancer metrics
|
||||||
vmDynamicMemoryBalancerAvailableMemory = "Available Memory"
|
VmDynamicMemoryBalancerAvailableMemory float64 `perfdata:"Available Memory"`
|
||||||
vmDynamicMemoryBalancerAvailableMemoryForBalancing = "Available Memory For Balancing"
|
VmDynamicMemoryBalancerAvailableMemoryForBalancing float64 `perfdata:"Available Memory For Balancing"`
|
||||||
vmDynamicMemoryBalancerAveragePressure = "Average Pressure"
|
VmDynamicMemoryBalancerAveragePressure float64 `perfdata:"Average Pressure"`
|
||||||
vmDynamicMemoryBalancerSystemCurrentPressure = "System Current Pressure"
|
VmDynamicMemoryBalancerSystemCurrentPressure float64 `perfdata:"System Current Pressure"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildDynamicMemoryBalancer() error {
|
func (c *Collector) buildDynamicMemoryBalancer() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/archive/blogs/chrisavis/monitoring-dynamic-memory-in-windows-server-hyper-v-2012
|
// https://learn.microsoft.com/en-us/archive/blogs/chrisavis/monitoring-dynamic-memory-in-windows-server-hyper-v-2012
|
||||||
c.perfDataCollectorDynamicMemoryBalancer, err = perfdata.NewCollector("Hyper-V Dynamic Memory Balancer", perfdata.InstancesAll, []string{
|
c.perfDataCollectorDynamicMemoryBalancer, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryBalancer](pdh.CounterTypeRaw, "Hyper-V Dynamic Memory Balancer", pdh.InstancesAll)
|
||||||
vmDynamicMemoryBalancerAvailableMemory,
|
|
||||||
vmDynamicMemoryBalancerAvailableMemoryForBalancing,
|
|
||||||
vmDynamicMemoryBalancerAveragePressure,
|
|
||||||
vmDynamicMemoryBalancerSystemCurrentPressure,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -84,38 +83,38 @@ func (c *Collector) buildDynamicMemoryBalancer() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDynamicMemoryBalancer(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectDynamicMemoryBalancer(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorDynamicMemoryBalancer.Collect()
|
err := c.perfDataCollectorDynamicMemoryBalancer.Collect(&c.perfDataObjectDynamicMemoryBalancer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory Balancer metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory Balancer metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, page := range data {
|
for _, data := range c.perfDataObjectDynamicMemoryBalancer {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmDynamicMemoryBalancerAvailableMemory,
|
c.vmDynamicMemoryBalancerAvailableMemory,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MBToBytes(page[vmDynamicMemoryBalancerAvailableMemory].FirstValue),
|
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemory),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing,
|
c.vmDynamicMemoryBalancerAvailableMemoryForBalancing,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MBToBytes(page[vmDynamicMemoryBalancerAvailableMemoryForBalancing].FirstValue),
|
utils.MBToBytes(data.VmDynamicMemoryBalancerAvailableMemoryForBalancing),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmDynamicMemoryBalancerAveragePressure,
|
c.vmDynamicMemoryBalancerAveragePressure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.PercentageToRatio(page[vmDynamicMemoryBalancerAveragePressure].FirstValue),
|
utils.PercentageToRatio(data.VmDynamicMemoryBalancerAveragePressure),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmDynamicMemoryBalancerSystemCurrentPressure,
|
c.vmDynamicMemoryBalancerSystemCurrentPressure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.PercentageToRatio(page[vmDynamicMemoryBalancerSystemCurrentPressure].FirstValue),
|
utils.PercentageToRatio(data.VmDynamicMemoryBalancerSystemCurrentPressure),
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -26,7 +26,9 @@ import (
|
|||||||
|
|
||||||
// collectorDynamicMemoryVM Hyper-V Dynamic Memory VM metrics
|
// collectorDynamicMemoryVM Hyper-V Dynamic Memory VM metrics
|
||||||
type collectorDynamicMemoryVM struct {
|
type collectorDynamicMemoryVM struct {
|
||||||
perfDataCollectorDynamicMemoryVM *perfdata.Collector
|
perfDataCollectorDynamicMemoryVM *pdh.Collector
|
||||||
|
perfDataObjectDynamicMemoryVM []perfDataCounterValuesDynamicMemoryVM
|
||||||
|
|
||||||
vmMemoryAddedMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Added Memory
|
vmMemoryAddedMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Added Memory
|
||||||
vmMemoryCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Current Pressure
|
vmMemoryCurrentPressure *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Current Pressure
|
||||||
vmMemoryGuestVisiblePhysicalMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Visible Physical Memory
|
vmMemoryGuestVisiblePhysicalMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Visible Physical Memory
|
||||||
@@ -39,35 +41,26 @@ type collectorDynamicMemoryVM struct {
|
|||||||
vmMemoryGuestAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Available Memory
|
vmMemoryGuestAvailableMemory *prometheus.Desc // \Hyper-V Dynamic Memory VM(*)\Guest Available Memory
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesDynamicMemoryVM struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
// Hyper-V Dynamic Memory VM metrics
|
// Hyper-V Dynamic Memory VM metrics
|
||||||
vmMemoryAddedMemory = "Added Memory"
|
VmMemoryAddedMemory float64 `perfdata:"Added Memory"`
|
||||||
vmMemoryCurrentPressure = "Current Pressure"
|
VmMemoryCurrentPressure float64 `perfdata:"Current Pressure"`
|
||||||
vmMemoryGuestAvailableMemory = "Guest Available Memory"
|
VmMemoryGuestAvailableMemory float64 `perfdata:"Guest Available Memory"`
|
||||||
vmMemoryGuestVisiblePhysicalMemory = "Guest Visible Physical Memory"
|
VmMemoryGuestVisiblePhysicalMemory float64 `perfdata:"Guest Visible Physical Memory"`
|
||||||
vmMemoryMaximumPressure = "Maximum Pressure"
|
VmMemoryMaximumPressure float64 `perfdata:"Maximum Pressure"`
|
||||||
vmMemoryMemoryAddOperations = "Memory Add Operations"
|
VmMemoryMemoryAddOperations float64 `perfdata:"Memory Add Operations"`
|
||||||
vmMemoryMemoryRemoveOperations = "Memory Remove Operations"
|
VmMemoryMemoryRemoveOperations float64 `perfdata:"Memory Remove Operations"`
|
||||||
vmMemoryMinimumPressure = "Minimum Pressure"
|
VmMemoryMinimumPressure float64 `perfdata:"Minimum Pressure"`
|
||||||
vmMemoryPhysicalMemory = "Physical Memory"
|
VmMemoryPhysicalMemory float64 `perfdata:"Physical Memory"`
|
||||||
vmMemoryRemovedMemory = "Removed Memory"
|
VmMemoryRemovedMemory float64 `perfdata:"Removed Memory"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildDynamicMemoryVM() error {
|
func (c *Collector) buildDynamicMemoryVM() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorDynamicMemoryVM, err = perfdata.NewCollector("Hyper-V Dynamic Memory VM", perfdata.InstancesAll, []string{
|
c.perfDataCollectorDynamicMemoryVM, err = pdh.NewCollector[perfDataCounterValuesDynamicMemoryVM](pdh.CounterTypeRaw, "Hyper-V Dynamic Memory VM", pdh.InstancesAll)
|
||||||
vmMemoryAddedMemory,
|
|
||||||
vmMemoryCurrentPressure,
|
|
||||||
vmMemoryGuestVisiblePhysicalMemory,
|
|
||||||
vmMemoryMaximumPressure,
|
|
||||||
vmMemoryMemoryAddOperations,
|
|
||||||
vmMemoryMemoryRemoveOperations,
|
|
||||||
vmMemoryMinimumPressure,
|
|
||||||
vmMemoryPhysicalMemory,
|
|
||||||
vmMemoryRemovedMemory,
|
|
||||||
vmMemoryGuestAvailableMemory,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Dynamic Memory VM collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Dynamic Memory VM collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -137,80 +130,80 @@ func (c *Collector) buildDynamicMemoryVM() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDynamicMemoryVM(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectDynamicMemoryVM(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorDynamicMemoryVM.Collect()
|
err := c.perfDataCollectorDynamicMemoryVM.Collect(&c.perfDataObjectDynamicMemoryVM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory VM metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Dynamic Memory VM metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for vmName, vmData := range data {
|
for _, data := range c.perfDataObjectDynamicMemoryVM {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryAddedMemory,
|
c.vmMemoryAddedMemory,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
utils.MBToBytes(vmData[vmMemoryAddedMemory].FirstValue),
|
utils.MBToBytes(data.VmMemoryAddedMemory),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryCurrentPressure,
|
c.vmMemoryCurrentPressure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.PercentageToRatio(vmData[vmMemoryCurrentPressure].FirstValue),
|
utils.PercentageToRatio(data.VmMemoryCurrentPressure),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryGuestAvailableMemory,
|
c.vmMemoryGuestAvailableMemory,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MBToBytes(vmData[vmMemoryGuestAvailableMemory].FirstValue),
|
utils.MBToBytes(data.VmMemoryGuestAvailableMemory),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryGuestVisiblePhysicalMemory,
|
c.vmMemoryGuestVisiblePhysicalMemory,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MBToBytes(vmData[vmMemoryGuestVisiblePhysicalMemory].FirstValue),
|
utils.MBToBytes(data.VmMemoryGuestVisiblePhysicalMemory),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryMaximumPressure,
|
c.vmMemoryMaximumPressure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.PercentageToRatio(vmData[vmMemoryMaximumPressure].FirstValue),
|
utils.PercentageToRatio(data.VmMemoryMaximumPressure),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryMemoryAddOperations,
|
c.vmMemoryMemoryAddOperations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
vmData[vmMemoryMemoryAddOperations].FirstValue,
|
data.VmMemoryMemoryAddOperations,
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryMemoryRemoveOperations,
|
c.vmMemoryMemoryRemoveOperations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
vmData[vmMemoryMemoryRemoveOperations].FirstValue,
|
data.VmMemoryMemoryRemoveOperations,
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryMinimumPressure,
|
c.vmMemoryMinimumPressure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.PercentageToRatio(vmData[vmMemoryMinimumPressure].FirstValue),
|
utils.PercentageToRatio(data.VmMemoryMinimumPressure),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryPhysicalMemory,
|
c.vmMemoryPhysicalMemory,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MBToBytes(vmData[vmMemoryPhysicalMemory].FirstValue),
|
utils.MBToBytes(data.VmMemoryPhysicalMemory),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.vmMemoryRemovedMemory,
|
c.vmMemoryRemovedMemory,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
utils.MBToBytes(vmData[vmMemoryRemovedMemory].FirstValue),
|
utils.MBToBytes(data.VmMemoryRemovedMemory),
|
||||||
vmName,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorHypervisorLogicalProcessor Hyper-V Hypervisor Logical Processor metrics
|
// collectorHypervisorLogicalProcessor Hyper-V Hypervisor Logical Processor metrics
|
||||||
type collectorHypervisorLogicalProcessor struct {
|
type collectorHypervisorLogicalProcessor struct {
|
||||||
perfDataCollectorHypervisorLogicalProcessor *perfdata.Collector
|
perfDataCollectorHypervisorLogicalProcessor *pdh.Collector
|
||||||
|
perfDataObjectHypervisorLogicalProcessor []perfDataCounterValuesHypervisorLogicalProcessor
|
||||||
|
|
||||||
// \Hyper-V Hypervisor Logical Processor(*)\% Guest Run Time
|
// \Hyper-V Hypervisor Logical Processor(*)\% Guest Run Time
|
||||||
// \Hyper-V Hypervisor Logical Processor(*)\% Hypervisor Run Time
|
// \Hyper-V Hypervisor Logical Processor(*)\% Hypervisor Run Time
|
||||||
@@ -36,24 +37,20 @@ type collectorHypervisorLogicalProcessor struct {
|
|||||||
hypervisorLogicalProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Logical Processor(*)\Context Switches/sec
|
hypervisorLogicalProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Logical Processor(*)\Context Switches/sec
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesHypervisorLogicalProcessor struct {
|
||||||
hypervisorLogicalProcessorGuestRunTimePercent = "% Guest Run Time"
|
Name string
|
||||||
hypervisorLogicalProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
|
|
||||||
hypervisorLogicalProcessorTotalRunTimePercent = "% Total Run Time"
|
HypervisorLogicalProcessorGuestRunTimePercent float64 `perfdata:"% Guest Run Time"`
|
||||||
hypervisorLogicalProcessorIdleRunTimePercent = "% Idle Time"
|
HypervisorLogicalProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
|
||||||
hypervisorLogicalProcessorContextSwitches = "Context Switches/sec"
|
HypervisorLogicalProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
|
||||||
)
|
HypervisorLogicalProcessorIdleRunTimePercent float64 `perfdata:"% Idle Time"`
|
||||||
|
HypervisorLogicalProcessorContextSwitches float64 `perfdata:"Context Switches/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildHypervisorLogicalProcessor() error {
|
func (c *Collector) buildHypervisorLogicalProcessor() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorHypervisorLogicalProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Logical Processor", perfdata.InstancesAll, []string{
|
c.perfDataCollectorHypervisorLogicalProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorLogicalProcessor](pdh.CounterTypeRaw, "Hyper-V Hypervisor Logical Processor", pdh.InstancesAll)
|
||||||
hypervisorLogicalProcessorGuestRunTimePercent,
|
|
||||||
hypervisorLogicalProcessorHypervisorRunTimePercent,
|
|
||||||
hypervisorLogicalProcessorTotalRunTimePercent,
|
|
||||||
hypervisorLogicalProcessorIdleRunTimePercent,
|
|
||||||
hypervisorLogicalProcessorContextSwitches,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Hypervisor Logical Processor collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Hypervisor Logical Processor collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -82,53 +79,53 @@ func (c *Collector) buildHypervisorLogicalProcessor() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectHypervisorLogicalProcessor(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectHypervisorLogicalProcessor(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorHypervisorLogicalProcessor.Collect()
|
err := c.perfDataCollectorHypervisorLogicalProcessor.Collect(&c.perfDataObjectHypervisorLogicalProcessor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Hypervisor Logical Processor metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Hypervisor Logical Processor metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for coreName, coreData := range data {
|
for _, data := range c.perfDataObjectHypervisorLogicalProcessor {
|
||||||
// The name format is Hv LP <core id>
|
// The name format is Hv LP <core id>
|
||||||
parts := strings.Split(coreName, " ")
|
parts := strings.Split(data.Name, " ")
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return fmt.Errorf("unexpected Hyper-V Hypervisor Logical Processor name format: %s", coreName)
|
return fmt.Errorf("unexpected Hyper-V Hypervisor Logical Processor name format: %s", data.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
coreId := parts[2]
|
coreID := parts[2]
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorLogicalProcessorTimeTotal,
|
c.hypervisorLogicalProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorLogicalProcessorGuestRunTimePercent].FirstValue,
|
data.HypervisorLogicalProcessorGuestRunTimePercent,
|
||||||
coreId, "guest",
|
coreID, "guest",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorLogicalProcessorTimeTotal,
|
c.hypervisorLogicalProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorLogicalProcessorHypervisorRunTimePercent].FirstValue,
|
data.HypervisorLogicalProcessorHypervisorRunTimePercent,
|
||||||
coreId, "hypervisor",
|
coreID, "hypervisor",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorLogicalProcessorTimeTotal,
|
c.hypervisorLogicalProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorLogicalProcessorIdleRunTimePercent].FirstValue,
|
data.HypervisorLogicalProcessorIdleRunTimePercent,
|
||||||
coreId, "idle",
|
coreID, "idle",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorLogicalProcessorTotalRunTimeTotal,
|
c.hypervisorLogicalProcessorTotalRunTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorLogicalProcessorTotalRunTimePercent].FirstValue,
|
data.HypervisorLogicalProcessorTotalRunTimePercent,
|
||||||
coreId,
|
coreID,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorLogicalProcessorContextSwitches,
|
c.hypervisorLogicalProcessorContextSwitches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorLogicalProcessorContextSwitches].FirstValue,
|
data.HypervisorLogicalProcessorContextSwitches,
|
||||||
coreId,
|
coreID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,18 @@
|
|||||||
package hyperv
|
package hyperv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorHypervisorRootPartition Hyper-V Hypervisor Root Partition metrics
|
// collectorHypervisorRootPartition Hyper-V Hypervisor Root Partition metrics
|
||||||
type collectorHypervisorRootPartition struct {
|
type collectorHypervisorRootPartition struct {
|
||||||
perfDataCollectorHypervisorRootPartition *perfdata.Collector
|
perfDataCollectorHypervisorRootPartition *pdh.Collector
|
||||||
|
perfDataObjectHypervisorRootPartition []perfDataCounterValuesHypervisorRootPartition
|
||||||
|
|
||||||
hypervisorRootPartitionAddressSpaces *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Address Spaces
|
hypervisorRootPartitionAddressSpaces *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Address Spaces
|
||||||
hypervisorRootPartitionAttachedDevices *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Attached Devices
|
hypervisorRootPartitionAttachedDevices *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Attached Devices
|
||||||
hypervisorRootPartitionDepositedPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Deposited Pages
|
hypervisorRootPartitionDepositedPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Deposited Pages
|
||||||
@@ -50,56 +51,34 @@ type collectorHypervisorRootPartition struct {
|
|||||||
hypervisorRootPartitionVirtualTLBPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Virtual TLB Pages
|
hypervisorRootPartitionVirtualTLBPages *prometheus.Desc // \Hyper-V Hypervisor Root Partition(*)\Virtual TLB Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesHypervisorRootPartition struct {
|
||||||
hypervisorRootPartitionAddressSpaces = "Address Spaces"
|
HypervisorRootPartitionAddressSpaces float64 `perfdata:"Address Spaces"`
|
||||||
hypervisorRootPartitionAttachedDevices = "Attached Devices"
|
HypervisorRootPartitionAttachedDevices float64 `perfdata:"Attached Devices"`
|
||||||
hypervisorRootPartitionDepositedPages = "Deposited Pages"
|
HypervisorRootPartitionDepositedPages float64 `perfdata:"Deposited Pages"`
|
||||||
hypervisorRootPartitionDeviceDMAErrors = "Device DMA Errors"
|
HypervisorRootPartitionDeviceDMAErrors float64 `perfdata:"Device DMA Errors"`
|
||||||
hypervisorRootPartitionDeviceInterruptErrors = "Device Interrupt Errors"
|
HypervisorRootPartitionDeviceInterruptErrors float64 `perfdata:"Device Interrupt Errors"`
|
||||||
hypervisorRootPartitionDeviceInterruptMappings = "Device Interrupt Mappings"
|
HypervisorRootPartitionDeviceInterruptMappings float64 `perfdata:"Device Interrupt Mappings"`
|
||||||
hypervisorRootPartitionDeviceInterruptThrottleEvents = "Device Interrupt Throttle Events"
|
HypervisorRootPartitionDeviceInterruptThrottleEvents float64 `perfdata:"Device Interrupt Throttle Events"`
|
||||||
hypervisorRootPartitionGPAPages = "GPA Pages"
|
HypervisorRootPartitionGPAPages float64 `perfdata:"GPA Pages"`
|
||||||
hypervisorRootPartitionGPASpaceModifications = "GPA Space Modifications/sec"
|
HypervisorRootPartitionGPASpaceModifications float64 `perfdata:"GPA Space Modifications/sec"`
|
||||||
hypervisorRootPartitionIOTLBFlushCost = "I/O TLB Flush Cost"
|
HypervisorRootPartitionIOTLBFlushCost float64 `perfdata:"I/O TLB Flush Cost"`
|
||||||
hypervisorRootPartitionIOTLBFlushes = "I/O TLB Flushes/sec"
|
HypervisorRootPartitionIOTLBFlushes float64 `perfdata:"I/O TLB Flushes/sec"`
|
||||||
hypervisorRootPartitionRecommendedVirtualTLBSize = "Recommended Virtual TLB Size"
|
HypervisorRootPartitionRecommendedVirtualTLBSize float64 `perfdata:"Recommended Virtual TLB Size"`
|
||||||
hypervisorRootPartitionSkippedTimerTicks = "Skipped Timer Ticks"
|
HypervisorRootPartitionSkippedTimerTicks float64 `perfdata:"Skipped Timer Ticks"`
|
||||||
hypervisorRootPartition1GDevicePages = "1G device pages"
|
HypervisorRootPartition1GDevicePages float64 `perfdata:"1G device pages"`
|
||||||
hypervisorRootPartition1GGPAPages = "1G GPA pages"
|
HypervisorRootPartition1GGPAPages float64 `perfdata:"1G GPA pages"`
|
||||||
hypervisorRootPartition2MDevicePages = "2M device pages"
|
HypervisorRootPartition2MDevicePages float64 `perfdata:"2M device pages"`
|
||||||
hypervisorRootPartition2MGPAPages = "2M GPA pages"
|
HypervisorRootPartition2MGPAPages float64 `perfdata:"2M GPA pages"`
|
||||||
hypervisorRootPartition4KDevicePages = "4K device pages"
|
HypervisorRootPartition4KDevicePages float64 `perfdata:"4K device pages"`
|
||||||
hypervisorRootPartition4KGPAPages = "4K GPA pages"
|
HypervisorRootPartition4KGPAPages float64 `perfdata:"4K GPA pages"`
|
||||||
hypervisorRootPartitionVirtualTLBFlushEntries = "Virtual TLB Flush Entires/sec"
|
HypervisorRootPartitionVirtualTLBFlushEntries float64 `perfdata:"Virtual TLB Flush Entires/sec"`
|
||||||
hypervisorRootPartitionVirtualTLBPages = "Virtual TLB Pages"
|
HypervisorRootPartitionVirtualTLBPages float64 `perfdata:"Virtual TLB Pages"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildHypervisorRootPartition() error {
|
func (c *Collector) buildHypervisorRootPartition() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorHypervisorRootPartition, err = perfdata.NewCollector("Hyper-V Hypervisor Root Partition", []string{"Root"}, []string{
|
c.perfDataCollectorHypervisorRootPartition, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootPartition](pdh.CounterTypeRaw, "Hyper-V Hypervisor Root Partition", []string{"Root"})
|
||||||
hypervisorRootPartitionAddressSpaces,
|
|
||||||
hypervisorRootPartitionAttachedDevices,
|
|
||||||
hypervisorRootPartitionDepositedPages,
|
|
||||||
hypervisorRootPartitionDeviceDMAErrors,
|
|
||||||
hypervisorRootPartitionDeviceInterruptErrors,
|
|
||||||
hypervisorRootPartitionDeviceInterruptMappings,
|
|
||||||
hypervisorRootPartitionDeviceInterruptThrottleEvents,
|
|
||||||
hypervisorRootPartitionGPAPages,
|
|
||||||
hypervisorRootPartitionGPASpaceModifications,
|
|
||||||
hypervisorRootPartitionIOTLBFlushCost,
|
|
||||||
hypervisorRootPartitionIOTLBFlushes,
|
|
||||||
hypervisorRootPartitionRecommendedVirtualTLBSize,
|
|
||||||
hypervisorRootPartitionSkippedTimerTicks,
|
|
||||||
hypervisorRootPartition1GDevicePages,
|
|
||||||
hypervisorRootPartition1GGPAPages,
|
|
||||||
hypervisorRootPartition2MDevicePages,
|
|
||||||
hypervisorRootPartition2MGPAPages,
|
|
||||||
hypervisorRootPartition4KDevicePages,
|
|
||||||
hypervisorRootPartition4KGPAPages,
|
|
||||||
hypervisorRootPartitionVirtualTLBFlushEntries,
|
|
||||||
hypervisorRootPartitionVirtualTLBPages,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Partition collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Partition collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -235,129 +214,124 @@ func (c *Collector) buildHypervisorRootPartition() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorHypervisorRootPartition.Collect()
|
err := c.perfDataCollectorHypervisorRootPartition.Collect(&c.perfDataObjectHypervisorRootPartition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Partition metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Partition metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rootData, ok := data["Root"]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("no data returned from Hyper-V Hypervisor Root Partition")
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionAddressSpaces,
|
c.hypervisorRootPartitionAddressSpaces,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionAddressSpaces].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAddressSpaces,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionAttachedDevices,
|
c.hypervisorRootPartitionAttachedDevices,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionAttachedDevices].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionAttachedDevices,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionDepositedPages,
|
c.hypervisorRootPartitionDepositedPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionDepositedPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDepositedPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionDeviceDMAErrors,
|
c.hypervisorRootPartitionDeviceDMAErrors,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionDeviceDMAErrors].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceDMAErrors,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionDeviceInterruptErrors,
|
c.hypervisorRootPartitionDeviceInterruptErrors,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionDeviceInterruptErrors].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptErrors,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionDeviceInterruptThrottleEvents,
|
c.hypervisorRootPartitionDeviceInterruptThrottleEvents,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionDeviceInterruptThrottleEvents].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionDeviceInterruptThrottleEvents,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionGPAPages,
|
c.hypervisorRootPartitionGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionGPAPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPAPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionGPASpaceModifications,
|
c.hypervisorRootPartitionGPASpaceModifications,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
rootData[hypervisorRootPartitionGPASpaceModifications].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionGPASpaceModifications,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionIOTLBFlushCost,
|
c.hypervisorRootPartitionIOTLBFlushCost,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionIOTLBFlushCost].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushCost,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionIOTLBFlushes,
|
c.hypervisorRootPartitionIOTLBFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
rootData[hypervisorRootPartitionIOTLBFlushes].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionIOTLBFlushes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionRecommendedVirtualTLBSize,
|
c.hypervisorRootPartitionRecommendedVirtualTLBSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionRecommendedVirtualTLBSize].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionRecommendedVirtualTLBSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionSkippedTimerTicks,
|
c.hypervisorRootPartitionSkippedTimerTicks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionSkippedTimerTicks].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionSkippedTimerTicks,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition1GDevicePages,
|
c.hypervisorRootPartition1GDevicePages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition1GDevicePages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GDevicePages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition1GGPAPages,
|
c.hypervisorRootPartition1GGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition1GGPAPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition1GGPAPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition2MDevicePages,
|
c.hypervisorRootPartition2MDevicePages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition2MDevicePages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition2MGPAPages,
|
c.hypervisorRootPartition2MGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition2MGPAPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition4KDevicePages,
|
c.hypervisorRootPartition4KDevicePages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition4KDevicePages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartition4KGPAPages,
|
c.hypervisorRootPartition4KGPAPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartition4KGPAPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionVirtualTLBFlushEntries,
|
c.hypervisorRootPartitionVirtualTLBFlushEntries,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
rootData[hypervisorRootPartitionVirtualTLBFlushEntries].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootPartitionVirtualTLBPages,
|
c.hypervisorRootPartitionVirtualTLBPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
rootData[hypervisorRootPartitionVirtualTLBPages].FirstValue,
|
c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBPages,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorHypervisorRootVirtualProcessor Hyper-V Hypervisor Root Virtual Processor metrics
|
// collectorHypervisorRootVirtualProcessor Hyper-V Hypervisor Root Virtual Processor metrics
|
||||||
type collectorHypervisorRootVirtualProcessor struct {
|
type collectorHypervisorRootVirtualProcessor struct {
|
||||||
perfDataCollectorHypervisorRootVirtualProcessor *perfdata.Collector
|
perfDataCollectorHypervisorRootVirtualProcessor *pdh.Collector
|
||||||
|
perfDataObjectHypervisorRootVirtualProcessor []perfDataCounterValuesHypervisorRootVirtualProcessor
|
||||||
|
|
||||||
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Guest Run Time
|
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Guest Run Time
|
||||||
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Hypervisor Run Time
|
// \Hyper-V Hypervisor Root Virtual Processor(*)\% Hypervisor Run Time
|
||||||
@@ -37,24 +38,20 @@ type collectorHypervisorRootVirtualProcessor struct {
|
|||||||
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch *prometheus.Desc // \Hyper-V Hypervisor Root Virtual Processor(*)\CPU Wait Time Per Dispatch
|
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch *prometheus.Desc // \Hyper-V Hypervisor Root Virtual Processor(*)\CPU Wait Time Per Dispatch
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesHypervisorRootVirtualProcessor struct {
|
||||||
hypervisorRootVirtualProcessorGuestRunTimePercent = "% Guest Run Time"
|
Name string
|
||||||
hypervisorRootVirtualProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
|
|
||||||
hypervisorRootVirtualProcessorTotalRunTimePercent = "% Total Run Time"
|
HypervisorRootVirtualProcessorGuestRunTimePercent float64 `perfdata:"% Guest Run Time"`
|
||||||
hypervisorRootVirtualProcessorRemoteRunTimePercent = "% Remote Run Time"
|
HypervisorRootVirtualProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
|
||||||
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch = "CPU Wait Time Per Dispatch"
|
HypervisorRootVirtualProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
|
||||||
)
|
HypervisorRootVirtualProcessorRemoteRunTimePercent float64 `perfdata:"% Remote Run Time"`
|
||||||
|
HypervisorRootVirtualProcessorCPUWaitTimePerDispatch float64 `perfdata:"CPU Wait Time Per Dispatch"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildHypervisorRootVirtualProcessor() error {
|
func (c *Collector) buildHypervisorRootVirtualProcessor() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorHypervisorRootVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Root Virtual Processor", perfdata.InstancesAll, []string{
|
c.perfDataCollectorHypervisorRootVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorRootVirtualProcessor](pdh.CounterTypeRaw, "Hyper-V Hypervisor Root Virtual Processor", pdh.InstancesAll)
|
||||||
hypervisorRootVirtualProcessorGuestRunTimePercent,
|
|
||||||
hypervisorRootVirtualProcessorHypervisorRunTimePercent,
|
|
||||||
hypervisorRootVirtualProcessorTotalRunTimePercent,
|
|
||||||
hypervisorRootVirtualProcessorRemoteRunTimePercent,
|
|
||||||
hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Virtual Processor collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Hypervisor Root Virtual Processor collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -84,53 +81,53 @@ func (c *Collector) buildHypervisorRootVirtualProcessor() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectHypervisorRootVirtualProcessor(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectHypervisorRootVirtualProcessor(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorHypervisorRootVirtualProcessor.Collect()
|
err := c.perfDataCollectorHypervisorRootVirtualProcessor.Collect(&c.perfDataObjectHypervisorRootVirtualProcessor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Virtual Processor metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Hypervisor Root Virtual Processor metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for coreName, coreData := range data {
|
for _, data := range c.perfDataObjectHypervisorRootVirtualProcessor {
|
||||||
// The name format is Hv LP <core id>
|
// The name format is Hv LP <core id>
|
||||||
parts := strings.Split(coreName, " ")
|
parts := strings.Split(data.Name, " ")
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return fmt.Errorf("unexpected Hyper-V Hypervisor Root Virtual Processor name format: %s", coreName)
|
return fmt.Errorf("unexpected Hyper-V Hypervisor Root Virtual Processor name format: %s", data.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
coreId := parts[2]
|
coreID := parts[2]
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootVirtualProcessorTimeTotal,
|
c.hypervisorRootVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorRootVirtualProcessorGuestRunTimePercent].FirstValue,
|
data.HypervisorRootVirtualProcessorGuestRunTimePercent,
|
||||||
coreId, "guest_run",
|
coreID, "guest_run",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootVirtualProcessorTimeTotal,
|
c.hypervisorRootVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorRootVirtualProcessorHypervisorRunTimePercent].FirstValue,
|
data.HypervisorRootVirtualProcessorHypervisorRunTimePercent,
|
||||||
coreId, "hypervisor",
|
coreID, "hypervisor",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootVirtualProcessorTimeTotal,
|
c.hypervisorRootVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorRootVirtualProcessorRemoteRunTimePercent].FirstValue,
|
data.HypervisorRootVirtualProcessorRemoteRunTimePercent,
|
||||||
coreId, "remote",
|
coreID, "remote",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootVirtualProcessorTotalRunTimeTotal,
|
c.hypervisorRootVirtualProcessorTotalRunTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorRootVirtualProcessorTotalRunTimePercent].FirstValue,
|
data.HypervisorRootVirtualProcessorTotalRunTimePercent,
|
||||||
coreId,
|
coreID,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
|
c.hypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorRootVirtualProcessorCPUWaitTimePerDispatch].FirstValue,
|
data.HypervisorRootVirtualProcessorCPUWaitTimePerDispatch,
|
||||||
coreId,
|
coreID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorHypervisorVirtualProcessor Hyper-V Hypervisor Virtual Processor metrics
|
// collectorHypervisorVirtualProcessor Hyper-V Hypervisor Virtual Processor metrics
|
||||||
type collectorHypervisorVirtualProcessor struct {
|
type collectorHypervisorVirtualProcessor struct {
|
||||||
perfDataCollectorHypervisorVirtualProcessor *perfdata.Collector
|
perfDataCollectorHypervisorVirtualProcessor *pdh.Collector
|
||||||
|
perfDataObjectHypervisorVirtualProcessor []perfDataCounterValuesHypervisorVirtualProcessor
|
||||||
|
|
||||||
// \Hyper-V Hypervisor Virtual Processor(*)\% Guest Run Time
|
// \Hyper-V Hypervisor Virtual Processor(*)\% Guest Run Time
|
||||||
// \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time
|
// \Hyper-V Hypervisor Virtual Processor(*)\% Hypervisor Run Time
|
||||||
@@ -36,24 +37,20 @@ type collectorHypervisorVirtualProcessor struct {
|
|||||||
hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
|
hypervisorVirtualProcessorContextSwitches *prometheus.Desc // \Hyper-V Hypervisor Virtual Processor(*)\CPU Wait Time Per Dispatch
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesHypervisorVirtualProcessor struct {
|
||||||
hypervisorVirtualProcessorGuestIdleTimePercent = "% Guest Idle Time"
|
Name string
|
||||||
hypervisorVirtualProcessorHypervisorRunTimePercent = "% Hypervisor Run Time"
|
|
||||||
hypervisorVirtualProcessorTotalRunTimePercent = "% Total Run Time"
|
HypervisorVirtualProcessorGuestIdleTimePercent float64 `perfdata:"% Guest Idle Time"`
|
||||||
hypervisorVirtualProcessorRemoteRunTimePercent = "% Remote Run Time"
|
HypervisorVirtualProcessorHypervisorRunTimePercent float64 `perfdata:"% Hypervisor Run Time"`
|
||||||
hypervisorVirtualProcessorCPUWaitTimePerDispatch = "CPU Wait Time Per Dispatch"
|
HypervisorVirtualProcessorTotalRunTimePercent float64 `perfdata:"% Total Run Time"`
|
||||||
)
|
HypervisorVirtualProcessorRemoteRunTimePercent float64 `perfdata:"% Remote Run Time"`
|
||||||
|
HypervisorVirtualProcessorCPUWaitTimePerDispatch float64 `perfdata:"CPU Wait Time Per Dispatch"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildHypervisorVirtualProcessor() error {
|
func (c *Collector) buildHypervisorVirtualProcessor() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorHypervisorVirtualProcessor, err = perfdata.NewCollector("Hyper-V Hypervisor Virtual Processor", perfdata.InstancesAll, []string{
|
c.perfDataCollectorHypervisorVirtualProcessor, err = pdh.NewCollector[perfDataCounterValuesHypervisorVirtualProcessor](pdh.CounterTypeRaw, "Hyper-V Hypervisor Virtual Processor", pdh.InstancesAll)
|
||||||
hypervisorVirtualProcessorGuestIdleTimePercent,
|
|
||||||
hypervisorVirtualProcessorHypervisorRunTimePercent,
|
|
||||||
hypervisorVirtualProcessorTotalRunTimePercent,
|
|
||||||
hypervisorVirtualProcessorRemoteRunTimePercent,
|
|
||||||
hypervisorVirtualProcessorCPUWaitTimePerDispatch,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Hypervisor Virtual Processor collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Hypervisor Virtual Processor collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -81,16 +78,16 @@ func (c *Collector) buildHypervisorVirtualProcessor() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorHypervisorVirtualProcessor.Collect()
|
err := c.perfDataCollectorHypervisorVirtualProcessor.Collect(&c.perfDataObjectHypervisorVirtualProcessor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Hypervisor Virtual Processor metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Hypervisor Virtual Processor metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for coreName, coreData := range data {
|
for _, data := range c.perfDataObjectHypervisorVirtualProcessor {
|
||||||
// The name format is <VM Name>:Hv VP <vcore id>
|
// The name format is <VM Name>:Hv VP <vcore id>
|
||||||
parts := strings.Split(coreName, ":")
|
parts := strings.Split(data.Name, ":")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
return fmt.Errorf("unexpected format of Name in Hyper-V Hypervisor Virtual Processor: %q, expected %q", coreName, "<VM Name>:Hv VP <vcore id>")
|
return fmt.Errorf("unexpected format of Name in Hyper-V Hypervisor Virtual Processor: %q, expected %q", data.Name, "<VM Name>:Hv VP <vcore id>")
|
||||||
}
|
}
|
||||||
|
|
||||||
coreParts := strings.Split(parts[1], " ")
|
coreParts := strings.Split(parts[1], " ")
|
||||||
@@ -99,41 +96,41 @@ func (c *Collector) collectHypervisorVirtualProcessor(ch chan<- prometheus.Metri
|
|||||||
}
|
}
|
||||||
|
|
||||||
vmName := parts[0]
|
vmName := parts[0]
|
||||||
coreId := coreParts[2]
|
coreID := coreParts[2]
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorVirtualProcessorTimeTotal,
|
c.hypervisorVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorVirtualProcessorHypervisorRunTimePercent].FirstValue,
|
data.HypervisorVirtualProcessorHypervisorRunTimePercent,
|
||||||
vmName, coreId, "hypervisor",
|
vmName, coreID, "hypervisor",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorVirtualProcessorTimeTotal,
|
c.hypervisorVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorVirtualProcessorGuestIdleTimePercent].FirstValue,
|
data.HypervisorVirtualProcessorGuestIdleTimePercent,
|
||||||
vmName, coreId, "guest_idle",
|
vmName, coreID, "guest_idle",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorVirtualProcessorTimeTotal,
|
c.hypervisorVirtualProcessorTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorVirtualProcessorGuestIdleTimePercent].FirstValue,
|
data.HypervisorVirtualProcessorGuestIdleTimePercent,
|
||||||
vmName, coreId, "guest_idle",
|
vmName, coreID, "guest_idle",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorVirtualProcessorTotalRunTimeTotal,
|
c.hypervisorVirtualProcessorTotalRunTimeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorVirtualProcessorTotalRunTimePercent].FirstValue,
|
data.HypervisorVirtualProcessorTotalRunTimePercent,
|
||||||
vmName, coreId,
|
vmName, coreID,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.hypervisorVirtualProcessorContextSwitches,
|
c.hypervisorVirtualProcessorContextSwitches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[hypervisorVirtualProcessorCPUWaitTimePerDispatch].FirstValue,
|
data.HypervisorVirtualProcessorCPUWaitTimePerDispatch,
|
||||||
vmName, coreId,
|
vmName, coreID,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorLegacyNetworkAdapter Hyper-V Legacy Network Adapter metrics
|
// collectorLegacyNetworkAdapter Hyper-V Legacy Network Adapter metrics
|
||||||
type collectorLegacyNetworkAdapter struct {
|
type collectorLegacyNetworkAdapter struct {
|
||||||
perfDataCollectorLegacyNetworkAdapter *perfdata.Collector
|
perfDataCollectorLegacyNetworkAdapter *pdh.Collector
|
||||||
|
perfDataObjectLegacyNetworkAdapter []perfDataCounterValuesLegacyNetworkAdapter
|
||||||
|
|
||||||
legacyNetworkAdapterBytesDropped *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Dropped
|
legacyNetworkAdapterBytesDropped *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Dropped
|
||||||
legacyNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Received/sec
|
legacyNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Bytes Received/sec
|
||||||
@@ -35,26 +36,21 @@ type collectorLegacyNetworkAdapter struct {
|
|||||||
legacyNetworkAdapterFramesSent *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Sent/sec
|
legacyNetworkAdapterFramesSent *prometheus.Desc // \Hyper-V Legacy Network Adapter(*)\Frames Sent/sec
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesLegacyNetworkAdapter struct {
|
||||||
legacyNetworkAdapterBytesDropped = "Bytes Dropped"
|
Name string
|
||||||
legacyNetworkAdapterBytesReceived = "Bytes Received/sec"
|
|
||||||
legacyNetworkAdapterBytesSent = "Bytes Sent/sec"
|
LegacyNetworkAdapterBytesDropped float64 `perfdata:"Bytes Dropped"`
|
||||||
legacyNetworkAdapterFramesDropped = "Frames Dropped"
|
LegacyNetworkAdapterBytesReceived float64 `perfdata:"Bytes Received/sec"`
|
||||||
legacyNetworkAdapterFramesReceived = "Frames Received/sec"
|
LegacyNetworkAdapterBytesSent float64 `perfdata:"Bytes Sent/sec"`
|
||||||
legacyNetworkAdapterFramesSent = "Frames Sent/sec"
|
LegacyNetworkAdapterFramesDropped float64 `perfdata:"Frames Dropped"`
|
||||||
)
|
LegacyNetworkAdapterFramesReceived float64 `perfdata:"Frames Received/sec"`
|
||||||
|
LegacyNetworkAdapterFramesSent float64 `perfdata:"Frames Sent/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildLegacyNetworkAdapter() error {
|
func (c *Collector) buildLegacyNetworkAdapter() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorLegacyNetworkAdapter, err = perfdata.NewCollector("Hyper-V Legacy Network Adapter", perfdata.InstancesAll, []string{
|
c.perfDataCollectorLegacyNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesLegacyNetworkAdapter](pdh.CounterTypeRaw, "Hyper-V Legacy Network Adapter", pdh.InstancesAll)
|
||||||
legacyNetworkAdapterBytesDropped,
|
|
||||||
legacyNetworkAdapterBytesReceived,
|
|
||||||
legacyNetworkAdapterBytesSent,
|
|
||||||
legacyNetworkAdapterFramesDropped,
|
|
||||||
legacyNetworkAdapterFramesReceived,
|
|
||||||
legacyNetworkAdapterFramesSent,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Legacy Network Adapter collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Legacy Network Adapter collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -100,52 +96,52 @@ func (c *Collector) buildLegacyNetworkAdapter() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectLegacyNetworkAdapter(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectLegacyNetworkAdapter(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorLegacyNetworkAdapter.Collect()
|
err := c.perfDataCollectorLegacyNetworkAdapter.Collect(&c.perfDataObjectLegacyNetworkAdapter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Legacy Network Adapter metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Legacy Network Adapter metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, adapter := range data {
|
for _, data := range c.perfDataObjectLegacyNetworkAdapter {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterBytesDropped,
|
c.legacyNetworkAdapterBytesDropped,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
adapter[legacyNetworkAdapterBytesDropped].FirstValue,
|
data.LegacyNetworkAdapterBytesDropped,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterBytesReceived,
|
c.legacyNetworkAdapterBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapter[legacyNetworkAdapterBytesReceived].FirstValue,
|
data.LegacyNetworkAdapterBytesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterBytesSent,
|
c.legacyNetworkAdapterBytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapter[legacyNetworkAdapterBytesSent].FirstValue,
|
data.LegacyNetworkAdapterBytesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterFramesReceived,
|
c.legacyNetworkAdapterFramesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapter[legacyNetworkAdapterFramesReceived].FirstValue,
|
data.LegacyNetworkAdapterFramesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterFramesDropped,
|
c.legacyNetworkAdapterFramesDropped,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapter[legacyNetworkAdapterFramesDropped].FirstValue,
|
data.LegacyNetworkAdapterFramesDropped,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.legacyNetworkAdapterFramesSent,
|
c.legacyNetworkAdapterFramesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapter[legacyNetworkAdapterFramesSent].FirstValue,
|
data.LegacyNetworkAdapterFramesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, hyperv.Name, hyperv.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, hyperv.Name, hyperv.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, hyperv.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,36 +16,33 @@
|
|||||||
package hyperv
|
package hyperv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualMachineHealthSummary Hyper-V Virtual Machine Health Summary metrics
|
// collectorVirtualMachineHealthSummary Hyper-V Virtual Machine Health Summary metrics
|
||||||
type collectorVirtualMachineHealthSummary struct {
|
type collectorVirtualMachineHealthSummary struct {
|
||||||
perfDataCollectorVirtualMachineHealthSummary *perfdata.Collector
|
perfDataCollectorVirtualMachineHealthSummary *pdh.Collector
|
||||||
|
perfDataObjectVirtualMachineHealthSummary []perfDataCounterValuesVirtualMachineHealthSummary
|
||||||
|
|
||||||
// \Hyper-V Virtual Machine Health Summary\Health Critical
|
// \Hyper-V Virtual Machine Health Summary\Health Critical
|
||||||
// \Hyper-V Virtual Machine Health Summary\Health Ok
|
// \Hyper-V Virtual Machine Health Summary\Health Ok
|
||||||
health *prometheus.Desc
|
health *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualMachineHealthSummary struct {
|
||||||
// Hyper-V Virtual Machine Health Summary
|
// Hyper-V Virtual Machine Health Summary
|
||||||
healthCritical = "Health Critical"
|
HealthCritical float64 `perfdata:"Health Critical"`
|
||||||
healthOk = "Health Ok"
|
HealthOk float64 `perfdata:"Health Ok"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualMachineHealthSummary() error {
|
func (c *Collector) buildVirtualMachineHealthSummary() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualMachineHealthSummary, err = perfdata.NewCollector("Hyper-V Virtual Machine Health Summary", nil, []string{
|
c.perfDataCollectorVirtualMachineHealthSummary, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineHealthSummary](pdh.CounterTypeRaw, "Hyper-V Virtual Machine Health Summary", nil)
|
||||||
healthCritical,
|
|
||||||
healthOk,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Machine Health Summary collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -61,27 +58,22 @@ func (c *Collector) buildVirtualMachineHealthSummary() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualMachineHealthSummary(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualMachineHealthSummary(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualMachineHealthSummary.Collect()
|
err := c.perfDataCollectorVirtualMachineHealthSummary.Collect(&c.perfDataObjectVirtualMachineHealthSummary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual Machine Health Summary metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual Machine Health Summary metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
healthData, ok := data[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return errors.New("no data returned for Hyper-V Virtual Machine Health Summary")
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.health,
|
c.health,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
healthData[healthCritical].FirstValue,
|
c.perfDataObjectVirtualMachineHealthSummary[0].HealthCritical,
|
||||||
"critical",
|
"critical",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.health,
|
c.health,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
healthData[healthOk].FirstValue,
|
c.perfDataObjectVirtualMachineHealthSummary[0].HealthOk,
|
||||||
"ok",
|
"ok",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -18,33 +18,33 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualMachineVidPartition Hyper-V VM Vid Partition metrics
|
// collectorVirtualMachineVidPartition Hyper-V VM Vid Partition metrics
|
||||||
type collectorVirtualMachineVidPartition struct {
|
type collectorVirtualMachineVidPartition struct {
|
||||||
perfDataCollectorVirtualMachineVidPartition *perfdata.Collector
|
perfDataCollectorVirtualMachineVidPartition *pdh.Collector
|
||||||
physicalPagesAllocated *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Physical Pages Allocated
|
perfDataObjectVirtualMachineVidPartition []perfDataCounterValuesVirtualMachineVidPartition
|
||||||
preferredNUMANodeIndex *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Preferred NUMA Node Index
|
|
||||||
remotePhysicalPages *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Remote Physical Pages
|
physicalPagesAllocated *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Physical Pages Allocated
|
||||||
|
preferredNUMANodeIndex *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Preferred NUMA Node Index
|
||||||
|
remotePhysicalPages *prometheus.Desc // \Hyper-V VM Vid Partition(*)\Remote Physical Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualMachineVidPartition struct {
|
||||||
physicalPagesAllocated = "Physical Pages Allocated"
|
Name string
|
||||||
preferredNUMANodeIndex = "Preferred NUMA Node Index"
|
|
||||||
remotePhysicalPages = "Remote Physical Pages"
|
PhysicalPagesAllocated float64 `perfdata:"Physical Pages Allocated"`
|
||||||
)
|
PreferredNUMANodeIndex float64 `perfdata:"Preferred NUMA Node Index"`
|
||||||
|
RemotePhysicalPages float64 `perfdata:"Remote Physical Pages"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualMachineVidPartition() error {
|
func (c *Collector) buildVirtualMachineVidPartition() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualMachineVidPartition, err = perfdata.NewCollector("Hyper-V VM Vid Partition", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualMachineVidPartition, err = pdh.NewCollector[perfDataCounterValuesVirtualMachineVidPartition](pdh.CounterTypeRaw, "Hyper-V VM Vid Partition", pdh.InstancesAll)
|
||||||
physicalPagesAllocated,
|
|
||||||
preferredNUMANodeIndex,
|
|
||||||
remotePhysicalPages,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V VM Vid Partition collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V VM Vid Partition collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -72,31 +72,31 @@ func (c *Collector) buildVirtualMachineVidPartition() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualMachineVidPartition(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualMachineVidPartition(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualMachineVidPartition.Collect()
|
err := c.perfDataCollectorVirtualMachineVidPartition.Collect(&c.perfDataObjectVirtualMachineVidPartition)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V VM Vid Partition metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V VM Vid Partition metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, page := range data {
|
for _, data := range c.perfDataObjectVirtualMachineVidPartition {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.physicalPagesAllocated,
|
c.physicalPagesAllocated,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[physicalPagesAllocated].FirstValue,
|
data.PhysicalPagesAllocated,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.preferredNUMANodeIndex,
|
c.preferredNUMANodeIndex,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[preferredNUMANodeIndex].FirstValue,
|
data.PreferredNUMANodeIndex,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.remotePhysicalPages,
|
c.remotePhysicalPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
page[remotePhysicalPages].FirstValue,
|
data.RemotePhysicalPages,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualNetworkAdapter Hyper-V Virtual Network Adapter metrics
|
// collectorVirtualNetworkAdapter Hyper-V Virtual Network Adapter metrics
|
||||||
type collectorVirtualNetworkAdapter struct {
|
type collectorVirtualNetworkAdapter struct {
|
||||||
perfDataCollectorVirtualNetworkAdapter *perfdata.Collector
|
perfDataCollectorVirtualNetworkAdapter *pdh.Collector
|
||||||
|
perfDataObjectVirtualNetworkAdapter []perfDataCounterValuesVirtualNetworkAdapter
|
||||||
|
|
||||||
virtualNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Received/sec
|
virtualNetworkAdapterBytesReceived *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Received/sec
|
||||||
virtualNetworkAdapterBytesSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Sent/sec
|
virtualNetworkAdapterBytesSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Bytes Sent/sec
|
||||||
@@ -35,26 +36,21 @@ type collectorVirtualNetworkAdapter struct {
|
|||||||
virtualNetworkAdapterPacketsSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Packets Sent/sec
|
virtualNetworkAdapterPacketsSent *prometheus.Desc // \Hyper-V Virtual Network Adapter(*)\Packets Sent/sec
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualNetworkAdapter struct {
|
||||||
virtualNetworkAdapterBytesReceived = "Bytes Received/sec"
|
Name string
|
||||||
virtualNetworkAdapterBytesSent = "Bytes Sent/sec"
|
|
||||||
virtualNetworkAdapterDroppedPacketsIncoming = "Dropped Packets Incoming/sec"
|
VirtualNetworkAdapterBytesReceived float64 `perfdata:"Bytes Received/sec"`
|
||||||
virtualNetworkAdapterDroppedPacketsOutgoing = "Dropped Packets Outgoing/sec"
|
VirtualNetworkAdapterBytesSent float64 `perfdata:"Bytes Sent/sec"`
|
||||||
virtualNetworkAdapterPacketsReceived = "Packets Received/sec"
|
VirtualNetworkAdapterDroppedPacketsIncoming float64 `perfdata:"Dropped Packets Incoming/sec"`
|
||||||
virtualNetworkAdapterPacketsSent = "Packets Sent/sec"
|
VirtualNetworkAdapterDroppedPacketsOutgoing float64 `perfdata:"Dropped Packets Outgoing/sec"`
|
||||||
)
|
VirtualNetworkAdapterPacketsReceived float64 `perfdata:"Packets Received/sec"`
|
||||||
|
VirtualNetworkAdapterPacketsSent float64 `perfdata:"Packets Sent/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualNetworkAdapter() error {
|
func (c *Collector) buildVirtualNetworkAdapter() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualNetworkAdapter, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualNetworkAdapter, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapter](pdh.CounterTypeRaw, "Hyper-V Virtual Network Adapter", pdh.InstancesAll)
|
||||||
virtualNetworkAdapterBytesReceived,
|
|
||||||
virtualNetworkAdapterBytesSent,
|
|
||||||
virtualNetworkAdapterDroppedPacketsIncoming,
|
|
||||||
virtualNetworkAdapterDroppedPacketsOutgoing,
|
|
||||||
virtualNetworkAdapterPacketsReceived,
|
|
||||||
virtualNetworkAdapterPacketsSent,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -100,52 +96,52 @@ func (c *Collector) buildVirtualNetworkAdapter() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualNetworkAdapter(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualNetworkAdapter(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualNetworkAdapter.Collect()
|
err := c.perfDataCollectorVirtualNetworkAdapter.Collect(&c.perfDataObjectVirtualNetworkAdapter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, adapterData := range data {
|
for _, data := range c.perfDataObjectVirtualNetworkAdapter {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterBytesReceived,
|
c.virtualNetworkAdapterBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterBytesReceived].FirstValue,
|
data.VirtualNetworkAdapterBytesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterBytesSent,
|
c.virtualNetworkAdapterBytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterBytesSent].FirstValue,
|
data.VirtualNetworkAdapterBytesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDroppedPacketsIncoming,
|
c.virtualNetworkAdapterDroppedPacketsIncoming,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDroppedPacketsIncoming].FirstValue,
|
data.VirtualNetworkAdapterDroppedPacketsIncoming,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDroppedPacketsOutgoing,
|
c.virtualNetworkAdapterDroppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDroppedPacketsOutgoing].FirstValue,
|
data.VirtualNetworkAdapterDroppedPacketsOutgoing,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterPacketsReceived,
|
c.virtualNetworkAdapterPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterPacketsReceived].FirstValue,
|
data.VirtualNetworkAdapterPacketsReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterPacketsSent,
|
c.virtualNetworkAdapterPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterPacketsSent].FirstValue,
|
data.VirtualNetworkAdapterPacketsSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualNetworkAdapterDropReasons Hyper-V Virtual Network Adapter Drop Reasons metrics
|
// collectorVirtualNetworkAdapterDropReasons Hyper-V Virtual Network Adapter Drop Reasons metrics
|
||||||
type collectorVirtualNetworkAdapterDropReasons struct {
|
type collectorVirtualNetworkAdapterDropReasons struct {
|
||||||
perfDataCollectorVirtualNetworkAdapterDropReasons *perfdata.Collector
|
perfDataCollectorVirtualNetworkAdapterDropReasons *pdh.Collector
|
||||||
|
perfDataObjectVirtualNetworkAdapterDropReasons []perfDataCounterValuesVirtualNetworkAdapterDropReasons
|
||||||
|
|
||||||
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing LowPowerPacketFilter
|
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Outgoing LowPowerPacketFilter
|
||||||
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming LowPowerPacketFilter
|
// \Hyper-V Virtual Network Adapter Drop Reasons(*)\Incoming LowPowerPacketFilter
|
||||||
@@ -106,114 +107,65 @@ type collectorVirtualNetworkAdapterDropReasons struct {
|
|||||||
virtualNetworkAdapterDropReasons *prometheus.Desc
|
virtualNetworkAdapterDropReasons *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualNetworkAdapterDropReasons struct {
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq = "Outgoing NativeFwdingReq"
|
Name string
|
||||||
virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq = "Incoming NativeFwdingReq"
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingMTUMismatch = "Outgoing MTUMismatch"
|
VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq float64 `perfdata:"Outgoing NativeFwdingReq"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingMTUMismatch = "Incoming MTUMismatch"
|
VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq float64 `perfdata:"Incoming NativeFwdingReq"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidConfig = "Outgoing InvalidConfig"
|
VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch float64 `perfdata:"Outgoing MTUMismatch"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidConfig = "Incoming InvalidConfig"
|
VirtualNetworkAdapterDropReasonsIncomingMTUMismatch float64 `perfdata:"Incoming MTUMismatch"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing = "Outgoing RequiredExtensionMissing"
|
VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig float64 `perfdata:"Outgoing InvalidConfig"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing = "Incoming RequiredExtensionMissing"
|
VirtualNetworkAdapterDropReasonsIncomingInvalidConfig float64 `perfdata:"Incoming InvalidConfig"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId = "Outgoing VirtualSubnetId"
|
VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing float64 `perfdata:"Outgoing RequiredExtensionMissing"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId = "Incoming VirtualSubnetId"
|
VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing float64 `perfdata:"Incoming RequiredExtensionMissing"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingBridgeReserved = "Outgoing BridgeReserved"
|
VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId float64 `perfdata:"Outgoing VirtualSubnetId"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingBridgeReserved = "Incoming BridgeReserved"
|
VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId float64 `perfdata:"Incoming VirtualSubnetId"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingRouterGuard = "Outgoing RouterGuard"
|
VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved float64 `perfdata:"Outgoing BridgeReserved"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingRouterGuard = "Incoming RouterGuard"
|
VirtualNetworkAdapterDropReasonsIncomingBridgeReserved float64 `perfdata:"Incoming BridgeReserved"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingDhcpGuard = "Outgoing DhcpGuard"
|
VirtualNetworkAdapterDropReasonsOutgoingRouterGuard float64 `perfdata:"Outgoing RouterGuard"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingDhcpGuard = "Incoming DhcpGuard"
|
VirtualNetworkAdapterDropReasonsIncomingRouterGuard float64 `perfdata:"Incoming RouterGuard"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingMacSpoofing = "Outgoing MacSpoofing"
|
VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard float64 `perfdata:"Outgoing DhcpGuard"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingMacSpoofing = "Incoming MacSpoofing"
|
VirtualNetworkAdapterDropReasonsIncomingDhcpGuard float64 `perfdata:"Incoming DhcpGuard"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingIpsec = "Outgoing Ipsec"
|
VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing float64 `perfdata:"Outgoing MacSpoofing"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingIpsec = "Incoming Ipsec"
|
VirtualNetworkAdapterDropReasonsIncomingMacSpoofing float64 `perfdata:"Incoming MacSpoofing"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingQos = "Outgoing Qos"
|
VirtualNetworkAdapterDropReasonsOutgoingIpsec float64 `perfdata:"Outgoing Ipsec"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingQos = "Incoming Qos"
|
VirtualNetworkAdapterDropReasonsIncomingIpsec float64 `perfdata:"Incoming Ipsec"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting = "Outgoing FailedPvlanSetting"
|
VirtualNetworkAdapterDropReasonsOutgoingQos float64 `perfdata:"Outgoing Qos"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting = "Incoming FailedPvlanSetting"
|
VirtualNetworkAdapterDropReasonsIncomingQos float64 `perfdata:"Incoming Qos"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy = "Outgoing FailedSecurityPolicy"
|
VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting float64 `perfdata:"Outgoing FailedPvlanSetting"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy = "Incoming FailedSecurityPolicy"
|
VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting float64 `perfdata:"Incoming FailedPvlanSetting"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC = "Outgoing UnauthorizedMAC"
|
VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy float64 `perfdata:"Outgoing FailedSecurityPolicy"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC = "Incoming UnauthorizedMAC"
|
VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy float64 `perfdata:"Incoming FailedSecurityPolicy"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN = "Outgoing UnauthorizedVLAN"
|
VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC float64 `perfdata:"Outgoing UnauthorizedMAC"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN = "Incoming UnauthorizedVLAN"
|
VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC float64 `perfdata:"Incoming UnauthorizedMAC"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN = "Outgoing FilteredVLAN"
|
VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN float64 `perfdata:"Outgoing UnauthorizedVLAN"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingFilteredVLAN = "Incoming FilteredVLAN"
|
VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN float64 `perfdata:"Incoming UnauthorizedVLAN"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFiltered = "Outgoing Filtered"
|
VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN float64 `perfdata:"Outgoing FilteredVLAN"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingFiltered = "Incoming Filtered"
|
VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN float64 `perfdata:"Incoming FilteredVLAN"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingBusy = "Outgoing Busy"
|
VirtualNetworkAdapterDropReasonsOutgoingFiltered float64 `perfdata:"Outgoing Filtered"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingBusy = "Incoming Busy"
|
VirtualNetworkAdapterDropReasonsIncomingFiltered float64 `perfdata:"Incoming Filtered"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNotAccepted = "Outgoing NotAccepted"
|
VirtualNetworkAdapterDropReasonsOutgoingBusy float64 `perfdata:"Outgoing Busy"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingNotAccepted = "Incoming NotAccepted"
|
VirtualNetworkAdapterDropReasonsIncomingBusy float64 `perfdata:"Incoming Busy"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingDisconnected = "Outgoing Disconnected"
|
VirtualNetworkAdapterDropReasonsOutgoingNotAccepted float64 `perfdata:"Outgoing NotAccepted"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingDisconnected = "Incoming Disconnected"
|
VirtualNetworkAdapterDropReasonsIncomingNotAccepted float64 `perfdata:"Incoming NotAccepted"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNotReady = "Outgoing NotReady"
|
VirtualNetworkAdapterDropReasonsOutgoingDisconnected float64 `perfdata:"Outgoing Disconnected"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingNotReady = "Incoming NotReady"
|
VirtualNetworkAdapterDropReasonsIncomingDisconnected float64 `perfdata:"Incoming Disconnected"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingResources = "Outgoing Resources"
|
VirtualNetworkAdapterDropReasonsOutgoingNotReady float64 `perfdata:"Outgoing NotReady"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingResources = "Incoming Resources"
|
VirtualNetworkAdapterDropReasonsIncomingNotReady float64 `perfdata:"Incoming NotReady"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidPacket = "Outgoing InvalidPacket"
|
VirtualNetworkAdapterDropReasonsOutgoingResources float64 `perfdata:"Outgoing Resources"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidPacket = "Incoming InvalidPacket"
|
VirtualNetworkAdapterDropReasonsIncomingResources float64 `perfdata:"Incoming Resources"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidData = "Outgoing InvalidData"
|
VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket float64 `perfdata:"Outgoing InvalidPacket"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidData = "Incoming InvalidData"
|
VirtualNetworkAdapterDropReasonsIncomingInvalidPacket float64 `perfdata:"Incoming InvalidPacket"`
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnknown = "Outgoing Unknown"
|
VirtualNetworkAdapterDropReasonsOutgoingInvalidData float64 `perfdata:"Outgoing InvalidData"`
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnknown = "Incoming Unknown"
|
VirtualNetworkAdapterDropReasonsIncomingInvalidData float64 `perfdata:"Incoming InvalidData"`
|
||||||
)
|
VirtualNetworkAdapterDropReasonsOutgoingUnknown float64 `perfdata:"Outgoing Unknown"`
|
||||||
|
VirtualNetworkAdapterDropReasonsIncomingUnknown float64 `perfdata:"Incoming Unknown"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
|
func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = perfdata.NewCollector("Hyper-V Virtual Network Adapter Drop Reasons", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualNetworkAdapterDropReasons, err = pdh.NewCollector[perfDataCounterValuesVirtualNetworkAdapterDropReasons](pdh.CounterTypeRaw, "Hyper-V Virtual Network Adapter Drop Reasons", pdh.InstancesAll)
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingMTUMismatch,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidConfig,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingBridgeReserved,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingRouterGuard,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingRouterGuard,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingDhcpGuard,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingMacSpoofing,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingIpsec,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingIpsec,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingQos,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingQos,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingFiltered,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingFiltered,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingBusy,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingBusy,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNotAccepted,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingNotAccepted,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingDisconnected,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingDisconnected,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingNotReady,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingNotReady,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingResources,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingResources,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidPacket,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingInvalidData,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingInvalidData,
|
|
||||||
virtualNetworkAdapterDropReasonsOutgoingUnknown,
|
|
||||||
virtualNetworkAdapterDropReasonsIncomingUnknown,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter Drop Reasons collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Network Adapter Drop Reasons collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -229,311 +181,311 @@ func (c *Collector) buildVirtualNetworkAdapterDropReasons() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualNetworkAdapterDropReasons.Collect()
|
err := c.perfDataCollectorVirtualNetworkAdapterDropReasons.Collect(&c.perfDataObjectVirtualNetworkAdapterDropReasons)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter Drop Reasons metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual Network Adapter Drop Reasons metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, adapterData := range data {
|
for _, data := range c.perfDataObjectVirtualNetworkAdapterDropReasons {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq,
|
||||||
name, "NativeFwdingReq", "outgoing",
|
data.Name, "NativeFwdingReq", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingNativeFwdingReq].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq,
|
||||||
name, "NativeFwdingReq", "incoming",
|
data.Name, "NativeFwdingReq", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingMTUMismatch].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch,
|
||||||
name, "MTUMismatch", "outgoing",
|
data.Name, "MTUMismatch", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingMTUMismatch].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch,
|
||||||
name, "MTUMismatch", "incoming",
|
data.Name, "MTUMismatch", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidConfig].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig,
|
||||||
name, "InvalidConfig", "outgoing",
|
data.Name, "InvalidConfig", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidConfig].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig,
|
||||||
name, "InvalidConfig", "incoming",
|
data.Name, "InvalidConfig", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing,
|
||||||
name, "RequiredExtensionMissing", "outgoing",
|
data.Name, "RequiredExtensionMissing", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing,
|
||||||
name, "RequiredExtensionMissing", "incoming",
|
data.Name, "RequiredExtensionMissing", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId,
|
||||||
name, "VirtualSubnetId", "outgoing",
|
data.Name, "VirtualSubnetId", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingVirtualSubnetId].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId,
|
||||||
name, "VirtualSubnetId", "incoming",
|
data.Name, "VirtualSubnetId", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingBridgeReserved].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved,
|
||||||
name, "BridgeReserved", "outgoing",
|
data.Name, "BridgeReserved", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingBridgeReserved].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved,
|
||||||
name, "BridgeReserved", "incoming",
|
data.Name, "BridgeReserved", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingRouterGuard].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard,
|
||||||
name, "RouterGuard", "outgoing",
|
data.Name, "RouterGuard", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingRouterGuard].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard,
|
||||||
name, "RouterGuard", "incoming",
|
data.Name, "RouterGuard", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingDhcpGuard].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard,
|
||||||
name, "DhcpGuard", "outgoing",
|
data.Name, "DhcpGuard", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingDhcpGuard].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard,
|
||||||
name, "DhcpGuard", "incoming",
|
data.Name, "DhcpGuard", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingMacSpoofing].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing,
|
||||||
name, "MacSpoofing", "outgoing",
|
data.Name, "MacSpoofing", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingMacSpoofing].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing,
|
||||||
name, "MacSpoofing", "incoming",
|
data.Name, "MacSpoofing", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingIpsec].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingIpsec,
|
||||||
name, "Ipsec", "outgoing",
|
data.Name, "Ipsec", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingIpsec].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingIpsec,
|
||||||
name, "Ipsec", "incoming",
|
data.Name, "Ipsec", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingQos].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingQos,
|
||||||
name, "Qos", "outgoing",
|
data.Name, "Qos", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingQos].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingQos,
|
||||||
name, "Qos", "incoming",
|
data.Name, "Qos", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting,
|
||||||
name, "FailedPvlanSetting", "outgoing",
|
data.Name, "FailedPvlanSetting", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting,
|
||||||
name, "FailedPvlanSetting", "incoming",
|
data.Name, "FailedPvlanSetting", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy,
|
||||||
name, "FailedSecurityPolicy", "outgoing",
|
data.Name, "FailedSecurityPolicy", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy,
|
||||||
name, "FailedSecurityPolicy", "incoming",
|
data.Name, "FailedSecurityPolicy", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC,
|
||||||
name, "UnauthorizedMAC", "outgoing",
|
data.Name, "UnauthorizedMAC", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC,
|
||||||
name, "UnauthorizedMAC", "incoming",
|
data.Name, "UnauthorizedMAC", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN,
|
||||||
name, "UnauthorizedVLAN", "outgoing",
|
data.Name, "UnauthorizedVLAN", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN,
|
||||||
name, "UnauthorizedVLAN", "incoming",
|
data.Name, "UnauthorizedVLAN", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingFilteredVLAN].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN,
|
||||||
name, "FilteredVLAN", "outgoing",
|
data.Name, "FilteredVLAN", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingFilteredVLAN].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN,
|
||||||
name, "FilteredVLAN", "incoming",
|
data.Name, "FilteredVLAN", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingFiltered].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingFiltered,
|
||||||
name, "Filtered", "outgoing",
|
data.Name, "Filtered", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingFiltered].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingFiltered,
|
||||||
name, "Filtered", "incoming",
|
data.Name, "Filtered", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingBusy].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingBusy,
|
||||||
name, "Busy", "outgoing",
|
data.Name, "Busy", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingBusy].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingBusy,
|
||||||
name, "Busy", "incoming",
|
data.Name, "Busy", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingNotAccepted].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted,
|
||||||
name, "NotAccepted", "outgoing",
|
data.Name, "NotAccepted", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingNotAccepted].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted,
|
||||||
name, "NotAccepted", "incoming",
|
data.Name, "NotAccepted", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingDisconnected].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected,
|
||||||
name, "Disconnected", "outgoing",
|
data.Name, "Disconnected", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingDisconnected].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingDisconnected,
|
||||||
name, "Disconnected", "incoming",
|
data.Name, "Disconnected", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingNotReady].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingNotReady,
|
||||||
name, "NotReady", "outgoing",
|
data.Name, "NotReady", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingNotReady].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingNotReady,
|
||||||
name, "NotReady", "incoming",
|
data.Name, "NotReady", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingResources].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingResources,
|
||||||
name, "Resources", "outgoing",
|
data.Name, "Resources", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingResources].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingResources,
|
||||||
name, "Resources", "incoming",
|
data.Name, "Resources", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidPacket].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket,
|
||||||
name, "InvalidPacket", "outgoing",
|
data.Name, "InvalidPacket", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidPacket].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket,
|
||||||
name, "InvalidPacket", "incoming",
|
data.Name, "InvalidPacket", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingInvalidData].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData,
|
||||||
name, "InvalidData", "outgoing",
|
data.Name, "InvalidData", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingInvalidData].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingInvalidData,
|
||||||
name, "InvalidData", "incoming",
|
data.Name, "InvalidData", "incoming",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsOutgoingUnknown].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsOutgoingUnknown,
|
||||||
name, "Unknown", "outgoing",
|
data.Name, "Unknown", "outgoing",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualNetworkAdapterDropReasons,
|
c.virtualNetworkAdapterDropReasons,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adapterData[virtualNetworkAdapterDropReasonsIncomingUnknown].FirstValue,
|
data.VirtualNetworkAdapterDropReasonsIncomingUnknown,
|
||||||
name, "Unknown", "incoming",
|
data.Name, "Unknown", "incoming",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualSMB Hyper-V Virtual SMB metrics
|
// collectorVirtualSMB Hyper-V Virtual SMB metrics
|
||||||
type collectorVirtualSMB struct {
|
type collectorVirtualSMB struct {
|
||||||
perfDataCollectorVirtualSMB *perfdata.Collector
|
perfDataCollectorVirtualSMB *pdh.Collector
|
||||||
|
perfDataObjectVirtualSMB []perfDataCounterValuesVirtualSMB
|
||||||
|
|
||||||
virtualSMBDirectMappedSections *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Sections
|
virtualSMBDirectMappedSections *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Sections
|
||||||
virtualSMBDirectMappedPages *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Pages
|
virtualSMBDirectMappedPages *prometheus.Desc // \Hyper-V Virtual SMB(*)\Direct-Mapped Pages
|
||||||
@@ -46,48 +47,32 @@ type collectorVirtualSMB struct {
|
|||||||
virtualSMBReceivedBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Received Bytes/sec
|
virtualSMBReceivedBytes *prometheus.Desc // \Hyper-V Virtual SMB(*)\Received Bytes/sec
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualSMB struct {
|
||||||
virtualSMBDirectMappedSections = "Direct-Mapped Sections"
|
Name string
|
||||||
virtualSMBDirectMappedPages = "Direct-Mapped Pages"
|
|
||||||
virtualSMBWriteBytesRDMA = "Write Bytes/sec (RDMA)"
|
VirtualSMBDirectMappedSections float64 `perfdata:"Direct-Mapped Sections"`
|
||||||
virtualSMBWriteBytes = "Write Bytes/sec"
|
VirtualSMBDirectMappedPages float64 `perfdata:"Direct-Mapped Pages"`
|
||||||
virtualSMBReadBytesRDMA = "Read Bytes/sec (RDMA)"
|
VirtualSMBWriteBytesRDMA float64 `perfdata:"Write Bytes/sec (RDMA)"`
|
||||||
virtualSMBReadBytes = "Read Bytes/sec"
|
VirtualSMBWriteBytes float64 `perfdata:"Write Bytes/sec"`
|
||||||
virtualSMBFlushRequests = "Flush Requests/sec"
|
VirtualSMBReadBytesRDMA float64 `perfdata:"Read Bytes/sec (RDMA)"`
|
||||||
virtualSMBWriteRequestsRDMA = "Write Requests/sec (RDMA)"
|
VirtualSMBReadBytes float64 `perfdata:"Read Bytes/sec"`
|
||||||
virtualSMBWriteRequests = "Write Requests/sec"
|
VirtualSMBFlushRequests float64 `perfdata:"Flush Requests/sec"`
|
||||||
virtualSMBReadRequestsRDMA = "Read Requests/sec (RDMA)"
|
VirtualSMBWriteRequestsRDMA float64 `perfdata:"Write Requests/sec (RDMA)"`
|
||||||
virtualSMBReadRequests = "Read Requests/sec"
|
VirtualSMBWriteRequests float64 `perfdata:"Write Requests/sec"`
|
||||||
virtualSMBCurrentPendingRequests = "Current Pending Requests"
|
VirtualSMBReadRequestsRDMA float64 `perfdata:"Read Requests/sec (RDMA)"`
|
||||||
virtualSMBCurrentOpenFileCount = "Current Open File Count"
|
VirtualSMBReadRequests float64 `perfdata:"Read Requests/sec"`
|
||||||
virtualSMBTreeConnectCount = "Tree Connect Count"
|
VirtualSMBCurrentPendingRequests float64 `perfdata:"Current Pending Requests"`
|
||||||
virtualSMBRequests = "Requests/sec"
|
VirtualSMBCurrentOpenFileCount float64 `perfdata:"Current Open File Count"`
|
||||||
virtualSMBSentBytes = "Sent Bytes/sec"
|
VirtualSMBTreeConnectCount float64 `perfdata:"Tree Connect Count"`
|
||||||
virtualSMBReceivedBytes = "Received Bytes/sec"
|
VirtualSMBRequests float64 `perfdata:"Requests/sec"`
|
||||||
)
|
VirtualSMBSentBytes float64 `perfdata:"Sent Bytes/sec"`
|
||||||
|
VirtualSMBReceivedBytes float64 `perfdata:"Received Bytes/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualSMB() error {
|
func (c *Collector) buildVirtualSMB() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualSMB, err = perfdata.NewCollector("Hyper-V Virtual SMB", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualSMB, err = pdh.NewCollector[perfDataCounterValuesVirtualSMB](pdh.CounterTypeRaw, "Hyper-V Virtual SMB", pdh.InstancesAll)
|
||||||
virtualSMBDirectMappedSections,
|
|
||||||
virtualSMBDirectMappedPages,
|
|
||||||
virtualSMBWriteBytesRDMA,
|
|
||||||
virtualSMBWriteBytes,
|
|
||||||
virtualSMBReadBytesRDMA,
|
|
||||||
virtualSMBReadBytes,
|
|
||||||
virtualSMBFlushRequests,
|
|
||||||
virtualSMBWriteRequestsRDMA,
|
|
||||||
virtualSMBWriteRequests,
|
|
||||||
virtualSMBReadRequestsRDMA,
|
|
||||||
virtualSMBReadRequests,
|
|
||||||
virtualSMBCurrentPendingRequests,
|
|
||||||
virtualSMBCurrentOpenFileCount,
|
|
||||||
virtualSMBTreeConnectCount,
|
|
||||||
virtualSMBRequests,
|
|
||||||
virtualSMBSentBytes,
|
|
||||||
virtualSMBReceivedBytes,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual SMB collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual SMB collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -199,129 +184,129 @@ func (c *Collector) buildVirtualSMB() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualSMB(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualSMB(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualSMB.Collect()
|
err := c.perfDataCollectorVirtualSMB.Collect(&c.perfDataObjectVirtualSMB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual SMB metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual SMB metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, smbData := range data {
|
for _, data := range c.perfDataObjectVirtualSMB {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBDirectMappedSections,
|
c.virtualSMBDirectMappedSections,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
smbData[virtualSMBDirectMappedSections].FirstValue,
|
data.VirtualSMBDirectMappedSections,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBDirectMappedPages,
|
c.virtualSMBDirectMappedPages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
smbData[virtualSMBDirectMappedPages].FirstValue,
|
data.VirtualSMBDirectMappedPages,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBWriteBytesRDMA,
|
c.virtualSMBWriteBytesRDMA,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBWriteBytesRDMA].FirstValue,
|
data.VirtualSMBWriteBytesRDMA,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBWriteBytes,
|
c.virtualSMBWriteBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBWriteBytes].FirstValue,
|
data.VirtualSMBWriteBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBReadBytesRDMA,
|
c.virtualSMBReadBytesRDMA,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBReadBytesRDMA].FirstValue,
|
data.VirtualSMBReadBytesRDMA,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBReadBytes,
|
c.virtualSMBReadBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBReadBytes].FirstValue,
|
data.VirtualSMBReadBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBFlushRequests,
|
c.virtualSMBFlushRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBFlushRequests].FirstValue,
|
data.VirtualSMBFlushRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBWriteRequestsRDMA,
|
c.virtualSMBWriteRequestsRDMA,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBWriteRequestsRDMA].FirstValue,
|
data.VirtualSMBWriteRequestsRDMA,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBWriteRequests,
|
c.virtualSMBWriteRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBWriteRequests].FirstValue,
|
data.VirtualSMBWriteRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBReadRequestsRDMA,
|
c.virtualSMBReadRequestsRDMA,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBReadRequestsRDMA].FirstValue,
|
data.VirtualSMBReadRequestsRDMA,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBReadRequests,
|
c.virtualSMBReadRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBReadRequests].FirstValue,
|
data.VirtualSMBReadRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBCurrentPendingRequests,
|
c.virtualSMBCurrentPendingRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
smbData[virtualSMBCurrentPendingRequests].FirstValue,
|
data.VirtualSMBCurrentPendingRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBCurrentOpenFileCount,
|
c.virtualSMBCurrentOpenFileCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
smbData[virtualSMBCurrentOpenFileCount].FirstValue,
|
data.VirtualSMBCurrentOpenFileCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBTreeConnectCount,
|
c.virtualSMBTreeConnectCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
smbData[virtualSMBTreeConnectCount].FirstValue,
|
data.VirtualSMBTreeConnectCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBRequests,
|
c.virtualSMBRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBRequests].FirstValue,
|
data.VirtualSMBRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBSentBytes,
|
c.virtualSMBSentBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBSentBytes].FirstValue,
|
data.VirtualSMBSentBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSMBReceivedBytes,
|
c.virtualSMBReceivedBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
smbData[virtualSMBReceivedBytes].FirstValue,
|
data.VirtualSMBReceivedBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hyper-V Virtual Storage Device metrics
|
// Hyper-V Virtual Storage Device metrics
|
||||||
type collectorVirtualStorageDevice struct {
|
type collectorVirtualStorageDevice struct {
|
||||||
perfDataCollectorVirtualStorageDevice *perfdata.Collector
|
perfDataCollectorVirtualStorageDevice *pdh.Collector
|
||||||
|
perfDataObjectVirtualStorageDevice []perfDataCounterValuesVirtualStorageDevice
|
||||||
|
|
||||||
virtualStorageDeviceErrorCount *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Error Count
|
virtualStorageDeviceErrorCount *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Error Count
|
||||||
virtualStorageDeviceQueueLength *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Queue Length
|
virtualStorageDeviceQueueLength *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\Queue Length
|
||||||
@@ -41,38 +42,27 @@ type collectorVirtualStorageDevice struct {
|
|||||||
virtualStorageDeviceIOQuotaReplenishmentRate *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\IO Quota Replenishment Rate
|
virtualStorageDeviceIOQuotaReplenishmentRate *prometheus.Desc // \Hyper-V Virtual Storage Device(*)\IO Quota Replenishment Rate
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualStorageDevice struct {
|
||||||
virtualStorageDeviceErrorCount = "Error Count"
|
Name string
|
||||||
virtualStorageDeviceQueueLength = "Queue Length"
|
|
||||||
virtualStorageDeviceReadBytes = "Read Bytes/sec"
|
VirtualStorageDeviceErrorCount float64 `perfdata:"Error Count"`
|
||||||
virtualStorageDeviceReadOperations = "Read Count"
|
VirtualStorageDeviceQueueLength float64 `perfdata:"Queue Length"`
|
||||||
virtualStorageDeviceWriteBytes = "Write Bytes/sec"
|
VirtualStorageDeviceReadBytes float64 `perfdata:"Read Bytes/sec"`
|
||||||
virtualStorageDeviceWriteOperations = "Write Count"
|
VirtualStorageDeviceReadOperations float64 `perfdata:"Read Count"`
|
||||||
virtualStorageDeviceLatency = "Latency"
|
VirtualStorageDeviceWriteBytes float64 `perfdata:"Write Bytes/sec"`
|
||||||
virtualStorageDeviceThroughput = "Throughput"
|
VirtualStorageDeviceWriteOperations float64 `perfdata:"Write Count"`
|
||||||
virtualStorageDeviceNormalizedThroughput = "Normalized Throughput"
|
VirtualStorageDeviceLatency float64 `perfdata:"Latency"`
|
||||||
virtualStorageDeviceLowerQueueLength = "Lower Queue Length"
|
VirtualStorageDeviceThroughput float64 `perfdata:"Throughput"`
|
||||||
virtualStorageDeviceLowerLatency = "Lower Latency"
|
VirtualStorageDeviceNormalizedThroughput float64 `perfdata:"Normalized Throughput"`
|
||||||
virtualStorageDeviceIOQuotaReplenishmentRate = "IO Quota Replenishment Rate"
|
VirtualStorageDeviceLowerQueueLength float64 `perfdata:"Lower Queue Length"`
|
||||||
)
|
VirtualStorageDeviceLowerLatency float64 `perfdata:"Lower Latency"`
|
||||||
|
VirtualStorageDeviceIOQuotaReplenishmentRate float64 `perfdata:"IO Quota Replenishment Rate"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualStorageDevice() error {
|
func (c *Collector) buildVirtualStorageDevice() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualStorageDevice, err = perfdata.NewCollector("Hyper-V Virtual Storage Device", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualStorageDevice, err = pdh.NewCollector[perfDataCounterValuesVirtualStorageDevice](pdh.CounterTypeRaw, "Hyper-V Virtual Storage Device", pdh.InstancesAll)
|
||||||
virtualStorageDeviceErrorCount,
|
|
||||||
virtualStorageDeviceQueueLength,
|
|
||||||
virtualStorageDeviceReadBytes,
|
|
||||||
virtualStorageDeviceReadOperations,
|
|
||||||
virtualStorageDeviceWriteBytes,
|
|
||||||
virtualStorageDeviceWriteOperations,
|
|
||||||
virtualStorageDeviceLatency,
|
|
||||||
virtualStorageDeviceThroughput,
|
|
||||||
virtualStorageDeviceNormalizedThroughput,
|
|
||||||
virtualStorageDeviceLowerQueueLength,
|
|
||||||
virtualStorageDeviceLowerLatency,
|
|
||||||
virtualStorageDeviceIOQuotaReplenishmentRate,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Storage Device collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Storage Device collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -154,94 +144,94 @@ func (c *Collector) buildVirtualStorageDevice() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualStorageDevice(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualStorageDevice(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualStorageDevice.Collect()
|
err := c.perfDataCollectorVirtualStorageDevice.Collect(&c.perfDataObjectVirtualStorageDevice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual Storage Device metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual Storage Device metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, device := range data {
|
for _, data := range c.perfDataObjectVirtualStorageDevice {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceErrorCount,
|
c.virtualStorageDeviceErrorCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
device[virtualStorageDeviceErrorCount].FirstValue,
|
data.VirtualStorageDeviceErrorCount,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceQueueLength,
|
c.virtualStorageDeviceQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceQueueLength].FirstValue,
|
data.VirtualStorageDeviceQueueLength,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceReadBytes,
|
c.virtualStorageDeviceReadBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
device[virtualStorageDeviceReadBytes].FirstValue,
|
data.VirtualStorageDeviceReadBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceReadOperations,
|
c.virtualStorageDeviceReadOperations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
device[virtualStorageDeviceReadOperations].FirstValue,
|
data.VirtualStorageDeviceReadOperations,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceWriteBytes,
|
c.virtualStorageDeviceWriteBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
device[virtualStorageDeviceWriteBytes].FirstValue,
|
data.VirtualStorageDeviceWriteBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceWriteOperations,
|
c.virtualStorageDeviceWriteOperations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
device[virtualStorageDeviceWriteOperations].FirstValue,
|
data.VirtualStorageDeviceWriteOperations,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceLatency,
|
c.virtualStorageDeviceLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceLatency].FirstValue,
|
data.VirtualStorageDeviceLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceThroughput,
|
c.virtualStorageDeviceThroughput,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceThroughput].FirstValue,
|
data.VirtualStorageDeviceThroughput,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceNormalizedThroughput,
|
c.virtualStorageDeviceNormalizedThroughput,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceNormalizedThroughput].FirstValue,
|
data.VirtualStorageDeviceNormalizedThroughput,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceLowerQueueLength,
|
c.virtualStorageDeviceLowerQueueLength,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceLowerQueueLength].FirstValue,
|
data.VirtualStorageDeviceLowerQueueLength,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceLowerLatency,
|
c.virtualStorageDeviceLowerLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceLowerLatency].FirstValue,
|
data.VirtualStorageDeviceLowerLatency,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualStorageDeviceIOQuotaReplenishmentRate,
|
c.virtualStorageDeviceIOQuotaReplenishmentRate,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
device[virtualStorageDeviceIOQuotaReplenishmentRate].FirstValue,
|
data.VirtualStorageDeviceIOQuotaReplenishmentRate,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,16 @@ package hyperv
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// collectorVirtualMachineHealthSummary Hyper-V Virtual Switch Summary metrics
|
// collectorVirtualMachineHealthSummary Hyper-V Virtual Switch Summary metrics
|
||||||
type collectorVirtualSwitch struct {
|
type collectorVirtualSwitch struct {
|
||||||
perfDataCollectorVirtualSwitch *perfdata.Collector
|
perfDataCollectorVirtualSwitch *pdh.Collector
|
||||||
|
perfDataObjectVirtualSwitch []perfDataCounterValuesVirtualSwitch
|
||||||
|
|
||||||
virtualSwitchBroadcastPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Received/sec
|
virtualSwitchBroadcastPacketsReceived *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Received/sec
|
||||||
virtualSwitchBroadcastPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Sent/sec
|
virtualSwitchBroadcastPacketsSent *prometheus.Desc // \Hyper-V Virtual Switch(*)\Broadcast Packets Sent/sec
|
||||||
virtualSwitchBytes *prometheus.Desc // \Hyper-V Virtual Switch(*)\Bytes/sec
|
virtualSwitchBytes *prometheus.Desc // \Hyper-V Virtual Switch(*)\Bytes/sec
|
||||||
@@ -49,56 +51,36 @@ type collectorVirtualSwitch struct {
|
|||||||
virtualSwitchPurgedMacAddresses *prometheus.Desc // \Hyper-V Virtual Switch(*)\Purged Mac Addresses
|
virtualSwitchPurgedMacAddresses *prometheus.Desc // \Hyper-V Virtual Switch(*)\Purged Mac Addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesVirtualSwitch struct {
|
||||||
virtualSwitchBroadcastPacketsReceived = "Broadcast Packets Received/sec"
|
Name string
|
||||||
virtualSwitchBroadcastPacketsSent = "Broadcast Packets Sent/sec"
|
|
||||||
virtualSwitchBytes = "Bytes/sec"
|
VirtualSwitchBroadcastPacketsReceived float64 `perfdata:"Broadcast Packets Received/sec"`
|
||||||
virtualSwitchBytesReceived = "Bytes Received/sec"
|
VirtualSwitchBroadcastPacketsSent float64 `perfdata:"Broadcast Packets Sent/sec"`
|
||||||
virtualSwitchBytesSent = "Bytes Sent/sec"
|
VirtualSwitchBytes float64 `perfdata:"Bytes/sec"`
|
||||||
virtualSwitchDirectedPacketsReceived = "Directed Packets Received/sec"
|
VirtualSwitchBytesReceived float64 `perfdata:"Bytes Received/sec"`
|
||||||
virtualSwitchDirectedPacketsSent = "Directed Packets Sent/sec"
|
VirtualSwitchBytesSent float64 `perfdata:"Bytes Sent/sec"`
|
||||||
virtualSwitchDroppedPacketsIncoming = "Dropped Packets Incoming/sec"
|
VirtualSwitchDirectedPacketsReceived float64 `perfdata:"Directed Packets Received/sec"`
|
||||||
virtualSwitchDroppedPacketsOutgoing = "Dropped Packets Outgoing/sec"
|
VirtualSwitchDirectedPacketsSent float64 `perfdata:"Directed Packets Sent/sec"`
|
||||||
virtualSwitchExtensionsDroppedPacketsIncoming = "Extensions Dropped Packets Incoming/sec"
|
VirtualSwitchDroppedPacketsIncoming float64 `perfdata:"Dropped Packets Incoming/sec"`
|
||||||
virtualSwitchExtensionsDroppedPacketsOutgoing = "Extensions Dropped Packets Outgoing/sec"
|
VirtualSwitchDroppedPacketsOutgoing float64 `perfdata:"Dropped Packets Outgoing/sec"`
|
||||||
virtualSwitchLearnedMacAddresses = "Learned Mac Addresses"
|
VirtualSwitchExtensionsDroppedPacketsIncoming float64 `perfdata:"Extensions Dropped Packets Incoming/sec"`
|
||||||
virtualSwitchMulticastPacketsReceived = "Multicast Packets Received/sec"
|
VirtualSwitchExtensionsDroppedPacketsOutgoing float64 `perfdata:"Extensions Dropped Packets Outgoing/sec"`
|
||||||
virtualSwitchMulticastPacketsSent = "Multicast Packets Sent/sec"
|
VirtualSwitchLearnedMacAddresses float64 `perfdata:"Learned Mac Addresses"`
|
||||||
virtualSwitchNumberOfSendChannelMoves = "Number of Send Channel Moves/sec"
|
VirtualSwitchMulticastPacketsReceived float64 `perfdata:"Multicast Packets Received/sec"`
|
||||||
virtualSwitchNumberOfVMQMoves = "Number of VMQ Moves/sec"
|
VirtualSwitchMulticastPacketsSent float64 `perfdata:"Multicast Packets Sent/sec"`
|
||||||
virtualSwitchPacketsFlooded = "Packets Flooded"
|
VirtualSwitchNumberOfSendChannelMoves float64 `perfdata:"Number of Send Channel Moves/sec"`
|
||||||
virtualSwitchPackets = "Packets/sec"
|
VirtualSwitchNumberOfVMQMoves float64 `perfdata:"Number of VMQ Moves/sec"`
|
||||||
virtualSwitchPacketsReceived = "Packets Received/sec"
|
VirtualSwitchPacketsFlooded float64 `perfdata:"Packets Flooded"`
|
||||||
virtualSwitchPacketsSent = "Packets Sent/sec"
|
VirtualSwitchPackets float64 `perfdata:"Packets/sec"`
|
||||||
virtualSwitchPurgedMacAddresses = "Purged Mac Addresses"
|
VirtualSwitchPacketsReceived float64 `perfdata:"Packets Received/sec"`
|
||||||
)
|
VirtualSwitchPacketsSent float64 `perfdata:"Packets Sent/sec"`
|
||||||
|
VirtualSwitchPurgedMacAddresses float64 `perfdata:"Purged Mac Addresses"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildVirtualSwitch() error {
|
func (c *Collector) buildVirtualSwitch() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorVirtualSwitch, err = perfdata.NewCollector("Hyper-V Virtual Switch", perfdata.InstancesAll, []string{
|
c.perfDataCollectorVirtualSwitch, err = pdh.NewCollector[perfDataCounterValuesVirtualSwitch](pdh.CounterTypeRaw, "Hyper-V Virtual Switch", pdh.InstancesAll)
|
||||||
virtualSwitchBroadcastPacketsReceived,
|
|
||||||
virtualSwitchBroadcastPacketsSent,
|
|
||||||
virtualSwitchBytes,
|
|
||||||
virtualSwitchBytesReceived,
|
|
||||||
virtualSwitchBytesSent,
|
|
||||||
virtualSwitchDirectedPacketsReceived,
|
|
||||||
virtualSwitchDirectedPacketsSent,
|
|
||||||
virtualSwitchDroppedPacketsIncoming,
|
|
||||||
virtualSwitchDroppedPacketsOutgoing,
|
|
||||||
virtualSwitchExtensionsDroppedPacketsIncoming,
|
|
||||||
virtualSwitchExtensionsDroppedPacketsOutgoing,
|
|
||||||
virtualSwitchLearnedMacAddresses,
|
|
||||||
virtualSwitchMulticastPacketsReceived,
|
|
||||||
virtualSwitchMulticastPacketsSent,
|
|
||||||
virtualSwitchNumberOfSendChannelMoves,
|
|
||||||
virtualSwitchNumberOfVMQMoves,
|
|
||||||
virtualSwitchPacketsFlooded,
|
|
||||||
virtualSwitchPackets,
|
|
||||||
virtualSwitchPacketsReceived,
|
|
||||||
virtualSwitchPacketsSent,
|
|
||||||
virtualSwitchPurgedMacAddresses,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Hyper-V Virtual Switch collector: %w", err)
|
return fmt.Errorf("failed to create Hyper-V Virtual Switch collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -234,147 +216,147 @@ func (c *Collector) buildVirtualSwitch() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error {
|
||||||
data, err := c.perfDataCollectorVirtualSwitch.Collect()
|
err := c.perfDataCollectorVirtualSwitch.Collect(&c.perfDataObjectVirtualSwitch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Hyper-V Virtual Switch metrics: %w", err)
|
return fmt.Errorf("failed to collect Hyper-V Virtual Switch metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, switchData := range data {
|
for _, data := range c.perfDataObjectVirtualSwitch {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchBroadcastPacketsReceived,
|
c.virtualSwitchBroadcastPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchBroadcastPacketsReceived].FirstValue,
|
data.VirtualSwitchBroadcastPacketsReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchBroadcastPacketsSent,
|
c.virtualSwitchBroadcastPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchBroadcastPacketsSent].FirstValue,
|
data.VirtualSwitchBroadcastPacketsSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchBytes,
|
c.virtualSwitchBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchBytes].FirstValue,
|
data.VirtualSwitchBytes,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchBytesReceived,
|
c.virtualSwitchBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchBytesReceived].FirstValue,
|
data.VirtualSwitchBytesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchBytesSent,
|
c.virtualSwitchBytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchBytesSent].FirstValue,
|
data.VirtualSwitchBytesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDirectedPacketsReceived,
|
c.virtualSwitchDirectedPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchDirectedPacketsReceived].FirstValue,
|
data.VirtualSwitchDirectedPacketsReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDirectedPacketsSent,
|
c.virtualSwitchDirectedPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchDirectedPacketsSent].FirstValue,
|
data.VirtualSwitchDirectedPacketsSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDroppedPacketsIncoming,
|
c.virtualSwitchDroppedPacketsIncoming,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchDroppedPacketsIncoming].FirstValue,
|
data.VirtualSwitchDroppedPacketsIncoming,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchDroppedPacketsOutgoing,
|
c.virtualSwitchDroppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchDroppedPacketsOutgoing].FirstValue,
|
data.VirtualSwitchDroppedPacketsOutgoing,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchExtensionsDroppedPacketsIncoming,
|
c.virtualSwitchExtensionsDroppedPacketsIncoming,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchExtensionsDroppedPacketsIncoming].FirstValue,
|
data.VirtualSwitchExtensionsDroppedPacketsIncoming,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
|
c.virtualSwitchExtensionsDroppedPacketsOutgoing,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchExtensionsDroppedPacketsOutgoing].FirstValue,
|
data.VirtualSwitchExtensionsDroppedPacketsOutgoing,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchLearnedMacAddresses,
|
c.virtualSwitchLearnedMacAddresses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchLearnedMacAddresses].FirstValue,
|
data.VirtualSwitchLearnedMacAddresses,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchMulticastPacketsReceived,
|
c.virtualSwitchMulticastPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchMulticastPacketsReceived].FirstValue,
|
data.VirtualSwitchMulticastPacketsReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchMulticastPacketsSent,
|
c.virtualSwitchMulticastPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchMulticastPacketsSent].FirstValue,
|
data.VirtualSwitchMulticastPacketsSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchNumberOfSendChannelMoves,
|
c.virtualSwitchNumberOfSendChannelMoves,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchNumberOfSendChannelMoves].FirstValue,
|
data.VirtualSwitchNumberOfSendChannelMoves,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchNumberOfVMQMoves,
|
c.virtualSwitchNumberOfVMQMoves,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchNumberOfVMQMoves].FirstValue,
|
data.VirtualSwitchNumberOfVMQMoves,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPacketsFlooded,
|
c.virtualSwitchPacketsFlooded,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchPacketsFlooded].FirstValue,
|
data.VirtualSwitchPacketsFlooded,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPackets,
|
c.virtualSwitchPackets,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchPackets].FirstValue,
|
data.VirtualSwitchPackets,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPacketsReceived,
|
c.virtualSwitchPacketsReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchPacketsReceived].FirstValue,
|
data.VirtualSwitchPacketsReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPacketsSent,
|
c.virtualSwitchPacketsSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchPacketsSent].FirstValue,
|
data.VirtualSwitchPacketsSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.virtualSwitchPurgedMacAddresses,
|
c.virtualSwitchPurgedMacAddresses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
switchData[virtualSwitchPurgedMacAddresses].FirstValue,
|
data.VirtualSwitchPurgedMacAddresses,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"maps"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
@@ -270,26 +268,36 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type collectorName interface {
|
||||||
|
GetName() string
|
||||||
|
}
|
||||||
|
|
||||||
// deduplicateIISNames deduplicate IIS site names from various IIS perflib objects.
|
// deduplicateIISNames deduplicate IIS site names from various IIS perflib objects.
|
||||||
//
|
//
|
||||||
// E.G. Given the following list of site names, "Site_B" would be
|
// E.G. Given the following list of site names, "Site_B" would be
|
||||||
// discarded, and "Site_B#2" would be kept and presented as "Site_B" in the
|
// discarded, and "Site_B#2" would be kept and presented as "Site_B" in the
|
||||||
// Collector metrics.
|
// Collector metrics.
|
||||||
// [ "Site_A", "Site_B", "Site_C", "Site_B#2" ].
|
// [ "Site_A", "Site_B", "Site_C", "Site_B#2" ].
|
||||||
func deduplicateIISNames(counterValues map[string]map[string]perfdata.CounterValue) {
|
func deduplicateIISNames[T collectorName](counterValues []T) {
|
||||||
services := slices.Collect(maps.Keys(counterValues))
|
indexes := make(map[string]int)
|
||||||
|
|
||||||
// Ensure IIS entry with the highest suffix occurs last
|
// Ensure IIS entry with the highest suffix occurs last
|
||||||
slices.Sort(services)
|
slices.SortFunc(counterValues, func(a, b T) int {
|
||||||
|
return strings.Compare(a.GetName(), b.GetName())
|
||||||
|
})
|
||||||
|
|
||||||
// Use map to deduplicate IIS entries
|
// Use map to deduplicate IIS entries
|
||||||
for _, entry := range services {
|
for index, counterValue := range counterValues {
|
||||||
name := strings.Split(entry, "#")[0]
|
name := strings.Split(counterValue.GetName(), "#")[0]
|
||||||
if name == entry {
|
if name == counterValue.GetName() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
counterValues[name] = counterValues[entry]
|
if originalIndex, ok := indexes[name]; !ok {
|
||||||
delete(counterValues, entry)
|
counterValues[originalIndex] = counterValue
|
||||||
|
counterValues = slices.Delete(counterValues, index, 1)
|
||||||
|
} else {
|
||||||
|
indexes[name] = index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ package iis
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorAppPoolWAS struct {
|
type collectorAppPoolWAS struct {
|
||||||
perfDataCollectorAppPoolWAS *perfdata.Collector
|
perfDataCollectorAppPoolWAS *pdh.Collector
|
||||||
|
perfDataObjectAppPoolWAS []perfDataCounterValuesAppPoolWAS
|
||||||
|
|
||||||
currentApplicationPoolState *prometheus.Desc
|
currentApplicationPoolState *prometheus.Desc
|
||||||
currentApplicationPoolUptime *prometheus.Desc
|
currentApplicationPoolUptime *prometheus.Desc
|
||||||
@@ -40,22 +41,27 @@ type collectorAppPoolWAS struct {
|
|||||||
totalWorkerProcessShutdownFailures *prometheus.Desc
|
totalWorkerProcessShutdownFailures *prometheus.Desc
|
||||||
totalWorkerProcessStartupFailures *prometheus.Desc
|
totalWorkerProcessStartupFailures *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
type perfDataCounterValuesAppPoolWAS struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
const (
|
CurrentApplicationPoolState float64 `perfdata:"Current Application Pool State"`
|
||||||
CurrentApplicationPoolState = "Current Application Pool State"
|
CurrentApplicationPoolUptime float64 `perfdata:"Current Application Pool Uptime"`
|
||||||
CurrentApplicationPoolUptime = "Current Application Pool Uptime"
|
CurrentWorkerProcesses float64 `perfdata:"Current Worker Processes"`
|
||||||
CurrentWorkerProcesses = "Current Worker Processes"
|
MaximumWorkerProcesses float64 `perfdata:"Maximum Worker Processes"`
|
||||||
MaximumWorkerProcesses = "Maximum Worker Processes"
|
RecentWorkerProcessFailures float64 `perfdata:"Recent Worker Process Failures"`
|
||||||
RecentWorkerProcessFailures = "Recent Worker Process Failures"
|
TimeSinceLastWorkerProcessFailure float64 `perfdata:"Time Since Last Worker Process Failure"`
|
||||||
TimeSinceLastWorkerProcessFailure = "Time Since Last Worker Process Failure"
|
TotalApplicationPoolRecycles float64 `perfdata:"Total Application Pool Recycles"`
|
||||||
TotalApplicationPoolRecycles = "Total Application Pool Recycles"
|
TotalApplicationPoolUptime float64 `perfdata:"Total Application Pool Uptime"`
|
||||||
TotalApplicationPoolUptime = "Total Application Pool Uptime"
|
TotalWorkerProcessesCreated float64 `perfdata:"Total Worker Processes Created"`
|
||||||
TotalWorkerProcessesCreated = "Total Worker Processes Created"
|
TotalWorkerProcessFailures float64 `perfdata:"Total Worker Process Failures"`
|
||||||
TotalWorkerProcessFailures = "Total Worker Process Failures"
|
TotalWorkerProcessPingFailures float64 `perfdata:"Total Worker Process Ping Failures"`
|
||||||
TotalWorkerProcessPingFailures = "Total Worker Process Ping Failures"
|
TotalWorkerProcessShutdownFailures float64 `perfdata:"Total Worker Process Shutdown Failures"`
|
||||||
TotalWorkerProcessShutdownFailures = "Total Worker Process Shutdown Failures"
|
TotalWorkerProcessStartupFailures float64 `perfdata:"Total Worker Process Startup Failures"`
|
||||||
TotalWorkerProcessStartupFailures = "Total Worker Process Startup Failures"
|
}
|
||||||
)
|
|
||||||
|
func (p perfDataCounterValuesAppPoolWAS) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
var applicationStates = map[uint32]string{
|
var applicationStates = map[uint32]string{
|
||||||
@@ -71,21 +77,7 @@ var applicationStates = map[uint32]string{
|
|||||||
func (c *Collector) buildAppPoolWAS() error {
|
func (c *Collector) buildAppPoolWAS() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorAppPoolWAS, err = perfdata.NewCollector("APP_POOL_WAS", perfdata.InstancesAll, []string{
|
c.perfDataCollectorAppPoolWAS, err = pdh.NewCollector[perfDataCounterValuesAppPoolWAS](pdh.CounterTypeRaw, "APP_POOL_WAS", pdh.InstancesAll)
|
||||||
CurrentApplicationPoolState,
|
|
||||||
CurrentApplicationPoolUptime,
|
|
||||||
CurrentWorkerProcesses,
|
|
||||||
MaximumWorkerProcesses,
|
|
||||||
RecentWorkerProcessFailures,
|
|
||||||
TimeSinceLastWorkerProcessFailure,
|
|
||||||
TotalApplicationPoolRecycles,
|
|
||||||
TotalApplicationPoolUptime,
|
|
||||||
TotalWorkerProcessesCreated,
|
|
||||||
TotalWorkerProcessFailures,
|
|
||||||
TotalWorkerProcessPingFailures,
|
|
||||||
TotalWorkerProcessShutdownFailures,
|
|
||||||
TotalWorkerProcessStartupFailures,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create APP_POOL_WAS collector: %w", err)
|
return fmt.Errorf("failed to create APP_POOL_WAS collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -174,21 +166,21 @@ func (c *Collector) buildAppPoolWAS() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorAppPoolWAS.Collect()
|
err := c.perfDataCollectorAppPoolWAS.Collect(&c.perfDataObjectAppPoolWAS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
|
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deduplicateIISNames(perfData)
|
deduplicateIISNames(c.perfDataObjectAppPoolWAS)
|
||||||
|
|
||||||
for name, app := range perfData {
|
for _, data := range c.perfDataObjectAppPoolWAS {
|
||||||
if c.config.AppExclude.MatchString(name) || !c.config.AppInclude.MatchString(name) {
|
if c.config.AppExclude.MatchString(data.Name) || !c.config.AppInclude.MatchString(data.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, label := range applicationStates {
|
for key, label := range applicationStates {
|
||||||
isCurrentState := 0.0
|
isCurrentState := 0.0
|
||||||
if key == uint32(app[CurrentApplicationPoolState].FirstValue) {
|
if key == uint32(data.CurrentApplicationPoolState) {
|
||||||
isCurrentState = 1.0
|
isCurrentState = 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +188,7 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
|
|||||||
c.currentApplicationPoolState,
|
c.currentApplicationPoolState,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
isCurrentState,
|
isCurrentState,
|
||||||
name,
|
data.Name,
|
||||||
label,
|
label,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -204,74 +196,74 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentApplicationPoolUptime,
|
c.currentApplicationPoolUptime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[CurrentApplicationPoolUptime].FirstValue,
|
data.CurrentApplicationPoolUptime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.currentWorkerProcesses,
|
c.currentWorkerProcesses,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[CurrentWorkerProcesses].FirstValue,
|
data.CurrentWorkerProcesses,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.maximumWorkerProcesses,
|
c.maximumWorkerProcesses,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[MaximumWorkerProcesses].FirstValue,
|
data.MaximumWorkerProcesses,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.recentWorkerProcessFailures,
|
c.recentWorkerProcessFailures,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[RecentWorkerProcessFailures].FirstValue,
|
data.RecentWorkerProcessFailures,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeSinceLastWorkerProcessFailure,
|
c.timeSinceLastWorkerProcessFailure,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[TimeSinceLastWorkerProcessFailure].FirstValue,
|
data.TimeSinceLastWorkerProcessFailure,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalApplicationPoolRecycles,
|
c.totalApplicationPoolRecycles,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalApplicationPoolRecycles].FirstValue,
|
data.TotalApplicationPoolRecycles,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalApplicationPoolUptime,
|
c.totalApplicationPoolUptime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalApplicationPoolUptime].FirstValue,
|
data.TotalApplicationPoolUptime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessesCreated,
|
c.totalWorkerProcessesCreated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalWorkerProcessesCreated].FirstValue,
|
data.TotalWorkerProcessesCreated,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessFailures,
|
c.totalWorkerProcessFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalWorkerProcessFailures].FirstValue,
|
data.TotalWorkerProcessFailures,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessPingFailures,
|
c.totalWorkerProcessPingFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalWorkerProcessPingFailures].FirstValue,
|
data.TotalWorkerProcessPingFailures,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessShutdownFailures,
|
c.totalWorkerProcessShutdownFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalWorkerProcessShutdownFailures].FirstValue,
|
data.TotalWorkerProcessShutdownFailures,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalWorkerProcessStartupFailures,
|
c.totalWorkerProcessStartupFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[TotalWorkerProcessStartupFailures].FirstValue,
|
data.TotalWorkerProcessStartupFailures,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,3 +25,7 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
testutils.FuncBenchmarkCollector(b, iis.Name, iis.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, iis.Name, iis.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, iis.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,13 +20,16 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorW3SVCW3WP struct {
|
type collectorW3SVCW3WP struct {
|
||||||
w3SVCW3WPPerfDataCollector *perfdata.Collector
|
w3SVCW3WPPerfDataCollector *pdh.Collector
|
||||||
|
w3SVCW3WPPerfDataCollectorV8 *pdh.Collector
|
||||||
|
perfDataObjectW3SVCW3WP []perfDataCounterValuesW3SVCW3WP
|
||||||
|
perfDataObjectW3SVCW3WPV8 []perfDataCounterValuesW3SVCW3WPV8
|
||||||
|
|
||||||
// W3SVC_W3WP
|
// W3SVC_W3WP
|
||||||
w3SVCW3WPThreads *prometheus.Desc
|
w3SVCW3WPThreads *prometheus.Desc
|
||||||
@@ -78,112 +81,85 @@ type collectorW3SVCW3WP struct {
|
|||||||
|
|
||||||
var workerProcessNameExtractor = regexp.MustCompile(`^(\d+)_(.+)$`)
|
var workerProcessNameExtractor = regexp.MustCompile(`^(\d+)_(.+)$`)
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesW3SVCW3WP struct {
|
||||||
w3SVCW3WPThreads = "Active Threads Count"
|
Name string
|
||||||
w3SVCW3WPMaximumThreads = "Maximum Threads Count"
|
|
||||||
|
|
||||||
w3SVCW3WPRequestsTotal = "Total HTTP Requests Served"
|
W3SVCW3WPThreads float64 `perfdata:"Active Threads Count"`
|
||||||
w3SVCW3WPRequestsActive = "Active Requests"
|
W3SVCW3WPMaximumThreads float64 `perfdata:"Maximum Threads Count"`
|
||||||
|
|
||||||
w3SVCW3WPActiveFlushedEntries = "Active Flushed Entries"
|
W3SVCW3WPRequestsTotal float64 `perfdata:"Total HTTP Requests Served"`
|
||||||
|
W3SVCW3WPRequestsActive float64 `perfdata:"Active Requests"`
|
||||||
|
|
||||||
w3SVCW3WPCurrentFileCacheMemoryUsage = "Current File Cache Memory Usage"
|
W3SVCW3WPActiveFlushedEntries float64 `perfdata:"Active Flushed Entries"`
|
||||||
w3SVCW3WPMaximumFileCacheMemoryUsage = "Maximum File Cache Memory Usage"
|
|
||||||
w3SVCW3WPFileCacheFlushesTotal = "File Cache Flushes"
|
|
||||||
w3SVCW3WPFileCacheHitsTotal = "File Cache Hits"
|
|
||||||
w3SVCW3WPFileCacheMissesTotal = "File Cache Misses"
|
|
||||||
w3SVCW3WPFilesCached = "Current Files Cached"
|
|
||||||
w3SVCW3WPFilesCachedTotal = "Total Files Cached"
|
|
||||||
w3SVCW3WPFilesFlushedTotal = "Total Flushed Files"
|
|
||||||
|
|
||||||
w3SVCW3WPURICacheFlushesTotal = "Total Flushed URIs"
|
W3SVCW3WPCurrentFileCacheMemoryUsage float64 `perfdata:"Current File Cache Memory Usage"`
|
||||||
w3SVCW3WPURICacheHitsTotal = "URI Cache Hits"
|
W3SVCW3WPMaximumFileCacheMemoryUsage float64 `perfdata:"Maximum File Cache Memory Usage"`
|
||||||
w3SVCW3WPURICacheMissesTotal = "URI Cache Misses"
|
W3SVCW3WPFileCacheFlushesTotal float64 `perfdata:"File Cache Flushes"`
|
||||||
w3SVCW3WPURIsCached = "Current URIs Cached"
|
W3SVCW3WPFileCacheHitsTotal float64 `perfdata:"File Cache Hits"`
|
||||||
w3SVCW3WPURIsCachedTotal = "Total URIs Cached"
|
W3SVCW3WPFileCacheMissesTotal float64 `perfdata:"File Cache Misses"`
|
||||||
w3SVCW3WPURIsFlushedTotal = "Total Flushed URIs"
|
W3SVCW3WPFilesCached float64 `perfdata:"Current Files Cached"`
|
||||||
|
W3SVCW3WPFilesCachedTotal float64 `perfdata:"Total Files Cached"`
|
||||||
|
W3SVCW3WPFilesFlushedTotal float64 `perfdata:"Total Flushed Files"`
|
||||||
|
|
||||||
w3SVCW3WPMetaDataCacheHits = "Metadata Cache Hits"
|
W3SVCW3WPURICacheFlushesTotal float64 `perfdata:"Total Flushed URIs"`
|
||||||
w3SVCW3WPMetaDataCacheMisses = "Metadata Cache Misses"
|
W3SVCW3WPURICacheHitsTotal float64 `perfdata:"URI Cache Hits"`
|
||||||
w3SVCW3WPMetadataCached = "Current Metadata Cached"
|
W3SVCW3WPURICacheMissesTotal float64 `perfdata:"URI Cache Misses"`
|
||||||
w3SVCW3WPMetadataCacheFlushes = "Metadata Cache Flushes"
|
W3SVCW3WPURIsCached float64 `perfdata:"Current URIs Cached"`
|
||||||
w3SVCW3WPMetadataCachedTotal = "Total Metadata Cached"
|
W3SVCW3WPURIsCachedTotal float64 `perfdata:"Total URIs Cached"`
|
||||||
w3SVCW3WPMetadataFlushedTotal = "Total Flushed Metadata"
|
W3SVCW3WPURIsFlushedTotal float64 `perfdata:"Total Flushed URIs"`
|
||||||
|
|
||||||
w3SVCW3WPOutputCacheActiveFlushedItems = "Output Cache Current Flushed Items"
|
W3SVCW3WPMetaDataCacheHits float64 `perfdata:"Metadata Cache Hits"`
|
||||||
w3SVCW3WPOutputCacheItems = "Output Cache Current Items"
|
W3SVCW3WPMetaDataCacheMisses float64 `perfdata:"Metadata Cache Misses"`
|
||||||
w3SVCW3WPOutputCacheMemoryUsage = "Output Cache Current Memory Usage"
|
W3SVCW3WPMetadataCached float64 `perfdata:"Current Metadata Cached"`
|
||||||
w3SVCW3WPOutputCacheHitsTotal = "Output Cache Total Hits"
|
W3SVCW3WPMetadataCacheFlushes float64 `perfdata:"Metadata Cache Flushes"`
|
||||||
w3SVCW3WPOutputCacheMissesTotal = "Output Cache Total Misses"
|
W3SVCW3WPMetadataCachedTotal float64 `perfdata:"Total Metadata Cached"`
|
||||||
w3SVCW3WPOutputCacheFlushedItemsTotal = "Output Cache Total Flushed Items"
|
W3SVCW3WPMetadataFlushedTotal float64 `perfdata:"Total Flushed Metadata"`
|
||||||
w3SVCW3WPOutputCacheFlushesTotal = "Output Cache Total Flushes"
|
|
||||||
|
W3SVCW3WPOutputCacheActiveFlushedItems float64 `perfdata:"Output Cache Current Flushed Items"`
|
||||||
|
W3SVCW3WPOutputCacheItems float64 `perfdata:"Output Cache Current Items"`
|
||||||
|
W3SVCW3WPOutputCacheMemoryUsage float64 `perfdata:"Output Cache Current Memory Usage"`
|
||||||
|
W3SVCW3WPOutputCacheHitsTotal float64 `perfdata:"Output Cache Total Hits"`
|
||||||
|
W3SVCW3WPOutputCacheMissesTotal float64 `perfdata:"Output Cache Total Misses"`
|
||||||
|
W3SVCW3WPOutputCacheFlushedItemsTotal float64 `perfdata:"Output Cache Total Flushed Items"`
|
||||||
|
W3SVCW3WPOutputCacheFlushesTotal float64 `perfdata:"Output Cache Total Flushes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p perfDataCounterValuesW3SVCW3WP) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesW3SVCW3WPV8 struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
// IIS8
|
// IIS8
|
||||||
w3SVCW3WPRequestErrors500 = "% 500 HTTP Response Sent"
|
W3SVCW3WPRequestErrors500 float64 `perfdata:"% 500 HTTP Response Sent"`
|
||||||
w3SVCW3WPRequestErrors404 = "% 404 HTTP Response Sent"
|
W3SVCW3WPRequestErrors404 float64 `perfdata:"% 404 HTTP Response Sent"`
|
||||||
w3SVCW3WPRequestErrors403 = "% 403 HTTP Response Sent"
|
W3SVCW3WPRequestErrors403 float64 `perfdata:"% 403 HTTP Response Sent"`
|
||||||
w3SVCW3WPRequestErrors401 = "% 401 HTTP Response Sent"
|
W3SVCW3WPRequestErrors401 float64 `perfdata:"% 401 HTTP Response Sent"`
|
||||||
|
|
||||||
w3SVCW3WPWebSocketRequestsActive = "WebSocket Active Requests"
|
W3SVCW3WPWebSocketRequestsActive float64 `perfdata:"WebSocket Active Requests"`
|
||||||
w3SVCW3WPWebSocketConnectionAttempts = "WebSocket Connection Attempts / Sec"
|
W3SVCW3WPWebSocketConnectionAttempts float64 `perfdata:"WebSocket Connection Attempts / Sec"`
|
||||||
w3SVCW3WPWebSocketConnectionsAccepted = "WebSocket Connections Accepted / Sec"
|
W3SVCW3WPWebSocketConnectionsAccepted float64 `perfdata:"WebSocket Connections Accepted / Sec"`
|
||||||
w3SVCW3WPWebSocketConnectionsRejected = "WebSocket Connections Rejected / Sec"
|
W3SVCW3WPWebSocketConnectionsRejected float64 `perfdata:"WebSocket Connections Rejected / Sec"`
|
||||||
)
|
}
|
||||||
|
|
||||||
|
func (p perfDataCounterValuesW3SVCW3WPV8) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildW3SVCW3WP() error {
|
func (c *Collector) buildW3SVCW3WP() error {
|
||||||
counters := []string{
|
var err error
|
||||||
w3SVCW3WPThreads,
|
|
||||||
w3SVCW3WPMaximumThreads,
|
c.w3SVCW3WPPerfDataCollector, err = pdh.NewCollector[perfDataCounterValuesW3SVCW3WP](pdh.CounterTypeRaw, "W3SVC_W3WP", pdh.InstancesAll)
|
||||||
w3SVCW3WPRequestsTotal,
|
if err != nil {
|
||||||
w3SVCW3WPRequestsActive,
|
return fmt.Errorf("failed to create W3SVC_W3WP collector: %w", err)
|
||||||
w3SVCW3WPActiveFlushedEntries,
|
|
||||||
w3SVCW3WPCurrentFileCacheMemoryUsage,
|
|
||||||
w3SVCW3WPMaximumFileCacheMemoryUsage,
|
|
||||||
w3SVCW3WPFileCacheFlushesTotal,
|
|
||||||
w3SVCW3WPFileCacheHitsTotal,
|
|
||||||
w3SVCW3WPFileCacheMissesTotal,
|
|
||||||
w3SVCW3WPFilesCached,
|
|
||||||
w3SVCW3WPFilesCachedTotal,
|
|
||||||
w3SVCW3WPFilesFlushedTotal,
|
|
||||||
w3SVCW3WPURICacheFlushesTotal,
|
|
||||||
w3SVCW3WPURICacheHitsTotal,
|
|
||||||
w3SVCW3WPURICacheMissesTotal,
|
|
||||||
w3SVCW3WPURIsCached,
|
|
||||||
w3SVCW3WPURIsCachedTotal,
|
|
||||||
w3SVCW3WPURIsFlushedTotal,
|
|
||||||
w3SVCW3WPMetaDataCacheHits,
|
|
||||||
w3SVCW3WPMetaDataCacheMisses,
|
|
||||||
w3SVCW3WPMetadataCached,
|
|
||||||
w3SVCW3WPMetadataCacheFlushes,
|
|
||||||
w3SVCW3WPMetadataCachedTotal,
|
|
||||||
w3SVCW3WPMetadataFlushedTotal,
|
|
||||||
w3SVCW3WPOutputCacheActiveFlushedItems,
|
|
||||||
w3SVCW3WPOutputCacheItems,
|
|
||||||
w3SVCW3WPOutputCacheMemoryUsage,
|
|
||||||
w3SVCW3WPOutputCacheHitsTotal,
|
|
||||||
w3SVCW3WPOutputCacheMissesTotal,
|
|
||||||
w3SVCW3WPOutputCacheFlushedItemsTotal,
|
|
||||||
w3SVCW3WPOutputCacheFlushesTotal,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.iisVersion.major >= 8 {
|
if c.iisVersion.major >= 8 {
|
||||||
counters = append(counters, []string{
|
c.w3SVCW3WPPerfDataCollectorV8, err = pdh.NewCollector[perfDataCounterValuesW3SVCW3WPV8](pdh.CounterTypeRaw, "W3SVC_W3WP", pdh.InstancesAll)
|
||||||
w3SVCW3WPRequestErrors500,
|
if err != nil {
|
||||||
w3SVCW3WPRequestErrors404,
|
return fmt.Errorf("failed to create W3SVC_W3WP collector: %w", err)
|
||||||
w3SVCW3WPRequestErrors403,
|
}
|
||||||
w3SVCW3WPRequestErrors401,
|
|
||||||
w3SVCW3WPWebSocketRequestsActive,
|
|
||||||
w3SVCW3WPWebSocketConnectionAttempts,
|
|
||||||
w3SVCW3WPWebSocketConnectionsAccepted,
|
|
||||||
w3SVCW3WPWebSocketConnectionsRejected,
|
|
||||||
}...)
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
|
|
||||||
c.w3SVCW3WPPerfDataCollector, err = perfdata.NewCollector("W3SVC_W3WP", perfdata.InstancesAll, counters)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to create W3SVC_W3WP collector: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// W3SVC_W3WP
|
// W3SVC_W3WP
|
||||||
@@ -415,22 +391,128 @@ func (c *Collector) buildW3SVCW3WP() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.w3SVCW3WPPerfDataCollector.Collect()
|
if err := c.collectW3SVCW3WPv7(ch); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.iisVersion.major >= 8 {
|
||||||
|
if err := c.collectW3SVCW3WPv8(ch); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error {
|
||||||
|
err := c.w3SVCW3WPPerfDataCollectorV8.Collect(&c.perfDataObjectW3SVCW3WPV8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
|
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deduplicateIISNames(perfData)
|
deduplicateIISNames(c.perfDataObjectW3SVCW3WPV8)
|
||||||
|
|
||||||
for name, app := range perfData {
|
for _, data := range c.perfDataObjectW3SVCW3WPV8 {
|
||||||
if c.config.AppExclude.MatchString(name) || !c.config.AppInclude.MatchString(name) {
|
if c.config.AppExclude.MatchString(data.Name) || !c.config.AppInclude.MatchString(data.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the apppool name from the format <PID>_<NAME>
|
// Extract the apppool name from the format <PID>_<NAME>
|
||||||
pid := workerProcessNameExtractor.ReplaceAllString(name, "$1")
|
pid := workerProcessNameExtractor.ReplaceAllString(data.Name, "$1")
|
||||||
|
|
||||||
name := workerProcessNameExtractor.ReplaceAllString(name, "$2")
|
name := workerProcessNameExtractor.ReplaceAllString(data.Name, "$2")
|
||||||
|
if name == "" || c.config.AppExclude.MatchString(name) ||
|
||||||
|
!c.config.AppInclude.MatchString(name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Duplicate instances are suffixed # with an index number. These should be ignored
|
||||||
|
if strings.Contains(name, "#") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPRequestErrors401,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
"401",
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPRequestErrors403,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
"403",
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPRequestErrors404,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
"404",
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPRequestErrorsTotal,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPRequestErrors500,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
"500",
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPWebSocketRequestsActive,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPWebSocketRequestsActive,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPWebSocketConnectionAttempts,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPWebSocketConnectionAttempts,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPWebSocketConnectionsAccepted,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPWebSocketConnectionsAccepted,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.w3SVCW3WPWebSocketConnectionsRejected,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
data.W3SVCW3WPWebSocketConnectionsRejected,
|
||||||
|
name,
|
||||||
|
pid,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error {
|
||||||
|
err := c.w3SVCW3WPPerfDataCollector.Collect(&c.perfDataObjectW3SVCW3WP)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to collect APP_POOL_WAS metrics: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
deduplicateIISNames(c.perfDataObjectW3SVCW3WP)
|
||||||
|
|
||||||
|
for _, data := range c.perfDataObjectW3SVCW3WP {
|
||||||
|
if c.config.AppExclude.MatchString(data.Name) || !c.config.AppInclude.MatchString(data.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the apppool name from the format <PID>_<NAME>
|
||||||
|
pid := workerProcessNameExtractor.ReplaceAllString(data.Name, "$1")
|
||||||
|
|
||||||
|
name := workerProcessNameExtractor.ReplaceAllString(data.Name, "$2")
|
||||||
if name == "" || c.config.AppExclude.MatchString(name) ||
|
if name == "" || c.config.AppExclude.MatchString(name) ||
|
||||||
!c.config.AppInclude.MatchString(name) {
|
!c.config.AppInclude.MatchString(name) {
|
||||||
continue
|
continue
|
||||||
@@ -444,7 +526,7 @@ func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPThreads,
|
c.w3SVCW3WPThreads,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPThreads].FirstValue,
|
data.W3SVCW3WPThreads,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
"busy",
|
"busy",
|
||||||
@@ -452,283 +534,220 @@ func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMaximumThreads,
|
c.w3SVCW3WPMaximumThreads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMaximumThreads].FirstValue,
|
data.W3SVCW3WPMaximumThreads,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestsTotal,
|
c.w3SVCW3WPRequestsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPRequestsTotal].FirstValue,
|
data.W3SVCW3WPRequestsTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPRequestsActive,
|
c.w3SVCW3WPRequestsActive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPRequestsActive].FirstValue,
|
data.W3SVCW3WPRequestsActive,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPActiveFlushedEntries,
|
c.w3SVCW3WPActiveFlushedEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPActiveFlushedEntries].FirstValue,
|
data.W3SVCW3WPActiveFlushedEntries,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPCurrentFileCacheMemoryUsage,
|
c.w3SVCW3WPCurrentFileCacheMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPCurrentFileCacheMemoryUsage].FirstValue,
|
data.W3SVCW3WPCurrentFileCacheMemoryUsage,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMaximumFileCacheMemoryUsage,
|
c.w3SVCW3WPMaximumFileCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMaximumFileCacheMemoryUsage].FirstValue,
|
data.W3SVCW3WPMaximumFileCacheMemoryUsage,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheFlushesTotal,
|
c.w3SVCW3WPFileCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPFileCacheFlushesTotal].FirstValue,
|
data.W3SVCW3WPFileCacheFlushesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheQueriesTotal,
|
c.w3SVCW3WPFileCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPFileCacheHitsTotal].FirstValue+app[w3SVCW3WPFileCacheMissesTotal].FirstValue,
|
data.W3SVCW3WPFileCacheHitsTotal+data.W3SVCW3WPFileCacheMissesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFileCacheHitsTotal,
|
c.w3SVCW3WPFileCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPFileCacheHitsTotal].FirstValue,
|
data.W3SVCW3WPFileCacheHitsTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesCached,
|
c.w3SVCW3WPFilesCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPFilesCached].FirstValue,
|
data.W3SVCW3WPFilesCached,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesCachedTotal,
|
c.w3SVCW3WPFilesCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPFilesCachedTotal].FirstValue,
|
data.W3SVCW3WPFilesCachedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPFilesFlushedTotal,
|
c.w3SVCW3WPFilesFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPFilesFlushedTotal].FirstValue,
|
data.W3SVCW3WPFilesFlushedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheFlushesTotal,
|
c.w3SVCW3WPURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPURICacheFlushesTotal].FirstValue,
|
data.W3SVCW3WPURICacheFlushesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheQueriesTotal,
|
c.w3SVCW3WPURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPURICacheHitsTotal].FirstValue+app[w3SVCW3WPURICacheMissesTotal].FirstValue,
|
data.W3SVCW3WPURICacheHitsTotal+data.W3SVCW3WPURICacheMissesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURICacheHitsTotal,
|
c.w3SVCW3WPURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPURICacheHitsTotal].FirstValue,
|
data.W3SVCW3WPURICacheHitsTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsCached,
|
c.w3SVCW3WPURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPURIsCached].FirstValue,
|
data.W3SVCW3WPURIsCached,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsCachedTotal,
|
c.w3SVCW3WPURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPURIsCachedTotal].FirstValue,
|
data.W3SVCW3WPURIsCachedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPURIsFlushedTotal,
|
c.w3SVCW3WPURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPURIsFlushedTotal].FirstValue,
|
data.W3SVCW3WPURIsFlushedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCached,
|
c.w3SVCW3WPMetadataCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[w3SVCW3WPMetadataCached].FirstValue,
|
data.W3SVCW3WPMetadataCached,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheFlushes,
|
c.w3SVCW3WPMetadataCacheFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMetadataCacheFlushes].FirstValue,
|
data.W3SVCW3WPMetadataCacheFlushes,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheQueriesTotal,
|
c.w3SVCW3WPMetadataCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMetaDataCacheHits].FirstValue+app[w3SVCW3WPMetaDataCacheMisses].FirstValue,
|
data.W3SVCW3WPMetaDataCacheHits+data.W3SVCW3WPMetaDataCacheMisses,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCacheHitsTotal,
|
c.w3SVCW3WPMetadataCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMetaDataCacheHits].FirstValue,
|
data.W3SVCW3WPMetaDataCacheHits,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataCachedTotal,
|
c.w3SVCW3WPMetadataCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMetadataCachedTotal].FirstValue,
|
data.W3SVCW3WPMetadataCachedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPMetadataFlushedTotal,
|
c.w3SVCW3WPMetadataFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPMetadataFlushedTotal].FirstValue,
|
data.W3SVCW3WPMetadataFlushedTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheActiveFlushedItems,
|
c.w3SVCW3WPOutputCacheActiveFlushedItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheActiveFlushedItems].FirstValue,
|
data.W3SVCW3WPOutputCacheActiveFlushedItems,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheItems,
|
c.w3SVCW3WPOutputCacheItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheItems].FirstValue,
|
data.W3SVCW3WPOutputCacheItems,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheMemoryUsage,
|
c.w3SVCW3WPOutputCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheMemoryUsage].FirstValue,
|
data.W3SVCW3WPOutputCacheMemoryUsage,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheQueriesTotal,
|
c.w3SVCW3WPOutputCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheHitsTotal].FirstValue+app[w3SVCW3WPOutputCacheMissesTotal].FirstValue,
|
data.W3SVCW3WPOutputCacheHitsTotal+data.W3SVCW3WPOutputCacheMissesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheHitsTotal,
|
c.w3SVCW3WPOutputCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheHitsTotal].FirstValue,
|
data.W3SVCW3WPOutputCacheHitsTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheFlushedItemsTotal,
|
c.w3SVCW3WPOutputCacheFlushedItemsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheFlushedItemsTotal].FirstValue,
|
data.W3SVCW3WPOutputCacheFlushedItemsTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.w3SVCW3WPOutputCacheFlushesTotal,
|
c.w3SVCW3WPOutputCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[w3SVCW3WPOutputCacheFlushesTotal].FirstValue,
|
data.W3SVCW3WPOutputCacheFlushesTotal,
|
||||||
name,
|
name,
|
||||||
pid,
|
pid,
|
||||||
)
|
)
|
||||||
|
|
||||||
if c.iisVersion.major >= 8 {
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPRequestErrors401].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
"401",
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPRequestErrors403].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
"403",
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPRequestErrors404].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
"404",
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPRequestErrorsTotal,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPRequestErrors500].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
"500",
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPWebSocketRequestsActive,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPWebSocketRequestsActive].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPWebSocketConnectionAttempts,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPWebSocketConnectionAttempts].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPWebSocketConnectionsAccepted,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPWebSocketConnectionsAccepted].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
)
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.w3SVCW3WPWebSocketConnectionsRejected,
|
|
||||||
prometheus.CounterValue,
|
|
||||||
app[w3SVCW3WPWebSocketConnectionsRejected].FirstValue,
|
|
||||||
name,
|
|
||||||
pid,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ package iis
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorWebService struct {
|
type collectorWebService struct {
|
||||||
perfDataCollectorWebService *perfdata.Collector
|
perfDataCollectorWebService *pdh.Collector
|
||||||
|
perfDataObjectWebService []perfDataCounterValuesWebService
|
||||||
|
|
||||||
webServiceCurrentAnonymousUsers *prometheus.Desc
|
webServiceCurrentAnonymousUsers *prometheus.Desc
|
||||||
webServiceCurrentBlockedAsyncIORequests *prometheus.Desc
|
webServiceCurrentBlockedAsyncIORequests *prometheus.Desc
|
||||||
@@ -50,88 +51,56 @@ type collectorWebService struct {
|
|||||||
webServiceTotalRejectedAsyncIORequests *prometheus.Desc
|
webServiceTotalRejectedAsyncIORequests *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesWebService struct {
|
||||||
webServiceCurrentAnonymousUsers = "Current Anonymous Users"
|
Name string
|
||||||
webServiceCurrentBlockedAsyncIORequests = "Current Blocked Async I/O Requests"
|
|
||||||
webServiceCurrentCGIRequests = "Current CGI Requests"
|
WebServiceCurrentAnonymousUsers float64 `perfdata:"Current Anonymous Users"`
|
||||||
webServiceCurrentConnections = "Current Connections"
|
WebServiceCurrentBlockedAsyncIORequests float64 `perfdata:"Current Blocked Async I/O Requests"`
|
||||||
webServiceCurrentISAPIExtensionRequests = "Current ISAPI Extension Requests"
|
WebServiceCurrentCGIRequests float64 `perfdata:"Current CGI Requests"`
|
||||||
webServiceCurrentNonAnonymousUsers = "Current NonAnonymous Users"
|
WebServiceCurrentConnections float64 `perfdata:"Current Connections"`
|
||||||
webServiceServiceUptime = "Service Uptime"
|
WebServiceCurrentISAPIExtensionRequests float64 `perfdata:"Current ISAPI Extension Requests"`
|
||||||
webServiceTotalBytesReceived = "Total Bytes Received"
|
WebServiceCurrentNonAnonymousUsers float64 `perfdata:"Current NonAnonymous Users"`
|
||||||
webServiceTotalBytesSent = "Total Bytes Sent"
|
WebServiceServiceUptime float64 `perfdata:"Service Uptime"`
|
||||||
webServiceTotalAnonymousUsers = "Total Anonymous Users"
|
WebServiceTotalBytesReceived float64 `perfdata:"Total Bytes Received"`
|
||||||
webServiceTotalBlockedAsyncIORequests = "Total Blocked Async I/O Requests"
|
WebServiceTotalBytesSent float64 `perfdata:"Total Bytes Sent"`
|
||||||
webServiceTotalCGIRequests = "Total CGI Requests"
|
WebServiceTotalAnonymousUsers float64 `perfdata:"Total Anonymous Users"`
|
||||||
webServiceTotalConnectionAttemptsAllInstances = "Total Connection Attempts (all instances)"
|
WebServiceTotalBlockedAsyncIORequests float64 `perfdata:"Total Blocked Async I/O Requests"`
|
||||||
webServiceTotalFilesReceived = "Total Files Received"
|
WebServiceTotalCGIRequests float64 `perfdata:"Total CGI Requests"`
|
||||||
webServiceTotalFilesSent = "Total Files Sent"
|
WebServiceTotalConnectionAttemptsAllInstances float64 `perfdata:"Total Connection Attempts (all instances)"`
|
||||||
webServiceTotalISAPIExtensionRequests = "Total ISAPI Extension Requests"
|
WebServiceTotalFilesReceived float64 `perfdata:"Total Files Received"`
|
||||||
webServiceTotalLockedErrors = "Total Locked Errors"
|
WebServiceTotalFilesSent float64 `perfdata:"Total Files Sent"`
|
||||||
webServiceTotalLogonAttempts = "Total Logon Attempts"
|
WebServiceTotalISAPIExtensionRequests float64 `perfdata:"Total ISAPI Extension Requests"`
|
||||||
webServiceTotalNonAnonymousUsers = "Total NonAnonymous Users"
|
WebServiceTotalLockedErrors float64 `perfdata:"Total Locked Errors"`
|
||||||
webServiceTotalNotFoundErrors = "Total Not Found Errors"
|
WebServiceTotalLogonAttempts float64 `perfdata:"Total Logon Attempts"`
|
||||||
webServiceTotalRejectedAsyncIORequests = "Total Rejected Async I/O Requests"
|
WebServiceTotalNonAnonymousUsers float64 `perfdata:"Total NonAnonymous Users"`
|
||||||
webServiceTotalCopyRequests = "Total Copy Requests"
|
WebServiceTotalNotFoundErrors float64 `perfdata:"Total Not Found Errors"`
|
||||||
webServiceTotalDeleteRequests = "Total Delete Requests"
|
WebServiceTotalRejectedAsyncIORequests float64 `perfdata:"Total Rejected Async I/O Requests"`
|
||||||
webServiceTotalGetRequests = "Total Get Requests"
|
WebServiceTotalCopyRequests float64 `perfdata:"Total Copy Requests"`
|
||||||
webServiceTotalHeadRequests = "Total Head Requests"
|
WebServiceTotalDeleteRequests float64 `perfdata:"Total Delete Requests"`
|
||||||
webServiceTotalLockRequests = "Total Lock Requests"
|
WebServiceTotalGetRequests float64 `perfdata:"Total Get Requests"`
|
||||||
webServiceTotalMkcolRequests = "Total Mkcol Requests"
|
WebServiceTotalHeadRequests float64 `perfdata:"Total Head Requests"`
|
||||||
webServiceTotalMoveRequests = "Total Move Requests"
|
WebServiceTotalLockRequests float64 `perfdata:"Total Lock Requests"`
|
||||||
webServiceTotalOptionsRequests = "Total Options Requests"
|
WebServiceTotalMkcolRequests float64 `perfdata:"Total Mkcol Requests"`
|
||||||
webServiceTotalOtherRequests = "Total Other Request Methods"
|
WebServiceTotalMoveRequests float64 `perfdata:"Total Move Requests"`
|
||||||
webServiceTotalPostRequests = "Total Post Requests"
|
WebServiceTotalOptionsRequests float64 `perfdata:"Total Options Requests"`
|
||||||
webServiceTotalPropfindRequests = "Total Propfind Requests"
|
WebServiceTotalOtherRequests float64 `perfdata:"Total Other Request Methods"`
|
||||||
webServiceTotalProppatchRequests = "Total Proppatch Requests"
|
WebServiceTotalPostRequests float64 `perfdata:"Total Post Requests"`
|
||||||
webServiceTotalPutRequests = "Total Put Requests"
|
WebServiceTotalPropfindRequests float64 `perfdata:"Total Propfind Requests"`
|
||||||
webServiceTotalSearchRequests = "Total Search Requests"
|
WebServiceTotalProppatchRequests float64 `perfdata:"Total Proppatch Requests"`
|
||||||
webServiceTotalTraceRequests = "Total Trace Requests"
|
WebServiceTotalPutRequests float64 `perfdata:"Total Put Requests"`
|
||||||
webServiceTotalUnlockRequests = "Total Unlock Requests"
|
WebServiceTotalSearchRequests float64 `perfdata:"Total Search Requests"`
|
||||||
)
|
WebServiceTotalTraceRequests float64 `perfdata:"Total Trace Requests"`
|
||||||
|
WebServiceTotalUnlockRequests float64 `perfdata:"Total Unlock Requests"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p perfDataCounterValuesWebService) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildWebService() error {
|
func (c *Collector) buildWebService() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollectorWebService, err = perfdata.NewCollector("Web Service", perfdata.InstancesAll, []string{
|
c.perfDataCollectorWebService, err = pdh.NewCollector[perfDataCounterValuesWebService](pdh.CounterTypeRaw, "Web Service", pdh.InstancesAll)
|
||||||
webServiceCurrentAnonymousUsers,
|
|
||||||
webServiceCurrentBlockedAsyncIORequests,
|
|
||||||
webServiceCurrentCGIRequests,
|
|
||||||
webServiceCurrentConnections,
|
|
||||||
webServiceCurrentISAPIExtensionRequests,
|
|
||||||
webServiceCurrentNonAnonymousUsers,
|
|
||||||
webServiceServiceUptime,
|
|
||||||
webServiceTotalBytesReceived,
|
|
||||||
webServiceTotalBytesSent,
|
|
||||||
webServiceTotalAnonymousUsers,
|
|
||||||
webServiceTotalBlockedAsyncIORequests,
|
|
||||||
webServiceTotalCGIRequests,
|
|
||||||
webServiceTotalConnectionAttemptsAllInstances,
|
|
||||||
webServiceTotalFilesReceived,
|
|
||||||
webServiceTotalFilesSent,
|
|
||||||
webServiceTotalISAPIExtensionRequests,
|
|
||||||
webServiceTotalLockedErrors,
|
|
||||||
webServiceTotalLogonAttempts,
|
|
||||||
webServiceTotalNonAnonymousUsers,
|
|
||||||
webServiceTotalNotFoundErrors,
|
|
||||||
webServiceTotalRejectedAsyncIORequests,
|
|
||||||
webServiceTotalCopyRequests,
|
|
||||||
webServiceTotalDeleteRequests,
|
|
||||||
webServiceTotalGetRequests,
|
|
||||||
webServiceTotalHeadRequests,
|
|
||||||
webServiceTotalLockRequests,
|
|
||||||
webServiceTotalMkcolRequests,
|
|
||||||
webServiceTotalMoveRequests,
|
|
||||||
webServiceTotalOptionsRequests,
|
|
||||||
webServiceTotalOtherRequests,
|
|
||||||
webServiceTotalPostRequests,
|
|
||||||
webServiceTotalPropfindRequests,
|
|
||||||
webServiceTotalProppatchRequests,
|
|
||||||
webServiceTotalPutRequests,
|
|
||||||
webServiceTotalSearchRequests,
|
|
||||||
webServiceTotalTraceRequests,
|
|
||||||
webServiceTotalUnlockRequests,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Web Service collector: %w", err)
|
return fmt.Errorf("failed to create Web Service collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -273,254 +242,254 @@ func (c *Collector) buildWebService() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollectorWebService.Collect()
|
err := c.perfDataCollectorWebService.Collect(&c.perfDataObjectWebService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Web Service metrics: %w", err)
|
return fmt.Errorf("failed to collect Web Service metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deduplicateIISNames(perfData)
|
deduplicateIISNames(c.perfDataObjectWebService)
|
||||||
|
|
||||||
for name, app := range perfData {
|
for _, data := range c.perfDataObjectWebService {
|
||||||
if c.config.SiteExclude.MatchString(name) || !c.config.SiteInclude.MatchString(name) {
|
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentAnonymousUsers,
|
c.webServiceCurrentAnonymousUsers,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentAnonymousUsers].FirstValue,
|
data.WebServiceCurrentAnonymousUsers,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentBlockedAsyncIORequests,
|
c.webServiceCurrentBlockedAsyncIORequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentBlockedAsyncIORequests].FirstValue,
|
data.WebServiceCurrentBlockedAsyncIORequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentCGIRequests,
|
c.webServiceCurrentCGIRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentCGIRequests].FirstValue,
|
data.WebServiceCurrentCGIRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentConnections,
|
c.webServiceCurrentConnections,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentConnections].FirstValue,
|
data.WebServiceCurrentConnections,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentISAPIExtensionRequests,
|
c.webServiceCurrentISAPIExtensionRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentISAPIExtensionRequests].FirstValue,
|
data.WebServiceCurrentISAPIExtensionRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceCurrentNonAnonymousUsers,
|
c.webServiceCurrentNonAnonymousUsers,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceCurrentNonAnonymousUsers].FirstValue,
|
data.WebServiceCurrentNonAnonymousUsers,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceServiceUptime,
|
c.webServiceServiceUptime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[webServiceServiceUptime].FirstValue,
|
data.WebServiceServiceUptime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBytesReceived,
|
c.webServiceTotalBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalBytesReceived].FirstValue,
|
data.WebServiceTotalBytesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBytesSent,
|
c.webServiceTotalBytesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalBytesSent].FirstValue,
|
data.WebServiceTotalBytesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalAnonymousUsers,
|
c.webServiceTotalAnonymousUsers,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalAnonymousUsers].FirstValue,
|
data.WebServiceTotalAnonymousUsers,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalBlockedAsyncIORequests,
|
c.webServiceTotalBlockedAsyncIORequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalBlockedAsyncIORequests].FirstValue,
|
data.WebServiceTotalBlockedAsyncIORequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalCGIRequests,
|
c.webServiceTotalCGIRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalCGIRequests].FirstValue,
|
data.WebServiceTotalCGIRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalConnectionAttemptsAllInstances,
|
c.webServiceTotalConnectionAttemptsAllInstances,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalConnectionAttemptsAllInstances].FirstValue,
|
data.WebServiceTotalConnectionAttemptsAllInstances,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalFilesReceived,
|
c.webServiceTotalFilesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalFilesReceived].FirstValue,
|
data.WebServiceTotalFilesReceived,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalFilesSent,
|
c.webServiceTotalFilesSent,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalFilesSent].FirstValue,
|
data.WebServiceTotalFilesSent,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalISAPIExtensionRequests,
|
c.webServiceTotalISAPIExtensionRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalISAPIExtensionRequests].FirstValue,
|
data.WebServiceTotalISAPIExtensionRequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalLockedErrors,
|
c.webServiceTotalLockedErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalLockedErrors].FirstValue,
|
data.WebServiceTotalLockedErrors,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalLogonAttempts,
|
c.webServiceTotalLogonAttempts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalLogonAttempts].FirstValue,
|
data.WebServiceTotalLogonAttempts,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalNonAnonymousUsers,
|
c.webServiceTotalNonAnonymousUsers,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalNonAnonymousUsers].FirstValue,
|
data.WebServiceTotalNonAnonymousUsers,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalNotFoundErrors,
|
c.webServiceTotalNotFoundErrors,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalNotFoundErrors].FirstValue,
|
data.WebServiceTotalNotFoundErrors,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRejectedAsyncIORequests,
|
c.webServiceTotalRejectedAsyncIORequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalRejectedAsyncIORequests].FirstValue,
|
data.WebServiceTotalRejectedAsyncIORequests,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalOtherRequests].FirstValue,
|
data.WebServiceTotalOtherRequests,
|
||||||
name,
|
data.Name,
|
||||||
"other",
|
"other",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalCopyRequests].FirstValue,
|
data.WebServiceTotalCopyRequests,
|
||||||
name,
|
data.Name,
|
||||||
"COPY",
|
"COPY",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalDeleteRequests].FirstValue,
|
data.WebServiceTotalDeleteRequests,
|
||||||
name,
|
data.Name,
|
||||||
"DELETE",
|
"DELETE",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalGetRequests].FirstValue,
|
data.WebServiceTotalGetRequests,
|
||||||
name,
|
data.Name,
|
||||||
"GET",
|
"GET",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalHeadRequests].FirstValue,
|
data.WebServiceTotalHeadRequests,
|
||||||
name,
|
data.Name,
|
||||||
"HEAD",
|
"HEAD",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalLockRequests].FirstValue,
|
data.WebServiceTotalLockRequests,
|
||||||
name,
|
data.Name,
|
||||||
"LOCK",
|
"LOCK",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalMkcolRequests].FirstValue,
|
data.WebServiceTotalMkcolRequests,
|
||||||
name,
|
data.Name,
|
||||||
"MKCOL",
|
"MKCOL",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalMoveRequests].FirstValue,
|
data.WebServiceTotalMoveRequests,
|
||||||
name,
|
data.Name,
|
||||||
"MOVE",
|
"MOVE",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalOptionsRequests].FirstValue,
|
data.WebServiceTotalOptionsRequests,
|
||||||
name,
|
data.Name,
|
||||||
"OPTIONS",
|
"OPTIONS",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalPostRequests].FirstValue,
|
data.WebServiceTotalPostRequests,
|
||||||
name,
|
data.Name,
|
||||||
"POST",
|
"POST",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalPropfindRequests].FirstValue,
|
data.WebServiceTotalPropfindRequests,
|
||||||
name,
|
data.Name,
|
||||||
"PROPFIND",
|
"PROPFIND",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalProppatchRequests].FirstValue,
|
data.WebServiceTotalProppatchRequests,
|
||||||
name,
|
data.Name,
|
||||||
"PROPPATCH",
|
"PROPPATCH",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalPutRequests].FirstValue,
|
data.WebServiceTotalPutRequests,
|
||||||
name,
|
data.Name,
|
||||||
"PUT",
|
"PUT",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalSearchRequests].FirstValue,
|
data.WebServiceTotalSearchRequests,
|
||||||
name,
|
data.Name,
|
||||||
"SEARCH",
|
"SEARCH",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalTraceRequests].FirstValue,
|
data.WebServiceTotalTraceRequests,
|
||||||
name,
|
data.Name,
|
||||||
"TRACE",
|
"TRACE",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.webServiceTotalRequests,
|
c.webServiceTotalRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[webServiceTotalUnlockRequests].FirstValue,
|
data.WebServiceTotalUnlockRequests,
|
||||||
name,
|
data.Name,
|
||||||
"UNLOCK",
|
"UNLOCK",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ package iis
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorWebServiceCache struct {
|
type collectorWebServiceCache struct {
|
||||||
serviceCachePerfDataCollector *perfdata.Collector
|
serviceCachePerfDataCollector *pdh.Collector
|
||||||
|
perfDataObjectServiceCache []perfDataCounterServiceCache
|
||||||
|
|
||||||
serviceCacheActiveFlushedEntries *prometheus.Desc
|
serviceCacheActiveFlushedEntries *prometheus.Desc
|
||||||
|
|
||||||
@@ -60,82 +61,53 @@ type collectorWebServiceCache struct {
|
|||||||
serviceCacheOutputCacheFlushesTotal *prometheus.Desc
|
serviceCacheOutputCacheFlushesTotal *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterServiceCache struct {
|
||||||
serviceCacheActiveFlushedEntries = "Active Flushed Entries"
|
Name string
|
||||||
serviceCacheCurrentFileCacheMemoryUsage = "Current File Cache Memory Usage"
|
|
||||||
serviceCacheMaximumFileCacheMemoryUsage = "Maximum File Cache Memory Usage"
|
ServiceCacheActiveFlushedEntries float64 `perfdata:"Active Flushed Entries"`
|
||||||
serviceCacheFileCacheFlushesTotal = "File Cache Flushes"
|
ServiceCacheCurrentFileCacheMemoryUsage float64 `perfdata:"Current File Cache Memory Usage"`
|
||||||
serviceCacheFileCacheHitsTotal = "File Cache Hits"
|
ServiceCacheMaximumFileCacheMemoryUsage float64 `perfdata:"Maximum File Cache Memory Usage"`
|
||||||
serviceCacheFileCacheMissesTotal = "File Cache Misses"
|
ServiceCacheFileCacheFlushesTotal float64 `perfdata:"File Cache Flushes"`
|
||||||
serviceCacheFilesCached = "Current Files Cached"
|
ServiceCacheFileCacheHitsTotal float64 `perfdata:"File Cache Hits"`
|
||||||
serviceCacheFilesCachedTotal = "Total Files Cached"
|
ServiceCacheFileCacheMissesTotal float64 `perfdata:"File Cache Misses"`
|
||||||
serviceCacheFilesFlushedTotal = "Total Flushed Files"
|
ServiceCacheFilesCached float64 `perfdata:"Current Files Cached"`
|
||||||
serviceCacheURICacheFlushesTotal = "Total Flushed URIs"
|
ServiceCacheFilesCachedTotal float64 `perfdata:"Total Files Cached"`
|
||||||
serviceCacheURICacheFlushesTotalKernel = "Total Flushed URIs"
|
ServiceCacheFilesFlushedTotal float64 `perfdata:"Total Flushed Files"`
|
||||||
serviceCacheURIsFlushedTotalKernel = "Kernel: Total Flushed URIs"
|
ServiceCacheURICacheFlushesTotal float64 `perfdata:"Total Flushed URIs"`
|
||||||
serviceCacheURICacheHitsTotal = "URI Cache Hits"
|
ServiceCacheURICacheFlushesTotalKernel float64 `perfdata:"Total Flushed URIs"`
|
||||||
serviceCacheURICacheHitsTotalKernel = "Kernel: URI Cache Hits"
|
ServiceCacheURIsFlushedTotalKernel float64 `perfdata:"Kernel: Total Flushed URIs"`
|
||||||
serviceCacheURICacheMissesTotal = "URI Cache Misses"
|
ServiceCacheURICacheHitsTotal float64 `perfdata:"URI Cache Hits"`
|
||||||
serviceCacheURICacheMissesTotalKernel = "Kernel: URI Cache Misses"
|
ServiceCacheURICacheHitsTotalKernel float64 `perfdata:"Kernel: URI Cache Hits"`
|
||||||
serviceCacheURIsCached = "Current URIs Cached"
|
ServiceCacheURICacheMissesTotal float64 `perfdata:"URI Cache Misses"`
|
||||||
serviceCacheURIsCachedKernel = "Kernel: Current URIs Cached"
|
ServiceCacheURICacheMissesTotalKernel float64 `perfdata:"Kernel: URI Cache Misses"`
|
||||||
serviceCacheURIsCachedTotal = "Total URIs Cached"
|
ServiceCacheURIsCached float64 `perfdata:"Current URIs Cached"`
|
||||||
serviceCacheURIsCachedTotalKernel = "Total URIs Cached"
|
ServiceCacheURIsCachedKernel float64 `perfdata:"Kernel: Current URIs Cached"`
|
||||||
serviceCacheURIsFlushedTotal = "Total Flushed URIs"
|
ServiceCacheURIsCachedTotal float64 `perfdata:"Total URIs Cached"`
|
||||||
serviceCacheMetaDataCacheHits = "Metadata Cache Hits"
|
ServiceCacheURIsCachedTotalKernel float64 `perfdata:"Total URIs Cached"`
|
||||||
serviceCacheMetaDataCacheMisses = "Metadata Cache Misses"
|
ServiceCacheURIsFlushedTotal float64 `perfdata:"Total Flushed URIs"`
|
||||||
serviceCacheMetadataCached = "Current Metadata Cached"
|
ServiceCacheMetaDataCacheHits float64 `perfdata:"Metadata Cache Hits"`
|
||||||
serviceCacheMetadataCacheFlushes = "Metadata Cache Flushes"
|
ServiceCacheMetaDataCacheMisses float64 `perfdata:"Metadata Cache Misses"`
|
||||||
serviceCacheMetadataCachedTotal = "Total Metadata Cached"
|
ServiceCacheMetadataCached float64 `perfdata:"Current Metadata Cached"`
|
||||||
serviceCacheMetadataFlushedTotal = "Total Flushed Metadata"
|
ServiceCacheMetadataCacheFlushes float64 `perfdata:"Metadata Cache Flushes"`
|
||||||
serviceCacheOutputCacheActiveFlushedItems = "Output Cache Current Flushed Items"
|
ServiceCacheMetadataCachedTotal float64 `perfdata:"Total Metadata Cached"`
|
||||||
serviceCacheOutputCacheItems = "Output Cache Current Items"
|
ServiceCacheMetadataFlushedTotal float64 `perfdata:"Total Flushed Metadata"`
|
||||||
serviceCacheOutputCacheMemoryUsage = "Output Cache Current Memory Usage"
|
ServiceCacheOutputCacheActiveFlushedItems float64 `perfdata:"Output Cache Current Flushed Items"`
|
||||||
serviceCacheOutputCacheHitsTotal = "Output Cache Total Hits"
|
ServiceCacheOutputCacheItems float64 `perfdata:"Output Cache Current Items"`
|
||||||
serviceCacheOutputCacheMissesTotal = "Output Cache Total Misses"
|
ServiceCacheOutputCacheMemoryUsage float64 `perfdata:"Output Cache Current Memory Usage"`
|
||||||
serviceCacheOutputCacheFlushedItemsTotal = "Output Cache Total Flushed Items"
|
ServiceCacheOutputCacheHitsTotal float64 `perfdata:"Output Cache Total Hits"`
|
||||||
serviceCacheOutputCacheFlushesTotal = "Output Cache Total Flushes"
|
ServiceCacheOutputCacheMissesTotal float64 `perfdata:"Output Cache Total Misses"`
|
||||||
)
|
ServiceCacheOutputCacheFlushedItemsTotal float64 `perfdata:"Output Cache Total Flushed Items"`
|
||||||
|
ServiceCacheOutputCacheFlushesTotal float64 `perfdata:"Output Cache Total Flushes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p perfDataCounterServiceCache) GetName() string {
|
||||||
|
return p.Name
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildWebServiceCache() error {
|
func (c *Collector) buildWebServiceCache() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.serviceCachePerfDataCollector, err = perfdata.NewCollector("Web Service Cache", perfdata.InstancesAll, []string{
|
c.serviceCachePerfDataCollector, err = pdh.NewCollector[perfDataCounterServiceCache](pdh.CounterTypeRaw, "Web Service Cache", pdh.InstancesAll)
|
||||||
serviceCacheActiveFlushedEntries,
|
|
||||||
serviceCacheCurrentFileCacheMemoryUsage,
|
|
||||||
serviceCacheMaximumFileCacheMemoryUsage,
|
|
||||||
serviceCacheFileCacheFlushesTotal,
|
|
||||||
serviceCacheFileCacheHitsTotal,
|
|
||||||
serviceCacheFileCacheMissesTotal,
|
|
||||||
serviceCacheFilesCached,
|
|
||||||
serviceCacheFilesCachedTotal,
|
|
||||||
serviceCacheFilesFlushedTotal,
|
|
||||||
serviceCacheURICacheFlushesTotal,
|
|
||||||
serviceCacheURICacheFlushesTotalKernel,
|
|
||||||
serviceCacheURIsFlushedTotalKernel,
|
|
||||||
serviceCacheURICacheHitsTotal,
|
|
||||||
serviceCacheURICacheHitsTotalKernel,
|
|
||||||
serviceCacheURICacheMissesTotal,
|
|
||||||
serviceCacheURICacheMissesTotalKernel,
|
|
||||||
serviceCacheURIsCached,
|
|
||||||
serviceCacheURIsCachedKernel,
|
|
||||||
serviceCacheURIsCachedTotal,
|
|
||||||
serviceCacheURIsCachedTotalKernel,
|
|
||||||
serviceCacheURIsFlushedTotal,
|
|
||||||
serviceCacheMetaDataCacheHits,
|
|
||||||
serviceCacheMetaDataCacheMisses,
|
|
||||||
serviceCacheMetadataCached,
|
|
||||||
serviceCacheMetadataCacheFlushes,
|
|
||||||
serviceCacheMetadataCachedTotal,
|
|
||||||
serviceCacheMetadataFlushedTotal,
|
|
||||||
serviceCacheOutputCacheActiveFlushedItems,
|
|
||||||
serviceCacheOutputCacheItems,
|
|
||||||
serviceCacheOutputCacheMemoryUsage,
|
|
||||||
serviceCacheOutputCacheHitsTotal,
|
|
||||||
serviceCacheOutputCacheMissesTotal,
|
|
||||||
serviceCacheOutputCacheFlushedItemsTotal,
|
|
||||||
serviceCacheOutputCacheFlushesTotal,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Web Service Cache collector: %w", err)
|
return fmt.Errorf("failed to create Web Service Cache collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -314,199 +286,199 @@ func (c *Collector) buildWebServiceCache() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectWebServiceCache(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectWebServiceCache(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.serviceCachePerfDataCollector.Collect()
|
err := c.serviceCachePerfDataCollector.Collect(&c.perfDataObjectServiceCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Web Service Cache metrics: %w", err)
|
return fmt.Errorf("failed to collect Web Service Cache metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deduplicateIISNames(perfData)
|
deduplicateIISNames(c.perfDataObjectServiceCache)
|
||||||
|
|
||||||
for name, app := range perfData {
|
for _, data := range c.perfDataObjectServiceCache {
|
||||||
if c.config.SiteExclude.MatchString(name) || !c.config.SiteInclude.MatchString(name) {
|
if c.config.SiteExclude.MatchString(data.Name) || !c.config.SiteInclude.MatchString(data.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheActiveFlushedEntries,
|
c.serviceCacheActiveFlushedEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheActiveFlushedEntries].FirstValue,
|
data.ServiceCacheActiveFlushedEntries,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheCurrentFileCacheMemoryUsage,
|
c.serviceCacheCurrentFileCacheMemoryUsage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheCurrentFileCacheMemoryUsage].FirstValue,
|
data.ServiceCacheCurrentFileCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMaximumFileCacheMemoryUsage,
|
c.serviceCacheMaximumFileCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheMaximumFileCacheMemoryUsage].FirstValue,
|
data.ServiceCacheMaximumFileCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheFlushesTotal,
|
c.serviceCacheFileCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheFileCacheFlushesTotal].FirstValue,
|
data.ServiceCacheFileCacheFlushesTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheQueriesTotal,
|
c.serviceCacheFileCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheFileCacheHitsTotal].FirstValue+app[serviceCacheFileCacheMissesTotal].FirstValue,
|
data.ServiceCacheFileCacheHitsTotal+data.ServiceCacheFileCacheMissesTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFileCacheHitsTotal,
|
c.serviceCacheFileCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheFileCacheHitsTotal].FirstValue,
|
data.ServiceCacheFileCacheHitsTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesCached,
|
c.serviceCacheFilesCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheFilesCached].FirstValue,
|
data.ServiceCacheFilesCached,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesCachedTotal,
|
c.serviceCacheFilesCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheFilesCachedTotal].FirstValue,
|
data.ServiceCacheFilesCachedTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheFilesFlushedTotal,
|
c.serviceCacheFilesFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheFilesFlushedTotal].FirstValue,
|
data.ServiceCacheFilesFlushedTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheFlushesTotal,
|
c.serviceCacheURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheFlushesTotal].FirstValue,
|
data.ServiceCacheURICacheFlushesTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheFlushesTotal,
|
c.serviceCacheURICacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheFlushesTotalKernel].FirstValue,
|
data.ServiceCacheURICacheFlushesTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheQueriesTotal,
|
c.serviceCacheURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheHitsTotal].FirstValue+app[serviceCacheURICacheMissesTotal].FirstValue,
|
data.ServiceCacheURICacheHitsTotal+data.ServiceCacheURICacheMissesTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheQueriesTotal,
|
c.serviceCacheURICacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheHitsTotalKernel].FirstValue+app[serviceCacheURICacheMissesTotalKernel].FirstValue,
|
data.ServiceCacheURICacheHitsTotalKernel+data.ServiceCacheURICacheMissesTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheHitsTotal,
|
c.serviceCacheURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheHitsTotal].FirstValue,
|
data.ServiceCacheURICacheHitsTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURICacheHitsTotal,
|
c.serviceCacheURICacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURICacheHitsTotalKernel].FirstValue,
|
data.ServiceCacheURICacheHitsTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCached,
|
c.serviceCacheURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheURIsCached].FirstValue,
|
data.ServiceCacheURIsCached,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCached,
|
c.serviceCacheURIsCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheURIsCachedKernel].FirstValue,
|
data.ServiceCacheURIsCachedKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCachedTotal,
|
c.serviceCacheURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURIsCachedTotal].FirstValue,
|
data.ServiceCacheURIsCachedTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsCachedTotal,
|
c.serviceCacheURIsCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURIsCachedTotalKernel].FirstValue,
|
data.ServiceCacheURIsCachedTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsFlushedTotal,
|
c.serviceCacheURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURIsFlushedTotal].FirstValue,
|
data.ServiceCacheURIsFlushedTotal,
|
||||||
"user",
|
"user",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheURIsFlushedTotal,
|
c.serviceCacheURIsFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheURIsFlushedTotalKernel].FirstValue,
|
data.ServiceCacheURIsFlushedTotalKernel,
|
||||||
"kernel",
|
"kernel",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCached,
|
c.serviceCacheMetadataCached,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
app[serviceCacheMetadataCached].FirstValue,
|
data.ServiceCacheMetadataCached,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheFlushes,
|
c.serviceCacheMetadataCacheFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheMetadataCacheFlushes].FirstValue,
|
data.ServiceCacheMetadataCacheFlushes,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheQueriesTotal,
|
c.serviceCacheMetadataCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheMetaDataCacheHits].FirstValue+app[serviceCacheMetaDataCacheMisses].FirstValue,
|
data.ServiceCacheMetaDataCacheHits+data.ServiceCacheMetaDataCacheMisses,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCacheHitsTotal,
|
c.serviceCacheMetadataCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
0, // app[serviceCacheMetadataCacheHitsTotal].FirstValue,
|
0, // data.ServiceCacheMetadataCacheHitsTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataCachedTotal,
|
c.serviceCacheMetadataCachedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheMetadataCachedTotal].FirstValue,
|
data.ServiceCacheMetadataCachedTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheMetadataFlushedTotal,
|
c.serviceCacheMetadataFlushedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheMetadataFlushedTotal].FirstValue,
|
data.ServiceCacheMetadataFlushedTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheActiveFlushedItems,
|
c.serviceCacheOutputCacheActiveFlushedItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheActiveFlushedItems].FirstValue,
|
data.ServiceCacheOutputCacheActiveFlushedItems,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheItems,
|
c.serviceCacheOutputCacheItems,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheItems].FirstValue,
|
data.ServiceCacheOutputCacheItems,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheMemoryUsage,
|
c.serviceCacheOutputCacheMemoryUsage,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheMemoryUsage].FirstValue,
|
data.ServiceCacheOutputCacheMemoryUsage,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheQueriesTotal,
|
c.serviceCacheOutputCacheQueriesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheHitsTotal].FirstValue+app[serviceCacheOutputCacheMissesTotal].FirstValue,
|
data.ServiceCacheOutputCacheHitsTotal+data.ServiceCacheOutputCacheMissesTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheHitsTotal,
|
c.serviceCacheOutputCacheHitsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheHitsTotal].FirstValue,
|
data.ServiceCacheOutputCacheHitsTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheFlushedItemsTotal,
|
c.serviceCacheOutputCacheFlushedItemsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheFlushedItemsTotal].FirstValue,
|
data.ServiceCacheOutputCacheFlushedItemsTotal,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.serviceCacheOutputCacheFlushesTotal,
|
c.serviceCacheOutputCacheFlushesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
app[serviceCacheOutputCacheFlushesTotal].FirstValue,
|
data.ServiceCacheOutputCacheFlushesTotal,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package logical_disk
|
|
||||||
|
|
||||||
const (
|
|
||||||
avgDiskReadQueueLength = "Avg. Disk Read Queue Length"
|
|
||||||
avgDiskSecPerRead = "Avg. Disk sec/Read"
|
|
||||||
avgDiskSecPerTransfer = "Avg. Disk sec/Transfer"
|
|
||||||
avgDiskSecPerWrite = "Avg. Disk sec/Write"
|
|
||||||
avgDiskWriteQueueLength = "Avg. Disk Write Queue Length"
|
|
||||||
currentDiskQueueLength = "Current Disk Queue Length"
|
|
||||||
freeSpace = "Free Megabytes"
|
|
||||||
diskReadBytesPerSec = "Disk Read Bytes/sec"
|
|
||||||
diskReadsPerSec = "Disk Reads/sec"
|
|
||||||
diskWriteBytesPerSec = "Disk Write Bytes/sec"
|
|
||||||
diskWritesPerSec = "Disk Writes/sec"
|
|
||||||
percentDiskReadTime = "% Disk Read Time"
|
|
||||||
percentDiskWriteTime = "% Disk Write Time"
|
|
||||||
percentFreeSpace = "% Free Space"
|
|
||||||
percentIdleTime = "% Idle Time"
|
|
||||||
splitIOPerSec = "Split IO/Sec"
|
|
||||||
)
|
|
||||||
@@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
@@ -51,7 +51,8 @@ type Collector struct {
|
|||||||
config Config
|
config Config
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
avgReadQueue *prometheus.Desc
|
avgReadQueue *prometheus.Desc
|
||||||
avgWriteQueue *prometheus.Desc
|
avgWriteQueue *prometheus.Desc
|
||||||
@@ -151,24 +152,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("LogicalDisk", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "LogicalDisk", pdh.InstancesAll)
|
||||||
currentDiskQueueLength,
|
|
||||||
avgDiskReadQueueLength,
|
|
||||||
avgDiskWriteQueueLength,
|
|
||||||
diskReadBytesPerSec,
|
|
||||||
diskReadsPerSec,
|
|
||||||
diskWriteBytesPerSec,
|
|
||||||
diskWritesPerSec,
|
|
||||||
percentDiskReadTime,
|
|
||||||
percentDiskWriteTime,
|
|
||||||
percentFreeSpace,
|
|
||||||
freeSpace,
|
|
||||||
percentIdleTime,
|
|
||||||
splitIOPerSec,
|
|
||||||
avgDiskSecPerRead,
|
|
||||||
avgDiskSecPerWrite,
|
|
||||||
avgDiskSecPerTransfer,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create LogicalDisk collector: %w", err)
|
return fmt.Errorf("failed to create LogicalDisk collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -303,12 +287,9 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
// Collect sends the metric values for each metric
|
// Collect sends the metric values for each metric
|
||||||
// to the provided prometheus Metric channel.
|
// to the provided prometheus Metric channel.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
var (
|
var info volumeInfo
|
||||||
err error
|
|
||||||
info volumeInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect LogicalDisk metrics: %w", err)
|
return fmt.Errorf("failed to collect LogicalDisk metrics: %w", err)
|
||||||
}
|
}
|
||||||
@@ -318,14 +299,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
return fmt.Errorf("failed to get volumes: %w", err)
|
return fmt.Errorf("failed to get volumes: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, volume := range perfData {
|
for _, data := range c.perfDataObject {
|
||||||
if c.config.VolumeExclude.MatchString(name) || !c.config.VolumeInclude.MatchString(name) {
|
if c.config.VolumeExclude.MatchString(data.Name) || !c.config.VolumeInclude.MatchString(data.Name) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err = getVolumeInfo(volumes, name)
|
info, err = getVolumeInfo(volumes, data.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warn("failed to get volume information for "+name,
|
c.logger.Warn("failed to get volume information for "+data.Name,
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -336,7 +317,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
1,
|
1,
|
||||||
info.diskIDs,
|
info.diskIDs,
|
||||||
info.volumeType,
|
info.volumeType,
|
||||||
name,
|
data.Name,
|
||||||
info.label,
|
info.label,
|
||||||
info.filesystem,
|
info.filesystem,
|
||||||
info.serialNumber,
|
info.serialNumber,
|
||||||
@@ -345,113 +326,113 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestsQueued,
|
c.requestsQueued,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[currentDiskQueueLength].FirstValue,
|
data.CurrentDiskQueueLength,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgReadQueue,
|
c.avgReadQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[avgDiskReadQueueLength].FirstValue*perfdata.TicksToSecondScaleFactor,
|
data.AvgDiskReadQueueLength*pdh.TicksToSecondScaleFactor,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.avgWriteQueue,
|
c.avgWriteQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[avgDiskWriteQueueLength].FirstValue*perfdata.TicksToSecondScaleFactor,
|
data.AvgDiskWriteQueueLength*pdh.TicksToSecondScaleFactor,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readBytesTotal,
|
c.readBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[diskReadBytesPerSec].FirstValue,
|
data.DiskReadBytesPerSec,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readsTotal,
|
c.readsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[diskReadsPerSec].FirstValue,
|
data.DiskReadsPerSec,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeBytesTotal,
|
c.writeBytesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[diskWriteBytesPerSec].FirstValue,
|
data.DiskWriteBytesPerSec,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writesTotal,
|
c.writesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[diskWritesPerSec].FirstValue,
|
data.DiskWritesPerSec,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readTime,
|
c.readTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[percentDiskReadTime].FirstValue,
|
data.PercentDiskReadTime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeTime,
|
c.writeTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[percentDiskWriteTime].FirstValue,
|
data.PercentDiskWriteTime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.freeSpace,
|
c.freeSpace,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[freeSpace].FirstValue*1024*1024,
|
data.FreeSpace*1024*1024,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.totalSpace,
|
c.totalSpace,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
volume[percentFreeSpace].SecondValue*1024*1024,
|
data.PercentFreeSpace*1024*1024,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.idleTime,
|
c.idleTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[percentIdleTime].FirstValue,
|
data.PercentIdleTime,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.splitIOs,
|
c.splitIOs,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[splitIOPerSec].FirstValue,
|
data.SplitIOPerSec,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readLatency,
|
c.readLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[avgDiskSecPerRead].FirstValue*perfdata.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerRead*pdh.TicksToSecondScaleFactor,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeLatency,
|
c.writeLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[avgDiskSecPerWrite].FirstValue*perfdata.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerWrite*pdh.TicksToSecondScaleFactor,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.readWriteLatency,
|
c.readWriteLatency,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
volume[avgDiskSecPerTransfer].FirstValue*perfdata.TicksToSecondScaleFactor,
|
data.AvgDiskSecPerTransfer*pdh.TicksToSecondScaleFactor,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +487,9 @@ func getVolumeInfo(volumes map[string]string, rootDrive string) (volumeInfo, err
|
|||||||
return volumeInfo{}, fmt.Errorf("could not open volume for %s: %w", rootDrive, err)
|
return volumeInfo{}, fmt.Errorf("could not open volume for %s: %w", rootDrive, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer windows.Close(volumeHandle)
|
defer func(fd windows.Handle) {
|
||||||
|
_ = windows.Close(fd)
|
||||||
|
}(volumeHandle)
|
||||||
|
|
||||||
controlCode := uint32(5636096) // IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
|
controlCode := uint32(5636096) // IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
|
||||||
volumeDiskExtents := make([]byte, 16*1024)
|
volumeDiskExtents := make([]byte, 16*1024)
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ import (
|
|||||||
func BenchmarkCollector(b *testing.B) {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
// Whitelist is not set in testing context (kingpin flags not parsed), causing the Collector to skip all disks.
|
// Whitelist is not set in testing context (kingpin flags not parsed), causing the Collector to skip all disks.
|
||||||
localVolumeInclude := ".+"
|
localVolumeInclude := ".+"
|
||||||
kingpin.CommandLine.GetArg("collector.logical_disk.volume-include").StringVar(&localVolumeInclude)
|
|
||||||
testutils.FuncBenchmarkCollector(b, "logical_disk", logical_disk.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, "logical_disk", logical_disk.NewWithFlags, func(app *kingpin.Application) {
|
||||||
|
app.GetFlag("collector.logical_disk.volume-include").StringVar(&localVolumeInclude)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollector(t *testing.T) {
|
func TestCollector(t *testing.T) {
|
||||||
|
|||||||
37
internal/collector/logical_disk/types.go
Normal file
37
internal/collector/logical_disk/types.go
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package logical_disk
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
AvgDiskReadQueueLength float64 `perfdata:"Avg. Disk Read Queue Length"`
|
||||||
|
AvgDiskSecPerRead float64 `perfdata:"Avg. Disk sec/Read"`
|
||||||
|
AvgDiskSecPerTransfer float64 `perfdata:"Avg. Disk sec/Transfer"`
|
||||||
|
AvgDiskSecPerWrite float64 `perfdata:"Avg. Disk sec/Write"`
|
||||||
|
AvgDiskWriteQueueLength float64 `perfdata:"Avg. Disk Write Queue Length"`
|
||||||
|
CurrentDiskQueueLength float64 `perfdata:"Current Disk Queue Length"`
|
||||||
|
FreeSpace float64 `perfdata:"Free Megabytes"`
|
||||||
|
DiskReadBytesPerSec float64 `perfdata:"Disk Read Bytes/sec"`
|
||||||
|
DiskReadsPerSec float64 `perfdata:"Disk Reads/sec"`
|
||||||
|
DiskWriteBytesPerSec float64 `perfdata:"Disk Write Bytes/sec"`
|
||||||
|
DiskWritesPerSec float64 `perfdata:"Disk Writes/sec"`
|
||||||
|
PercentDiskReadTime float64 `perfdata:"% Disk Read Time"`
|
||||||
|
PercentDiskWriteTime float64 `perfdata:"% Disk Write Time"`
|
||||||
|
PercentFreeSpace float64 `perfdata:"% Free Space,secondvalue"`
|
||||||
|
PercentIdleTime float64 `perfdata:"% Idle Time"`
|
||||||
|
SplitIOPerSec float64 `perfdata:"Split IO/Sec"`
|
||||||
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
// Copyright 2024 The Prometheus Authors
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build windows
|
|
||||||
|
|
||||||
package memory
|
|
||||||
|
|
||||||
const (
|
|
||||||
availableBytes = "Available Bytes"
|
|
||||||
availableKBytes = "Available KBytes"
|
|
||||||
availableMBytes = "Available MBytes"
|
|
||||||
cacheBytes = "Cache Bytes"
|
|
||||||
cacheBytesPeak = "Cache Bytes Peak"
|
|
||||||
cacheFaultsPerSec = "Cache Faults/sec"
|
|
||||||
commitLimit = "Commit Limit"
|
|
||||||
committedBytes = "Committed Bytes"
|
|
||||||
demandZeroFaultsPerSec = "Demand Zero Faults/sec"
|
|
||||||
freeAndZeroPageListBytes = "Free & Zero Page List Bytes"
|
|
||||||
freeSystemPageTableEntries = "Free System Page Table Entries"
|
|
||||||
modifiedPageListBytes = "Modified Page List Bytes"
|
|
||||||
pageFaultsPerSec = "Page Faults/sec"
|
|
||||||
pageReadsPerSec = "Page Reads/sec"
|
|
||||||
pagesInputPerSec = "Pages Input/sec"
|
|
||||||
pagesOutputPerSec = "Pages Output/sec"
|
|
||||||
pagesPerSec = "Pages/sec"
|
|
||||||
pageWritesPerSec = "Page Writes/sec"
|
|
||||||
poolNonpagedAllocs = "Pool Nonpaged Allocs"
|
|
||||||
poolNonpagedBytes = "Pool Nonpaged Bytes"
|
|
||||||
poolPagedAllocs = "Pool Paged Allocs"
|
|
||||||
poolPagedBytes = "Pool Paged Bytes"
|
|
||||||
poolPagedResidentBytes = "Pool Paged Resident Bytes"
|
|
||||||
standbyCacheCoreBytes = "Standby Cache Core Bytes"
|
|
||||||
standbyCacheNormalPriorityBytes = "Standby Cache Normal Priority Bytes"
|
|
||||||
standbyCacheReserveBytes = "Standby Cache Reserve Bytes"
|
|
||||||
systemCacheResidentBytes = "System Cache Resident Bytes"
|
|
||||||
systemCodeResidentBytes = "System Code Resident Bytes"
|
|
||||||
systemCodeTotalBytes = "System Code Total Bytes"
|
|
||||||
systemDriverResidentBytes = "System Driver Resident Bytes"
|
|
||||||
systemDriverTotalBytes = "System Driver Total Bytes"
|
|
||||||
transitionFaultsPerSec = "Transition Faults/sec"
|
|
||||||
transitionPagesRePurposedPerSec = "Transition Pages RePurposed/sec"
|
|
||||||
writeCopiesPerSec = "Write Copies/sec"
|
|
||||||
)
|
|
||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/sysinfoapi"
|
"github.com/prometheus-community/windows_exporter/internal/headers/sysinfoapi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -42,7 +42,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
// Performance metrics
|
// Performance metrics
|
||||||
availableBytes *prometheus.Desc
|
availableBytes *prometheus.Desc
|
||||||
@@ -109,46 +110,9 @@ func (c *Collector) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
counters := []string{
|
|
||||||
availableBytes,
|
|
||||||
availableKBytes,
|
|
||||||
availableMBytes,
|
|
||||||
cacheBytes,
|
|
||||||
cacheBytesPeak,
|
|
||||||
cacheFaultsPerSec,
|
|
||||||
commitLimit,
|
|
||||||
committedBytes,
|
|
||||||
demandZeroFaultsPerSec,
|
|
||||||
freeAndZeroPageListBytes,
|
|
||||||
freeSystemPageTableEntries,
|
|
||||||
modifiedPageListBytes,
|
|
||||||
pageFaultsPerSec,
|
|
||||||
pageReadsPerSec,
|
|
||||||
pagesInputPerSec,
|
|
||||||
pagesOutputPerSec,
|
|
||||||
pagesPerSec,
|
|
||||||
pageWritesPerSec,
|
|
||||||
poolNonpagedAllocs,
|
|
||||||
poolNonpagedBytes,
|
|
||||||
poolPagedAllocs,
|
|
||||||
poolPagedBytes,
|
|
||||||
poolPagedResidentBytes,
|
|
||||||
standbyCacheCoreBytes,
|
|
||||||
standbyCacheNormalPriorityBytes,
|
|
||||||
standbyCacheReserveBytes,
|
|
||||||
systemCacheResidentBytes,
|
|
||||||
systemCodeResidentBytes,
|
|
||||||
systemCodeTotalBytes,
|
|
||||||
systemDriverResidentBytes,
|
|
||||||
systemDriverTotalBytes,
|
|
||||||
transitionFaultsPerSec,
|
|
||||||
transitionPagesRePurposedPerSec,
|
|
||||||
writeCopiesPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("Memory", perfdata.InstancesAll, counters)
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "Memory", pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create Memory collector: %w", err)
|
return fmt.Errorf("failed to create Memory collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -423,207 +387,201 @@ func (c *Collector) collectGlobalMemoryStatus(ch chan<- prometheus.Metric) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect Memory metrics: %w", err)
|
return fmt.Errorf("failed to collect Memory metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("failed to collect Memory metrics: %w", types.ErrNoData)
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availableBytes,
|
c.availableBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[availableBytes].FirstValue,
|
c.perfDataObject[0].AvailableBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cacheBytes,
|
c.cacheBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[cacheBytes].FirstValue,
|
c.perfDataObject[0].CacheBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cacheBytesPeak,
|
c.cacheBytesPeak,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[cacheBytesPeak].FirstValue,
|
c.perfDataObject[0].CacheBytesPeak,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cacheFaultsTotal,
|
c.cacheFaultsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[cacheFaultsPerSec].FirstValue,
|
c.perfDataObject[0].CacheFaultsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.commitLimit,
|
c.commitLimit,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[commitLimit].FirstValue,
|
c.perfDataObject[0].CommitLimit,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.committedBytes,
|
c.committedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[committedBytes].FirstValue,
|
c.perfDataObject[0].CommittedBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.demandZeroFaultsTotal,
|
c.demandZeroFaultsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[demandZeroFaultsPerSec].FirstValue,
|
c.perfDataObject[0].DemandZeroFaultsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.freeAndZeroPageListBytes,
|
c.freeAndZeroPageListBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[freeAndZeroPageListBytes].FirstValue,
|
c.perfDataObject[0].FreeAndZeroPageListBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.freeSystemPageTableEntries,
|
c.freeSystemPageTableEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[freeSystemPageTableEntries].FirstValue,
|
c.perfDataObject[0].FreeSystemPageTableEntries,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.modifiedPageListBytes,
|
c.modifiedPageListBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[modifiedPageListBytes].FirstValue,
|
c.perfDataObject[0].ModifiedPageListBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pageFaultsTotal,
|
c.pageFaultsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pageFaultsPerSec].FirstValue,
|
c.perfDataObject[0].PageFaultsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.swapPageReadsTotal,
|
c.swapPageReadsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pageReadsPerSec].FirstValue,
|
c.perfDataObject[0].PageReadsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.swapPagesReadTotal,
|
c.swapPagesReadTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pagesInputPerSec].FirstValue,
|
c.perfDataObject[0].PagesInputPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.swapPagesWrittenTotal,
|
c.swapPagesWrittenTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pagesOutputPerSec].FirstValue,
|
c.perfDataObject[0].PagesOutputPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.swapPageOperationsTotal,
|
c.swapPageOperationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pagesPerSec].FirstValue,
|
c.perfDataObject[0].PagesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.swapPageWritesTotal,
|
c.swapPageWritesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[pageWritesPerSec].FirstValue,
|
c.perfDataObject[0].PageWritesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolNonPagedAllocationsTotal,
|
c.poolNonPagedAllocationsTotal,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[poolNonpagedAllocs].FirstValue,
|
c.perfDataObject[0].PoolNonpagedAllocs,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolNonPagedBytes,
|
c.poolNonPagedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[poolNonpagedBytes].FirstValue,
|
c.perfDataObject[0].PoolNonpagedBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolPagedAllocationsTotal,
|
c.poolPagedAllocationsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[poolPagedAllocs].FirstValue,
|
c.perfDataObject[0].PoolPagedAllocs,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolPagedBytes,
|
c.poolPagedBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[poolPagedBytes].FirstValue,
|
c.perfDataObject[0].PoolPagedBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.poolPagedResidentBytes,
|
c.poolPagedResidentBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[poolPagedResidentBytes].FirstValue,
|
c.perfDataObject[0].PoolPagedResidentBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.standbyCacheCoreBytes,
|
c.standbyCacheCoreBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[standbyCacheCoreBytes].FirstValue,
|
c.perfDataObject[0].StandbyCacheCoreBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.standbyCacheNormalPriorityBytes,
|
c.standbyCacheNormalPriorityBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[standbyCacheNormalPriorityBytes].FirstValue,
|
c.perfDataObject[0].StandbyCacheNormalPriorityBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.standbyCacheReserveBytes,
|
c.standbyCacheReserveBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[standbyCacheReserveBytes].FirstValue,
|
c.perfDataObject[0].StandbyCacheReserveBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemCacheResidentBytes,
|
c.systemCacheResidentBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[systemCacheResidentBytes].FirstValue,
|
c.perfDataObject[0].SystemCacheResidentBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemCodeResidentBytes,
|
c.systemCodeResidentBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[systemCodeResidentBytes].FirstValue,
|
c.perfDataObject[0].SystemCodeResidentBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemCodeTotalBytes,
|
c.systemCodeTotalBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[systemCodeTotalBytes].FirstValue,
|
c.perfDataObject[0].SystemCodeTotalBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemDriverResidentBytes,
|
c.systemDriverResidentBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[systemDriverResidentBytes].FirstValue,
|
c.perfDataObject[0].SystemDriverResidentBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.systemDriverTotalBytes,
|
c.systemDriverTotalBytes,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[systemDriverTotalBytes].FirstValue,
|
c.perfDataObject[0].SystemDriverTotalBytes,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.transitionFaultsTotal,
|
c.transitionFaultsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[transitionFaultsPerSec].FirstValue,
|
c.perfDataObject[0].TransitionFaultsPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.transitionPagesRepurposedTotal,
|
c.transitionPagesRepurposedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[transitionPagesRePurposedPerSec].FirstValue,
|
c.perfDataObject[0].TransitionPagesRePurposedPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.writeCopiesTotal,
|
c.writeCopiesTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[writeCopiesPerSec].FirstValue,
|
c.perfDataObject[0].WriteCopiesPerSec,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
53
internal/collector/memory/types.go
Normal file
53
internal/collector/memory/types.go
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package memory
|
||||||
|
|
||||||
|
type perfDataCounterValues struct {
|
||||||
|
AvailableBytes float64 `perfdata:"Available Bytes"`
|
||||||
|
AvailableKBytes float64 `perfdata:"Available KBytes"`
|
||||||
|
AvailableMBytes float64 `perfdata:"Available MBytes"`
|
||||||
|
CacheBytes float64 `perfdata:"Cache Bytes"`
|
||||||
|
CacheBytesPeak float64 `perfdata:"Cache Bytes Peak"`
|
||||||
|
CacheFaultsPerSec float64 `perfdata:"Cache Faults/sec"`
|
||||||
|
CommitLimit float64 `perfdata:"Commit Limit"`
|
||||||
|
CommittedBytes float64 `perfdata:"Committed Bytes"`
|
||||||
|
DemandZeroFaultsPerSec float64 `perfdata:"Demand Zero Faults/sec"`
|
||||||
|
FreeAndZeroPageListBytes float64 `perfdata:"Free & Zero Page List Bytes"`
|
||||||
|
FreeSystemPageTableEntries float64 `perfdata:"Free System Page Table Entries"`
|
||||||
|
ModifiedPageListBytes float64 `perfdata:"Modified Page List Bytes"`
|
||||||
|
PageFaultsPerSec float64 `perfdata:"Page Faults/sec"`
|
||||||
|
PageReadsPerSec float64 `perfdata:"Page Reads/sec"`
|
||||||
|
PagesInputPerSec float64 `perfdata:"Pages Input/sec"`
|
||||||
|
PagesOutputPerSec float64 `perfdata:"Pages Output/sec"`
|
||||||
|
PagesPerSec float64 `perfdata:"Pages/sec"`
|
||||||
|
PageWritesPerSec float64 `perfdata:"Page Writes/sec"`
|
||||||
|
PoolNonpagedAllocs float64 `perfdata:"Pool Nonpaged Allocs"`
|
||||||
|
PoolNonpagedBytes float64 `perfdata:"Pool Nonpaged Bytes"`
|
||||||
|
PoolPagedAllocs float64 `perfdata:"Pool Paged Allocs"`
|
||||||
|
PoolPagedBytes float64 `perfdata:"Pool Paged Bytes"`
|
||||||
|
PoolPagedResidentBytes float64 `perfdata:"Pool Paged Resident Bytes"`
|
||||||
|
StandbyCacheCoreBytes float64 `perfdata:"Standby Cache Core Bytes"`
|
||||||
|
StandbyCacheNormalPriorityBytes float64 `perfdata:"Standby Cache Normal Priority Bytes"`
|
||||||
|
StandbyCacheReserveBytes float64 `perfdata:"Standby Cache Reserve Bytes"`
|
||||||
|
SystemCacheResidentBytes float64 `perfdata:"System Cache Resident Bytes"`
|
||||||
|
SystemCodeResidentBytes float64 `perfdata:"System Code Resident Bytes"`
|
||||||
|
SystemCodeTotalBytes float64 `perfdata:"System Code Total Bytes"`
|
||||||
|
SystemDriverResidentBytes float64 `perfdata:"System Driver Resident Bytes"`
|
||||||
|
SystemDriverTotalBytes float64 `perfdata:"System Driver Total Bytes"`
|
||||||
|
TransitionFaultsPerSec float64 `perfdata:"Transition Faults/sec"`
|
||||||
|
TransitionPagesRePurposedPerSec float64 `perfdata:"Transition Pages RePurposed/sec"`
|
||||||
|
WriteCopiesPerSec float64 `perfdata:"Write Copies/sec"`
|
||||||
|
}
|
||||||
@@ -13,17 +13,19 @@
|
|||||||
|
|
||||||
//go:build windows
|
//go:build windows
|
||||||
|
|
||||||
package perfdata
|
package mscluster_test
|
||||||
|
|
||||||
import "github.com/prometheus/client_golang/prometheus"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
const (
|
"github.com/prometheus-community/windows_exporter/internal/collector/mscluster"
|
||||||
InstanceEmpty = "------"
|
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
|
||||||
InstanceTotal = "_Total"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CounterValue struct {
|
func BenchmarkCollector(b *testing.B) {
|
||||||
Type prometheus.ValueType
|
testutils.FuncBenchmarkCollector(b, mscluster.Name, mscluster.NewWithFlags)
|
||||||
FirstValue float64
|
}
|
||||||
SecondValue float64
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, mscluster.New, nil)
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
@@ -36,7 +36,8 @@ var ConfigDefaults = Config{}
|
|||||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics.
|
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics.
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
perfDataCollector *perfdata.Collector
|
perfDataCollector *pdh.Collector
|
||||||
|
perfDataObject []perfDataCounterValues
|
||||||
|
|
||||||
bytesInJournalQueue *prometheus.Desc
|
bytesInJournalQueue *prometheus.Desc
|
||||||
bytesInQueue *prometheus.Desc
|
bytesInQueue *prometheus.Desc
|
||||||
@@ -75,12 +76,7 @@ func (c *Collector) Close() error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.perfDataCollector, err = perfdata.NewCollector("MSMQ Queue", perfdata.InstancesAll, []string{
|
c.perfDataCollector, err = pdh.NewCollector[perfDataCounterValues](pdh.CounterTypeRaw, "MSMQ Queue", pdh.InstancesAll)
|
||||||
bytesInJournalQueue,
|
|
||||||
bytesInQueue,
|
|
||||||
messagesInJournalQueue,
|
|
||||||
messagesInQueue,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create MSMQ Queue collector: %w", err)
|
return fmt.Errorf("failed to create MSMQ Queue collector: %w", err)
|
||||||
}
|
}
|
||||||
@@ -116,38 +112,38 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
|||||||
// Collect sends the metric values for each metric
|
// Collect sends the metric values for each metric
|
||||||
// to the provided prometheus Metric channel.
|
// to the provided prometheus Metric channel.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
perfData, err := c.perfDataCollector.Collect()
|
err := c.perfDataCollector.Collect(&c.perfDataObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect MSMQ Queue metrics: %w", err)
|
return fmt.Errorf("failed to collect MSMQ Queue metrics: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, data := range perfData {
|
for _, data := range c.perfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesInJournalQueue,
|
c.bytesInJournalQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bytesInJournalQueue].FirstValue,
|
data.BytesInJournalQueue,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bytesInQueue,
|
c.bytesInQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bytesInQueue].FirstValue,
|
data.BytesInQueue,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesInJournalQueue,
|
c.messagesInJournalQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[messagesInJournalQueue].FirstValue,
|
data.MessagesInJournalQueue,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.messagesInQueue,
|
c.messagesInQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[messagesInQueue].FirstValue,
|
data.MessagesInQueue,
|
||||||
name,
|
data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,3 +26,7 @@ func BenchmarkCollector(b *testing.B) {
|
|||||||
// No context name required as Collector source is WMI
|
// No context name required as Collector source is WMI
|
||||||
testutils.FuncBenchmarkCollector(b, msmq.Name, msmq.NewWithFlags)
|
testutils.FuncBenchmarkCollector(b, msmq.Name, msmq.NewWithFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCollector(t *testing.T) {
|
||||||
|
testutils.TestCollector(t, msmq.New, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,9 +15,11 @@
|
|||||||
|
|
||||||
package msmq
|
package msmq
|
||||||
|
|
||||||
const (
|
type perfDataCounterValues struct {
|
||||||
bytesInJournalQueue = "Bytes in Journal Queue"
|
Name string
|
||||||
bytesInQueue = "Bytes in Queue"
|
|
||||||
messagesInJournalQueue = "Messages in Journal Queue"
|
BytesInJournalQueue float64 `perfdata:"Bytes in Journal Queue"`
|
||||||
messagesInQueue = "Messages in Queue"
|
BytesInQueue float64 `perfdata:"Bytes in Queue"`
|
||||||
)
|
MessagesInJournalQueue float64 `perfdata:"Messages in Journal Queue"`
|
||||||
|
MessagesInQueue float64 `perfdata:"Messages in Queue"`
|
||||||
|
}
|
||||||
@@ -16,24 +16,20 @@
|
|||||||
package mssql
|
package mssql
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/Microsoft/go-winio/pkg/process"
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/headers/iphlpapi"
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"golang.org/x/sys/windows"
|
|
||||||
"golang.org/x/sys/windows/registry"
|
"golang.org/x/sys/windows/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,6 +42,7 @@ const (
|
|||||||
subCollectorDatabases = "databases"
|
subCollectorDatabases = "databases"
|
||||||
subCollectorDatabaseReplica = "dbreplica"
|
subCollectorDatabaseReplica = "dbreplica"
|
||||||
subCollectorGeneralStatistics = "genstats"
|
subCollectorGeneralStatistics = "genstats"
|
||||||
|
subCollectorInfo = "info"
|
||||||
subCollectorLocks = "locks"
|
subCollectorLocks = "locks"
|
||||||
subCollectorMemoryManager = "memmgr"
|
subCollectorMemoryManager = "memmgr"
|
||||||
subCollectorSQLErrors = "sqlerrors"
|
subCollectorSQLErrors = "sqlerrors"
|
||||||
@@ -56,7 +53,6 @@ const (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
CollectorsEnabled []string `yaml:"collectors_enabled"`
|
CollectorsEnabled []string `yaml:"collectors_enabled"`
|
||||||
Port uint16 `yaml:"port"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gochecknoglobals
|
//nolint:gochecknoglobals
|
||||||
@@ -68,6 +64,7 @@ var ConfigDefaults = Config{
|
|||||||
subCollectorDatabases,
|
subCollectorDatabases,
|
||||||
subCollectorDatabaseReplica,
|
subCollectorDatabaseReplica,
|
||||||
subCollectorGeneralStatistics,
|
subCollectorGeneralStatistics,
|
||||||
|
subCollectorInfo,
|
||||||
subCollectorLocks,
|
subCollectorLocks,
|
||||||
subCollectorMemoryManager,
|
subCollectorMemoryManager,
|
||||||
subCollectorSQLErrors,
|
subCollectorSQLErrors,
|
||||||
@@ -75,7 +72,6 @@ var ConfigDefaults = Config{
|
|||||||
subCollectorTransactions,
|
subCollectorTransactions,
|
||||||
subCollectorWaitStats,
|
subCollectorWaitStats,
|
||||||
},
|
},
|
||||||
Port: 1433,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics.
|
// A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics.
|
||||||
@@ -84,17 +80,13 @@ type Collector struct {
|
|||||||
|
|
||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
|
|
||||||
mssqlInstances mssqlInstancesType
|
mssqlInstances []mssqlInstance
|
||||||
collectorFns []func(ch chan<- prometheus.Metric) error
|
collectorFns []func(ch chan<- prometheus.Metric) error
|
||||||
closeFns []func()
|
closeFns []func()
|
||||||
|
|
||||||
fileVersion string
|
|
||||||
productVersion string
|
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
mssqlScrapeDurationDesc *prometheus.Desc
|
mssqlScrapeDurationDesc *prometheus.Desc
|
||||||
mssqlScrapeSuccessDesc *prometheus.Desc
|
mssqlScrapeSuccessDesc *prometheus.Desc
|
||||||
mssqlInfoDesc *prometheus.Desc
|
|
||||||
|
|
||||||
collectorAccessMethods
|
collectorAccessMethods
|
||||||
collectorAvailabilityReplica
|
collectorAvailabilityReplica
|
||||||
@@ -102,6 +94,7 @@ type Collector struct {
|
|||||||
collectorDatabaseReplica
|
collectorDatabaseReplica
|
||||||
collectorDatabases
|
collectorDatabases
|
||||||
collectorGeneralStatistics
|
collectorGeneralStatistics
|
||||||
|
collectorInstance
|
||||||
collectorLocks
|
collectorLocks
|
||||||
collectorMemoryManager
|
collectorMemoryManager
|
||||||
collectorSQLErrors
|
collectorSQLErrors
|
||||||
@@ -110,8 +103,6 @@ type Collector struct {
|
|||||||
collectorWaitStats
|
collectorWaitStats
|
||||||
}
|
}
|
||||||
|
|
||||||
type mssqlInstancesType map[string]string
|
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &ConfigDefaults
|
config = &ConfigDefaults
|
||||||
@@ -121,10 +112,6 @@ func New(config *Config) *Collector {
|
|||||||
config.CollectorsEnabled = ConfigDefaults.CollectorsEnabled
|
config.CollectorsEnabled = ConfigDefaults.CollectorsEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Port == 0 {
|
|
||||||
config.Port = ConfigDefaults.Port
|
|
||||||
}
|
|
||||||
|
|
||||||
c := &Collector{
|
c := &Collector{
|
||||||
config: *config,
|
config: *config,
|
||||||
}
|
}
|
||||||
@@ -144,11 +131,6 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
"Comma-separated list of collectors to use.",
|
"Comma-separated list of collectors to use.",
|
||||||
).Default(strings.Join(c.config.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)
|
).Default(strings.Join(c.config.CollectorsEnabled, ",")).StringVar(&collectorsEnabled)
|
||||||
|
|
||||||
app.Flag(
|
|
||||||
"collector.mssql.port",
|
|
||||||
"Port of MSSQL server used for windows_mssql_info metric.",
|
|
||||||
).Default(strconv.FormatUint(uint64(c.config.Port), 10)).Uint16Var(&c.config.Port)
|
|
||||||
|
|
||||||
app.Action(func(*kingpin.ParseContext) error {
|
app.Action(func(*kingpin.ParseContext) error {
|
||||||
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
|
c.config.CollectorsEnabled = strings.Split(collectorsEnabled, ",")
|
||||||
|
|
||||||
@@ -172,18 +154,13 @@ func (c *Collector) Close() error {
|
|||||||
|
|
||||||
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||||
c.logger = logger.With(slog.String("collector", Name))
|
c.logger = logger.With(slog.String("collector", Name))
|
||||||
c.mssqlInstances = c.getMSSQLInstances()
|
|
||||||
|
|
||||||
fileVersion, productVersion, err := c.getMSSQLServerVersion(c.config.Port)
|
instances, err := c.getMSSQLInstances()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("failed to get MSSQL server version",
|
return fmt.Errorf("couldn't get SQL instances: %w", err)
|
||||||
slog.Any("err", err),
|
|
||||||
slog.String("collector", Name),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.fileVersion = fileVersion
|
c.mssqlInstances = instances
|
||||||
c.productVersion = productVersion
|
|
||||||
|
|
||||||
subCollectors := map[string]struct {
|
subCollectors := map[string]struct {
|
||||||
build func() error
|
build func() error
|
||||||
@@ -220,6 +197,11 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
collect: c.collectGeneralStatistics,
|
collect: c.collectGeneralStatistics,
|
||||||
close: c.closeGeneralStatistics,
|
close: c.closeGeneralStatistics,
|
||||||
},
|
},
|
||||||
|
subCollectorInfo: {
|
||||||
|
build: c.buildInstance,
|
||||||
|
collect: c.collectInstance,
|
||||||
|
close: c.closeInstance,
|
||||||
|
},
|
||||||
subCollectorLocks: {
|
subCollectorLocks: {
|
||||||
build: c.buildLocks,
|
build: c.buildLocks,
|
||||||
collect: c.collectLocks,
|
collect: c.collectLocks,
|
||||||
@@ -272,14 +254,6 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
c.closeFns = append(c.closeFns, subCollectors[name].close)
|
c.closeFns = append(c.closeFns, subCollectors[name].close)
|
||||||
}
|
}
|
||||||
|
|
||||||
// meta
|
|
||||||
c.mssqlInfoDesc = prometheus.NewDesc(
|
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "info"),
|
|
||||||
"mssql server information",
|
|
||||||
[]string{"file_version", "version"},
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
|
|
||||||
c.mssqlScrapeDurationDesc = prometheus.NewDesc(
|
c.mssqlScrapeDurationDesc = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "collector_duration_seconds"),
|
prometheus.BuildFQName(types.Namespace, Name, "collector_duration_seconds"),
|
||||||
"windows_exporter: Duration of an mssql child collection.",
|
"windows_exporter: Duration of an mssql child collection.",
|
||||||
@@ -299,6 +273,10 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
// Collect sends the metric values for each metric
|
// Collect sends the metric values for each metric
|
||||||
// to the provided prometheus Metric channel.
|
// to the provided prometheus Metric channel.
|
||||||
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||||
|
if len(c.mssqlInstances) == 0 {
|
||||||
|
return fmt.Errorf("no SQL instances found: %w", pdh.ErrNoData)
|
||||||
|
}
|
||||||
|
|
||||||
errCh := make(chan error, len(c.collectorFns))
|
errCh := make(chan error, len(c.collectorFns))
|
||||||
errs := make([]error, 0, len(c.collectorFns))
|
errs := make([]error, 0, len(c.collectorFns))
|
||||||
|
|
||||||
@@ -326,22 +304,12 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
|||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) getMSSQLInstances() mssqlInstancesType {
|
func (c *Collector) getMSSQLInstances() ([]mssqlInstance, error) {
|
||||||
sqlInstances := make(mssqlInstancesType)
|
|
||||||
|
|
||||||
// in case querying the registry fails, return the default instance
|
|
||||||
sqlDefaultInstance := make(mssqlInstancesType)
|
|
||||||
sqlDefaultInstance["MSSQLSERVER"] = ""
|
|
||||||
|
|
||||||
regKey := `Software\Microsoft\Microsoft SQL Server\Instance Names\SQL`
|
regKey := `Software\Microsoft\Microsoft SQL Server\Instance Names\SQL`
|
||||||
|
|
||||||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regKey, registry.QUERY_VALUE)
|
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regKey, registry.QUERY_VALUE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warn("couldn't open registry to determine SQL instances",
|
return nil, fmt.Errorf("couldn't open registry to determine SQL instances: %w", err)
|
||||||
slog.Any("err", err),
|
|
||||||
)
|
|
||||||
|
|
||||||
return sqlDefaultInstance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func(key registry.Key) {
|
defer func(key registry.Key) {
|
||||||
@@ -354,22 +322,28 @@ func (c *Collector) getMSSQLInstances() mssqlInstancesType {
|
|||||||
|
|
||||||
instanceNames, err := k.ReadValueNames(0)
|
instanceNames, err := k.ReadValueNames(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warn("can't ReadSubKeyNames",
|
return nil, fmt.Errorf("couldn't read subkey names: %w", err)
|
||||||
slog.Any("err", err),
|
|
||||||
)
|
|
||||||
|
|
||||||
return sqlDefaultInstance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sqlInstances := make([]mssqlInstance, 0, len(instanceNames))
|
||||||
|
|
||||||
for _, instanceName := range instanceNames {
|
for _, instanceName := range instanceNames {
|
||||||
if instanceVersion, _, err := k.GetStringValue(instanceName); err == nil {
|
instanceVersion, _, err := k.GetStringValue(instanceName)
|
||||||
sqlInstances[instanceName] = instanceVersion
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("couldn't get instance info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instance, err := newMssqlInstance(instanceVersion)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlInstances = append(sqlInstances, instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Debug(fmt.Sprintf("detected MSSQL Instances: %#v\n", sqlInstances))
|
c.logger.Debug(fmt.Sprintf("detected MSSQL Instances: %#v\n", sqlInstances))
|
||||||
|
|
||||||
return sqlInstances
|
return sqlInstances, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// mssqlGetPerfObjectName returns the name of the Windows Performance
|
// mssqlGetPerfObjectName returns the name of the Windows Performance
|
||||||
@@ -395,26 +369,32 @@ func (c *Collector) mssqlGetPerfObjectName(sqlInstance string, collector string)
|
|||||||
func (c *Collector) collect(
|
func (c *Collector) collect(
|
||||||
ch chan<- prometheus.Metric,
|
ch chan<- prometheus.Metric,
|
||||||
collector string,
|
collector string,
|
||||||
perfDataCollectors map[string]*perfdata.Collector,
|
perfDataCollectors map[string]*pdh.Collector,
|
||||||
collectFn func(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error,
|
collectFn func(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error,
|
||||||
) error {
|
) error {
|
||||||
errs := make([]error, 0, len(perfDataCollectors))
|
errs := make([]error, 0, len(perfDataCollectors))
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
for sqlInstance, perfDataCollector := range perfDataCollectors {
|
for sqlInstance, perfDataCollector := range perfDataCollectors {
|
||||||
begin := time.Now()
|
begin := time.Now()
|
||||||
success := 1.0
|
success := 1.0
|
||||||
err := collectFn(ch, sqlInstance, perfDataCollector)
|
err := collectFn(ch, sqlInstance, perfDataCollector)
|
||||||
duration := time.Since(begin)
|
duration := time.Since(begin)
|
||||||
|
|
||||||
if err != nil && !errors.Is(err, perfdata.ErrNoData) {
|
if err != nil && !errors.Is(err, pdh.ErrNoData) {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
success = 0.0
|
success = 0.0
|
||||||
|
|
||||||
c.logger.Debug(fmt.Sprintf("mssql class collector %s for instance %s failed after %s", collector, sqlInstance, duration),
|
c.logger.LogAttrs(ctx, slog.LevelDebug, fmt.Sprintf("mssql class collector %s for instance %s failed after %s", collector, sqlInstance, duration),
|
||||||
slog.Any("err", err),
|
slog.Any("err", err),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
c.logger.Debug(fmt.Sprintf("mssql class collector %s for instance %s succeeded after %s.", collector, sqlInstance, duration))
|
c.logger.LogAttrs(ctx, slog.LevelDebug, fmt.Sprintf("mssql class collector %s for instance %s succeeded after %s", collector, sqlInstance, duration))
|
||||||
|
}
|
||||||
|
|
||||||
|
if collector == "" {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
@@ -433,68 +413,3 @@ func (c *Collector) collect(
|
|||||||
|
|
||||||
return errors.Join(errs...)
|
return errors.Join(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getMSSQLServerVersion get the version of the SQL Server instance by
|
|
||||||
// reading the version information from the process running the SQL Server instance port.
|
|
||||||
func (c *Collector) getMSSQLServerVersion(port uint16) (string, string, error) {
|
|
||||||
pid, err := iphlpapi.GetOwnerPIDOfTCPPort(windows.AF_INET, port)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to get the PID of the process running on port 1433: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
hProcess, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, pid)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to open the process with PID %d: %w", pid, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer windows.CloseHandle(hProcess) //nolint:errcheck
|
|
||||||
|
|
||||||
processFilePath, err := process.QueryFullProcessImageName(hProcess, process.ImageNameFormatWin32Path)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to query the full path of the process with PID %d: %w", pid, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the file version information
|
|
||||||
size, err := windows.GetFileVersionInfoSize(processFilePath, nil)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to get the size of the file version information: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fileVersionInfo := make([]byte, size)
|
|
||||||
|
|
||||||
err = windows.GetFileVersionInfo(processFilePath, 0, size, unsafe.Pointer(&fileVersionInfo[0]))
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to get the file version information: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
verData *byte
|
|
||||||
verSize uint32
|
|
||||||
)
|
|
||||||
|
|
||||||
err = windows.VerQueryValue(
|
|
||||||
unsafe.Pointer(&fileVersionInfo[0]),
|
|
||||||
`\StringFileInfo\040904b0\ProductVersion`,
|
|
||||||
unsafe.Pointer(&verData),
|
|
||||||
&verSize,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to query the product version: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
productVersion := windows.UTF16ToString((*[1 << 16]uint16)(unsafe.Pointer(verData))[:verSize])
|
|
||||||
|
|
||||||
err = windows.VerQueryValue(
|
|
||||||
unsafe.Pointer(&fileVersionInfo[0]),
|
|
||||||
`\StringFileInfo\040904b0\FileVersion`,
|
|
||||||
unsafe.Pointer(&verData),
|
|
||||||
&verSize,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return "", "", fmt.Errorf("failed to query the file version: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fileVersion := windows.UTF16ToString((*[1 << 16]uint16)(unsafe.Pointer(verData))[:verSize])
|
|
||||||
|
|
||||||
return fileVersion, productVersion, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorAccessMethods struct {
|
type collectorAccessMethods struct {
|
||||||
accessMethodsPerfDataCollectors map[string]*perfdata.Collector
|
accessMethodsPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
accessMethodsPerfDataObject []perfDataCounterValuesAccessMethods
|
||||||
|
|
||||||
accessMethodsAUcleanupbatches *prometheus.Desc
|
accessMethodsAUcleanupbatches *prometheus.Desc
|
||||||
accessMethodsAUcleanups *prometheus.Desc
|
accessMethodsAUcleanups *prometheus.Desc
|
||||||
@@ -73,109 +74,63 @@ type collectorAccessMethods struct {
|
|||||||
accessMethodsWorktablesFromCacheLookups *prometheus.Desc
|
accessMethodsWorktablesFromCacheLookups *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesAccessMethods struct {
|
||||||
accessMethodsAUCleanupbatchesPerSec = "AU cleanup batches/sec"
|
AccessMethodsAUCleanupbatchesPerSec float64 `perfdata:"AU cleanup batches/sec"`
|
||||||
accessMethodsAUCleanupsPerSec = "AU cleanups/sec"
|
AccessMethodsAUCleanupsPerSec float64 `perfdata:"AU cleanups/sec"`
|
||||||
accessMethodsByReferenceLobCreateCount = "By-reference Lob Create Count"
|
AccessMethodsByReferenceLobCreateCount float64 `perfdata:"By-reference Lob Create Count"`
|
||||||
accessMethodsByReferenceLobUseCount = "By-reference Lob Use Count"
|
AccessMethodsByReferenceLobUseCount float64 `perfdata:"By-reference Lob Use Count"`
|
||||||
accessMethodsCountLobReadahead = "Count Lob Readahead"
|
AccessMethodsCountLobReadahead float64 `perfdata:"Count Lob Readahead"`
|
||||||
accessMethodsCountPullInRow = "Count Pull In Row"
|
AccessMethodsCountPullInRow float64 `perfdata:"Count Pull In Row"`
|
||||||
accessMethodsCountPushOffRow = "Count Push Off Row"
|
AccessMethodsCountPushOffRow float64 `perfdata:"Count Push Off Row"`
|
||||||
accessMethodsDeferredDroppedAUs = "Deferred dropped AUs"
|
AccessMethodsDeferredDroppedAUs float64 `perfdata:"Deferred dropped AUs"`
|
||||||
accessMethodsDeferredDroppedRowsets = "Deferred Dropped rowsets"
|
AccessMethodsDeferredDroppedRowsets float64 `perfdata:"Deferred Dropped rowsets"`
|
||||||
accessMethodsDroppedRowsetCleanupsPerSec = "Dropped rowset cleanups/sec"
|
AccessMethodsDroppedRowsetCleanupsPerSec float64 `perfdata:"Dropped rowset cleanups/sec"`
|
||||||
accessMethodsDroppedRowsetsSkippedPerSec = "Dropped rowsets skipped/sec"
|
AccessMethodsDroppedRowsetsSkippedPerSec float64 `perfdata:"Dropped rowsets skipped/sec"`
|
||||||
accessMethodsExtentDeallocationsPerSec = "Extent Deallocations/sec"
|
AccessMethodsExtentDeallocationsPerSec float64 `perfdata:"Extent Deallocations/sec"`
|
||||||
accessMethodsExtentsAllocatedPerSec = "Extents Allocated/sec"
|
AccessMethodsExtentsAllocatedPerSec float64 `perfdata:"Extents Allocated/sec"`
|
||||||
accessMethodsFailedAUCleanupBatchesPerSec = "Failed AU cleanup batches/sec"
|
AccessMethodsFailedAUCleanupBatchesPerSec float64 `perfdata:"Failed AU cleanup batches/sec"`
|
||||||
accessMethodsFailedLeafPageCookie = "Failed leaf page cookie"
|
AccessMethodsFailedLeafPageCookie float64 `perfdata:"Failed leaf page cookie"`
|
||||||
accessMethodsFailedTreePageCookie = "Failed tree page cookie"
|
AccessMethodsFailedTreePageCookie float64 `perfdata:"Failed tree page cookie"`
|
||||||
accessMethodsForwardedRecordsPerSec = "Forwarded Records/sec"
|
AccessMethodsForwardedRecordsPerSec float64 `perfdata:"Forwarded Records/sec"`
|
||||||
accessMethodsFreeSpacePageFetchesPerSec = "FreeSpace Page Fetches/sec"
|
AccessMethodsFreeSpacePageFetchesPerSec float64 `perfdata:"FreeSpace Page Fetches/sec"`
|
||||||
accessMethodsFreeSpaceScansPerSec = "FreeSpace Scans/sec"
|
AccessMethodsFreeSpaceScansPerSec float64 `perfdata:"FreeSpace Scans/sec"`
|
||||||
accessMethodsFullScansPerSec = "Full Scans/sec"
|
AccessMethodsFullScansPerSec float64 `perfdata:"Full Scans/sec"`
|
||||||
accessMethodsIndexSearchesPerSec = "Index Searches/sec"
|
AccessMethodsIndexSearchesPerSec float64 `perfdata:"Index Searches/sec"`
|
||||||
accessMethodsInSysXactWaitsPerSec = "InSysXact waits/sec"
|
AccessMethodsInSysXactWaitsPerSec float64 `perfdata:"InSysXact waits/sec"`
|
||||||
accessMethodsLobHandleCreateCount = "LobHandle Create Count"
|
AccessMethodsLobHandleCreateCount float64 `perfdata:"LobHandle Create Count"`
|
||||||
accessMethodsLobHandleDestroyCount = "LobHandle Destroy Count"
|
AccessMethodsLobHandleDestroyCount float64 `perfdata:"LobHandle Destroy Count"`
|
||||||
accessMethodsLobSSProviderCreateCount = "LobSS Provider Create Count"
|
AccessMethodsLobSSProviderCreateCount float64 `perfdata:"LobSS Provider Create Count"`
|
||||||
accessMethodsLobSSProviderDestroyCount = "LobSS Provider Destroy Count"
|
AccessMethodsLobSSProviderDestroyCount float64 `perfdata:"LobSS Provider Destroy Count"`
|
||||||
accessMethodsLobSSProviderTruncationCount = "LobSS Provider Truncation Count"
|
AccessMethodsLobSSProviderTruncationCount float64 `perfdata:"LobSS Provider Truncation Count"`
|
||||||
accessMethodsMixedPageAllocationsPerSec = "Mixed page allocations/sec"
|
AccessMethodsMixedPageAllocationsPerSec float64 `perfdata:"Mixed page allocations/sec"`
|
||||||
accessMethodsPageCompressionAttemptsPerSec = "Page compression attempts/sec"
|
AccessMethodsPageCompressionAttemptsPerSec float64 `perfdata:"Page compression attempts/sec"`
|
||||||
accessMethodsPageDeallocationsPerSec = "Page Deallocations/sec"
|
AccessMethodsPageDeallocationsPerSec float64 `perfdata:"Page Deallocations/sec"`
|
||||||
accessMethodsPagesAllocatedPerSec = "Pages Allocated/sec"
|
AccessMethodsPagesAllocatedPerSec float64 `perfdata:"Pages Allocated/sec"`
|
||||||
accessMethodsPagesCompressedPerSec = "Pages compressed/sec"
|
AccessMethodsPagesCompressedPerSec float64 `perfdata:"Pages compressed/sec"`
|
||||||
accessMethodsPageSplitsPerSec = "Page Splits/sec"
|
AccessMethodsPageSplitsPerSec float64 `perfdata:"Page Splits/sec"`
|
||||||
accessMethodsProbeScansPerSec = "Probe Scans/sec"
|
AccessMethodsProbeScansPerSec float64 `perfdata:"Probe Scans/sec"`
|
||||||
accessMethodsRangeScansPerSec = "Range Scans/sec"
|
AccessMethodsRangeScansPerSec float64 `perfdata:"Range Scans/sec"`
|
||||||
accessMethodsScanPointRevalidationsPerSec = "Scan Point Revalidations/sec"
|
AccessMethodsScanPointRevalidationsPerSec float64 `perfdata:"Scan Point Revalidations/sec"`
|
||||||
accessMethodsSkippedGhostedRecordsPerSec = "Skipped Ghosted Records/sec"
|
AccessMethodsSkippedGhostedRecordsPerSec float64 `perfdata:"Skipped Ghosted Records/sec"`
|
||||||
accessMethodsTableLockEscalationsPerSec = "Table Lock Escalations/sec"
|
AccessMethodsTableLockEscalationsPerSec float64 `perfdata:"Table Lock Escalations/sec"`
|
||||||
accessMethodsUsedLeafPageCookie = "Used leaf page cookie"
|
AccessMethodsUsedLeafPageCookie float64 `perfdata:"Used leaf page cookie"`
|
||||||
accessMethodsUsedTreePageCookie = "Used tree page cookie"
|
AccessMethodsUsedTreePageCookie float64 `perfdata:"Used tree page cookie"`
|
||||||
accessMethodsWorkfilesCreatedPerSec = "Workfiles Created/sec"
|
AccessMethodsWorkfilesCreatedPerSec float64 `perfdata:"Workfiles Created/sec"`
|
||||||
accessMethodsWorktablesCreatedPerSec = "Worktables Created/sec"
|
AccessMethodsWorktablesCreatedPerSec float64 `perfdata:"Worktables Created/sec"`
|
||||||
accessMethodsWorktablesFromCacheRatio = "Worktables From Cache Ratio"
|
AccessMethodsWorktablesFromCacheRatio float64 `perfdata:"Worktables From Cache Ratio"`
|
||||||
accessMethodsWorktablesFromCacheRatioBase = "Worktables From Cache Base"
|
AccessMethodsWorktablesFromCacheRatioBase float64 `perfdata:"Worktables From Cache Base,secondvalue"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildAccessMethods() error {
|
func (c *Collector) buildAccessMethods() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.accessMethodsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.accessMethodsPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
accessMethodsAUCleanupbatchesPerSec,
|
|
||||||
accessMethodsAUCleanupsPerSec,
|
|
||||||
accessMethodsByReferenceLobCreateCount,
|
|
||||||
accessMethodsByReferenceLobUseCount,
|
|
||||||
accessMethodsCountLobReadahead,
|
|
||||||
accessMethodsCountPullInRow,
|
|
||||||
accessMethodsCountPushOffRow,
|
|
||||||
accessMethodsDeferredDroppedAUs,
|
|
||||||
accessMethodsDeferredDroppedRowsets,
|
|
||||||
accessMethodsDroppedRowsetCleanupsPerSec,
|
|
||||||
accessMethodsDroppedRowsetsSkippedPerSec,
|
|
||||||
accessMethodsExtentDeallocationsPerSec,
|
|
||||||
accessMethodsExtentsAllocatedPerSec,
|
|
||||||
accessMethodsFailedAUCleanupBatchesPerSec,
|
|
||||||
accessMethodsFailedLeafPageCookie,
|
|
||||||
accessMethodsFailedTreePageCookie,
|
|
||||||
accessMethodsForwardedRecordsPerSec,
|
|
||||||
accessMethodsFreeSpacePageFetchesPerSec,
|
|
||||||
accessMethodsFreeSpaceScansPerSec,
|
|
||||||
accessMethodsFullScansPerSec,
|
|
||||||
accessMethodsIndexSearchesPerSec,
|
|
||||||
accessMethodsInSysXactWaitsPerSec,
|
|
||||||
accessMethodsLobHandleCreateCount,
|
|
||||||
accessMethodsLobHandleDestroyCount,
|
|
||||||
accessMethodsLobSSProviderCreateCount,
|
|
||||||
accessMethodsLobSSProviderDestroyCount,
|
|
||||||
accessMethodsLobSSProviderTruncationCount,
|
|
||||||
accessMethodsMixedPageAllocationsPerSec,
|
|
||||||
accessMethodsPageCompressionAttemptsPerSec,
|
|
||||||
accessMethodsPageDeallocationsPerSec,
|
|
||||||
accessMethodsPagesAllocatedPerSec,
|
|
||||||
accessMethodsPagesCompressedPerSec,
|
|
||||||
accessMethodsPageSplitsPerSec,
|
|
||||||
accessMethodsProbeScansPerSec,
|
|
||||||
accessMethodsRangeScansPerSec,
|
|
||||||
accessMethodsScanPointRevalidationsPerSec,
|
|
||||||
accessMethodsSkippedGhostedRecordsPerSec,
|
|
||||||
accessMethodsTableLockEscalationsPerSec,
|
|
||||||
accessMethodsUsedLeafPageCookie,
|
|
||||||
accessMethodsUsedTreePageCookie,
|
|
||||||
accessMethodsWorkfilesCreatedPerSec,
|
|
||||||
accessMethodsWorktablesCreatedPerSec,
|
|
||||||
accessMethodsWorktablesFromCacheRatio,
|
|
||||||
accessMethodsWorktablesFromCacheRatioBase,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.accessMethodsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Access Methods"), nil, counters)
|
c.accessMethodsPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesAccessMethods](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Access Methods"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create AccessMethods collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create AccessMethods collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,326 +407,317 @@ func (c *Collector) collectAccessMethods(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorAccessMethods, c.accessMethodsPerfDataCollectors, c.collectAccessMethodsInstance)
|
return c.collect(ch, subCollectorAccessMethods, c.accessMethodsPerfDataCollectors, c.collectAccessMethodsInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectAccessMethodsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectAccessMethodsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.accessMethodsPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "AccessMethods"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "AccessMethods"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "AccessMethods"))
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsAUcleanupbatches,
|
c.accessMethodsAUcleanupbatches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsAUCleanupbatchesPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsAUCleanupbatchesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsAUcleanups,
|
c.accessMethodsAUcleanups,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsAUCleanupsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsAUCleanupsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsByReferenceLobCreateCount,
|
c.accessMethodsByReferenceLobCreateCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsByReferenceLobCreateCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsByReferenceLobCreateCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsByReferenceLobUseCount,
|
c.accessMethodsByReferenceLobUseCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsByReferenceLobUseCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsByReferenceLobUseCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsCountLobReadahead,
|
c.accessMethodsCountLobReadahead,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsCountLobReadahead].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsCountLobReadahead,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsCountPullInRow,
|
c.accessMethodsCountPullInRow,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsCountPullInRow].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsCountPullInRow,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsCountPushOffRow,
|
c.accessMethodsCountPushOffRow,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsCountPushOffRow].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsCountPushOffRow,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsDeferreddroppedAUs,
|
c.accessMethodsDeferreddroppedAUs,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[accessMethodsDeferredDroppedAUs].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsDeferredDroppedAUs,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsDeferredDroppedrowsets,
|
c.accessMethodsDeferredDroppedrowsets,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[accessMethodsDeferredDroppedRowsets].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsDeferredDroppedRowsets,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsDroppedrowsetcleanups,
|
c.accessMethodsDroppedrowsetcleanups,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsDroppedRowsetCleanupsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsDroppedRowsetCleanupsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsDroppedrowsetsskipped,
|
c.accessMethodsDroppedrowsetsskipped,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsDroppedRowsetsSkippedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsDroppedRowsetsSkippedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsExtentDeallocations,
|
c.accessMethodsExtentDeallocations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsExtentDeallocationsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsExtentDeallocationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsExtentsAllocated,
|
c.accessMethodsExtentsAllocated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsExtentsAllocatedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsExtentsAllocatedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFailedAUcleanupbatches,
|
c.accessMethodsFailedAUcleanupbatches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFailedAUCleanupBatchesPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFailedAUCleanupBatchesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFailedleafpagecookie,
|
c.accessMethodsFailedleafpagecookie,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFailedLeafPageCookie].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFailedLeafPageCookie,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFailedtreepagecookie,
|
c.accessMethodsFailedtreepagecookie,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFailedTreePageCookie].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFailedTreePageCookie,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsForwardedRecords,
|
c.accessMethodsForwardedRecords,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsForwardedRecordsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsForwardedRecordsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFreeSpacePageFetches,
|
c.accessMethodsFreeSpacePageFetches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFreeSpacePageFetchesPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFreeSpacePageFetchesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFreeSpaceScans,
|
c.accessMethodsFreeSpaceScans,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFreeSpaceScansPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFreeSpaceScansPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsFullScans,
|
c.accessMethodsFullScans,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsFullScansPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsFullScansPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsIndexSearches,
|
c.accessMethodsIndexSearches,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsIndexSearchesPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsIndexSearchesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsInSysXactwaits,
|
c.accessMethodsInSysXactwaits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsInSysXactWaitsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsInSysXactWaitsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsLobHandleCreateCount,
|
c.accessMethodsLobHandleCreateCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsLobHandleCreateCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsLobHandleCreateCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsLobHandleDestroyCount,
|
c.accessMethodsLobHandleDestroyCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsLobHandleDestroyCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsLobHandleDestroyCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsLobSSProviderCreateCount,
|
c.accessMethodsLobSSProviderCreateCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsLobSSProviderCreateCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsLobSSProviderCreateCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsLobSSProviderDestroyCount,
|
c.accessMethodsLobSSProviderDestroyCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsLobSSProviderDestroyCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsLobSSProviderDestroyCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsLobSSProviderTruncationCount,
|
c.accessMethodsLobSSProviderTruncationCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsLobSSProviderTruncationCount].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsLobSSProviderTruncationCount,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsMixedPageAllocations,
|
c.accessMethodsMixedPageAllocations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsMixedPageAllocationsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsMixedPageAllocationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsPageCompressionAttempts,
|
c.accessMethodsPageCompressionAttempts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsPageCompressionAttemptsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsPageCompressionAttemptsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsPageDeallocations,
|
c.accessMethodsPageDeallocations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsPageDeallocationsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsPageDeallocationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsPagesAllocated,
|
c.accessMethodsPagesAllocated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsPagesAllocatedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsPagesAllocatedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsPagesCompressed,
|
c.accessMethodsPagesCompressed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsPagesCompressedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsPagesCompressedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsPageSplits,
|
c.accessMethodsPageSplits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsPageSplitsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsPageSplitsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsProbeScans,
|
c.accessMethodsProbeScans,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsProbeScansPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsProbeScansPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsRangeScans,
|
c.accessMethodsRangeScans,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsRangeScansPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsRangeScansPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsScanPointRevalidations,
|
c.accessMethodsScanPointRevalidations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsScanPointRevalidationsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsScanPointRevalidationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsSkippedGhostedRecords,
|
c.accessMethodsSkippedGhostedRecords,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsSkippedGhostedRecordsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsSkippedGhostedRecordsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsTableLockEscalations,
|
c.accessMethodsTableLockEscalations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsTableLockEscalationsPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsTableLockEscalationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsUsedleafpagecookie,
|
c.accessMethodsUsedleafpagecookie,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsUsedLeafPageCookie].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsUsedLeafPageCookie,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsUsedtreepagecookie,
|
c.accessMethodsUsedtreepagecookie,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsUsedTreePageCookie].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsUsedTreePageCookie,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsWorkfilesCreated,
|
c.accessMethodsWorkfilesCreated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsWorkfilesCreatedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsWorkfilesCreatedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsWorktablesCreated,
|
c.accessMethodsWorktablesCreated,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsWorktablesCreatedPerSec].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsWorktablesCreatedPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsWorktablesFromCacheHits,
|
c.accessMethodsWorktablesFromCacheHits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsWorktablesFromCacheRatio].FirstValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsWorktablesFromCacheRatio,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.accessMethodsWorktablesFromCacheLookups,
|
c.accessMethodsWorktablesFromCacheLookups,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[accessMethodsWorktablesFromCacheRatioBase].SecondValue,
|
c.accessMethodsPerfDataObject[0].AccessMethodsWorktablesFromCacheRatioBase,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/utils"
|
"github.com/prometheus-community/windows_exporter/internal/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorAvailabilityReplica struct {
|
type collectorAvailabilityReplica struct {
|
||||||
availabilityReplicaPerfDataCollectors map[string]*perfdata.Collector
|
availabilityReplicaPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
availabilityReplicaPerfDataObject []perfDataCounterValuesAvailabilityReplica
|
||||||
|
|
||||||
availReplicaBytesReceivedFromReplica *prometheus.Desc
|
availReplicaBytesReceivedFromReplica *prometheus.Desc
|
||||||
availReplicaBytesSentToReplica *prometheus.Desc
|
availReplicaBytesSentToReplica *prometheus.Desc
|
||||||
@@ -39,39 +40,30 @@ type collectorAvailabilityReplica struct {
|
|||||||
availReplicaSendsToTransport *prometheus.Desc
|
availReplicaSendsToTransport *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesAvailabilityReplica struct {
|
||||||
availReplicaBytesReceivedFromReplicaPerSec = "Bytes Received from Replica/sec"
|
Name string
|
||||||
availReplicaBytesSentToReplicaPerSec = "Bytes Sent to Replica/sec"
|
|
||||||
availReplicaBytesSentToTransportPerSec = "Bytes Sent to Transport/sec"
|
AvailReplicaBytesReceivedFromReplicaPerSec float64 `perfdata:"Bytes Received from Replica/sec"`
|
||||||
availReplicaFlowControlPerSec = "Flow Control/sec"
|
AvailReplicaBytesSentToReplicaPerSec float64 `perfdata:"Bytes Sent to Replica/sec"`
|
||||||
availReplicaFlowControlTimeMSPerSec = "Flow Control Time (ms/sec)"
|
AvailReplicaBytesSentToTransportPerSec float64 `perfdata:"Bytes Sent to Transport/sec"`
|
||||||
availReplicaReceivesFromReplicaPerSec = "Receives from Replica/sec"
|
AvailReplicaFlowControlPerSec float64 `perfdata:"Flow Control/sec"`
|
||||||
availReplicaResentMessagesPerSec = "Resent Messages/sec"
|
AvailReplicaFlowControlTimeMSPerSec float64 `perfdata:"Flow Control Time (ms/sec)"`
|
||||||
availReplicaSendsToReplicaPerSec = "Sends to Replica/sec"
|
AvailReplicaReceivesFromReplicaPerSec float64 `perfdata:"Receives from Replica/sec"`
|
||||||
availReplicaSendsToTransportPerSec = "Sends to Transport/sec"
|
AvailReplicaResentMessagesPerSec float64 `perfdata:"Resent Messages/sec"`
|
||||||
)
|
AvailReplicaSendsToReplicaPerSec float64 `perfdata:"Sends to Replica/sec"`
|
||||||
|
AvailReplicaSendsToTransportPerSec float64 `perfdata:"Sends to Transport/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildAvailabilityReplica() error {
|
func (c *Collector) buildAvailabilityReplica() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.availabilityReplicaPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.availabilityReplicaPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
availReplicaBytesReceivedFromReplicaPerSec,
|
|
||||||
availReplicaBytesSentToReplicaPerSec,
|
|
||||||
availReplicaBytesSentToTransportPerSec,
|
|
||||||
availReplicaFlowControlPerSec,
|
|
||||||
availReplicaFlowControlTimeMSPerSec,
|
|
||||||
availReplicaReceivesFromReplicaPerSec,
|
|
||||||
availReplicaResentMessagesPerSec,
|
|
||||||
availReplicaSendsToReplicaPerSec,
|
|
||||||
availReplicaSendsToTransportPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.availabilityReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Availability Replica"), perfdata.InstancesAll, counters)
|
c.availabilityReplicaPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesAvailabilityReplica](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Availability Replica"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Availability Replica collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Availability Replica collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,78 +130,74 @@ func (c *Collector) collectAvailabilityReplica(ch chan<- prometheus.Metric) erro
|
|||||||
return c.collect(ch, subCollectorAvailabilityReplica, c.availabilityReplicaPerfDataCollectors, c.collectAvailabilityReplicaInstance)
|
return c.collect(ch, subCollectorAvailabilityReplica, c.availabilityReplicaPerfDataCollectors, c.collectAvailabilityReplicaInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectAvailabilityReplicaInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectAvailabilityReplicaInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.availabilityReplicaPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Availability Replica"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Availability Replica"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for replicaName, data := range perfData {
|
for _, data := range c.availabilityReplicaPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaBytesReceivedFromReplica,
|
c.availReplicaBytesReceivedFromReplica,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaBytesReceivedFromReplicaPerSec].FirstValue,
|
data.AvailReplicaBytesReceivedFromReplicaPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaBytesSentToReplica,
|
c.availReplicaBytesSentToReplica,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaBytesSentToReplicaPerSec].FirstValue,
|
data.AvailReplicaBytesSentToReplicaPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaBytesSentToTransport,
|
c.availReplicaBytesSentToTransport,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaBytesSentToTransportPerSec].FirstValue,
|
data.AvailReplicaBytesSentToTransportPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaFlowControl,
|
c.availReplicaFlowControl,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaFlowControlPerSec].FirstValue,
|
data.AvailReplicaFlowControlPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaFlowControlTimeMS,
|
c.availReplicaFlowControlTimeMS,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
utils.MilliSecToSec(data[availReplicaFlowControlTimeMSPerSec].FirstValue),
|
utils.MilliSecToSec(data.AvailReplicaFlowControlTimeMSPerSec),
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaReceivesFromReplica,
|
c.availReplicaReceivesFromReplica,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaReceivesFromReplicaPerSec].FirstValue,
|
data.AvailReplicaReceivesFromReplicaPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaResentMessages,
|
c.availReplicaResentMessages,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaResentMessagesPerSec].FirstValue,
|
data.AvailReplicaResentMessagesPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaSendsToReplica,
|
c.availReplicaSendsToReplica,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaSendsToReplicaPerSec].FirstValue,
|
data.AvailReplicaSendsToReplicaPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.availReplicaSendsToTransport,
|
c.availReplicaSendsToTransport,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[availReplicaSendsToTransportPerSec].FirstValue,
|
data.AvailReplicaSendsToTransportPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorBufferManager struct {
|
type collectorBufferManager struct {
|
||||||
bufManPerfDataCollectors map[string]*perfdata.Collector
|
bufManPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
bufManPerfDataObject []perfDataCounterValuesBufMan
|
||||||
|
|
||||||
bufManBackgroundwriterpages *prometheus.Desc
|
bufManBackgroundwriterpages *prometheus.Desc
|
||||||
bufManBuffercachehits *prometheus.Desc
|
bufManBuffercachehits *prometheus.Desc
|
||||||
@@ -52,67 +53,42 @@ type collectorBufferManager struct {
|
|||||||
bufManTargetpages *prometheus.Desc
|
bufManTargetpages *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesBufMan struct {
|
||||||
bufManBackgroundWriterPagesPerSec = "Background writer pages/sec"
|
BufManBackgroundWriterPagesPerSec float64 `perfdata:"Background writer pages/sec"`
|
||||||
bufManBufferCacheHitRatio = "Buffer cache hit ratio"
|
BufManBufferCacheHitRatio float64 `perfdata:"Buffer cache hit ratio"`
|
||||||
bufManBufferCacheHitRatioBase = "Buffer cache hit ratio base"
|
BufManBufferCacheHitRatioBase float64 `perfdata:"Buffer cache hit ratio base,secondvalue"`
|
||||||
bufManCheckpointPagesPerSec = "Checkpoint pages/sec"
|
BufManCheckpointPagesPerSec float64 `perfdata:"Checkpoint pages/sec"`
|
||||||
bufManDatabasePages = "Database pages"
|
BufManDatabasePages float64 `perfdata:"Database pages"`
|
||||||
bufManExtensionAllocatedPages = "Extension allocated pages"
|
BufManExtensionAllocatedPages float64 `perfdata:"Extension allocated pages"`
|
||||||
bufManExtensionFreePages = "Extension free pages"
|
BufManExtensionFreePages float64 `perfdata:"Extension free pages"`
|
||||||
bufManExtensionInUseAsPercentage = "Extension in use as percentage"
|
BufManExtensionInUseAsPercentage float64 `perfdata:"Extension in use as percentage"`
|
||||||
bufManExtensionOutstandingIOCounter = "Extension outstanding IO counter"
|
BufManExtensionOutstandingIOCounter float64 `perfdata:"Extension outstanding IO counter"`
|
||||||
bufManExtensionPageEvictionsPerSec = "Extension page evictions/sec"
|
BufManExtensionPageEvictionsPerSec float64 `perfdata:"Extension page evictions/sec"`
|
||||||
bufManExtensionPageReadsPerSec = "Extension page reads/sec"
|
BufManExtensionPageReadsPerSec float64 `perfdata:"Extension page reads/sec"`
|
||||||
bufManExtensionPageUnreferencedTime = "Extension page unreferenced time"
|
BufManExtensionPageUnreferencedTime float64 `perfdata:"Extension page unreferenced time"`
|
||||||
bufManExtensionPageWritesPerSec = "Extension page writes/sec"
|
BufManExtensionPageWritesPerSec float64 `perfdata:"Extension page writes/sec"`
|
||||||
bufManFreeListStallsPerSec = "Free list stalls/sec"
|
BufManFreeListStallsPerSec float64 `perfdata:"Free list stalls/sec"`
|
||||||
bufManIntegralControllerSlope = "Integral Controller Slope"
|
BufManIntegralControllerSlope float64 `perfdata:"Integral Controller Slope"`
|
||||||
bufManLazyWritesPerSec = "Lazy writes/sec"
|
BufManLazyWritesPerSec float64 `perfdata:"Lazy writes/sec"`
|
||||||
bufManPageLifeExpectancy = "Page life expectancy"
|
BufManPageLifeExpectancy float64 `perfdata:"Page life expectancy"`
|
||||||
bufManPageLookupsPerSec = "Page lookups/sec"
|
BufManPageLookupsPerSec float64 `perfdata:"Page lookups/sec"`
|
||||||
bufManPageReadsPerSec = "Page reads/sec"
|
BufManPageReadsPerSec float64 `perfdata:"Page reads/sec"`
|
||||||
bufManPageWritesPerSec = "Page writes/sec"
|
BufManPageWritesPerSec float64 `perfdata:"Page writes/sec"`
|
||||||
bufManReadaheadPagesPerSec = "Readahead pages/sec"
|
BufManReadaheadPagesPerSec float64 `perfdata:"Readahead pages/sec"`
|
||||||
bufManReadaheadTimePerSec = "Readahead time/sec"
|
BufManReadaheadTimePerSec float64 `perfdata:"Readahead time/sec"`
|
||||||
bufManTargetPages = "Target pages"
|
BufManTargetPages float64 `perfdata:"Target pages"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildBufferManager() error {
|
func (c *Collector) buildBufferManager() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.bufManPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.bufManPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
bufManBackgroundWriterPagesPerSec,
|
|
||||||
bufManBufferCacheHitRatio,
|
|
||||||
bufManBufferCacheHitRatioBase,
|
|
||||||
bufManCheckpointPagesPerSec,
|
|
||||||
bufManDatabasePages,
|
|
||||||
bufManExtensionAllocatedPages,
|
|
||||||
bufManExtensionFreePages,
|
|
||||||
bufManExtensionInUseAsPercentage,
|
|
||||||
bufManExtensionOutstandingIOCounter,
|
|
||||||
bufManExtensionPageEvictionsPerSec,
|
|
||||||
bufManExtensionPageReadsPerSec,
|
|
||||||
bufManExtensionPageUnreferencedTime,
|
|
||||||
bufManExtensionPageWritesPerSec,
|
|
||||||
bufManFreeListStallsPerSec,
|
|
||||||
bufManIntegralControllerSlope,
|
|
||||||
bufManLazyWritesPerSec,
|
|
||||||
bufManPageLifeExpectancy,
|
|
||||||
bufManPageLookupsPerSec,
|
|
||||||
bufManPageReadsPerSec,
|
|
||||||
bufManPageWritesPerSec,
|
|
||||||
bufManReadaheadPagesPerSec,
|
|
||||||
bufManReadaheadTimePerSec,
|
|
||||||
bufManTargetPages,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.bufManPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Buffer Manager"), nil, counters)
|
c.bufManPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesBufMan](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Buffer Manager"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Buffer Manager collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Buffer Manager collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,175 +238,171 @@ func (c *Collector) collectBufferManager(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorBufferManager, c.bufManPerfDataCollectors, c.collectBufferManagerInstance)
|
return c.collect(ch, subCollectorBufferManager, c.bufManPerfDataCollectors, c.collectBufferManagerInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectBufferManagerInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectBufferManagerInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.bufManPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Buffer Manager"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Buffer Manager"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, data := range perfData {
|
for _, data := range c.bufManPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManBackgroundwriterpages,
|
c.bufManBackgroundwriterpages,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManBackgroundWriterPagesPerSec].FirstValue,
|
data.BufManBackgroundWriterPagesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManBuffercachehits,
|
c.bufManBuffercachehits,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManBufferCacheHitRatio].FirstValue,
|
data.BufManBufferCacheHitRatio,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManBuffercachelookups,
|
c.bufManBuffercachelookups,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManBufferCacheHitRatioBase].SecondValue,
|
data.BufManBufferCacheHitRatioBase,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManCheckpointpages,
|
c.bufManCheckpointpages,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManCheckpointPagesPerSec].FirstValue,
|
data.BufManCheckpointPagesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManDatabasepages,
|
c.bufManDatabasepages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManDatabasePages].FirstValue,
|
data.BufManDatabasePages,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionallocatedpages,
|
c.bufManExtensionallocatedpages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManExtensionAllocatedPages].FirstValue,
|
data.BufManExtensionAllocatedPages,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionfreepages,
|
c.bufManExtensionfreepages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManExtensionFreePages].FirstValue,
|
data.BufManExtensionFreePages,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensioninuseaspercentage,
|
c.bufManExtensioninuseaspercentage,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManExtensionInUseAsPercentage].FirstValue,
|
data.BufManExtensionInUseAsPercentage,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionoutstandingIOcounter,
|
c.bufManExtensionoutstandingIOcounter,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManExtensionOutstandingIOCounter].FirstValue,
|
data.BufManExtensionOutstandingIOCounter,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionpageevictions,
|
c.bufManExtensionpageevictions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManExtensionPageEvictionsPerSec].FirstValue,
|
data.BufManExtensionPageEvictionsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionpagereads,
|
c.bufManExtensionpagereads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManExtensionPageReadsPerSec].FirstValue,
|
data.BufManExtensionPageReadsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionpageunreferencedtime,
|
c.bufManExtensionpageunreferencedtime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManExtensionPageUnreferencedTime].FirstValue,
|
data.BufManExtensionPageUnreferencedTime,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManExtensionpagewrites,
|
c.bufManExtensionpagewrites,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManExtensionPageWritesPerSec].FirstValue,
|
data.BufManExtensionPageWritesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManFreeliststalls,
|
c.bufManFreeliststalls,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManFreeListStallsPerSec].FirstValue,
|
data.BufManFreeListStallsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManIntegralControllerSlope,
|
c.bufManIntegralControllerSlope,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManIntegralControllerSlope].FirstValue,
|
data.BufManIntegralControllerSlope,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManLazywrites,
|
c.bufManLazywrites,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManLazyWritesPerSec].FirstValue,
|
data.BufManLazyWritesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManPagelifeexpectancy,
|
c.bufManPagelifeexpectancy,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManPageLifeExpectancy].FirstValue,
|
data.BufManPageLifeExpectancy,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManPagelookups,
|
c.bufManPagelookups,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManPageLookupsPerSec].FirstValue,
|
data.BufManPageLookupsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManPagereads,
|
c.bufManPagereads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManPageReadsPerSec].FirstValue,
|
data.BufManPageReadsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManPagewrites,
|
c.bufManPagewrites,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManPageWritesPerSec].FirstValue,
|
data.BufManPageWritesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManReadaheadpages,
|
c.bufManReadaheadpages,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManReadaheadPagesPerSec].FirstValue,
|
data.BufManReadaheadPagesPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManReadaheadtime,
|
c.bufManReadaheadtime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[bufManReadaheadTimePerSec].FirstValue,
|
data.BufManReadaheadTimePerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.bufManTargetpages,
|
c.bufManTargetpages,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[bufManTargetPages].FirstValue,
|
data.BufManTargetPages,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,16 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorDatabases struct {
|
type collectorDatabases struct {
|
||||||
databasesPerfDataCollectors map[string]*perfdata.Collector
|
databasesPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
databasesPerfDataCollectors2019 map[string]*pdh.Collector
|
||||||
|
databasesPerfDataObject []perfDataCounterValuesDatabases
|
||||||
|
databasesPerfDataObject2019 []perfDataCounterValuesDatabases2019
|
||||||
|
|
||||||
databasesActiveParallelRedoThreads *prometheus.Desc
|
databasesActiveParallelRedoThreads *prometheus.Desc
|
||||||
databasesActiveTransactions *prometheus.Desc
|
databasesActiveTransactions *prometheus.Desc
|
||||||
@@ -77,117 +80,82 @@ type collectorDatabases struct {
|
|||||||
databasesXTPMemoryUsedKB *prometheus.Desc
|
databasesXTPMemoryUsedKB *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesDatabases struct {
|
||||||
databasesActiveParallelRedoThreads = "Active parallel redo threads"
|
Name string
|
||||||
databasesActiveTransactions = "Active Transactions"
|
|
||||||
databasesBackupPerRestoreThroughputPerSec = "Backup/Restore Throughput/sec"
|
DatabasesActiveTransactions float64 `perfdata:"Active Transactions"`
|
||||||
databasesBulkCopyRowsPerSec = "Bulk Copy Rows/sec"
|
DatabasesBackupPerRestoreThroughputPerSec float64 `perfdata:"Backup/Restore Throughput/sec"`
|
||||||
databasesBulkCopyThroughputPerSec = "Bulk Copy Throughput/sec"
|
DatabasesBulkCopyRowsPerSec float64 `perfdata:"Bulk Copy Rows/sec"`
|
||||||
databasesCommitTableEntries = "Commit table entries"
|
DatabasesBulkCopyThroughputPerSec float64 `perfdata:"Bulk Copy Throughput/sec"`
|
||||||
databasesDataFilesSizeKB = "Data File(s) Size (KB)"
|
DatabasesCommitTableEntries float64 `perfdata:"Commit table entries"`
|
||||||
databasesDBCCLogicalScanBytesPerSec = "DBCC Logical Scan Bytes/sec"
|
DatabasesDataFilesSizeKB float64 `perfdata:"Data File(s) Size (KB)"`
|
||||||
databasesGroupCommitTimePerSec = "Group Commit Time/sec"
|
DatabasesDBCCLogicalScanBytesPerSec float64 `perfdata:"DBCC Logical Scan Bytes/sec"`
|
||||||
databasesLogBytesFlushedPerSec = "Log Bytes Flushed/sec"
|
DatabasesGroupCommitTimePerSec float64 `perfdata:"Group Commit Time/sec"`
|
||||||
databasesLogCacheHitRatio = "Log Cache Hit Ratio"
|
DatabasesLogBytesFlushedPerSec float64 `perfdata:"Log Bytes Flushed/sec"`
|
||||||
databasesLogCacheHitRatioBase = "Log Cache Hit Ratio Base"
|
DatabasesLogCacheHitRatio float64 `perfdata:"Log Cache Hit Ratio"`
|
||||||
databasesLogCacheReadsPerSec = "Log Cache Reads/sec"
|
DatabasesLogCacheHitRatioBase float64 `perfdata:"Log Cache Hit Ratio Base,secondvalue"`
|
||||||
databasesLogFilesSizeKB = "Log File(s) Size (KB)"
|
DatabasesLogCacheReadsPerSec float64 `perfdata:"Log Cache Reads/sec"`
|
||||||
databasesLogFilesUsedSizeKB = "Log File(s) Used Size (KB)"
|
DatabasesLogFilesSizeKB float64 `perfdata:"Log File(s) Size (KB)"`
|
||||||
databasesLogFlushesPerSec = "Log Flushes/sec"
|
DatabasesLogFilesUsedSizeKB float64 `perfdata:"Log File(s) Used Size (KB)"`
|
||||||
databasesLogFlushWaitsPerSec = "Log Flush Waits/sec"
|
DatabasesLogFlushesPerSec float64 `perfdata:"Log Flushes/sec"`
|
||||||
databasesLogFlushWaitTime = "Log Flush Wait Time"
|
DatabasesLogFlushWaitsPerSec float64 `perfdata:"Log Flush Waits/sec"`
|
||||||
databasesLogFlushWriteTimeMS = "Log Flush Write Time (ms)"
|
DatabasesLogFlushWaitTime float64 `perfdata:"Log Flush Wait Time"`
|
||||||
databasesLogGrowths = "Log Growths"
|
DatabasesLogFlushWriteTimeMS float64 `perfdata:"Log Flush Write Time (ms)"`
|
||||||
databasesLogPoolCacheMissesPerSec = "Log Pool Cache Misses/sec"
|
DatabasesLogGrowths float64 `perfdata:"Log Growths"`
|
||||||
databasesLogPoolDiskReadsPerSec = "Log Pool Disk Reads/sec"
|
DatabasesLogPoolCacheMissesPerSec float64 `perfdata:"Log Pool Cache Misses/sec"`
|
||||||
databasesLogPoolHashDeletesPerSec = "Log Pool Hash Deletes/sec"
|
DatabasesLogPoolDiskReadsPerSec float64 `perfdata:"Log Pool Disk Reads/sec"`
|
||||||
databasesLogPoolHashInsertsPerSec = "Log Pool Hash Inserts/sec"
|
DatabasesLogPoolHashDeletesPerSec float64 `perfdata:"Log Pool Hash Deletes/sec"`
|
||||||
databasesLogPoolInvalidHashEntryPerSec = "Log Pool Invalid Hash Entry/sec"
|
DatabasesLogPoolHashInsertsPerSec float64 `perfdata:"Log Pool Hash Inserts/sec"`
|
||||||
databasesLogPoolLogScanPushesPerSec = "Log Pool Log Scan Pushes/sec"
|
DatabasesLogPoolInvalidHashEntryPerSec float64 `perfdata:"Log Pool Invalid Hash Entry/sec"`
|
||||||
databasesLogPoolLogWriterPushesPerSec = "Log Pool LogWriter Pushes/sec"
|
DatabasesLogPoolLogScanPushesPerSec float64 `perfdata:"Log Pool Log Scan Pushes/sec"`
|
||||||
databasesLogPoolPushEmptyFreePoolPerSec = "Log Pool Push Empty FreePool/sec"
|
DatabasesLogPoolLogWriterPushesPerSec float64 `perfdata:"Log Pool LogWriter Pushes/sec"`
|
||||||
databasesLogPoolPushLowMemoryPerSec = "Log Pool Push Low Memory/sec"
|
DatabasesLogPoolPushEmptyFreePoolPerSec float64 `perfdata:"Log Pool Push Empty FreePool/sec"`
|
||||||
databasesLogPoolPushNoFreeBufferPerSec = "Log Pool Push No Free Buffer/sec"
|
DatabasesLogPoolPushLowMemoryPerSec float64 `perfdata:"Log Pool Push Low Memory/sec"`
|
||||||
databasesLogPoolReqBehindTruncPerSec = "Log Pool Req. Behind Trunc/sec"
|
DatabasesLogPoolPushNoFreeBufferPerSec float64 `perfdata:"Log Pool Push No Free Buffer/sec"`
|
||||||
databasesLogPoolRequestsOldVLFPerSec = "Log Pool Requests Old VLF/sec"
|
DatabasesLogPoolReqBehindTruncPerSec float64 `perfdata:"Log Pool Req. Behind Trunc/sec"`
|
||||||
databasesLogPoolRequestsPerSec = "Log Pool Requests/sec"
|
DatabasesLogPoolRequestsOldVLFPerSec float64 `perfdata:"Log Pool Requests Old VLF/sec"`
|
||||||
databasesLogPoolTotalActiveLogSize = "Log Pool Total Active Log Size"
|
DatabasesLogPoolRequestsPerSec float64 `perfdata:"Log Pool Requests/sec"`
|
||||||
databasesLogPoolTotalSharedPoolSize = "Log Pool Total Shared Pool Size"
|
DatabasesLogPoolTotalActiveLogSize float64 `perfdata:"Log Pool Total Active Log Size"`
|
||||||
databasesLogShrinks = "Log Shrinks"
|
DatabasesLogPoolTotalSharedPoolSize float64 `perfdata:"Log Pool Total Shared Pool Size"`
|
||||||
databasesLogTruncations = "Log Truncations"
|
DatabasesLogShrinks float64 `perfdata:"Log Shrinks"`
|
||||||
databasesPercentLogUsed = "Percent Log Used"
|
DatabasesLogTruncations float64 `perfdata:"Log Truncations"`
|
||||||
databasesReplPendingXacts = "Repl. Pending Xacts"
|
DatabasesPercentLogUsed float64 `perfdata:"Percent Log Used"`
|
||||||
databasesReplTransRate = "Repl. Trans. Rate"
|
DatabasesReplPendingXacts float64 `perfdata:"Repl. Pending Xacts"`
|
||||||
databasesShrinkDataMovementBytesPerSec = "Shrink Data Movement Bytes/sec"
|
DatabasesReplTransRate float64 `perfdata:"Repl. Trans. Rate"`
|
||||||
databasesTrackedTransactionsPerSec = "Tracked transactions/sec"
|
DatabasesShrinkDataMovementBytesPerSec float64 `perfdata:"Shrink Data Movement Bytes/sec"`
|
||||||
databasesTransactionsPerSec = "Transactions/sec"
|
DatabasesTrackedTransactionsPerSec float64 `perfdata:"Tracked transactions/sec"`
|
||||||
databasesWriteTransactionsPerSec = "Write Transactions/sec"
|
DatabasesTransactionsPerSec float64 `perfdata:"Transactions/sec"`
|
||||||
databasesXTPControllerDLCLatencyPerFetch = "XTP Controller DLC Latency/Fetch"
|
DatabasesWriteTransactionsPerSec float64 `perfdata:"Write Transactions/sec"`
|
||||||
databasesXTPControllerDLCPeakLatency = "XTP Controller DLC Peak Latency"
|
DatabasesXTPControllerDLCLatencyPerFetch float64 `perfdata:"XTP Controller DLC Latency/Fetch"`
|
||||||
databasesXTPControllerLogProcessedPerSec = "XTP Controller Log Processed/sec"
|
DatabasesXTPControllerDLCPeakLatency float64 `perfdata:"XTP Controller DLC Peak Latency"`
|
||||||
databasesXTPMemoryUsedKB = "XTP Memory Used (KB)"
|
DatabasesXTPControllerLogProcessedPerSec float64 `perfdata:"XTP Controller Log Processed/sec"`
|
||||||
)
|
DatabasesXTPMemoryUsedKB float64 `perfdata:"XTP Memory Used (KB)"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type perfDataCounterValuesDatabases2019 struct {
|
||||||
|
Name string
|
||||||
|
|
||||||
|
DatabasesActiveParallelRedoThreads float64 `perfdata:"Active parallel redo threads"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildDatabases() error {
|
func (c *Collector) buildDatabases() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.databasesPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.databasesPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
|
c.databasesPerfDataCollectors2019 = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
databasesActiveParallelRedoThreads,
|
|
||||||
databasesActiveTransactions,
|
|
||||||
databasesBackupPerRestoreThroughputPerSec,
|
|
||||||
databasesBulkCopyRowsPerSec,
|
|
||||||
databasesBulkCopyThroughputPerSec,
|
|
||||||
databasesCommitTableEntries,
|
|
||||||
databasesDataFilesSizeKB,
|
|
||||||
databasesDBCCLogicalScanBytesPerSec,
|
|
||||||
databasesGroupCommitTimePerSec,
|
|
||||||
databasesLogBytesFlushedPerSec,
|
|
||||||
databasesLogCacheHitRatio,
|
|
||||||
databasesLogCacheHitRatioBase,
|
|
||||||
databasesLogCacheReadsPerSec,
|
|
||||||
databasesLogFilesSizeKB,
|
|
||||||
databasesLogFilesUsedSizeKB,
|
|
||||||
databasesLogFlushesPerSec,
|
|
||||||
databasesLogFlushWaitsPerSec,
|
|
||||||
databasesLogFlushWaitTime,
|
|
||||||
databasesLogFlushWriteTimeMS,
|
|
||||||
databasesLogGrowths,
|
|
||||||
databasesLogPoolCacheMissesPerSec,
|
|
||||||
databasesLogPoolDiskReadsPerSec,
|
|
||||||
databasesLogPoolHashDeletesPerSec,
|
|
||||||
databasesLogPoolHashInsertsPerSec,
|
|
||||||
databasesLogPoolInvalidHashEntryPerSec,
|
|
||||||
databasesLogPoolLogScanPushesPerSec,
|
|
||||||
databasesLogPoolLogWriterPushesPerSec,
|
|
||||||
databasesLogPoolPushEmptyFreePoolPerSec,
|
|
||||||
databasesLogPoolPushLowMemoryPerSec,
|
|
||||||
databasesLogPoolPushNoFreeBufferPerSec,
|
|
||||||
databasesLogPoolReqBehindTruncPerSec,
|
|
||||||
databasesLogPoolRequestsOldVLFPerSec,
|
|
||||||
databasesLogPoolRequestsPerSec,
|
|
||||||
databasesLogPoolTotalActiveLogSize,
|
|
||||||
databasesLogPoolTotalSharedPoolSize,
|
|
||||||
databasesLogShrinks,
|
|
||||||
databasesLogTruncations,
|
|
||||||
databasesPercentLogUsed,
|
|
||||||
databasesReplPendingXacts,
|
|
||||||
databasesReplTransRate,
|
|
||||||
databasesShrinkDataMovementBytesPerSec,
|
|
||||||
databasesTrackedTransactionsPerSec,
|
|
||||||
databasesTransactionsPerSec,
|
|
||||||
databasesWriteTransactionsPerSec,
|
|
||||||
databasesXTPControllerDLCLatencyPerFetch,
|
|
||||||
databasesXTPControllerDLCPeakLatency,
|
|
||||||
databasesXTPControllerLogProcessedPerSec,
|
|
||||||
databasesXTPMemoryUsedKB,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.databasesPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Databases"), perfdata.InstancesAll, counters)
|
c.databasesPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesDatabases](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Databases"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Databases collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Databases collector for instance %s: %w", sqlInstance.name, err))
|
||||||
|
}
|
||||||
|
|
||||||
|
if sqlInstance.isVersionGreaterOrEqualThan(serverVersion2019) {
|
||||||
|
c.databasesPerfDataCollectors2019[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesDatabases2019](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Databases"), pdh.InstancesAll)
|
||||||
|
if err != nil {
|
||||||
|
errs = append(errs, fmt.Errorf("failed to create Databases 2019 collector for instance %s: %w", sqlInstance.name, err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,354 +452,364 @@ func (c *Collector) buildDatabases() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDatabases(ch chan<- prometheus.Metric) error {
|
func (c *Collector) collectDatabases(ch chan<- prometheus.Metric) error {
|
||||||
return c.collect(ch, subCollectorDatabases, c.databasesPerfDataCollectors, c.collectDatabasesInstance)
|
return errors.Join(
|
||||||
|
c.collect(ch, subCollectorDatabases, c.databasesPerfDataCollectors, c.collectDatabasesInstance),
|
||||||
|
c.collect(ch, "", c.databasesPerfDataCollectors2019, c.collectDatabasesInstance2019),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDatabasesInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectDatabasesInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.databasesPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Databases"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Databases"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for dbName, data := range perfData {
|
for _, data := range c.databasesPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
|
||||||
c.databasesActiveParallelRedoThreads,
|
|
||||||
prometheus.GaugeValue,
|
|
||||||
data[databasesActiveParallelRedoThreads].FirstValue,
|
|
||||||
sqlInstance, dbName,
|
|
||||||
)
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesActiveTransactions,
|
c.databasesActiveTransactions,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesActiveTransactions].FirstValue,
|
data.DatabasesActiveTransactions,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesBackupPerRestoreThroughput,
|
c.databasesBackupPerRestoreThroughput,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesBackupPerRestoreThroughputPerSec].FirstValue,
|
data.DatabasesBackupPerRestoreThroughputPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesBulkCopyRows,
|
c.databasesBulkCopyRows,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesBulkCopyRowsPerSec].FirstValue,
|
data.DatabasesBulkCopyRowsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesBulkCopyThroughput,
|
c.databasesBulkCopyThroughput,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesBulkCopyThroughputPerSec].FirstValue*1024,
|
data.DatabasesBulkCopyThroughputPerSec*1024,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesCommitTableEntries,
|
c.databasesCommitTableEntries,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesCommitTableEntries].FirstValue,
|
data.DatabasesCommitTableEntries,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesDataFilesSizeKB,
|
c.databasesDataFilesSizeKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesDataFilesSizeKB].FirstValue*1024,
|
data.DatabasesDataFilesSizeKB*1024,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesDBCCLogicalScanBytes,
|
c.databasesDBCCLogicalScanBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesDBCCLogicalScanBytesPerSec].FirstValue,
|
data.DatabasesDBCCLogicalScanBytesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesGroupCommitTime,
|
c.databasesGroupCommitTime,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesGroupCommitTimePerSec].FirstValue/1000000.0,
|
data.DatabasesGroupCommitTimePerSec/1000000.0,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogBytesFlushed,
|
c.databasesLogBytesFlushed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogBytesFlushedPerSec].FirstValue,
|
data.DatabasesLogBytesFlushedPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogCacheHits,
|
c.databasesLogCacheHits,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogCacheHitRatio].FirstValue,
|
data.DatabasesLogCacheHitRatio,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogCacheLookups,
|
c.databasesLogCacheLookups,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogCacheHitRatioBase].SecondValue,
|
data.DatabasesLogCacheHitRatioBase,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogCacheReads,
|
c.databasesLogCacheReads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogCacheReadsPerSec].FirstValue,
|
data.DatabasesLogCacheReadsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFilesSizeKB,
|
c.databasesLogFilesSizeKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogFilesSizeKB].FirstValue*1024,
|
data.DatabasesLogFilesSizeKB*1024,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFilesUsedSizeKB,
|
c.databasesLogFilesUsedSizeKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogFilesUsedSizeKB].FirstValue*1024,
|
data.DatabasesLogFilesUsedSizeKB*1024,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFlushes,
|
c.databasesLogFlushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogFlushesPerSec].FirstValue,
|
data.DatabasesLogFlushesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFlushWaits,
|
c.databasesLogFlushWaits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogFlushWaitsPerSec].FirstValue,
|
data.DatabasesLogFlushWaitsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFlushWaitTime,
|
c.databasesLogFlushWaitTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogFlushWaitTime].FirstValue/1000.0,
|
data.DatabasesLogFlushWaitTime/1000.0,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogFlushWriteTimeMS,
|
c.databasesLogFlushWriteTimeMS,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogFlushWriteTimeMS].FirstValue/1000.0,
|
data.DatabasesLogFlushWriteTimeMS/1000.0,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogGrowths,
|
c.databasesLogGrowths,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogGrowths].FirstValue,
|
data.DatabasesLogGrowths,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolCacheMisses,
|
c.databasesLogPoolCacheMisses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolCacheMissesPerSec].FirstValue,
|
data.DatabasesLogPoolCacheMissesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolDiskReads,
|
c.databasesLogPoolDiskReads,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolDiskReadsPerSec].FirstValue,
|
data.DatabasesLogPoolDiskReadsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolHashDeletes,
|
c.databasesLogPoolHashDeletes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolHashDeletesPerSec].FirstValue,
|
data.DatabasesLogPoolHashDeletesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolHashInserts,
|
c.databasesLogPoolHashInserts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolHashInsertsPerSec].FirstValue,
|
data.DatabasesLogPoolHashInsertsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolInvalidHashEntry,
|
c.databasesLogPoolInvalidHashEntry,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolInvalidHashEntryPerSec].FirstValue,
|
data.DatabasesLogPoolInvalidHashEntryPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolLogScanPushes,
|
c.databasesLogPoolLogScanPushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolLogScanPushesPerSec].FirstValue,
|
data.DatabasesLogPoolLogScanPushesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolLogWriterPushes,
|
c.databasesLogPoolLogWriterPushes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolLogWriterPushesPerSec].FirstValue,
|
data.DatabasesLogPoolLogWriterPushesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolPushEmptyFreePool,
|
c.databasesLogPoolPushEmptyFreePool,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolPushEmptyFreePoolPerSec].FirstValue,
|
data.DatabasesLogPoolPushEmptyFreePoolPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolPushLowMemory,
|
c.databasesLogPoolPushLowMemory,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolPushLowMemoryPerSec].FirstValue,
|
data.DatabasesLogPoolPushLowMemoryPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolPushNoFreeBuffer,
|
c.databasesLogPoolPushNoFreeBuffer,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolPushNoFreeBufferPerSec].FirstValue,
|
data.DatabasesLogPoolPushNoFreeBufferPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolReqBehindTrunc,
|
c.databasesLogPoolReqBehindTrunc,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolReqBehindTruncPerSec].FirstValue,
|
data.DatabasesLogPoolReqBehindTruncPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolRequestsOldVLF,
|
c.databasesLogPoolRequestsOldVLF,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolRequestsOldVLFPerSec].FirstValue,
|
data.DatabasesLogPoolRequestsOldVLFPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolRequests,
|
c.databasesLogPoolRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesLogPoolRequestsPerSec].FirstValue,
|
data.DatabasesLogPoolRequestsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolTotalActiveLogSize,
|
c.databasesLogPoolTotalActiveLogSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogPoolTotalActiveLogSize].FirstValue,
|
data.DatabasesLogPoolTotalActiveLogSize,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogPoolTotalSharedPoolSize,
|
c.databasesLogPoolTotalSharedPoolSize,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogPoolTotalSharedPoolSize].FirstValue,
|
data.DatabasesLogPoolTotalSharedPoolSize,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogShrinks,
|
c.databasesLogShrinks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogShrinks].FirstValue,
|
data.DatabasesLogShrinks,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesLogTruncations,
|
c.databasesLogTruncations,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesLogTruncations].FirstValue,
|
data.DatabasesLogTruncations,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesPercentLogUsed,
|
c.databasesPercentLogUsed,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesPercentLogUsed].FirstValue,
|
data.DatabasesPercentLogUsed,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesReplPendingXacts,
|
c.databasesReplPendingXacts,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesReplPendingXacts].FirstValue,
|
data.DatabasesReplPendingXacts,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesReplTransRate,
|
c.databasesReplTransRate,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesReplTransRate].FirstValue,
|
data.DatabasesReplTransRate,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesShrinkDataMovementBytes,
|
c.databasesShrinkDataMovementBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesShrinkDataMovementBytesPerSec].FirstValue,
|
data.DatabasesShrinkDataMovementBytesPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesTrackedTransactions,
|
c.databasesTrackedTransactions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesTrackedTransactionsPerSec].FirstValue,
|
data.DatabasesTrackedTransactionsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesTransactions,
|
c.databasesTransactions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesTransactionsPerSec].FirstValue,
|
data.DatabasesTransactionsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesWriteTransactions,
|
c.databasesWriteTransactions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesWriteTransactionsPerSec].FirstValue,
|
data.DatabasesWriteTransactionsPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesXTPControllerDLCLatencyPerFetch,
|
c.databasesXTPControllerDLCLatencyPerFetch,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesXTPControllerDLCLatencyPerFetch].FirstValue,
|
data.DatabasesXTPControllerDLCLatencyPerFetch,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesXTPControllerDLCPeakLatency,
|
c.databasesXTPControllerDLCPeakLatency,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesXTPControllerDLCPeakLatency].FirstValue*1000000.0,
|
data.DatabasesXTPControllerDLCPeakLatency*1000000.0,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesXTPControllerLogProcessed,
|
c.databasesXTPControllerLogProcessed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[databasesXTPControllerLogProcessedPerSec].FirstValue,
|
data.DatabasesXTPControllerLogProcessedPerSec,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.databasesXTPMemoryUsedKB,
|
c.databasesXTPMemoryUsedKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[databasesXTPMemoryUsedKB].FirstValue*1024,
|
data.DatabasesXTPMemoryUsedKB*1024,
|
||||||
sqlInstance, dbName,
|
sqlInstance, data.Name,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collectDatabasesInstance2019(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
|
err := perfDataCollector.Collect(&c.databasesPerfDataObject2019)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Databases"), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, data := range c.databasesPerfDataObject2019 {
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.databasesActiveParallelRedoThreads,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
data.DatabasesActiveParallelRedoThreads,
|
||||||
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorDatabaseReplica struct {
|
type collectorDatabaseReplica struct {
|
||||||
dbReplicaPerfDataCollectors map[string]*perfdata.Collector
|
dbReplicaPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
dbReplicaPerfDataObject []perfDataCounterValuesDBReplica
|
||||||
|
|
||||||
dbReplicaDatabaseFlowControlDelay *prometheus.Desc
|
dbReplicaDatabaseFlowControlDelay *prometheus.Desc
|
||||||
dbReplicaDatabaseFlowControls *prometheus.Desc
|
dbReplicaDatabaseFlowControls *prometheus.Desc
|
||||||
@@ -53,69 +54,45 @@ type collectorDatabaseReplica struct {
|
|||||||
dbReplicaTransactionDelay *prometheus.Desc
|
dbReplicaTransactionDelay *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesDBReplica struct {
|
||||||
dbReplicaDatabaseFlowControlDelay = "Database Flow Control Delay"
|
Name string
|
||||||
dbReplicaDatabaseFlowControlsPerSec = "Database Flow Controls/sec"
|
|
||||||
dbReplicaFileBytesReceivedPerSec = "File Bytes Received/sec"
|
DbReplicaDatabaseFlowControlDelay float64 `perfdata:"Database Flow Control Delay"`
|
||||||
dbReplicaGroupCommitsPerSec = "Group Commits/Sec"
|
DbReplicaDatabaseFlowControlsPerSec float64 `perfdata:"Database Flow Controls/sec"`
|
||||||
dbReplicaGroupCommitTime = "Group Commit Time"
|
DbReplicaFileBytesReceivedPerSec float64 `perfdata:"File Bytes Received/sec"`
|
||||||
dbReplicaLogApplyPendingQueue = "Log Apply Pending Queue"
|
DbReplicaGroupCommitsPerSec float64 `perfdata:"Group Commits/Sec"`
|
||||||
dbReplicaLogApplyReadyQueue = "Log Apply Ready Queue"
|
DbReplicaGroupCommitTime float64 `perfdata:"Group Commit Time"`
|
||||||
dbReplicaLogBytesCompressedPerSec = "Log Bytes Compressed/sec"
|
DbReplicaLogApplyPendingQueue float64 `perfdata:"Log Apply Pending Queue"`
|
||||||
dbReplicaLogBytesDecompressedPerSec = "Log Bytes Decompressed/sec"
|
DbReplicaLogApplyReadyQueue float64 `perfdata:"Log Apply Ready Queue"`
|
||||||
dbReplicaLogBytesReceivedPerSec = "Log Bytes Received/sec"
|
DbReplicaLogBytesCompressedPerSec float64 `perfdata:"Log Bytes Compressed/sec"`
|
||||||
dbReplicaLogCompressionCacheHitsPerSec = "Log Compression Cache hits/sec"
|
DbReplicaLogBytesDecompressedPerSec float64 `perfdata:"Log Bytes Decompressed/sec"`
|
||||||
dbReplicaLogCompressionCacheMissesPerSec = "Log Compression Cache misses/sec"
|
DbReplicaLogBytesReceivedPerSec float64 `perfdata:"Log Bytes Received/sec"`
|
||||||
dbReplicaLogCompressionsPerSec = "Log Compressions/sec"
|
DbReplicaLogCompressionCacheHitsPerSec float64 `perfdata:"Log Compression Cache hits/sec"`
|
||||||
dbReplicaLogDecompressionsPerSec = "Log Decompressions/sec"
|
DbReplicaLogCompressionCacheMissesPerSec float64 `perfdata:"Log Compression Cache misses/sec"`
|
||||||
dbReplicaLogRemainingForUndo = "Log remaining for undo"
|
DbReplicaLogCompressionsPerSec float64 `perfdata:"Log Compressions/sec"`
|
||||||
dbReplicaLogSendQueue = "Log Send Queue"
|
DbReplicaLogDecompressionsPerSec float64 `perfdata:"Log Decompressions/sec"`
|
||||||
dbReplicaMirroredWriteTransactionsPerSec = "Mirrored Write Transactions/sec"
|
DbReplicaLogRemainingForUndo float64 `perfdata:"Log remaining for undo"`
|
||||||
dbReplicaRecoveryQueue = "Recovery Queue"
|
DbReplicaLogSendQueue float64 `perfdata:"Log Send Queue"`
|
||||||
dbReplicaRedoBlockedPerSec = "Redo blocked/sec"
|
DbReplicaMirroredWriteTransactionsPerSec float64 `perfdata:"Mirrored Write Transactions/sec"`
|
||||||
dbReplicaRedoBytesRemaining = "Redo Bytes Remaining"
|
DbReplicaRecoveryQueue float64 `perfdata:"Recovery Queue"`
|
||||||
dbReplicaRedoneBytesPerSec = "Redone Bytes/sec"
|
DbReplicaRedoBlockedPerSec float64 `perfdata:"Redo blocked/sec"`
|
||||||
dbReplicaRedonesPerSec = "Redones/sec"
|
DbReplicaRedoBytesRemaining float64 `perfdata:"Redo Bytes Remaining"`
|
||||||
dbReplicaTotalLogRequiringUndo = "Total Log requiring undo"
|
DbReplicaRedoneBytesPerSec float64 `perfdata:"Redone Bytes/sec"`
|
||||||
dbReplicaTransactionDelay = "Transaction Delay"
|
DbReplicaRedonesPerSec float64 `perfdata:"Redones/sec"`
|
||||||
)
|
DbReplicaTotalLogRequiringUndo float64 `perfdata:"Total Log requiring undo"`
|
||||||
|
DbReplicaTransactionDelay float64 `perfdata:"Transaction Delay"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildDatabaseReplica() error {
|
func (c *Collector) buildDatabaseReplica() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.dbReplicaPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.dbReplicaPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
dbReplicaDatabaseFlowControlDelay,
|
|
||||||
dbReplicaDatabaseFlowControlsPerSec,
|
|
||||||
dbReplicaFileBytesReceivedPerSec,
|
|
||||||
dbReplicaGroupCommitsPerSec,
|
|
||||||
dbReplicaGroupCommitTime,
|
|
||||||
dbReplicaLogApplyPendingQueue,
|
|
||||||
dbReplicaLogApplyReadyQueue,
|
|
||||||
dbReplicaLogBytesCompressedPerSec,
|
|
||||||
dbReplicaLogBytesDecompressedPerSec,
|
|
||||||
dbReplicaLogBytesReceivedPerSec,
|
|
||||||
dbReplicaLogCompressionCacheHitsPerSec,
|
|
||||||
dbReplicaLogCompressionCacheMissesPerSec,
|
|
||||||
dbReplicaLogCompressionsPerSec,
|
|
||||||
dbReplicaLogDecompressionsPerSec,
|
|
||||||
dbReplicaLogRemainingForUndo,
|
|
||||||
dbReplicaLogSendQueue,
|
|
||||||
dbReplicaMirroredWriteTransactionsPerSec,
|
|
||||||
dbReplicaRecoveryQueue,
|
|
||||||
dbReplicaRedoBlockedPerSec,
|
|
||||||
dbReplicaRedoBytesRemaining,
|
|
||||||
dbReplicaRedoneBytesPerSec,
|
|
||||||
dbReplicaRedonesPerSec,
|
|
||||||
dbReplicaTotalLogRequiringUndo,
|
|
||||||
dbReplicaTransactionDelay,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.dbReplicaPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Database Replica"), perfdata.InstancesAll, counters)
|
c.dbReplicaPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesDBReplica](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Database Replica"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Database Replica collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Database Replica collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,183 +249,179 @@ func (c *Collector) collectDatabaseReplica(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorDatabaseReplica, c.dbReplicaPerfDataCollectors, c.collectDatabaseReplicaInstance)
|
return c.collect(ch, subCollectorDatabaseReplica, c.dbReplicaPerfDataCollectors, c.collectDatabaseReplicaInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectDatabaseReplicaInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectDatabaseReplicaInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.dbReplicaPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Database Replica"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Database Replica"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for replicaName, data := range perfData {
|
for _, data := range c.dbReplicaPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaDatabaseFlowControlDelay,
|
c.dbReplicaDatabaseFlowControlDelay,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaDatabaseFlowControlDelay].FirstValue,
|
data.DbReplicaDatabaseFlowControlDelay,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaDatabaseFlowControls,
|
c.dbReplicaDatabaseFlowControls,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaDatabaseFlowControlsPerSec].FirstValue,
|
data.DbReplicaDatabaseFlowControlsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaFileBytesReceived,
|
c.dbReplicaFileBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaFileBytesReceivedPerSec].FirstValue,
|
data.DbReplicaFileBytesReceivedPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaGroupCommits,
|
c.dbReplicaGroupCommits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaGroupCommitsPerSec].FirstValue,
|
data.DbReplicaGroupCommitsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaGroupCommitTime,
|
c.dbReplicaGroupCommitTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaGroupCommitTime].FirstValue,
|
data.DbReplicaGroupCommitTime,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogApplyPendingQueue,
|
c.dbReplicaLogApplyPendingQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaLogApplyPendingQueue].FirstValue,
|
data.DbReplicaLogApplyPendingQueue,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogApplyReadyQueue,
|
c.dbReplicaLogApplyReadyQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaLogApplyReadyQueue].FirstValue,
|
data.DbReplicaLogApplyReadyQueue,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogBytesCompressed,
|
c.dbReplicaLogBytesCompressed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogBytesCompressedPerSec].FirstValue,
|
data.DbReplicaLogBytesCompressedPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogBytesDecompressed,
|
c.dbReplicaLogBytesDecompressed,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogBytesDecompressedPerSec].FirstValue,
|
data.DbReplicaLogBytesDecompressedPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogBytesReceived,
|
c.dbReplicaLogBytesReceived,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogBytesReceivedPerSec].FirstValue,
|
data.DbReplicaLogBytesReceivedPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogCompressionCachehits,
|
c.dbReplicaLogCompressionCachehits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogCompressionCacheHitsPerSec].FirstValue,
|
data.DbReplicaLogCompressionCacheHitsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogCompressionCachemisses,
|
c.dbReplicaLogCompressionCachemisses,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogCompressionCacheMissesPerSec].FirstValue,
|
data.DbReplicaLogCompressionCacheMissesPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogCompressions,
|
c.dbReplicaLogCompressions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogCompressionsPerSec].FirstValue,
|
data.DbReplicaLogCompressionsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogDecompressions,
|
c.dbReplicaLogDecompressions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaLogDecompressionsPerSec].FirstValue,
|
data.DbReplicaLogDecompressionsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogremainingforundo,
|
c.dbReplicaLogremainingforundo,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaLogRemainingForUndo].FirstValue,
|
data.DbReplicaLogRemainingForUndo,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaLogSendQueue,
|
c.dbReplicaLogSendQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaLogSendQueue].FirstValue,
|
data.DbReplicaLogSendQueue,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaMirroredWritetransactions,
|
c.dbReplicaMirroredWritetransactions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaMirroredWriteTransactionsPerSec].FirstValue,
|
data.DbReplicaMirroredWriteTransactionsPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaRecoveryQueue,
|
c.dbReplicaRecoveryQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaRecoveryQueue].FirstValue,
|
data.DbReplicaRecoveryQueue,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaRedoblocked,
|
c.dbReplicaRedoblocked,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaRedoBlockedPerSec].FirstValue,
|
data.DbReplicaRedoBlockedPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaRedoBytesRemaining,
|
c.dbReplicaRedoBytesRemaining,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaRedoBytesRemaining].FirstValue,
|
data.DbReplicaRedoBytesRemaining,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaRedoneBytes,
|
c.dbReplicaRedoneBytes,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaRedoneBytesPerSec].FirstValue,
|
data.DbReplicaRedoneBytesPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaRedones,
|
c.dbReplicaRedones,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[dbReplicaRedonesPerSec].FirstValue,
|
data.DbReplicaRedonesPerSec,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaTotalLogrequiringundo,
|
c.dbReplicaTotalLogrequiringundo,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaTotalLogRequiringUndo].FirstValue,
|
data.DbReplicaTotalLogRequiringUndo,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dbReplicaTransactionDelay,
|
c.dbReplicaTransactionDelay,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[dbReplicaTransactionDelay].FirstValue/1000.0,
|
data.DbReplicaTransactionDelay/1000.0,
|
||||||
sqlInstance, replicaName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorGeneralStatistics struct {
|
type collectorGeneralStatistics struct {
|
||||||
genStatsPerfDataCollectors map[string]*perfdata.Collector
|
genStatsPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
genStatsPerfDataObject []perfDataCounterValuesGenStats
|
||||||
|
|
||||||
genStatsActiveTempTables *prometheus.Desc
|
genStatsActiveTempTables *prometheus.Desc
|
||||||
genStatsConnectionReset *prometheus.Desc
|
genStatsConnectionReset *prometheus.Desc
|
||||||
@@ -53,69 +54,43 @@ type collectorGeneralStatistics struct {
|
|||||||
genStatsUserConnections *prometheus.Desc
|
genStatsUserConnections *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesGenStats struct {
|
||||||
genStatsActiveTempTables = "Active Temp Tables"
|
GenStatsActiveTempTables float64 `perfdata:"Active Temp Tables"`
|
||||||
genStatsConnectionResetPerSec = "Connection Reset/sec"
|
GenStatsConnectionResetPerSec float64 `perfdata:"Connection Reset/sec"`
|
||||||
genStatsEventNotificationsDelayedDrop = "Event Notifications Delayed Drop"
|
GenStatsEventNotificationsDelayedDrop float64 `perfdata:"Event Notifications Delayed Drop"`
|
||||||
genStatsHTTPAuthenticatedRequests = "HTTP Authenticated Requests"
|
GenStatsHTTPAuthenticatedRequests float64 `perfdata:"HTTP Authenticated Requests"`
|
||||||
genStatsLogicalConnections = "Logical Connections"
|
GenStatsLogicalConnections float64 `perfdata:"Logical Connections"`
|
||||||
genStatsLoginsPerSec = "Logins/sec"
|
GenStatsLoginsPerSec float64 `perfdata:"Logins/sec"`
|
||||||
genStatsLogoutsPerSec = "Logouts/sec"
|
GenStatsLogoutsPerSec float64 `perfdata:"Logouts/sec"`
|
||||||
genStatsMarsDeadlocks = "Mars Deadlocks"
|
GenStatsMarsDeadlocks float64 `perfdata:"Mars Deadlocks"`
|
||||||
genStatsNonatomicYieldRate = "Non-atomic yield rate"
|
GenStatsNonatomicYieldRate float64 `perfdata:"Non-atomic yield rate"`
|
||||||
genStatsProcessesBlocked = "Processes blocked"
|
GenStatsProcessesBlocked float64 `perfdata:"Processes blocked"`
|
||||||
genStatsSOAPEmptyRequests = "SOAP Empty Requests"
|
GenStatsSOAPEmptyRequests float64 `perfdata:"SOAP Empty Requests"`
|
||||||
genStatsSOAPMethodInvocations = "SOAP Method Invocations"
|
GenStatsSOAPMethodInvocations float64 `perfdata:"SOAP Method Invocations"`
|
||||||
genStatsSOAPSessionInitiateRequests = "SOAP Session Initiate Requests"
|
GenStatsSOAPSessionInitiateRequests float64 `perfdata:"SOAP Session Initiate Requests"`
|
||||||
genStatsSOAPSessionTerminateRequests = "SOAP Session Terminate Requests"
|
GenStatsSOAPSessionTerminateRequests float64 `perfdata:"SOAP Session Terminate Requests"`
|
||||||
genStatsSOAPSQLRequests = "SOAP SQL Requests"
|
GenStatsSOAPSQLRequests float64 `perfdata:"SOAP SQL Requests"`
|
||||||
genStatsSOAPWSDLRequests = "SOAP WSDL Requests"
|
GenStatsSOAPWSDLRequests float64 `perfdata:"SOAP WSDL Requests"`
|
||||||
genStatsSQLTraceIOProviderLockWaits = "SQL Trace IO Provider Lock Waits"
|
GenStatsSQLTraceIOProviderLockWaits float64 `perfdata:"SQL Trace IO Provider Lock Waits"`
|
||||||
genStatsTempdbRecoveryUnitID = "Tempdb recovery unit id"
|
GenStatsTempdbRecoveryUnitID float64 `perfdata:"Tempdb recovery unit id"`
|
||||||
genStatsTempdbRowsetID = "Tempdb rowset id"
|
GenStatsTempdbRowsetID float64 `perfdata:"Tempdb rowset id"`
|
||||||
genStatsTempTablesCreationRate = "Temp Tables Creation Rate"
|
GenStatsTempTablesCreationRate float64 `perfdata:"Temp Tables Creation Rate"`
|
||||||
genStatsTempTablesForDestruction = "Temp Tables For Destruction"
|
GenStatsTempTablesForDestruction float64 `perfdata:"Temp Tables For Destruction"`
|
||||||
genStatsTraceEventNotificationQueue = "Trace Event Notification Queue"
|
GenStatsTraceEventNotificationQueue float64 `perfdata:"Trace Event Notification Queue"`
|
||||||
genStatsTransactions = "Transactions"
|
GenStatsTransactions float64 `perfdata:"Transactions"`
|
||||||
genStatsUserConnections = "User Connections"
|
GenStatsUserConnections float64 `perfdata:"User Connections"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildGeneralStatistics() error {
|
func (c *Collector) buildGeneralStatistics() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.genStatsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.genStatsPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
genStatsActiveTempTables,
|
|
||||||
genStatsConnectionResetPerSec,
|
|
||||||
genStatsEventNotificationsDelayedDrop,
|
|
||||||
genStatsHTTPAuthenticatedRequests,
|
|
||||||
genStatsLogicalConnections,
|
|
||||||
genStatsLoginsPerSec,
|
|
||||||
genStatsLogoutsPerSec,
|
|
||||||
genStatsMarsDeadlocks,
|
|
||||||
genStatsNonatomicYieldRate,
|
|
||||||
genStatsProcessesBlocked,
|
|
||||||
genStatsSOAPEmptyRequests,
|
|
||||||
genStatsSOAPMethodInvocations,
|
|
||||||
genStatsSOAPSessionInitiateRequests,
|
|
||||||
genStatsSOAPSessionTerminateRequests,
|
|
||||||
genStatsSOAPSQLRequests,
|
|
||||||
genStatsSOAPWSDLRequests,
|
|
||||||
genStatsSQLTraceIOProviderLockWaits,
|
|
||||||
genStatsTempdbRecoveryUnitID,
|
|
||||||
genStatsTempdbRowsetID,
|
|
||||||
genStatsTempTablesCreationRate,
|
|
||||||
genStatsTempTablesForDestruction,
|
|
||||||
genStatsTraceEventNotificationQueue,
|
|
||||||
genStatsTransactions,
|
|
||||||
genStatsUserConnections,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.genStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "General Statistics"), nil, counters)
|
c.genStatsPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesGenStats](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "General Statistics"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create General Statistics collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create General Statistics collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,186 +247,177 @@ func (c *Collector) collectGeneralStatistics(ch chan<- prometheus.Metric) error
|
|||||||
return c.collect(ch, subCollectorGeneralStatistics, c.genStatsPerfDataCollectors, c.collectGeneralStatisticsInstance)
|
return c.collect(ch, subCollectorGeneralStatistics, c.genStatsPerfDataCollectors, c.collectGeneralStatisticsInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectGeneralStatisticsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectGeneralStatisticsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.genStatsPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "General Statistics"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "General Statistics"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "General Statistics"))
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsActiveTempTables,
|
c.genStatsActiveTempTables,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsActiveTempTables].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsActiveTempTables,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsConnectionReset,
|
c.genStatsConnectionReset,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[genStatsConnectionResetPerSec].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsConnectionResetPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsEventNotificationsDelayedDrop,
|
c.genStatsEventNotificationsDelayedDrop,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsEventNotificationsDelayedDrop].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsEventNotificationsDelayedDrop,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsHTTPAuthenticatedRequests,
|
c.genStatsHTTPAuthenticatedRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsHTTPAuthenticatedRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsHTTPAuthenticatedRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsLogicalConnections,
|
c.genStatsLogicalConnections,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsLogicalConnections].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsLogicalConnections,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsLogins,
|
c.genStatsLogins,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[genStatsLoginsPerSec].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsLoginsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsLogouts,
|
c.genStatsLogouts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[genStatsLogoutsPerSec].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsLogoutsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsMarsDeadlocks,
|
c.genStatsMarsDeadlocks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsMarsDeadlocks].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsMarsDeadlocks,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsNonAtomicYieldRate,
|
c.genStatsNonAtomicYieldRate,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[genStatsNonatomicYieldRate].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsNonatomicYieldRate,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsProcessesBlocked,
|
c.genStatsProcessesBlocked,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsProcessesBlocked].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsProcessesBlocked,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPEmptyRequests,
|
c.genStatsSOAPEmptyRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPEmptyRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPEmptyRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPMethodInvocations,
|
c.genStatsSOAPMethodInvocations,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPMethodInvocations].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPMethodInvocations,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPSessionInitiateRequests,
|
c.genStatsSOAPSessionInitiateRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPSessionInitiateRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPSessionInitiateRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPSessionTerminateRequests,
|
c.genStatsSOAPSessionTerminateRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPSessionTerminateRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPSessionTerminateRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPSQLRequests,
|
c.genStatsSOAPSQLRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPSQLRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPSQLRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSOAPWSDLRequests,
|
c.genStatsSOAPWSDLRequests,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSOAPWSDLRequests].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSOAPWSDLRequests,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsSQLTraceIOProviderLockWaits,
|
c.genStatsSQLTraceIOProviderLockWaits,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsSQLTraceIOProviderLockWaits].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsSQLTraceIOProviderLockWaits,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTempDBRecoveryUnitID,
|
c.genStatsTempDBRecoveryUnitID,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsTempdbRecoveryUnitID].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTempdbRecoveryUnitID,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTempDBrowSetID,
|
c.genStatsTempDBrowSetID,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsTempdbRowsetID].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTempdbRowsetID,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTempTablesCreationRate,
|
c.genStatsTempTablesCreationRate,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[genStatsTempTablesCreationRate].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTempTablesCreationRate,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTempTablesForDestruction,
|
c.genStatsTempTablesForDestruction,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsTempTablesForDestruction].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTempTablesForDestruction,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTraceEventNotificationQueue,
|
c.genStatsTraceEventNotificationQueue,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsTraceEventNotificationQueue].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTraceEventNotificationQueue,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsTransactions,
|
c.genStatsTransactions,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsTransactions].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsTransactions,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.genStatsUserConnections,
|
c.genStatsUserConnections,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[genStatsUserConnections].FirstValue,
|
c.genStatsPerfDataObject[0].GenStatsUserConnections,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
52
internal/collector/mssql/mssql_instance.go
Normal file
52
internal/collector/mssql/mssql_instance.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Copyright 2024 The Prometheus Authors
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package mssql
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type collectorInstance struct {
|
||||||
|
instances *prometheus.GaugeVec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) buildInstance() error {
|
||||||
|
c.instances = prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Namespace: types.Namespace,
|
||||||
|
Subsystem: Name,
|
||||||
|
Name: "instance_info",
|
||||||
|
Help: "A metric with a constant '1' value labeled with mssql instance information",
|
||||||
|
},
|
||||||
|
[]string{"edition", "mssql_instance", "patch", "version"},
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, instance := range c.mssqlInstances {
|
||||||
|
c.instances.WithLabelValues(instance.edition, instance.name, instance.patchVersion, instance.majorVersion.String()).Set(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collectInstance(ch chan<- prometheus.Metric) error {
|
||||||
|
c.instances.Collect(ch)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) closeInstance() {
|
||||||
|
}
|
||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorLocks struct {
|
type collectorLocks struct {
|
||||||
locksPerfDataCollectors map[string]*perfdata.Collector
|
locksPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
locksPerfDataObject []perfDataCounterValuesLocks
|
||||||
|
|
||||||
// Win32_PerfRawData_{instance}_SQLServerLocks
|
// Win32_PerfRawData_{instance}_SQLServerLocks
|
||||||
locksWaitTime *prometheus.Desc
|
locksWaitTime *prometheus.Desc
|
||||||
@@ -38,37 +39,29 @@ type collectorLocks struct {
|
|||||||
locksNumberOfDeadlocks *prometheus.Desc
|
locksNumberOfDeadlocks *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesLocks struct {
|
||||||
locksAverageWaitTimeMS = "Average Wait Time (ms)"
|
Name string
|
||||||
locksAverageWaitTimeMSBase = "Average Wait Time Base"
|
|
||||||
locksLockRequestsPerSec = "Lock Requests/sec"
|
LocksAverageWaitTimeMS float64 `perfdata:"Average Wait Time (ms)"`
|
||||||
locksLockTimeoutsPerSec = "Lock Timeouts/sec"
|
LocksAverageWaitTimeMSBase float64 `perfdata:"Average Wait Time Base,secondvalue"`
|
||||||
locksLockTimeoutsTimeout0PerSec = "Lock Timeouts (timeout > 0)/sec"
|
LocksLockRequestsPerSec float64 `perfdata:"Lock Requests/sec"`
|
||||||
locksLockWaitsPerSec = "Lock Waits/sec"
|
LocksLockTimeoutsPerSec float64 `perfdata:"Lock Timeouts/sec"`
|
||||||
locksLockWaitTimeMS = "Lock Wait Time (ms)"
|
LocksLockTimeoutsTimeout0PerSec float64 `perfdata:"Lock Timeouts (timeout > 0)/sec"`
|
||||||
locksNumberOfDeadlocksPerSec = "Number of Deadlocks/sec"
|
LocksLockWaitsPerSec float64 `perfdata:"Lock Waits/sec"`
|
||||||
)
|
LocksLockWaitTimeMS float64 `perfdata:"Lock Wait Time (ms)"`
|
||||||
|
LocksNumberOfDeadlocksPerSec float64 `perfdata:"Number of Deadlocks/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildLocks() error {
|
func (c *Collector) buildLocks() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.locksPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.locksPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
locksAverageWaitTimeMS,
|
|
||||||
locksAverageWaitTimeMSBase,
|
|
||||||
locksLockRequestsPerSec,
|
|
||||||
locksLockTimeoutsPerSec,
|
|
||||||
locksLockTimeoutsTimeout0PerSec,
|
|
||||||
locksLockWaitsPerSec,
|
|
||||||
locksLockWaitTimeMS,
|
|
||||||
locksNumberOfDeadlocksPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.locksPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Locks"), perfdata.InstancesAll, counters)
|
c.locksPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesLocks](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Locks"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Locks collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Locks collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,71 +121,67 @@ func (c *Collector) collectLocks(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorLocks, c.locksPerfDataCollectors, c.collectLocksInstance)
|
return c.collect(ch, subCollectorLocks, c.locksPerfDataCollectors, c.collectLocksInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectLocksInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectLocksInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.locksPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Locks"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Locks"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for lockResourceName, data := range perfData {
|
for _, data := range c.locksPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksWaitTime,
|
c.locksWaitTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[locksAverageWaitTimeMS].FirstValue/1000.0,
|
data.LocksAverageWaitTimeMS/1000.0,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksCount,
|
c.locksCount,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[locksAverageWaitTimeMSBase].SecondValue/1000.0,
|
data.LocksAverageWaitTimeMSBase/1000.0,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksLockRequests,
|
c.locksLockRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[locksLockRequestsPerSec].FirstValue,
|
data.LocksLockRequestsPerSec,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksLockTimeouts,
|
c.locksLockTimeouts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[locksLockTimeoutsPerSec].FirstValue,
|
data.LocksLockTimeoutsPerSec,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksLockTimeoutstimeout0,
|
c.locksLockTimeoutstimeout0,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[locksLockTimeoutsTimeout0PerSec].FirstValue,
|
data.LocksLockTimeoutsTimeout0PerSec,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksLockWaits,
|
c.locksLockWaits,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[locksLockWaitsPerSec].FirstValue,
|
data.LocksLockWaitsPerSec,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksLockWaitTimeMS,
|
c.locksLockWaitTimeMS,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[locksLockWaitTimeMS].FirstValue/1000.0,
|
data.LocksLockWaitTimeMS/1000.0,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.locksNumberOfDeadlocks,
|
c.locksNumberOfDeadlocks,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[locksNumberOfDeadlocksPerSec].FirstValue,
|
data.LocksNumberOfDeadlocksPerSec,
|
||||||
sqlInstance, lockResourceName,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorMemoryManager struct {
|
type collectorMemoryManager struct {
|
||||||
memMgrPerfDataCollectors map[string]*perfdata.Collector
|
memMgrPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
memMgrPerfDataObject []perfDataCounterValuesMemMgr
|
||||||
|
|
||||||
memMgrConnectionMemoryKB *prometheus.Desc
|
memMgrConnectionMemoryKB *prometheus.Desc
|
||||||
memMgrDatabaseCacheMemoryKB *prometheus.Desc
|
memMgrDatabaseCacheMemoryKB *prometheus.Desc
|
||||||
@@ -49,61 +50,39 @@ type collectorMemoryManager struct {
|
|||||||
memMgrTotalServerMemoryKB *prometheus.Desc
|
memMgrTotalServerMemoryKB *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesMemMgr struct {
|
||||||
memMgrConnectionMemoryKB = "Connection Memory (KB)"
|
MemMgrConnectionMemoryKB float64 `perfdata:"Connection Memory (KB)"`
|
||||||
memMgrDatabaseCacheMemoryKB = "Database Cache Memory (KB)"
|
MemMgrDatabaseCacheMemoryKB float64 `perfdata:"Database Cache Memory (KB)"`
|
||||||
memMgrExternalBenefitOfMemory = "External benefit of memory"
|
MemMgrExternalBenefitOfMemory float64 `perfdata:"External benefit of memory"`
|
||||||
memMgrFreeMemoryKB = "Free Memory (KB)"
|
MemMgrFreeMemoryKB float64 `perfdata:"Free Memory (KB)"`
|
||||||
memMgrGrantedWorkspaceMemoryKB = "Granted Workspace Memory (KB)"
|
MemMgrGrantedWorkspaceMemoryKB float64 `perfdata:"Granted Workspace Memory (KB)"`
|
||||||
memMgrLockBlocks = "Lock Blocks"
|
MemMgrLockBlocks float64 `perfdata:"Lock Blocks"`
|
||||||
memMgrLockBlocksAllocated = "Lock Blocks Allocated"
|
MemMgrLockBlocksAllocated float64 `perfdata:"Lock Blocks Allocated"`
|
||||||
memMgrLockMemoryKB = "Lock Memory (KB)"
|
MemMgrLockMemoryKB float64 `perfdata:"Lock Memory (KB)"`
|
||||||
memMgrLockOwnerBlocks = "Lock Owner Blocks"
|
MemMgrLockOwnerBlocks float64 `perfdata:"Lock Owner Blocks"`
|
||||||
memMgrLockOwnerBlocksAllocated = "Lock Owner Blocks Allocated"
|
MemMgrLockOwnerBlocksAllocated float64 `perfdata:"Lock Owner Blocks Allocated"`
|
||||||
memMgrLogPoolMemoryKB = "Log Pool Memory (KB)"
|
MemMgrLogPoolMemoryKB float64 `perfdata:"Log Pool Memory (KB)"`
|
||||||
memMgrMaximumWorkspaceMemoryKB = "Maximum Workspace Memory (KB)"
|
MemMgrMaximumWorkspaceMemoryKB float64 `perfdata:"Maximum Workspace Memory (KB)"`
|
||||||
memMgrMemoryGrantsOutstanding = "Memory Grants Outstanding"
|
MemMgrMemoryGrantsOutstanding float64 `perfdata:"Memory Grants Outstanding"`
|
||||||
memMgrMemoryGrantsPending = "Memory Grants Pending"
|
MemMgrMemoryGrantsPending float64 `perfdata:"Memory Grants Pending"`
|
||||||
memMgrOptimizerMemoryKB = "Optimizer Memory (KB)"
|
MemMgrOptimizerMemoryKB float64 `perfdata:"Optimizer Memory (KB)"`
|
||||||
memMgrReservedServerMemoryKB = "Reserved Server Memory (KB)"
|
MemMgrReservedServerMemoryKB float64 `perfdata:"Reserved Server Memory (KB)"`
|
||||||
memMgrSQLCacheMemoryKB = "SQL Cache Memory (KB)"
|
MemMgrSQLCacheMemoryKB float64 `perfdata:"SQL Cache Memory (KB)"`
|
||||||
memMgrStolenServerMemoryKB = "Stolen Server Memory (KB)"
|
MemMgrStolenServerMemoryKB float64 `perfdata:"Stolen Server Memory (KB)"`
|
||||||
memMgrTargetServerMemoryKB = "Target Server Memory (KB)"
|
MemMgrTargetServerMemoryKB float64 `perfdata:"Target Server Memory (KB)"`
|
||||||
memMgrTotalServerMemoryKB = "Total Server Memory (KB)"
|
MemMgrTotalServerMemoryKB float64 `perfdata:"Total Server Memory (KB)"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildMemoryManager() error {
|
func (c *Collector) buildMemoryManager() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.memMgrPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.memMgrPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
memMgrConnectionMemoryKB,
|
|
||||||
memMgrDatabaseCacheMemoryKB,
|
|
||||||
memMgrExternalBenefitOfMemory,
|
|
||||||
memMgrFreeMemoryKB,
|
|
||||||
memMgrGrantedWorkspaceMemoryKB,
|
|
||||||
memMgrLockBlocks,
|
|
||||||
memMgrLockBlocksAllocated,
|
|
||||||
memMgrLockMemoryKB,
|
|
||||||
memMgrLockOwnerBlocks,
|
|
||||||
memMgrLockOwnerBlocksAllocated,
|
|
||||||
memMgrLogPoolMemoryKB,
|
|
||||||
memMgrMaximumWorkspaceMemoryKB,
|
|
||||||
memMgrMemoryGrantsOutstanding,
|
|
||||||
memMgrMemoryGrantsPending,
|
|
||||||
memMgrOptimizerMemoryKB,
|
|
||||||
memMgrReservedServerMemoryKB,
|
|
||||||
memMgrSQLCacheMemoryKB,
|
|
||||||
memMgrStolenServerMemoryKB,
|
|
||||||
memMgrTargetServerMemoryKB,
|
|
||||||
memMgrTotalServerMemoryKB,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.memMgrPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), perfdata.InstancesAll, counters)
|
c.memMgrPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesMemMgr](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "Memory Manager"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create Memory Manager collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create Memory Manager collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,158 +214,149 @@ func (c *Collector) collectMemoryManager(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorMemoryManager, c.memMgrPerfDataCollectors, c.collectMemoryManagerInstance)
|
return c.collect(ch, subCollectorMemoryManager, c.memMgrPerfDataCollectors, c.collectMemoryManagerInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectMemoryManagerInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectMemoryManagerInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.memMgrPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "Memory Manager"))
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrConnectionMemoryKB,
|
c.memMgrConnectionMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrConnectionMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrConnectionMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrDatabaseCacheMemoryKB,
|
c.memMgrDatabaseCacheMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrDatabaseCacheMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrDatabaseCacheMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrExternalBenefitOfMemory,
|
c.memMgrExternalBenefitOfMemory,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrExternalBenefitOfMemory].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrExternalBenefitOfMemory,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrFreeMemoryKB,
|
c.memMgrFreeMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrFreeMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrFreeMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrGrantedWorkspaceMemoryKB,
|
c.memMgrGrantedWorkspaceMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrGrantedWorkspaceMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrGrantedWorkspaceMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLockBlocks,
|
c.memMgrLockBlocks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLockBlocks].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrLockBlocks,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLockBlocksAllocated,
|
c.memMgrLockBlocksAllocated,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLockBlocksAllocated].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrLockBlocksAllocated,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLockMemoryKB,
|
c.memMgrLockMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLockMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrLockMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLockOwnerBlocks,
|
c.memMgrLockOwnerBlocks,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLockOwnerBlocks].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrLockOwnerBlocks,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLockOwnerBlocksAllocated,
|
c.memMgrLockOwnerBlocksAllocated,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLockOwnerBlocksAllocated].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrLockOwnerBlocksAllocated,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrLogPoolMemoryKB,
|
c.memMgrLogPoolMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrLogPoolMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrLogPoolMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrMaximumWorkspaceMemoryKB,
|
c.memMgrMaximumWorkspaceMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrMaximumWorkspaceMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrMaximumWorkspaceMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrMemoryGrantsOutstanding,
|
c.memMgrMemoryGrantsOutstanding,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrMemoryGrantsOutstanding].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrMemoryGrantsOutstanding,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrMemoryGrantsPending,
|
c.memMgrMemoryGrantsPending,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrMemoryGrantsPending].FirstValue,
|
c.memMgrPerfDataObject[0].MemMgrMemoryGrantsPending,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrOptimizerMemoryKB,
|
c.memMgrOptimizerMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrOptimizerMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrOptimizerMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrReservedServerMemoryKB,
|
c.memMgrReservedServerMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrReservedServerMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrReservedServerMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrSQLCacheMemoryKB,
|
c.memMgrSQLCacheMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrSQLCacheMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrSQLCacheMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrStolenServerMemoryKB,
|
c.memMgrStolenServerMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrStolenServerMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrStolenServerMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrTargetServerMemoryKB,
|
c.memMgrTargetServerMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrTargetServerMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrTargetServerMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.memMgrTotalServerMemoryKB,
|
c.memMgrTotalServerMemoryKB,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
data[memMgrTotalServerMemoryKB].FirstValue*1024,
|
c.memMgrPerfDataObject[0].MemMgrTotalServerMemoryKB*1024,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -19,35 +19,35 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorSQLErrors struct {
|
type collectorSQLErrors struct {
|
||||||
sqlErrorsPerfDataCollectors map[string]*perfdata.Collector
|
sqlErrorsPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
sqlErrorsPerfDataObject []perfDataCounterValuesSqlErrors
|
||||||
|
|
||||||
// Win32_PerfRawData_{instance}_SQLServerSQLErrors
|
// Win32_PerfRawData_{instance}_SQLServerSQLErrors
|
||||||
sqlErrorsTotal *prometheus.Desc
|
sqlErrorsTotal *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesSqlErrors struct {
|
||||||
sqlErrorsErrorsPerSec = "Errors/sec"
|
Name string
|
||||||
)
|
|
||||||
|
SqlErrorsErrorsPerSec float64 `perfdata:"Errors/sec"`
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Collector) buildSQLErrors() error {
|
func (c *Collector) buildSQLErrors() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.sqlErrorsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.sqlErrorsPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
sqlErrorsErrorsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.sqlErrorsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), perfdata.InstancesAll, counters)
|
c.sqlErrorsPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesSqlErrors](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "SQL Errors"), pdh.InstancesAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create SQL Errors collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create SQL Errors collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,22 +66,18 @@ func (c *Collector) collectSQLErrors(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorSQLErrors, c.sqlErrorsPerfDataCollectors, c.collectSQLErrorsInstance)
|
return c.collect(ch, subCollectorSQLErrors, c.sqlErrorsPerfDataCollectors, c.collectSQLErrorsInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectSQLErrorsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectSQLErrorsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.sqlErrorsPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "SQL Errors"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for resource, data := range perfData {
|
for _, data := range c.sqlErrorsPerfDataObject {
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlErrorsTotal,
|
c.sqlErrorsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlErrorsErrorsPerSec].FirstValue,
|
data.SqlErrorsErrorsPerSec,
|
||||||
sqlInstance, resource,
|
sqlInstance, data.Name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||||
"github.com/prometheus-community/windows_exporter/internal/types"
|
"github.com/prometheus-community/windows_exporter/internal/types"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type collectorSQLStats struct {
|
type collectorSQLStats struct {
|
||||||
sqlStatsPerfDataCollectors map[string]*perfdata.Collector
|
sqlStatsPerfDataCollectors map[string]*pdh.Collector
|
||||||
|
sqlStatsPerfDataObject []perfDataCounterValuesSqlStats
|
||||||
|
|
||||||
sqlStatsAutoParamAttempts *prometheus.Desc
|
sqlStatsAutoParamAttempts *prometheus.Desc
|
||||||
sqlStatsBatchRequests *prometheus.Desc
|
sqlStatsBatchRequests *prometheus.Desc
|
||||||
@@ -40,43 +41,30 @@ type collectorSQLStats struct {
|
|||||||
sqlStatsUnsafeAutoParams *prometheus.Desc
|
sqlStatsUnsafeAutoParams *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type perfDataCounterValuesSqlStats struct {
|
||||||
sqlStatsAutoParamAttemptsPerSec = "Auto-Param Attempts/sec"
|
SqlStatsAutoParamAttemptsPerSec float64 `perfdata:"Auto-Param Attempts/sec"`
|
||||||
sqlStatsBatchRequestsPerSec = "Batch Requests/sec"
|
SqlStatsBatchRequestsPerSec float64 `perfdata:"Batch Requests/sec"`
|
||||||
sqlStatsFailedAutoParamsPerSec = "Failed Auto-Params/sec"
|
SqlStatsFailedAutoParamsPerSec float64 `perfdata:"Failed Auto-Params/sec"`
|
||||||
sqlStatsForcedParameterizationsPerSec = "Forced Parameterizations/sec"
|
SqlStatsForcedParameterizationsPerSec float64 `perfdata:"Forced Parameterizations/sec"`
|
||||||
sqlStatsGuidedplanexecutionsPerSec = "Guided plan executions/sec"
|
SqlStatsGuidedplanexecutionsPerSec float64 `perfdata:"Guided plan executions/sec"`
|
||||||
sqlStatsMisguidedplanexecutionsPerSec = "Misguided plan executions/sec"
|
SqlStatsMisguidedplanexecutionsPerSec float64 `perfdata:"Misguided plan executions/sec"`
|
||||||
sqlStatsSafeAutoParamsPerSec = "Safe Auto-Params/sec"
|
SqlStatsSafeAutoParamsPerSec float64 `perfdata:"Safe Auto-Params/sec"`
|
||||||
sqlStatsSQLAttentionrate = "SQL Attention rate"
|
SqlStatsSQLAttentionrate float64 `perfdata:"SQL Attention rate"`
|
||||||
sqlStatsSQLCompilationsPerSec = "SQL Compilations/sec"
|
SqlStatsSQLCompilationsPerSec float64 `perfdata:"SQL Compilations/sec"`
|
||||||
sqlStatsSQLReCompilationsPerSec = "SQL Re-Compilations/sec"
|
SqlStatsSQLReCompilationsPerSec float64 `perfdata:"SQL Re-Compilations/sec"`
|
||||||
sqlStatsUnsafeAutoParamsPerSec = "Unsafe Auto-Params/sec"
|
SqlStatsUnsafeAutoParamsPerSec float64 `perfdata:"Unsafe Auto-Params/sec"`
|
||||||
)
|
}
|
||||||
|
|
||||||
func (c *Collector) buildSQLStats() error {
|
func (c *Collector) buildSQLStats() error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
c.sqlStatsPerfDataCollectors = make(map[string]*perfdata.Collector, len(c.mssqlInstances))
|
c.sqlStatsPerfDataCollectors = make(map[string]*pdh.Collector, len(c.mssqlInstances))
|
||||||
errs := make([]error, 0, len(c.mssqlInstances))
|
errs := make([]error, 0, len(c.mssqlInstances))
|
||||||
counters := []string{
|
|
||||||
sqlStatsAutoParamAttemptsPerSec,
|
|
||||||
sqlStatsBatchRequestsPerSec,
|
|
||||||
sqlStatsFailedAutoParamsPerSec,
|
|
||||||
sqlStatsForcedParameterizationsPerSec,
|
|
||||||
sqlStatsGuidedplanexecutionsPerSec,
|
|
||||||
sqlStatsMisguidedplanexecutionsPerSec,
|
|
||||||
sqlStatsSafeAutoParamsPerSec,
|
|
||||||
sqlStatsSQLAttentionrate,
|
|
||||||
sqlStatsSQLCompilationsPerSec,
|
|
||||||
sqlStatsSQLReCompilationsPerSec,
|
|
||||||
sqlStatsUnsafeAutoParamsPerSec,
|
|
||||||
}
|
|
||||||
|
|
||||||
for sqlInstance := range c.mssqlInstances {
|
for _, sqlInstance := range c.mssqlInstances {
|
||||||
c.sqlStatsPerfDataCollectors[sqlInstance], err = perfdata.NewCollector(c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), nil, counters)
|
c.sqlStatsPerfDataCollectors[sqlInstance.name], err = pdh.NewCollector[perfDataCounterValuesSqlStats](pdh.CounterTypeRaw, c.mssqlGetPerfObjectName(sqlInstance.name, "SQL Statistics"), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("failed to create SQL Statistics collector for instance %s: %w", sqlInstance, err))
|
errs = append(errs, fmt.Errorf("failed to create SQL Statistics collector for instance %s: %w", sqlInstance.name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,95 +142,86 @@ func (c *Collector) collectSQLStats(ch chan<- prometheus.Metric) error {
|
|||||||
return c.collect(ch, subCollectorSQLStats, c.sqlStatsPerfDataCollectors, c.collectSQLStatsInstance)
|
return c.collect(ch, subCollectorSQLStats, c.sqlStatsPerfDataCollectors, c.collectSQLStatsInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) collectSQLStatsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *perfdata.Collector) error {
|
func (c *Collector) collectSQLStatsInstance(ch chan<- prometheus.Metric, sqlInstance string, perfDataCollector *pdh.Collector) error {
|
||||||
if perfDataCollector == nil {
|
err := perfDataCollector.Collect(&c.sqlStatsPerfDataObject)
|
||||||
return types.ErrCollectorNotInitialized
|
|
||||||
}
|
|
||||||
|
|
||||||
perfData, err := perfDataCollector.Collect()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), err)
|
return fmt.Errorf("failed to collect %s metrics: %w", c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, ok := perfData[perfdata.InstanceEmpty]
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("perflib query for %s returned empty result set", c.mssqlGetPerfObjectName(sqlInstance, "SQL Statistics"))
|
|
||||||
}
|
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsAutoParamAttempts,
|
c.sqlStatsAutoParamAttempts,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsAutoParamAttemptsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsAutoParamAttemptsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsBatchRequests,
|
c.sqlStatsBatchRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsBatchRequestsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsBatchRequestsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsFailedAutoParams,
|
c.sqlStatsFailedAutoParams,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsFailedAutoParamsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsFailedAutoParamsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsForcedParameterizations,
|
c.sqlStatsForcedParameterizations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsForcedParameterizationsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsForcedParameterizationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsGuidedplanexecutions,
|
c.sqlStatsGuidedplanexecutions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsGuidedplanexecutionsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsGuidedplanexecutionsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsMisguidedplanexecutions,
|
c.sqlStatsMisguidedplanexecutions,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsMisguidedplanexecutionsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsMisguidedplanexecutionsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsSafeAutoParams,
|
c.sqlStatsSafeAutoParams,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsSafeAutoParamsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsSafeAutoParamsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsSQLAttentionrate,
|
c.sqlStatsSQLAttentionrate,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsSQLAttentionrate].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsSQLAttentionrate,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsSQLCompilations,
|
c.sqlStatsSQLCompilations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsSQLCompilationsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsSQLCompilationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsSQLReCompilations,
|
c.sqlStatsSQLReCompilations,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsSQLReCompilationsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsSQLReCompilationsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.sqlStatsUnsafeAutoParams,
|
c.sqlStatsUnsafeAutoParams,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
data[sqlStatsUnsafeAutoParamsPerSec].FirstValue,
|
c.sqlStatsPerfDataObject[0].SqlStatsUnsafeAutoParamsPerSec,
|
||||||
sqlInstance,
|
sqlInstance,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user