Skip to content

Commit 52d6fdd

Browse files
committed
metrics: export 'netbios name' as label
Add "netbiosname" label to smb_metrics_status which may be used as cluster identifier on deployments which run multiple instances of smbmetrics via single dashboard. Signed-off-by: Shachar Sharon <ssharon@redhat.com>
1 parent 7c009e8 commit 52d6fdd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ $ curl --request GET "http://localhost:9922/metrics"
6363

6464
# HELP smb_metrics_status Current metrics-collector status versions
6565
# TYPE smb_metrics_status gauge
66-
smb_metrics_status{commitid="092fe2bb0",ctdbvers="4.20.0-103",sambaimage="",sambavers="4.20.0-103",version="v0.2-28-g092fe2b"} 1
66+
smb_metrics_status{commitid="092fe2bb0",ctdbvers="4.20.0-103",netbiosname="cluster1",sambaimage="",sambavers="4.20.0-103",version="v0.2-28-g092fe2b"} 1
6767
# HELP smb_sessions_total Number of currently active SMB sessions
6868
# TYPE smb_sessions_total gauge
6969
smb_sessions_total 8

internal/metrics/collectors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func (col *smbVersionsCollector) Collect(ch chan<- prometheus.Metric) {
4848
if err != nil {
4949
status = 1
5050
}
51+
netbiosName, err := resolveNetbiosName()
52+
if err != nil {
53+
netbiosName = ""
54+
}
5155
ch <- prometheus.MustNewConstMetric(
5256
col.dsc[0],
5357
prometheus.GaugeValue,
@@ -57,6 +61,7 @@ func (col *smbVersionsCollector) Collect(ch chan<- prometheus.Metric) {
5761
vers.SambaImage,
5862
vers.SambaVersion,
5963
vers.CtdbVersion,
64+
netbiosName,
6065
)
6166
}
6267

@@ -74,6 +79,7 @@ func (sme *smbMetricsExporter) newSMBVersionsCollector() prometheus.Collector {
7479
"sambaimage",
7580
"sambavers",
7681
"ctdbvers",
82+
"netbiosname",
7783
}, nil),
7884
}
7985
return col

internal/metrics/versions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ func resolveCtdbVersion() (string, error) {
6464
func executeRpmQCommand(name string) (string, error) {
6565
return executeCommand("rpm", "-q", name)
6666
}
67+
68+
func resolveNetbiosName() (string, error) {
69+
return executeCommand("net", "conf", "getparm", "global", "netbios name")
70+
}

0 commit comments

Comments
 (0)