# Ubuntu application monitoring

**URL:** https://discourse.nodered.org/t/ubuntu-application-monitoring/95545
**Category:** General
**Created:** [21 February 2025 00:28 UTC](https://discourse.nodered.org/t/ubuntu-application-monitoring/95545 "2025-02-21T00:28:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dweb32](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@dweb32](https://discourse.nodered.org/u/dweb32)
#### Post date: [21 February 2025 00:28 UTC](https://discourse.nodered.org/t/ubuntu-application-monitoring/95545/1 "2025-02-21T00:28:54Z")

</div>

I am trying to create a couple of flows in Node Red 3.1.0 running on Ubuntu that will send a HTTP JSON or MQTT message when an application, such as Chrome or other application for example, opens or closes on that local system. Is this possible and if so how do I do that?

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [21 February 2025 01:10 UTC](https://discourse.nodered.org/t/ubuntu-application-monitoring/95545/2 "2025-02-21T01:10:35Z")

</div>

Welcome to the forum @dweb32.

Perhaps the pgrep command will work.  
Here `node-red` is running (output 1), `chrome` is not (output 0).

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd74e86b1d501e66b487e161d99ad58b58ba4419.png)

```auto
[{"id":"d2a7bbe4acf004f3","type":"exec","z":"3b562c3873fb06e7","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":530,"y":160,"wires":[["0785a033b75dc140"],[],[]]},{"id":"0e22cf2822cdbdf7","type":"inject","z":"3b562c3873fb06e7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"node-red","payloadType":"str","x":520,"y":60,"wires":[["d1e21593fec9c7bf"]]},{"id":"d1e21593fec9c7bf","type":"change","z":"3b562c3873fb06e7","name":"Command","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"'/usr/bin/pgrep --count ' & payload & \" || true\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":80,"wires":[["d2a7bbe4acf004f3"]]},{"id":"012a51f5642ef264","type":"inject","z":"3b562c3873fb06e7","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"chrome","payloadType":"str","x":510,"y":100,"wires":[["d1e21593fec9c7bf"]]},{"id":"0785a033b75dc140","type":"change","z":"3b562c3873fb06e7","name":"As number","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number($substringBefore(payload, '\\n'))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":160,"wires":[["77ac297536dc32f8"]]},{"id":"77ac297536dc32f8","type":"debug","z":"3b562c3873fb06e7","name":"Result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":160,"wires":[]}]

```

Note if the process named is not running, the pgrep exit code is 1, so exec also indicates an error "command failed".

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 May 2025 01:11 UTC](https://discourse.nodered.org/t/ubuntu-application-monitoring/95545/3 "2025-05-22T01:11:18Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
