# Procstat plugin returns process\_name='pgrep' when the given pattern is not found

**URL:** https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349
**Category:** Telegraf
**Tags:** telegraf
**Created:** [August 31, 2023, 8:41am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349 "2023-08-31T08:41:16Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![neo1702](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@neo1702](https://community.influxdata.com/u/neo1702)
#### Post date: [August 31, 2023, 8:41am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/1 "2023-08-31T08:41:16Z")

</div>

i am using the **procstat plugin to gather information of a running process.**  
the process runs for 6hrs(0900-1500hrs) daily.  
**when the process is taken down procstat starts returning process\_name as pgrep and the pid keeps changing.**  
the frequency of these pgrep process\_names are not periodic also.

i am trying to create a column which will say running/not\_running based on whether pid value is being received or not.

**is this a intended behavior of procstat plugin to report the pid of the pgrep command** when the actual process is not running or am i missing something here.  
please help

---

<div class="post-metadata">

### Author: ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)
#### Post date: [August 31, 2023, 10:53am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/2 "2023-08-31T10:53:54Z")

</div>

It should indeed not occur for pgrep to return its own pid when the process is not running. Could you share a relevant part of your config (in code blocks please)

---

<div class="post-metadata">

### Author: ![neo1702](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@neo1702](https://community.influxdata.com/u/neo1702)
#### Post date: [August 31, 2023, 12:30pm UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/3 "2023-08-31T12:30:16Z")

</div>

@Hipska thank you for responding

following the config:

```auto
[[inputs.procstat]]
  ## PID file to monitor process
  pattern = "/foodir/process_name/bin/process_name"

```

---

<div class="post-metadata">

### Author: ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)
#### Post date: [August 31, 2023, 1:18pm UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/4 "2023-08-31T13:18:08Z")

</div>

And what metric does telegraf provide when the process is not running? (For example by running telegraf with `--test`)

---

<div class="post-metadata">

### Author: ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)
#### Post date: [September 6, 2023, 10:34am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/5 "2023-09-06T10:34:25Z")

</div>

@neo1702 please also open an issue with the information requested by @Hipska!

---

<div class="post-metadata">

### Author: ![neo1702](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@neo1702](https://community.influxdata.com/u/neo1702)
#### Post date: [September 6, 2023, 11:40am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/6 "2023-09-06T11:40:40Z")

</div>

@Hipska telegraf with --test option outputs only the internal\* measurements and procstat\_lookup. there is no procstat

---

<div class="post-metadata">

### Author: ![neo1702](https://avatars.discourse-cdn.com/v4/letter/n/d9b06d/32.png) [@neo1702](https://community.influxdata.com/u/neo1702)
#### Post date: [September 6, 2023, 11:41am UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/7 "2023-09-06T11:41:40Z")

</div>

@srebhan i have never done that before. can you help me with the process of it

---

<div class="post-metadata">

### Author: ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)
#### Post date: [September 6, 2023, 12:48pm UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/8 "2023-09-06T12:48:58Z")

</div>

Sure. You can open the issue [here on the Telegraf Github project](https://github.com/influxdata/telegraf/issues/new?assignees=&labels=bug&projects=&template=BUG_REPORT.yml). You need a Github account for that I guess…  
The link takes you to a form asking you for some things. For reproducing the issue on my side, the most important items are:

1. The relevant config part, in your case the `inputs.procstat` section. Please redact sensible information before putting it there.
2. The relevant part of the environment you run Telegraf in. How do you start Telegraf? Does it run on the machine or in a Docker container etc. Which version of Telegraf are you using? In your case you should mention that the process PID you are querying does not exist.
3. The output of Telegraf, i.e. an error message, the log-lines relevant to the issue, **but also** the metric you see.
4. The expected output/result.

Thank you in advance @neo1702!

---

<div class="post-metadata">

### Author: ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)
#### Post date: [September 6, 2023, 3:11pm UTC](https://community.influxdata.com/t/procstat-plugin-returns-process-name-pgrep-when-the-given-pattern-is-not-found/31349/9 "2023-09-06T15:11:32Z")

</div>

Well, that is indeed the expected behaviour. Why or how do you think procstat is emitting a metric with the pid of pgrep?
