Skip to content
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

feat(inputs.procstat): Obtain process information through supervisor #13417

Merged
merged 14 commits into from Nov 13, 2023

Conversation

chenbt-hz
Copy link
Contributor

@chenbt-hz chenbt-hz commented Jun 9, 2023

resolves #13416

@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Jun 9, 2023

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@srebhan srebhan changed the title feat(inputs.procstat):Supports obtaining process information through … feat(inputs.procstat): Obtain process information through supervisor Jun 16, 2023
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chenbt-hz for the nice feature! I have some comments in the code. Please take a look and let me know once you addressed them.

plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/README.md Outdated Show resolved Hide resolved
plugins/inputs/procstat/native_finder_windows_test.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/pgrep.go Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
@srebhan srebhan added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin area/procstat plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jun 16, 2023
@srebhan srebhan self-assigned this Jun 16, 2023
@chenbt-hz chenbt-hz marked this pull request as draft June 17, 2023 08:51
@chenbt-hz
Copy link
Contributor Author

Hello, I have modified PR according to the suggestion, but I still have a few questions.
May I ask if you @srebhan have time to help review again or answer my questions? Thank you!

The following are the main contents of my modifications this time:

  1. Fix unit test for the 'supervisor'_ Unit [] string`
  2. Fix the bug of procstat_ Lookup that tags ["supervisor unit"] is incorrect
  3. Adjust the code one by one according to the modification suggestions.

@chenbt-hz chenbt-hz requested a review from srebhan June 19, 2023 07:47
@chenbt-hz chenbt-hz marked this pull request as ready for review June 19, 2023 07:47
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, but I think you should also implement the ChildPattern function for the native finder...

plugins/inputs/procstat/native_finder.go Outdated Show resolved Hide resolved
@srebhan srebhan added the waiting for response waiting for response from contributor label Aug 8, 2023
@telegraf-tiger
Copy link
Contributor

Hello! I am closing this issue due to inactivity. I hope you were able to resolve your problem, if not please try posting this question in our Community Slack or Community Forums or provide additional details in this issue and reqeust that it be re-opened. Thank you!

@telegraf-tiger telegraf-tiger bot closed this Aug 23, 2023
@chenbt-hz
Copy link
Contributor Author

Hello, I noticed that this pull request has been closed.
@srebhan Would you be able to take a moment to review the current code and see if it can be merged? Thank you very much for your time and assistance!

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Aug 24, 2023
@srebhan srebhan reopened this Aug 31, 2023
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update and sorry for missing out on your update @chenbt-hz!

I do have some more small comments. Nothing too big. Can you please additionally check the unit-tests which should be adapted as we now also get childs from the native-finder...

plugins/inputs/procstat/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/procstat/native_finder.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/pgrep.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
plugins/inputs/procstat/procstat.go Outdated Show resolved Hide resolved
@chenbt-hz
Copy link
Contributor Author

Thanks for the update and sorry for missing out on your update @chenbt-hz!

I do have some more small comments. Nothing too big. Can you please additionally check the unit-tests which should be adapted as we now also get childs from the native-finder...

I added the TestChildPattern function test. May I ask if that's what you're talking about?

@srebhan
Copy link
Contributor

srebhan commented Sep 6, 2023

Sure, if you look at the test-go-linux CI test at the end of the PR it says

=== FAIL: plugins/inputs/procstat TestChildPattern (0.02s)
    native_finder_test.go:50: 
                Error Trace:    /go/src/github.com/influxdata/telegraf/plugins/inputs/procstat/native_finder_test.go:50
                Error:          Not equal: 
                                expected: []procstat.PID{145942}
                                actual  : []procstat.PID(nil)
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,4 +1,2 @@
                                -([]procstat.PID) (len=1) {
                                - (procstat.PID) 145942
                                -}
                                +([]procstat.PID) <nil>
                                 
                Test:           TestChildPattern

DONE 6550 tests, 224 skipped, 1 failure in 432.569s

I guess it is because before the latest commits you returned nil for the native child finders and now you return an actual PID. That's what the unit-test TestChildPattern is complaining about. Therefore, I think you need to adapt the TestChildPattern test to reflect that the native finder for children is implemented now.

@powersj
Copy link
Contributor

powersj commented Sep 27, 2023

@chenbt-hz - Were you able to look at Sven's comment about updating a test case now that you have implemented the child pattern? Thanks

@powersj powersj added the waiting for response waiting for response from contributor label Sep 27, 2023
@chenbt-hz
Copy link
Contributor Author

@chenbt-hz - Were you able to look at Sven's comment about updating a test case now that you have implemented the child pattern? Thanks

I'm sorry for my late reply. I may need your @srebhan @powersj help to solve this problem, as my free account cannot be tested in circleci until 11/01/2023.

The current issue is that it is not possible to access the sub process PID number under the current testing process in circleci.
I used the vscode plugin during local testing on Mac, the testing process was usr/local/go/bin/go test timeout 30s - run ^ TestChildPattern $github. com/influxdata/delete/plugins/inputs/procstat , so I was able to pass the test normally.

However, I found that gotestsum testing was used in cricleci, so I tried to modify the code as follows, but still couldn't obtain the correct pid。

func TestChildPattern(t *testing.T) {
	if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
		cmd := exec.Command("/bin/bash", "-c", "echo \"TestChildPattern\" && sleep 10")
		....
		childpids, err := f.ChildPattern("TestChildPattern")
		...
    }
}

or

func TestChildPattern(t *testing.T) {
	if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
		cmd := exec.Command("/bin/bash", "-c", " sleep 10")
		....
		childpids, err := f.ChildPattern("gotestsum")
		...
  }
}

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Oct 5, 2023
@powersj
Copy link
Contributor

powersj commented Oct 13, 2023

Hi,

Should the pattern be the sleep or echo command?

@powersj powersj added the waiting for response waiting for response from contributor label Oct 13, 2023
@chenbt-hz
Copy link
Contributor Author

Hi,

Should the pattern be the sleep or echo command?

I have tried using the sleep or echo command but still couldn't obtain it. I'm not sure if there are unknown differences between CircleCI's environment and my local Mac environment that caused this anomaly.

@telegraf-tiger telegraf-tiger bot removed the waiting for response waiting for response from contributor label Oct 16, 2023
@powersj powersj added the waiting for response waiting for response from contributor label Nov 3, 2023
@telegraf-tiger
Copy link
Contributor

@srebhan srebhan added ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. and removed waiting for response waiting for response from contributor labels Nov 13, 2023
@srebhan srebhan assigned powersj and unassigned srebhan Nov 13, 2023
Copy link
Contributor

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this due to formal reasons and without the neutral view required... ;-)

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both!

@powersj powersj merged commit 2c5fbbc into influxdata:master Nov 13, 2023
23 checks passed
@github-actions github-actions bot added this to the v1.29.0 milestone Nov 13, 2023
@hackery
Copy link
Contributor

hackery commented Dec 12, 2023

This creates a breaking change for the systemd_unit part of the plugin, renaming it to systemd_units. Not updated in latest README for the plugin.

Raised by @tjnome in #14438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/procstat feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[procstat] Supports obtaining process information directly through the supervisor
4 participants