# Advice needed on Pi CPU usage

**URL:** <https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279>\
**Category:** General\
**Created:** [27 March 2021 12:13 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279 "2021-03-27T12:13:16Z")\
**Posts on this page:** 15\
**Page:** 8

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2021 21:50 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/142 "2021-04-12T21:50:39Z")

</div>

> [@TotallyInformation](#):
>
> > [@Steve-Mcl](#):
> >
> > Node-red-node-ping any day of the week.
> 
> Nope, Telegraf every day of the week (actually every 5 or 15 min

Sure. But within the context of node-red, Node-red-node-ping 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 April 2021 22:00 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/143 "2021-04-12T22:00:43Z")

</div>

Just because you can, doesn't always mean you should 🤣

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 14:53 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/144 "2021-04-13T14:53:50Z")

</div>

Hey Steve...

> [@Steve-Mcl](#):
>
> Node-red-node-ping any day of the week.

Strangely, this is what I am using.... As to why Balena is involved, I have no idea.... Any hints?

> [@Steve-Mcl](#):
>
> Cron-plus

Is this a "native" node red node? ... I take it that its not, as it says "contrib" in the naming... Is there a NR "internal" node of similarity?

Ed

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2021 14:57 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/145 "2021-04-13T14:57:22Z")

</div>

> [@eddee54455](#):
>
> As to why Balena is involved, I have no idea.... Any hints?

I have no idea.

> [@eddee54455](#):
>
> Is this a "native" node red node?

Contrib

> [@eddee54455](#):
>
> Is there a NR "internal" node of similarity?

Kinda, the "inject node", but cron-plus much more flexible & has many more features and is 100% programmable / flexible. I suggested it as you had 3 different "scheduling nodes to achieve your requirements" - cron-plus can do most of what they all do.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 15:02 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/146 "2021-04-13T15:02:08Z")

</div>

Indeed it can... It is EXTREMELY powerful.... but as the superheroes say, with great power comes great... Knowledge to set it up and use it correctly... I will give it a go again, but I ran around in little square circles last time trying to wrap my head around how to use it properly... Was a little "beyond me" at the time... hence the 3x "easier to set up" nodes I used for different tasks....

E

Edit: AdHD....Highway to...Oh look, a squirrel... I must focus on trying to find a way to do a simple online check(To replace the troublesome "isonline" node), ping a unit, if it doesn't come back within a user-definable time(different for the units involved as close units respond quickly on the wifi, some of the others can take up to 500ms as they are relayed through multiple AP/repeaters), raise an alert and then send via Telegram if it is too far out of spec.... Possibly a subflow as there are quite a few to keep an eye on...Any hints?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2021 15:05 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/147 "2021-04-13T15:05:17Z")

</div>

there are lots of built in helpers (like the cron examples in the dropdown, a cron builder, map picker for solar events location etc etc) and built in demos (CTRL+I)

the built in help is also quite extensive.

and you can always as "how do I" in the forum 🙂

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 15:14 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/148 "2021-04-13T15:14:28Z")

</div>

Oops, you were replying as I was editing the previous post... I must really avoid hitting "send" before I am finished ....

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2021 15:18 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/149 "2021-04-13T15:18:35Z")

</div>

> [@eddee54455](#):
>
> ping a unit, if it doesn't come back within a user-definable time(different for the units involved as close units respond quickly on the wifi, some of the others can take up to 500ms as they are relayed through multiple AP/repeaters), raise an alert and then send via Telegram if it is too far out of spec

This will get you started: [Ping Network Devices From a List - #12 by Steve-Mcl](https://discourse.nodered.org/t/ping-network-devices-from-a-list/43563/12)

you could break it up so that 5sec after issuing ping, check the results in context & send a telegram accordingly.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 15:23 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/150 "2021-04-13T15:23:50Z")

</div>

Thank you!!

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 15:57 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/151 "2021-04-13T15:57:37Z")

</div>

Hi Steve,

Query:

In the example (Which is Sterling if I might add), is there any way to set a global timeout value in the inject payload as opposed to setting each timeout individually?

Regds  
Ed

Edit: Spotted the timeout value, found a workaround using it ... then discovered something interesting.... The lowest it can be set to is 1000ms....

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 April 2021 16:36 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/152 "2021-04-13T16:36:39Z")

</div>

> [@eddee54455](#):
>
> is there any way to set a global timeout value in the inject payload as opposed to setting each timeout individually

> [@eddee54455](#):
>
> Edit: Spotted the timeout value, found a workaround using it ... then discovered something interesting.... The lowest it can be set to is 1000ms

not entirely certain what yo mean here. If you mean can an inject be set less than 1s then yes, it can...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52bd2b272d8ed23ece5ee568ad5813161d4e4275.png)

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 17:17 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/153 "2021-04-13T17:17:01Z")

</div>

Thanks for coming back to me Steve,

But no, the timeout as in:

```auto
Timeout = msg.timeout;
msg.payload = [
    {
        "name": "USFridge",
        "host": "192.168.0.139",
        "timeout": Timeout
    },
    {
        "name": "Fridge",
        "host": "192.168.0.145",
        "timeout": Timeout
    },
    {
        "name": "FFridge",
        "host": "192.168.0.146",
        "timeout": Timeout
    },
    {
        "name": "DFreeze",
        "host": "192.168.0.155",
        "timeout": Timeout
    },
    {
        "name": "EGEle",
        "host": "192.168.0.156",
        "timeout": Timeout
    },
    {
        "name": "EGMain",
        "host": "192.168.0.161",
        "timeout": Timeout
    }
]
return msg;

```

I presume that this timeout value denotes the fail boundary... It cannot be set to less than 1000ms though...

Regds  
Ed

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 April 2021 17:17 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/154 "2021-04-13T17:17:03Z")

