UNPKG

node-red-contrib-self-healing

Version:
124 lines (118 loc) 3.84 kB
<!-- main node definition --> <script type="text/javascript"> RED.nodes.registerType("heartbeat", { //node definition category: "SHEN", color: "#74b9ff", defaults: { frequency: { value: 30, required: true, validate: RED.validators.number(), }, protocol: { required: true }, onfail: { required: true, value: false }, delay: { value: 5, required: false, validate: RED.validators.number(), }, }, inputs: 1, outputs: 3, outputLabels: ["ping (active mode)", "ok (if enabled)", "timeout"], icon: "status.png", label: function () { return this.name || "heartbeat"; }, }); function showDelay() { let chosenProtocol = document.getElementById("node-input-protocol").value; let divActive = document.getElementById("activeinput"); if (chosenProtocol == "passive") { divActive.style.visibility = "hidden"; } else if (chosenProtocol == "active") { divActive.style.visibility = "visible"; } } </script> <!-- edit template --> <script type="text/html" data-template-name="heartbeat"> <div class="form-row"> <label for="node-input-frequency"> <i class="icon-tag"></i>Frequency (s) </label> <input type="text" id="node-input-frequency" placeholder="30" /> </div> <div class="form-row"> <label for="node-input-protocol"> <i class="fa fa-tag"></i> Heartbeat Protocol </label> <select type="text" id="node-input-protocol" onChange="showDelay()"> <option>passive</option> <option>active</option> </select> </div> <div class="form-row"> <label for="node-input-onfail"> <i class="icon-tag"></i>Only send msg on fail </label> <input type="checkbox" id="node-input-onfail" /> </div> <div id="activeinput" style="visibility: hidden"> <div class="form-row"> <label for="node-input-delay"> <i class="icon-tag"></i>Delay (s) </label> <input type="text" id="node-input-delay" placeholder="5" /> </div> </div> </script> <!-- help text --> <script type="text/html" data-help-name="heartbeat"> <p> A node that provides a heartbeat probe for the HTTP and MQTT communication protocols. </p> <h3>Properties</h3> <dl class="message-properties"> <dt>frequency</dt> <dd>time interval for the heartbeats, in seconds</dd> <dt>protocol</dt> <dd> heartbeat protocol, either active or passive. This property defines the way the node will check for a live connection. If active is chosen, this node will check for a connection, within the frequency chosen, to be established at max in a certain delay (in seconds), which must be specified. If passive is chosen, this node will check for a connection to be established within the frequency chosen </dd> <dt>onfail</dt> <dd>if checked, only sends a message if an error occurs</dd> <dt>delay</dt> <dd>used for "active" protocols</dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p> Depending on the protocol to be tested, a "HTTP in" or "MQTT in" node must be provided. </p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p> First output is used for sending a message into "MQTT out"/"HTTP request" nodes in "active" verifications. </p> <p> Error message when an error occured (third output), or a success message (second output), if the user did not select the "Only send msg on fail" checkbox. </p> </dl> <h3>Details</h3> <p> "Alive" if the heartbeat node receives back the message sent to either a "HTTP request" (in case of the HTTP protocol) or "MQTT out" (MQTT protocol) node, which means a connection was established successfully. </p> </script>