UNPKG

node-red-contrib-cpu

Version:
105 lines (102 loc) 5.5 kB
<!-- Copyright 2017, Bart Butenaers Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <script type="text/javascript"> RED.nodes.registerType('cpu',{ category: 'performance', color: '#a6bbcf', defaults: { name: {value:""}, msgCore: {value:true}, msgOverall: {value:false}, msgArray: {value:false}, msgTemp: {value:false} }, inputs:1, outputs:1, icon: "cpu.png", label: function() { return this.name||"CPU usage"; }, oneditprepare: function() { if (this.msgCore === undefined) { // Select the msgCore checkbox by default, for existing nodes that don't have that field yet. $('#node-input-msgCore').prop('checked',true); } } }); </script> <script type="text/x-red" data-template-name="cpu"> <div class="form-row"> <input type="checkbox" id="node-input-msgOverall" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-msgOverall" style="width:70%;"> Send a message for overall usage</label> </div> <div class="form-row"> <input type="checkbox" id="node-input-msgCore" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-msgCore" style="width:70%;"> Send a separate message for each core usage</label> </div> <div class="form-row"> <input type="checkbox" id="node-input-msgArray" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-msgArray" style="width:70%;"> Send a single message with array of core usages</label> </div> <div class="form-row"> <input type="checkbox" id="node-input-msgTemp" style="display: inline-block; width: auto; vertical-align: top;"> <label for="node-input-msgTemp" style="width:70%;"> Send a single message with core temperature(s)</label> </div> <br> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="cpu"> <p>A node to monitor CPU usage.</p> <p>The CPU usage will be calculated for each core individually. Such a CPU core usage is in fact the average usage since the previous calculation. Therefore the value will become more accurate when it is calculated more frequently (e.g. when a trigger message is put on the input port every second)!</p> <p><strong>Send a message for overall usage:</strong><br/> When this option is selected, a single output message will be send containing the aggregated usage of all cores together: <ul> <li><code>payload</code> is the overall usage percentage (<i>sum of usage of all cores / number of cores</i>)</li> <li><code>speed</code> is processor speed (in MHz)</li> <li><code>topic</code> is a fixed text (<i>overall</i>)</li> <li><code>model</code> is the CPU model</li> </ul></p> <p><strong>Send a separate message for each core usage:</strong><br/> When this option is selected, an output message will be send for each core separately: <ul> <li><code>payload</code> is the core usage (as a percentage)</li> <li><code>speed</code> is processor speed (in MHz)</li> <li><code>topic</code> is the name of the (logical) CPU core (<i>core_xxx</i>)</li> <li><code>model</code> is the CPU model</li> </ul></p> <p><strong>Send a single message with array of core usages:</strong><br/> When this option is selected, a single output message will be send containing an array of all core usages: <ul> <li><code>payload</code> is the array with information of all cores:</li> <ul> <li><code>name</code> is the name of the (logical) CPU core (<i>core_xxx</i>)</li> <li><code>usage</code> is the core usage (as a percentage)</li> <li><code>model</code> is the CPU model</li> <li><code>speed</code> is processor speed (in MHz)</li> </ul> <li><code>topic</code> is a fixed text (<i>all_cores</i>)</li> </ul></p> <p><strong>Send a single message with core temperature(s):</strong><br/> When this option is selected, a single output message will be send containing the core temperature(s) in °C: <ul> <li><code>payload</code> is the main (average) temperature</li> <li><code>max</code> is the maximum temperature</li> <li><code>cores</code> is an array of the temperatures of all cores</li> <li><code>topic</code> is a fixed text (<i>temperature</i>)</li> </ul> CAUTION: the temperature information is not available on some systems! </p> </script>