</div>

> [@eddee54455](#):
>
> As to why Balena is involved, I have no idea

Actually, I think this is a shortcoming of the flow inspector that it can only guess what node module a node belongs to where there are nodes of the same name from different modules. That's why I keep a small flow around that actually analyses both my flow file and my package.json:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/991e27a5c2e96da400b5413119e991f363d6b4fb.png)

```auto
[{"id":"51fb56d2.8ca248","type":"inject","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":95,"y":1140,"wires":[["1dd9f4ac.8347eb","b0df5fa0.7698b"]],"l":false},{"id":"2d29205.cb6abe","type":"comment","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"How Many Nodes in my flow?","info":"Don't forget to change the path to your flow file.\n\nNote the oddity regarding subflows. \nThey appear firstly as type \"subflow\" which is the\ndefinition, then again in the form\n\"subflow:<id>\" once for each instance of that\nsubflow `<id>` in your flows.\n\nI show both a JSONata and a function node\napproach to getting the data but note that\nthe JSONata version _is not quite correct_.\nIn the sense that it doesn't subtract the tabs\nand subflows from the overal counts.\n\nSo while the execution time of both approaches\nseems to be pretty identical, the function node\nis more comprehensive.","x":200,"y":1100,"wires":[]},{"id":"1dd9f4ac.8347eb","type":"file in","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","filename":"./data/nrmain_flows.json","format":"utf8","chunk":false,"sendError":false,"x":270,"y":1140,"wires":[["7db3c4dc.803e6c"]]},{"id":"b0df5fa0.7698b","type":"file in","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","filename":"./data/package.json","format":"utf8","chunk":false,"sendError":false,"x":250,"y":1260,"wires":[["b4c067a0.285bd8"]]},{"id":"b4c067a0.285bd8","type":"json","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","property":"payload","action":"","pretty":false,"x":435,"y":1260,"wires":[["dff7c57.77c4138"]],"l":false},{"id":"7db3c4dc.803e6c","type":"json","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","property":"payload","action":"","pretty":false,"x":435,"y":1140,"wires":[["3aeb5629.c2b33a","9c8f63ea.e8083"]],"l":false},{"id":"3aeb5629.c2b33a","type":"change","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","rules":[{"t":"set","p":"totalNodes","pt":"msg","to":"$count(payload)\t","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"payload^(type) {\t `type`: $count([$])\t}","tot":"jsonata"},{"t":"set","p":"nodeTypesCount","pt":"msg","to":"$count($keys(payload))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":515,"y":1140,"wires":[["5de6fbf7.a75344"]],"l":false},{"id":"9c8f63ea.e8083","type":"function","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"","func":"msg.totalNodes = msg.payload.length\n\nlet tabsCount = 0, subflowsCount = 0, nodeTypesCount = 0\nlet totalNodes = 0\nlet tabs = {}, subflows = {}, nodeTypes = {}\n\nmsg.payload.sort(function(a, b) {\n var typeA = a.type.toUpperCase(); // ignore upper and lowercase\n var typeB = b.type.toUpperCase(); // ignore upper and lowercase\n if (typeA < typeB) {\n return -1;\n }\n if (typeA > typeB) {\n return 1;\n }\n\n // names must be equal\n return 0;\n})\n\nmsg.payload.forEach((el) => {\n if ( el.type === 'tab' ) {\n tabsCount++\n tabs[el.label] = el.id\n } else if ( el.type === 'subflow' ) {\n subflowsCount++\n subflows[el.name] = el.id\n } else {\n nodeTypes[el.type] = nodeTypes[el.type]+1 || 1\n totalNodes++\n }\n})\n\nmsg.payload = {\n 'totalNodesCount': totalNodes,\n 'tabsCount': tabsCount,\n 'subflowsCount': subflowsCount,\n 'nodeTypesCount': Object.keys(nodeTypes).length,\n 'tabs': tabs,\n 'subflows': subflows,\n 'nodeTypes': nodeTypes,\n}\n\nreturn msg","outputs":1,"noerr":0,"x":515,"y":1200,"wires":[["97a2dead.fea94"]],"l":false},{"id":"5de6fbf7.a75344","type":"debug","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"All Nodes (incl. Config.)","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"\"Nodes: \" & totalNodes & \", Types: \" & nodeTypesCount","statusType":"jsonata","x":690,"y":1140,"wires":[]},{"id":"97a2dead.fea94","type":"debug","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"Nodes, Tabs, Subflows","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"\"N: \" & payload.totalNodesCount & \", Tabs: \" & payload.tabsCount & \", Subflows: \" & payload.subflowsCount","statusType":"jsonata","x":680,"y":1200,"wires":[]},{"id":"dff7c57.77c4138","type":"debug","z":"d0860be6.7951b8","g":"68054db5.4e78b4","name":"Package Dependencies","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload.dependencies","targetType":"msg","statusVal":"\"#: \" & $count($keys(payload.dependencies))","statusType":"jsonata","x":690,"y":1260,"wires":[]}]

```

It tells me all of the node packages I've got installed and analyses all of the nodes.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c7aabb977f5bb82fbc893c1bece73f4c2f5d89cd.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/2/52fcb46200049d9177a52d9a4ecec2fe6cfc2d62.png)

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [13 April 2021 19:16 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/155 "2021-04-13T19:16:14Z")

</div>

> [@TotallyInformation](#):
>
> That's why I keep a small flow around that actually analyses both my flow file and my package.json

Ooooh.... Flashy light toy things... I like it!

Thanx!!

---

<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:** [27 April 2021 19:16 UTC](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279/156 "2021-04-27T19:16:24Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/advice-needed-on-pi-cpu-usage/43279.md?page=7)
