mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-13 08:26:37 +00:00
smb: extend smb share metrics (#1765)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -15,8 +15,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
InstanceAll = []string{"*"}
|
||||
InstanceTotal = []string{"_Total"}
|
||||
InstancesAll = []string{"*"}
|
||||
InstancesTotal = []string{InstanceTotal}
|
||||
)
|
||||
|
||||
type Collector struct {
|
||||
@@ -43,14 +43,14 @@ func NewCollector(object string, instances []string, counters []string) (*Collec
|
||||
}
|
||||
|
||||
if len(instances) == 0 {
|
||||
instances = []string{EmptyInstance}
|
||||
instances = []string{InstanceEmpty}
|
||||
}
|
||||
|
||||
collector := &Collector{
|
||||
object: object,
|
||||
counters: make(map[string]Counter, len(counters)),
|
||||
handle: handle,
|
||||
totalCounterRequested: slices.Contains(instances, "_Total"),
|
||||
totalCounterRequested: slices.Contains(instances, InstanceTotal),
|
||||
mu: sync.RWMutex{},
|
||||
}
|
||||
|
||||
@@ -186,12 +186,12 @@ func (c *Collector) Collect() (map[string]map[string]CounterValues, error) {
|
||||
for _, item := range items {
|
||||
if item.RawValue.CStatus == PdhCstatusValidData || item.RawValue.CStatus == PdhCstatusNewData {
|
||||
instanceName := windows.UTF16PtrToString(item.SzName)
|
||||
if strings.HasSuffix(instanceName, "_Total") && !c.totalCounterRequested {
|
||||
if strings.HasSuffix(instanceName, InstanceTotal) && !c.totalCounterRequested {
|
||||
continue
|
||||
}
|
||||
|
||||
if instanceName == "" || instanceName == "*" {
|
||||
instanceName = EmptyInstance
|
||||
instanceName = InstanceEmpty
|
||||
}
|
||||
|
||||
if _, ok := data[instanceName]; !ok {
|
||||
@@ -239,7 +239,7 @@ func (c *Collector) Close() {
|
||||
func formatCounterPath(object, instance, counterName string) string {
|
||||
var counterPath string
|
||||
|
||||
if instance == EmptyInstance {
|
||||
if instance == InstanceEmpty {
|
||||
counterPath = fmt.Sprintf(`\%s\%s`, object, counterName)
|
||||
} else {
|
||||
counterPath = fmt.Sprintf(`\%s(%s)\%s`, object, instance, counterName)
|
||||
|
||||
@@ -4,7 +4,10 @@ package perfdata
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
const EmptyInstance = "------"
|
||||
const (
|
||||
InstanceEmpty = "------"
|
||||
InstanceTotal = "_Total"
|
||||
)
|
||||
|
||||
type CounterValues struct {
|
||||
Type prometheus.ValueType
|
||||
|
||||
Reference in New Issue
Block a user