Skip to content

Commit 6a7eb74

Browse files
committed
metrics: wrappers over 'smbstatus --json'
With json mode enabled, allow parsing all of smbstatus information via single execution into in-memory Go struct representation. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 695c8cc commit 6a7eb74

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

internal/metrics/smbstatus.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ func LocateSMBStatus() (string, error) {
115115
return "", errors.New("failed to locate smbstatus")
116116
}
117117

118+
// RunSMBStatus executes 'smbstatus --json' on host machine
119+
func RunSMBStatus() (*SMBStatus, error) {
120+
dat, err := executeSMBStatusCommand("--json")
121+
if err != nil {
122+
return &SMBStatus{}, err
123+
}
124+
return parseSMBStatus(dat)
125+
}
126+
118127
// RunSMBStatusVersion executes 'smbstatus --version' on host container
119128
func RunSMBStatusVersion() (string, error) {
120129
ver, err := executeSMBStatusCommand("--version")

0 commit comments

Comments
 (0)