mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-03 17:16:37 +00:00
fixed collectServerShare
Signed-off-by: Andrey Burtasov <BurtasovAA@GSP-I.RU>
This commit is contained in:
@@ -165,23 +165,15 @@ func (c *collector) collectServerShares(ctx *types.ScrapeContext, ch chan<- prom
|
|||||||
if err := perflib.UnmarshalObject(ctx.PerfObjects["SMB Server Shares"], &data, c.logger); err != nil {
|
if err := perflib.UnmarshalObject(ctx.PerfObjects["SMB Server Shares"], &data, c.logger); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
labelUseCount := make(map[string]int)
|
for _, instance := range data {
|
||||||
for _, proc := range data {
|
labelName := c.toLabelName(instance.Name)
|
||||||
labelName := c.toLabelName(proc.Name)
|
|
||||||
if strings.HasSuffix(labelName, "_total") {
|
if strings.HasSuffix(labelName, "_total") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
labelUseCount[labelName]++
|
|
||||||
if labelUseCount[labelName] > 1 {
|
|
||||||
labelName = fmt.Sprintf("%s_%d", labelName, labelUseCount[labelName])
|
|
||||||
}
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.CurrentOpenFileCount,
|
c.CurrentOpenFileCount,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
c.msToSec(proc.CurrentOpenFileCount),
|
instance.CurrentOpenFileCount,
|
||||||
labelName,
|
labelName,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user