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

(SLV-771) Fix bug where process data is missed #42

Merged
merged 3 commits into from
Feb 7, 2020
Merged

(SLV-771) Fix bug where process data is missed #42

merged 3 commits into from
Feb 7, 2020

Conversation

RandellP
Copy link
Contributor

@RandellP RandellP commented Feb 6, 2020

The process data gathering greps process names for the ones we wanted to track... then passes the list to sar to track. If a process passed to sar exists when sar starts, but exits before sar gathers the first round of data, then sar will crash while printing the average summaries. Thus we lose data.

Also, if the process exited before sar ran, there would be no data and some of the generate_system_metrics code would crash expecting to find that process in the sar results.

Fine tuned the process grep to avoid matching processes we don't care about.
Put a catch to not crash if one of the processes we expect doesn't have any data.

Copy link
Contributor

@johnduarte johnduarte left a comment

Choose a reason for hiding this comment

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

You may want to review your commit comment. It could use a little bit of love.

johnduarte
johnduarte previously approved these changes Feb 6, 2020
@tkishel
Copy link
Contributor

tkishel commented Feb 6, 2020

LTGM, though this comment is explicit and subject to being out of sync:

# --process_expression '/opt/puppetlabs|puma.*/etc/puppetlabs'

FWIW, these unless File.directory checks are unnecessary:

FileUtils.mkdir_p(@metrics_dir) unless File.directory?(@metrics_dir)

as they are inherent:

mkdir_p(list, mode: nil, noop: nil, verbose: nil)
Creates a directory and all its parent directories ...
causes to make following directories, if it does not exist.

https://ruby-doc.org/stdlib-2.4.1/libdoc/fileutils/rdoc/FileUtils.html#method-c-mkdir_p

tkishel
tkishel previously approved these changes Feb 6, 2020
@RandellP RandellP dismissed stale reviews from tkishel and johnduarte via 47fb64d February 6, 2020 19:32
tkishel and others added 3 commits February 6, 2020 11:37
These files could/should be functionaly identical:

puppetlabs-puppet-metrics-viewer/json2graphite.rb
puppetlabs-puppet_metrics_collector/files/json2timeseriesdb

With this commit:

Bi-directional merge of changes.
Added comments.
Replaced unnessary double-quotes with single-quotes.
The process data gathering greps process names for the ones we wanted to track... then passes the list to sar to track. If a process passed to sar exists when sar starts, but exits before sar gathers the first round of data, then sar will crash while printing the average summaries. Thus we lose data.

Also, if the process exited before sar ran, there would be no data and some of the generate_system_metrics code would crash expecting to find that process in the sar results.

Fine tuned the process grep to avoid matching processes we don't care about.
Put a catch to not crash if one of the processes we expect doesn't have any data.
@RandellP
Copy link
Contributor Author

RandellP commented Feb 6, 2020

@tkishel @johnduarte Fixed commit and PR message. made the example more general.
On the mkdir conditional... yeah, it isn't technically necessary, but I think I read somewhere it was a touch faster or something... so I left it in.

@RandellP
Copy link
Contributor Author

RandellP commented Feb 7, 2020

If we are all good, let's merge this.

@tkishel tkishel merged commit 86e9aa4 into master Feb 7, 2020
@johnduarte johnduarte deleted the SLV-771 branch February 7, 2020 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants