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

Fix pid_count with systemd_unit in procstat_lookup #5972

Merged
merged 2 commits into from
Jun 14, 2019

Conversation

Frakenz
Copy link
Contributor

@Frakenz Frakenz commented Jun 8, 2019

Attempt at fixing #5300. Not sure if using an OR statement or writing a separate if was a better practice. Since both check for valid PIDs I used an OR statement.
Also I tested this on golang and know almost nothing of GO, so there might be better ways to write this.

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Attempt at fixing influxdata#5300. Not sure if using an OR statement or writing a separate if was a better practice. Since both check for valid PIDs I used an OR statement.
Also I tested this on golang and know almost nothing of GO, so there might be better ways to write this.
@Frakenz
Copy link
Contributor Author

Frakenz commented Jun 8, 2019

Is there a chance this failed because I made the edit directly on github's website?
What am I doing wrong?

It could be a syntax error that worked on versions 1.9 and 1.10 but not from 1.11 onwards. I will give it another Go on a few days if I have enough time to install and learn the language a bit.

plugins/inputs/procstat/procstat.go
Run make fmt to fix them.
make: *** [fmtcheck] Error 1
Command exited with code 2

@danielnelson
Copy link
Contributor

I think you just need a space before the {:

- if len(kv[1]) == 0 || bytes.Equal(kv[1], []byte("0")){
+ if len(kv[1]) == 0 || bytes.Equal(kv[1], []byte("0")) {

@danielnelson danielnelson added the fix pr to fix corresponding bug label Jun 14, 2019
@danielnelson danielnelson added this to the 1.11.1 milestone Jun 14, 2019
@danielnelson danielnelson merged commit cc2f3b2 into influxdata:master Jun 14, 2019
danielnelson pushed a commit that referenced this pull request Jun 14, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
@xczdenis
Copy link

It seems to me that it doesn't work as expected. When I use influx db as output client, it works fine. However, I also use prometheus_client:

[[outputs.prometheus_client]]
    listen = ":9193"
    path = "/metrics"
    expiration_interval = "0s"

I want to control the status of nexus.service. When the nexus is running, I get a response on url my-server-ip:9193/metrics like this:

# HELP systemd_units_active_code Telegraf collected metric
# TYPE systemd_units_active_code untyped
systemd_units_active_code{active="active",load="loaded",name="nexus.service",sub="running"} 0

But if I shut down the service, I get this:

# HELP systemd_units_active_code Telegraf collected metric
# TYPE systemd_units_active_code untyped
systemd_units_active_code{active="active",load="loaded",name="nexus.service",sub="running"} 0
systemd_units_active_code{active="inactive",load="loaded",name="nexus.service",sub="dead"} 2

So when I use this query: systemd_units_active_code{name="nexus.service"} I get 2 rows every time period - active and inactive. Therefore, I can't define the correct current state. Maybe i'm doing smth wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants