-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIFS client support for Linux #103
Conversation
2f5136d
to
d774d6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I think this needs some work in the readability department, and I can't say I'm comfortable with the heavy use of regex for string parsing.
Is there any better way? Is there a more machine-readable CIFS interface?
I believe some improvements can be made here that will make this code more maintainable in the long run.
I will overwork this and open a new PR, when it's ready. |
No need to close it, just following up with more commits is totally fine! |
@mdlayher I have finally some time to code further on it. So I have reopen the pull Request and did further research. I've found another solution for getting CIFS statistics. The
This is much less output as we get via
So I would prefer for writing a parser for |
@mdlayher @SuperQ Can one of you have a look at the newest commit? If this commit is okay I would rebase, squash and commit with sign-off message. I am unhappy with a few things at the moment:
EDIT: I have changed the datastructure. I am using the same hashmap for SMB1 and SMB2 now. This way the code is a lot easier to read and it should be easier to access the data as well. |
3040ba7
to
8176ff2
Compare
441d371
to
1f1c397
Compare
@mdlayher @SuperQ Could you review again? It builds fine now, but it still uses the regex approach to get the statistics. A better solution would be to write an own parser for cifs statistics (maybe in a seperate project?). However this approach works fine, feedback to my code is welcome. I am still a golang newbie and need to learn a lot. |
|
||
// parseHeader parses our SMB header | ||
func parseHeader(line string, header map[string]uint64) error { | ||
for _, regexpHeader := range regexpHeaders { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a single multline regex instead of this array? I think it would make the code be more readable.
Renames: 0 T2 Renames 0 | ||
FindFirst: 1 FNext 0 FClose 0 | ||
|
||
2) \\server2\share2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use different numbers in the second fixture? I think there might be an issue with the parsing.
Sorry for not responding earlier! So this looks really hard to parse.. :-/ I don't think the loop over the file is doing the right thing. After it finds the 'new smb block', it always run the parse block function. Either way, I'd suggest you first try to split the file into the 'global' and per mount blocks and parse these with big multiline regex. I think that would make the code much more readable. |
Hi @discordianfish,
The tests that I have attached are working fine. |
Try using different numbers in the different fixtures, that should expose the issue. Or I'm wrong, quite possible :) |
Ok I tried using different numbers in the second fixture and you are correct. The tests will fail, but I have no idea why. When I introspect the two stats About parsing it as one file: this makes parsing of the cifsstats really difficult. It's strange that no kernel developer tried changing this already. I mean human readable output is nice, but it would be nice for us to have more machine readable output (the NFS stats are awesome for example) |
This commit adds CIFS/SMB client support for procfs. It support SMB version 1,2 and 3. We parse /proc/fs/cifs/stats for CIFS and SMB statistics. Signed-off-by: Christian Rebischke <[email protected]>
1f1c397
to
b862ab7
Compare
I'm going to close this for now. Let's re-open when the changes are addressed. |
Add two new fields to Meminfo struct
Supported are any client statistics in SMB1 and SMB2. This should fix #95