Skip to content

Commit 0aedee4

Browse files
committed
metrics: extend open-files info
Add extra layer of JSON parsing for more file-grained details on currently open-files. In particular, parse access-modes. Signed-off-by: Shachar Sharon <[email protected]>
1 parent 7de36b7 commit 0aedee4

File tree

2 files changed

+529
-35
lines changed

2 files changed

+529
-35
lines changed

internal/metrics/smbstatus.go

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,70 @@ type SMBStatusFileID struct {
7070

7171
// SMBStatusOpenFile represents a open-file output field
7272
type SMBStatusOpenFile struct {
73-
ServicePath string `json:"service_path"`
74-
Filename string `json:"filename"`
75-
FileID SMBStatusFileID `json:"fileid"`
76-
NumPendingDeletes int `json:"num_pending_deletes"`
73+
ServicePath string `json:"service_path"`
74+
Filename string `json:"filename"`
75+
FileID SMBStatusFileID `json:"fileid"`
76+
NumPendingDeletes int `json:"num_pending_deletes"`
77+
Opens map[string]SMBStatusOpenInfo `json:"opens"`
78+
}
79+
80+
// SMBStatusOpenInfo represents a single entry open_files/opens output field
81+
type SMBStatusOpenInfo struct {
82+
UID int `json:"uid"`
83+
ShareFileID string `json:"share_file_id"`
84+
OpenedAt string `json:"opened_at"`
85+
ShareMode SMBStatusOpenShareMode `json:"sharemode"`
86+
AccessMask SMBStatusOpenAccessMask `json:"access_mask"`
87+
OpLock SMBStatusOpenOpLock `json:"oplock"`
88+
Lease SMBStatusOpenLease `json:"lease"`
89+
}
90+
91+
// SMBStatusOpenShareMode represents a open file share-mode entry
92+
type SMBStatusOpenShareMode struct {
93+
Read bool `json:"READ"`
94+
Write bool `json:"WRITE"`
95+
Delete bool `json:"DELETE"`
96+
Text string `json:"text"`
97+
Hex string `json:"hex"`
98+
}
99+
100+
// SMBStatusOpenShareMode represents a open file access-mask entry
101+
type SMBStatusOpenAccessMask struct {
102+
ReadData bool `json:"READ_DATA"`
103+
WriteData bool `json:"WRITE_DATA"`
104+
AppendData bool `json:"APPEND_DATA"`
105+
ReadEA bool `json:"READ_EA"`
106+
WriteEA bool `json:"WRITE_EA"`
107+
Execute bool `json:"EXECUTE"`
108+
ReadAttributes bool `json:"READ_ATTRIBUTES"`
109+
WriteAttributes bool `json:"WRITE_ATTRIBUTES"`
110+
DeleteChild bool `json:"DELETE_CHILD"`
111+
Delete bool `json:"DELETE"`
112+
ReadControl bool `json:"READ_CONTROL"`
113+
WriteDAC bool `json:"WRITE_DAC"`
114+
Synchronize bool `json:"SYNCHRONIZE"`
115+
AccessSystemSecurity bool `json:"ACCESS_SYSTEM_SECURITY"`
116+
Text string `json:"text"`
117+
Hex string `json:"hex"`
118+
}
119+
120+
// SMBStatusOpenOplock represents an open file operation-lock entry
121+
type SMBStatusOpenOpLock struct {
122+
Exclusive bool `json:"EXCLUSIVE"`
123+
Batch bool `json:"BATCH"`
124+
LevelII bool `json:"LEVEL_II"`
125+
Lease bool `json:"LEASE"`
126+
Text string `json:"text"`
127+
}
128+
129+
// SMBStatusOpenLease represents an open file lease entry
130+
type SMBStatusOpenLease struct {
131+
LeaseKey string `json:"lease_key"`
132+
Read bool `json:"READ"`
133+
Write bool `json:"WRITE"`
134+
Handle bool `json:"HANDLE"`
135+
Text string `json:"text"`
136+
Hex string `json:"hex"`
77137
}
78138

79139
// SMBStatus represents output of 'smbstatus --json'

0 commit comments

Comments
 (0)