-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add GetProcCredName implementation to windows gosigar #13
Conversation
func GetProcCredName(pid int) (string, error) { | ||
handle, err := syscall.OpenProcess(syscall.PROCESS_QUERY_INFORMATION, false, uint32(pid)) | ||
|
||
defer syscall.CloseHandle(handle) |
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.
Check the err
status prior the defer CloseHandle
.
Thanks for adding this feature. It would be great if you could add a test case to sigar_windows_test.go. You could create a test that compares the username returned by |
@@ -106,6 +106,7 @@ const ( | |||
|
|||
type ProcState struct { | |||
Name string | |||
UserId string |
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.
When I read UserId
I am thinking of a numeric value like a unix UID (or alphanumeric value like a Windows SID). I think I would name this Username
like Golang does in their User struct. But that's just one person's opinion, I'm open to hearing others' opinions.
@andrewkroh Awesome feedback! I'll work on the updates tomorrow. |
@andrewkroh Hmm, I could be wrong. But it doesn't look like the current test suite works (unmodified by me) on windows. If I pull down master clean, many of the tests to not run if I run This is one example of a failure. Apologies for the gross formatting :( ←[90m------------------------------←[0m
←[32m+←[0m
←[90m------------------------------←[0m
←[91m←[1m+ Failure [0.049 seconds]←[0m
Sigar
←[90mC:/Projects/GoWorkspace/src/github.com/eonarheim/gosigar/sigar_interface_te
st.go:135←[0m
←[91m←[1mproc state [It]←[0m
←[90mC:/Projects/GoWorkspace/src/github.com/eonarheim/gosigar/sigar_interface_
test.go:100←[0m
←[91mExpected
<[]string | len:2, cap:2>: ["go", "ginkgo"]
to contain element matching
<string>: go.exe←[0m
It looks like all of the failures are coming from the If I run the specific test for windows things are okay.
I've opened an issue about this #14 please correct me if I'm wrong :) |
Yeah, I think there are problems with the tests on Windows. Because of this, when I made a change last week I only ran the test cases I added. Windows seems to be in need of some clean up. |
Will you please run go fmt to format the code. The changes look good. |
@andrewkroh Awesome! Looking forward to this feature :) |
One more request, can you please squash your commits? |
Will do |
…stic/topbeat#36 in windows
Squashed! |
Add GetProcCredName implementation to windows gosigar
When collecting process information in windows, it is sometimes useful to know the process identity to disambiguate like process (web sites) or identify problem users on a system.
This can be implemented fairly simply with the win32 api bindings in go.
This is related to the topbeats issue elastic/beats#590 and elastic/topbeat#36, basically enables a simple call to gosigar from topbeat to implement.