Skip to content

Commit e60bcb6

Browse files
committed
metrics: ignore "IPC$" service-id
Ignore the special value of "IPC$" when collecting and exporting shares' metrics. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 67fb65f commit e60bcb6

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

internal/metrics/smbinfo.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ func (smbinfo *SMBInfo) TotalSessions() int {
3535
}
3636

3737
func (smbinfo *SMBInfo) TotalTreeCons() int {
38-
return len(smbinfo.smbstat.TCons)
38+
total := 0
39+
for _, tcon := range smbinfo.smbstat.TCons {
40+
serviceID := tcon.Service
41+
if isInternalServiceID(serviceID) {
42+
continue
43+
}
44+
total++
45+
}
46+
return total
3947
}
4048

4149
func (smbinfo *SMBInfo) TotalOpenFiles() int {
@@ -79,6 +87,9 @@ func (smbinfo *SMBInfo) MapServiceToTreeCons() map[string][]*SMBStatusTreeCon {
7987
ret := map[string][]*SMBStatusTreeCon{}
8088
for _, tcon := range smbinfo.smbstat.TCons {
8189
serviceID := tcon.Service
90+
if isInternalServiceID(serviceID) {
91+
continue
92+
}
8293
tconRef := &tcon
8394
ret[serviceID] = append(ret[serviceID], tconRef)
8495
}
@@ -88,6 +99,10 @@ func (smbinfo *SMBInfo) MapServiceToTreeCons() map[string][]*SMBStatusTreeCon {
8899
func (smbinfo *SMBInfo) MapMachineToTreeCons() map[string][]*SMBStatusTreeCon {
89100
ret := map[string][]*SMBStatusTreeCon{}
90101
for _, tcon := range smbinfo.smbstat.TCons {
102+
serviceID := tcon.Service
103+
if isInternalServiceID(serviceID) {
104+
continue
105+
}
91106
machineID := tcon.Machine
92107
tconRef := &tcon
93108
ret[machineID] = append(ret[machineID], tconRef)
@@ -99,6 +114,9 @@ func (smbinfo *SMBInfo) MapServiceToMachines() map[string]map[string]int {
99114
ret := map[string]map[string]int{}
100115
for _, tcon := range smbinfo.smbstat.TCons {
101116
serviceID := tcon.Service
117+
if isInternalServiceID(serviceID) {
118+
continue
119+
}
102120
machineID := tcon.Machine
103121
sub, found := ret[serviceID]
104122
if !found {
@@ -114,6 +132,9 @@ func (smbinfo *SMBInfo) MapMachineToServies() map[string]map[string]int {
114132
ret := map[string]map[string]int{}
115133
for _, tcon := range smbinfo.smbstat.TCons {
116134
serviceID := tcon.Service
135+
if isInternalServiceID(serviceID) {
136+
continue
137+
}
117138
machineID := tcon.Machine
118139
sub, found := ret[machineID]
119140
if !found {
@@ -124,3 +145,7 @@ func (smbinfo *SMBInfo) MapMachineToServies() map[string]map[string]int {
124145
}
125146
return ret
126147
}
148+
149+
func isInternalServiceID(serviceID string) bool {
150+
return serviceID == "IPC$"
151+
}

0 commit comments

Comments
 (0)