Last active
May 29, 2017 21:56
-
-
Save peko/9ea1fabbfe810a02d74eed86b65223b8 to your computer and use it in GitHub Desktop.
node red balancer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "801152e3.b71c6", | |
| "type": "subflow", | |
| "name": "To telegram", | |
| "info": "", | |
| "in": [ | |
| { | |
| "x": 40, | |
| "y": 40, | |
| "wires": [ | |
| { | |
| "id": "8200e1e4.c30d2" | |
| } | |
| ] | |
| } | |
| ], | |
| "out": [] | |
| }, | |
| { | |
| "id": "8200e1e4.c30d2", | |
| "type": "function", | |
| "z": "801152e3.b71c6", | |
| "name": "to telegram", | |
| "func": "var d = msg.payload;\nvar p = msg.payload = {};\np.chatId = 56010024;\np.type = 'message';\np.content = d;\nreturn {payload:p};", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 190, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "c01bd95f.9b7e28" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "c01bd95f.9b7e28", | |
| "type": "telegram sender", | |
| "z": "801152e3.b71c6", | |
| "name": "", | |
| "bot": "4b8a768a.2192c8", | |
| "x": 390, | |
| "y": 40, | |
| "wires": [ | |
| [] | |
| ] | |
| }, | |
| { | |
| "id": "4b8a768a.2192c8", | |
| "type": "telegram bot", | |
| "z": "", | |
| "botname": "notify bot", | |
| "usernames": "[]", | |
| "chatids": "[]" | |
| }, | |
| { | |
| "id": "9aee49d5.53d368", | |
| "type": "tab", | |
| "label": "Aitarget balancer" | |
| }, | |
| { | |
| "id": "e135f68c.f7d9d8", | |
| "type": "http request", | |
| "z": "9aee49d5.53d368", | |
| "name": "check queue", | |
| "method": "GET", | |
| "ret": "obj", | |
| "url": "http://aitarget.ddns.net:4444/api/stats", | |
| "tls": "", | |
| "x": 320, | |
| "y": 160, | |
| "wires": [ | |
| [ | |
| "b64976c5.8d21a8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7ed3ffee.05685", | |
| "type": "inject", | |
| "z": "9aee49d5.53d368", | |
| "name": "every min", | |
| "topic": "", | |
| "payload": "", | |
| "payloadType": "date", | |
| "repeat": "60", | |
| "crontab": "", | |
| "once": false, | |
| "x": 150, | |
| "y": 160, | |
| "wires": [ | |
| [ | |
| "e135f68c.f7d9d8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8d38fa15.317428", | |
| "type": "debug", | |
| "z": "9aee49d5.53d368", | |
| "name": "", | |
| "active": true, | |
| "console": "false", | |
| "complete": "payload", | |
| "x": 500, | |
| "y": 40, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "b64976c5.8d21a8", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "waiting tasks", | |
| "property": "payload.inactiveCount", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "0", | |
| "vt": "num" | |
| }, | |
| { | |
| "t": "gt", | |
| "v": "0", | |
| "vt": "num" | |
| }, | |
| { | |
| "t": "gte", | |
| "v": "5", | |
| "vt": "num" | |
| } | |
| ], | |
| "checkall": "true", | |
| "outputs": 3, | |
| "x": 500, | |
| "y": 160, | |
| "wires": [ | |
| [ | |
| "1707f42c.cab18c" | |
| ], | |
| [ | |
| "a655067c.959c98" | |
| ], | |
| [ | |
| "23aed7e7.4564c8", | |
| "a655067c.959c98" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "b2c23d7b.573b9", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "log", | |
| "links": [ | |
| "2aa6fe32.5ee192", | |
| "fd0a4e11.dcd6f" | |
| ], | |
| "x": 395, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "8d38fa15.317428" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "60feb9a2.183688", | |
| "type": "catch", | |
| "z": "9aee49d5.53d368", | |
| "name": "", | |
| "scope": null, | |
| "x": 100, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "8f14e761.dec638" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "733628f8.38ad68", | |
| "type": "http request", | |
| "z": "9aee49d5.53d368", | |
| "name": "check queue", | |
| "method": "GET", | |
| "ret": "obj", | |
| "url": "http://aitarget.ddns.net:4444/api/stats", | |
| "tls": "", | |
| "x": 720, | |
| "y": 300, | |
| "wires": [ | |
| [ | |
| "25c76346.5f098c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "8edd4736.8a9a08", | |
| "type": "function", | |
| "z": "9aee49d5.53d368", | |
| "name": "format", | |
| "func": "var d = msg.payload;\n\nserver_info = function(r) {\n return [\n r.Instances[0].Tags[0].Value,\n \"status: \" + r.Instances[0].State.Name,\n \"ip: \" + r.Instances[0].PublicIpAddress\n ].join(\"\\n\");\n};\n\nvar p;\nif(d.Reservations) {\n p = server_info(d.Reservations[0]); \n} else {\n p = \n \"complete: \" + d.completeCount+\"\\n\"+\n \"active: \" + d.activeCount +\"\\n\"+\n \"waiting: \" + d.inactiveCount;\n}\n\nreturn {payload: p};", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "x": 900, | |
| "y": 340, | |
| "wires": [ | |
| [ | |
| "c89bc3b7.b1ac5" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "ac996d1f.516c1", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "/cmd", | |
| "property": "payload.content", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "/aws", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "eq", | |
| "v": "/start-worker", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "eq", | |
| "v": "/stop-worker", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "eq", | |
| "v": "/kue", | |
| "vt": "str" | |
| } | |
| ], | |
| "checkall": "true", | |
| "outputs": 4, | |
| "x": 490, | |
| "y": 360, | |
| "wires": [ | |
| [ | |
| "577a1b85.f2f894", | |
| "f23bd491.8ad8b8" | |
| ], | |
| [ | |
| "8cac5362.ec05a" | |
| ], | |
| [ | |
| "b21377d0.137728" | |
| ], | |
| [ | |
| "733628f8.38ad68" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "577a1b85.f2f894", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "describe", | |
| "region": "us-east-1", | |
| "instanceid": "i-0d9fa86a035964129", | |
| "name": "check server", | |
| "x": 720, | |
| "y": 340, | |
| "wires": [ | |
| [ | |
| "8edd4736.8a9a08" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f23bd491.8ad8b8", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "describe", | |
| "region": "us-east-1", | |
| "instanceid": "i-0ba014b322e050441", | |
| "name": "check worker", | |
| "x": 720, | |
| "y": 380, | |
| "wires": [ | |
| [ | |
| "8edd4736.8a9a08" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "e0537577.d5f5a8", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "to telegram", | |
| "links": [ | |
| "c89bc3b7.b1ac5", | |
| "fa14168b.7dda68", | |
| "f17f0b85.74e2a8", | |
| "2aa6fe32.5ee192", | |
| "f732e6a6.5c5768", | |
| "a3c44571.94ef98" | |
| ], | |
| "x": 935, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "c45ebe4f.f42c7" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "c89bc3b7.b1ac5", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity by command", | |
| "links": [ | |
| "e0537577.d5f5a8" | |
| ], | |
| "x": 995, | |
| "y": 340, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "a655067c.959c98", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity on timer", | |
| "links": [ | |
| "8084da7f.992b88" | |
| ], | |
| "x": 775, | |
| "y": 160, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "8cac5362.ec05a", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "start", | |
| "region": "us-east-1", | |
| "instanceid": "i-0ba014b322e050441", | |
| "name": "start worker", | |
| "x": 720, | |
| "y": 440, | |
| "wires": [ | |
| [ | |
| "25f33383.3f8d5c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "25f33383.3f8d5c", | |
| "type": "delay", | |
| "z": "9aee49d5.53d368", | |
| "name": "", | |
| "pauseType": "delay", | |
| "timeout": "1", | |
| "timeoutUnits": "minutes", | |
| "rate": "1", | |
| "nbRateUnits": "1", | |
| "rateUnits": "second", | |
| "randomFirst": "1", | |
| "randomLast": "5", | |
| "randomUnits": "seconds", | |
| "drop": false, | |
| "x": 910, | |
| "y": 440, | |
| "wires": [ | |
| [ | |
| "ef8e00b1.1d156" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "33e2532d.14d37c", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "check worker", | |
| "links": [ | |
| "ef8e00b1.1d156" | |
| ], | |
| "x": 515, | |
| "y": 420, | |
| "wires": [ | |
| [ | |
| "f23bd491.8ad8b8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "ef8e00b1.1d156", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "start worker", | |
| "links": [ | |
| "33e2532d.14d37c" | |
| ], | |
| "x": 1015, | |
| "y": 440, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "b21377d0.137728", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "stop", | |
| "region": "us-east-1", | |
| "instanceid": "i-0ba014b322e050441", | |
| "name": "stop worker", | |
| "x": 710, | |
| "y": 480, | |
| "wires": [ | |
| [ | |
| "25f33383.3f8d5c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "7a3a580.7eb48a8", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "check user", | |
| "property": "payload.chatId", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "56010024", | |
| "vt": "num" | |
| } | |
| ], | |
| "checkall": "true", | |
| "outputs": 1, | |
| "x": 350, | |
| "y": 360, | |
| "wires": [ | |
| [ | |
| "ac996d1f.516c1" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "9f89056b.838c98", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "describe", | |
| "region": "us-east-1", | |
| "instanceid": "i-0ba014b322e050441", | |
| "name": "check worker", | |
| "x": 320, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "cbd81010.d6e5f" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "cbd81010.d6e5f", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "Stoped?", | |
| "property": "payload.Reservations[0].Instances[0].State.Name", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "stopped", | |
| "vt": "str" | |
| } | |
| ], | |
| "checkall": "true", | |
| "outputs": 1, | |
| "x": 480, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "8cac5362.ec05a", | |
| "38db5486.894f9c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "1707f42c.cab18c", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "active", | |
| "property": "payload.activeCount", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "0", | |
| "vt": "num" | |
| }, | |
| { | |
| "t": "gt", | |
| "v": "0", | |
| "vt": "str" | |
| } | |
| ], | |
| "checkall": "false", | |
| "outputs": 2, | |
| "x": 670, | |
| "y": 120, | |
| "wires": [ | |
| [ | |
| "a8f4b191.9b736" | |
| ], | |
| [ | |
| "a655067c.959c98" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "f9efe2dd.abe9e", | |
| "type": "amazon ec2", | |
| "z": "9aee49d5.53d368", | |
| "aws": "699c77c0.1bdd08", | |
| "operation": "describe", | |
| "region": "us-east-1", | |
| "instanceid": "i-0ba014b322e050441", | |
| "name": "check worker", | |
| "x": 320, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "5eb52502.8dae1c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5eb52502.8dae1c", | |
| "type": "switch", | |
| "z": "9aee49d5.53d368", | |
| "name": "Not stoped?", | |
| "property": "payload.Reservations[0].Instances[0].State.Name", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "neq", | |
| "v": "stopped", | |
| "vt": "str" | |
| } | |
| ], | |
| "checkall": "true", | |
| "outputs": 1, | |
| "x": 500, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "b21377d0.137728", | |
| "6312c4a1.f0605c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "23aed7e7.4564c8", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "high load", | |
| "links": [ | |
| "8b00410d.ba085" | |
| ], | |
| "x": 775, | |
| "y": 200, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "8b00410d.ba085", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "start worker", | |
| "links": [ | |
| "23aed7e7.4564c8" | |
| ], | |
| "x": 195, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "9f89056b.838c98" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "fed24d2a.55ccf", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "stop worker", | |
| "links": [ | |
| "a8f4b191.9b736" | |
| ], | |
| "x": 195, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "f9efe2dd.abe9e" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "a8f4b191.9b736", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "no load", | |
| "links": [ | |
| "fed24d2a.55ccf" | |
| ], | |
| "x": 775, | |
| "y": 120, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "171b74fd.a235fb", | |
| "type": "comment", | |
| "z": "9aee49d5.53d368", | |
| "name": "High load", | |
| "info": "", | |
| "x": 860, | |
| "y": 200, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "1a1b1128.83487f", | |
| "type": "comment", | |
| "z": "9aee49d5.53d368", | |
| "name": "No load", | |
| "info": "", | |
| "x": 860, | |
| "y": 120, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "78985278.e645cc", | |
| "type": "telegram receiver", | |
| "z": "9aee49d5.53d368", | |
| "name": "msg", | |
| "bot": "4b8a768a.2192c8", | |
| "saveDataDir": "/tmp", | |
| "x": 210, | |
| "y": 360, | |
| "wires": [ | |
| [ | |
| "7a3a580.7eb48a8" | |
| ], | |
| [ | |
| "7a3a580.7eb48a8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "38db5486.894f9c", | |
| "type": "template", | |
| "z": "9aee49d5.53d368", | |
| "name": "START", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "High load comming!\nStarting huge worker!", | |
| "x": 690, | |
| "y": 540, | |
| "wires": [ | |
| [ | |
| "fa14168b.7dda68" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "6312c4a1.f0605c", | |
| "type": "template", | |
| "z": "9aee49d5.53d368", | |
| "name": "STOP", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "No load, stopping server!", | |
| "x": 690, | |
| "y": 580, | |
| "wires": [ | |
| [ | |
| "fa14168b.7dda68" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "fa14168b.7dda68", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity by command", | |
| "links": [ | |
| "e0537577.d5f5a8" | |
| ], | |
| "x": 795, | |
| "y": 560, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "8f14e761.dec638", | |
| "type": "template", | |
| "z": "9aee49d5.53d368", | |
| "name": "error", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "ERROR\n{{error.message}}", | |
| "x": 230, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "2aa6fe32.5ee192" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "2aa6fe32.5ee192", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity on timer", | |
| "links": [ | |
| "b2c23d7b.573b9", | |
| "e0537577.d5f5a8" | |
| ], | |
| "x": 315, | |
| "y": 40, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "c45ebe4f.f42c7", | |
| "type": "subflow:801152e3.b71c6", | |
| "z": "9aee49d5.53d368", | |
| "name": "", | |
| "x": 1050, | |
| "y": 40, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "65616243.bd751c", | |
| "type": "template", | |
| "z": "9aee49d5.53d368", | |
| "name": "format", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "complete: {{payload.completeCount}}\nactive: {{payload.activeCount}}\nwaiting: {{payload.inactiveCount}}", | |
| "x": 760, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "a3c44571.94ef98" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "a3c44571.94ef98", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity on timer", | |
| "links": [ | |
| "e0537577.d5f5a8" | |
| ], | |
| "x": 855, | |
| "y": 40, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "8084da7f.992b88", | |
| "type": "link in", | |
| "z": "9aee49d5.53d368", | |
| "name": "send kue status", | |
| "links": [ | |
| "a655067c.959c98", | |
| "25c76346.5f098c" | |
| ], | |
| "x": 655, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "65616243.bd751c" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "25c76346.5f098c", | |
| "type": "link out", | |
| "z": "9aee49d5.53d368", | |
| "name": "activity on timer", | |
| "links": [ | |
| "8084da7f.992b88" | |
| ], | |
| "x": 855, | |
| "y": 300, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "bed77f14.b752d", | |
| "type": "comment", | |
| "z": "9aee49d5.53d368", | |
| "name": "Notify", | |
| "info": "", | |
| "x": 850, | |
| "y": 160, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "699c77c0.1bdd08", | |
| "type": "aws-config", | |
| "z": "", | |
| "name": "AWS new", | |
| "region": "us-east-1" | |
| }, | |
| { | |
| "id": "4b8a768a.2192c8", | |
| "type": "telegram bot", | |
| "z": "", | |
| "botname": "notify bot", | |
| "usernames": "[]", | |
| "chatids": "[]" | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment