Grautier.com - Projekte

Geht nicht gibt es nicht !!!

Benutzer-Werkzeuge

Webseiten-Werkzeuge


faqs:router:freifunknodered

Freifunk Status mit NodeRED auslesen

Beschreibung

Ich betreibe eine kleine Freifunk-Node mit der Freifunk-HH Firmware diese hat eine Übersichtsseite da ich da nicht immer extra drauf möchte hab ich mal geschaut wie man das ganze in Node-Red einbinden kann.

Anleitung

Als erstes brauchen wir Zugriff auf die Statusseite dieses geht wie es voreingestellt ist nur über die Öffentliche IPv6 Adresse, ich möchte dieses aber über das Heimische LAN abfragen dazu muss man die Statusseite auf den WAN Port legen dieses geht recht einfach in dem wir die Firewall regeln etwas anpassen.

In der /etc/config/firewall fügen wir die folgende Regel für die Firewall ein:

config rule 'wan_http'
        option dest_port '80'
        option src 'wan'
        option name 'wan_http'
        option target 'ACCEPT'
        option proto 'tcp'

Danach starten wir die Firewall noch mit dem Folgenden Befehl neu:

/etc/init.d/firewall restart

Jetzt sollte die Statusseite über die Lokale IPv4 Adresse der Node erreichbar sein, jetzt müssen wir noch auf dem Router ein passendes Script erstellen welches die Daten bereitstellt dieses ist leider nötig weil die JSON Daten die für die Statusseite nicht JSON Konform sind und in einer Endlosschleife abgefragt werden.

In /lib/gluon/status-page/www/cgi-bin/dyn/ erstellen wir die Datei nodered und fügen folgenden Inhalt ein.

nodered
#!/bin/sh
 
CMD='gluon-neighbour-info -s "" -d ::1 -p 1001 -t 3 -r statistics | sed "s/event: eot//g" | /bin/sed "s/data: null//g" | /bin/sed "s/data: //g"'
exec /usr/sbin/sse-multiplex "$CMD"
 
exit 0

Dieses script ist über <Locale IPv4>/cgi-bin/dyn/nodered erreichbar und gibt ein für Node-Red verarbeitbares JSON aus.

Für Node-Red hab ich einen kleinen Flow gebastelt den ihr einfach importieren könnt bei diesem fehlen aber die Mesh Daten da ich noch keinen zweiten Router habe.

flow
[
    {
        "id": "be6e7638.7b89e8",
        "type": "tab",
        "label": "Freifunk",
        "disabled": false,
        "info": ""
    },
    {
        "id": "f7f19273.502da",
        "type": "json",
        "z": "be6e7638.7b89e8",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": true,
        "x": 430,
        "y": 100,
        "wires": [
            [
                "433774e8.fd969c",
                "c36ebbe6.65c058",
                "3ac3232e.4a5c8c",
                "ec42889.93b2878",
                "15bd2941.f51e77",
                "b5304fa3.f8bd6",
                "a62decc3.265cb",
                "ed63d0d3.fc975",
                "2a281ada.b027c6",
                "aebf75db.56d418",
                "e87a6bb8.401998",
                "185c948e.0505ab",
                "8bbd04cd.09b9f8",
                "863c3043.7d64f",
                "15c9bc48.620514",
                "28c6fb77.3db614",
                "bbe9a0aa.cc15a"
            ]
        ]
    },
    {
        "id": "433774e8.fd969c",
        "type": "debug",
        "z": "be6e7638.7b89e8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 350,
        "y": 160,
        "wires": []
    },
    {
        "id": "60cca275.de7cdc",
        "type": "http request",
        "z": "be6e7638.7b89e8",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": false,
        "url": "http://192.168.0.50/cgi-bin/dyn/nodered",
        "tls": "",
        "proxy": "",
        "authType": "basic",
        "x": 230,
        "y": 100,
        "wires": [
            [
                "f7f19273.502da"
            ]
        ]
    },
    {
        "id": "fa8c6b36.820448",
        "type": "comment",
        "z": "be6e7638.7b89e8",
        "name": "5_MIN_TIMER",
        "info": "",
        "x": 120,
        "y": 60,
        "wires": []
    },
    {
        "id": "a55bafeb.d81be",
        "type": "link in",
        "z": "be6e7638.7b89e8",
        "name": "5_MIN_TIMER",
        "links": [
            "dfee8134.a93fd",
            "f58cbba2.25b358"
        ],
        "x": 55,
        "y": 100,
        "wires": [
            [
                "60cca275.de7cdc"
            ]
        ]
    },
    {
        "id": "4085a0db.55982",
        "type": "inject",
        "z": "be6e7638.7b89e8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 120,
        "y": 160,
        "wires": [
            [
                "60cca275.de7cdc"
            ]
        ]
    },
    {
        "id": "c36ebbe6.65c058",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "Convert",
        "func": "var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.payload = msg.payload.clients.total;\nmsg1.topic = \"Total\";\n\nmsg2.payload = msg.payload.clients.wifi24;\nmsg2.topic = \"2.4Ghz\";\n\nmsg3.payload = msg.payload.clients.wifi5;\nmsg3.topic = \"5Ghz\";\n\nreturn [msg1, msg2, msg3];",
        "outputs": 3,
        "noerr": 0,
        "x": 600,
        "y": 100,
        "wires": [
            [
                "3227dfd7.79fad"
            ],
            [
                "3227dfd7.79fad"
            ],
            [
                "3227dfd7.79fad"
            ]
        ],
        "icon": "node-red/batch.png"
    },
    {
        "id": "3227dfd7.79fad",
        "type": "ui_chart",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "ae365d99.3c1e5",
        "order": 1,
        "width": "18",
        "height": "5",
        "label": "Clients",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 810,
        "y": 100,
        "wires": [
            []
        ]
    },
    {
        "id": "3ac3232e.4a5c8c",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "Convert",
        "func": "var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nvar msg4 = {};\nvar msg5 = {};\nvar msg6 = {};\nvar msg7 = {};\nvar msg8 = {};\nvar msg9 = {};\nvar msg10 = {};\nvar msg11 = {};\n\nmsg1.payload = msg.payload.traffic.rx.packets;\nmsg1.payload = (parseInt(msg1.payload))/1000;\nmsg1.topic = \"RX-kPakete\";\n\nmsg2.payload = msg.payload.traffic.rx.bytes;\nmsg2.payload = (parseInt(msg2.payload))/1000000;\nmsg2.topic = \"RX-MB\";\n\nmsg3.payload = msg.payload.traffic.tx.packets;\nmsg3.payload = (parseInt(msg3.payload))/1000;\nmsg3.topic = \"TX-kPakete\";\n\nmsg4.payload = msg.payload.traffic.tx.bytes;\nmsg4.payload = (parseInt(msg4.payload))/1000000;\nmsg4.topic = \"TX-MB\";\n\nmsg5.payload = msg.payload.traffic.tx.dropped;\nmsg5.topic = \"TX-Drop-Byte\";\n\nmsg6.payload = msg.payload.traffic.forward.bytes;\nmsg6.payload = (parseInt(msg6.payload))/1000000;\nmsg6.topic = \"FW-MB\";\n\nmsg7.payload = msg.payload.traffic.forward.packets;\nmsg7.payload = (parseInt(msg7.payload))/1000;\nmsg7.topic = \"FW-kPakete\";\n\nmsg8.payload = msg.payload.traffic.mgmt_rx.bytes;\nmsg8.payload = (parseInt(msg8.payload))/1000000;\nmsg8.topic = \"MGMT-RX-MB\";\n\nmsg9.payload = msg.payload.traffic.mgmt_rx.packets;\nmsg9.payload = (parseInt(msg9.payload))/1000;\nmsg9.topic = \"MGMT-RX-kPakete\";\n\nmsg10.payload = msg.payload.traffic.mgmt_tx.bytes;\nmsg10.payload = (parseInt(msg10.payload))/1000000;\nmsg10.topic = \"MGMT-TX-MB\";\n\nmsg11.payload = msg.payload.traffic.mgmt_tx.packets;\nmsg11.payload = (parseInt(msg11.payload))/1000;\nmsg11.topic = \"MGMT-TX-kPakete\";\n\nreturn [msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9, msg10, msg11];",
        "outputs": 11,
        "noerr": 0,
        "x": 600,
        "y": 220,
        "wires": [
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ],
            [
                "47f3b2e7.dd36ec"
            ]
        ],
        "icon": "node-red/batch.png"
    },
    {
        "id": "47f3b2e7.dd36ec",
        "type": "ui_chart",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "244e4c30.951924",
        "order": 1,
        "width": "18",
        "height": "5",
        "label": "Traffic",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 810,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "15bd2941.f51e77",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 1,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway",
        "format": "{{msg.payload.gateway}}",
        "layout": "row-spread",
        "x": 600,
        "y": 360,
        "wires": []
    },
    {
        "id": "b5304fa3.f8bd6",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 2,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Next Gateway",
        "format": "{{msg.payload.gateway_nexthop}}",
        "layout": "row-spread",
        "x": 620,
        "y": 400,
        "wires": []
    },
    {
        "id": "ad1ebb39.b6bc68",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 3,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 01",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 440,
        "wires": []
    },
    {
        "id": "7eba7b37.04bea4",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 8,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 06",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 640,
        "wires": []
    },
    {
        "id": "cbbb8f43.50bc4",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 7,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 05",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 600,
        "wires": []
    },
    {
        "id": "6aaba9bf.e96348",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 5,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 03",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 520,
        "wires": []
    },
    {
        "id": "9d19e478.760a38",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 4,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 02",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 480,
        "wires": []
    },
    {
        "id": "38ebd19f.7ae36e",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "617262ba.cd435c",
        "order": 6,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Gateway 04",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 830,
        "y": 560,
        "wires": []
    },
    {
        "id": "ec42889.93b2878",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway03.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 520,
        "wires": [
            [
                "6aaba9bf.e96348"
            ]
        ]
    },
    {
        "id": "e87a6bb8.401998",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway06.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 640,
        "wires": [
            [
                "7eba7b37.04bea4"
            ]
        ]
    },
    {
        "id": "aebf75db.56d418",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway05.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 600,
        "wires": [
            [
                "cbbb8f43.50bc4"
            ]
        ]
    },
    {
        "id": "2a281ada.b027c6",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway04.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 560,
        "wires": [
            [
                "38ebd19f.7ae36e"
            ]
        ]
    },
    {
        "id": "ed63d0d3.fc975",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway02.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 480,
        "wires": [
            [
                "9d19e478.760a38"
            ]
        ]
    },
    {
        "id": "a62decc3.265cb",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.mesh_vpn.groups.backbone.peers.gateway01.established;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 440,
        "wires": [
            [
                "ad1ebb39.b6bc68"
            ]
        ]
    },
    {
        "id": "abea7c39.47bcb",
        "type": "ui_gauge",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "68da99b3.710ef8",
        "order": 1,
        "width": "6",
        "height": "5",
        "gtype": "gage",
        "title": "CPU",
        "label": "%",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "60",
        "seg2": "80",
        "x": 810,
        "y": 720,
        "wires": []
    },
    {
        "id": "5746e059.0fb99",
        "type": "ui_gauge",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "68da99b3.710ef8",
        "order": 2,
        "width": "6",
        "height": "5",
        "gtype": "gage",
        "title": "Memory",
        "label": "%",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "60",
        "seg2": "80",
        "x": 820,
        "y": 760,
        "wires": []
    },
    {
        "id": "185c948e.0505ab",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "Convert",
        "func": "var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.payload = msg.payload.loadavg;\nmsg1.topic = \"Systemlast\";\n\nmsg2.payload = msg.payload.memory.total / 100 \nmsg2.payload = msg.payload.memory.available  / msg2.payload;\nmsg2.payload = 100 - msg2.payload\nmsg2.payload = msg2.payload.toFixed(2);\nmsg2.topic = \"Memory\";\n\nmsg3.payload = msg.payload.rootfs_usage*100;\nmsg3.payload = msg3.payload.toFixed(2);\nmsg3.topic = \"Dateisystem\";\n\nreturn [msg1, msg2, msg3];",
        "outputs": 3,
        "noerr": 0,
        "x": 600,
        "y": 760,
        "wires": [
            [
                "abea7c39.47bcb"
            ],
            [
                "5746e059.0fb99"
            ],
            [
                "6c42f72e.ce44a8"
            ]
        ],
        "icon": "node-red/batch.png"
    },
    {
        "id": "6c42f72e.ce44a8",
        "type": "ui_gauge",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "68da99b3.710ef8",
        "order": 3,
        "width": "6",
        "height": "5",
        "gtype": "gage",
        "title": "Dateisystem",
        "label": "%",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "60",
        "seg2": "80",
        "x": 830,
        "y": 800,
        "wires": []
    },
    {
        "id": "8bbd04cd.09b9f8",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "Convert",
        "func": "var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nvar msg4 = {};\nvar msg5 = {};\n\nmsg1.payload = msg.payload.memory.total;\nmsg1.topic = \"Total\";\n\nmsg2.payload = msg.payload.memory.free;\nmsg2.topic = \"Free\";\n\nmsg3.payload = msg.payload.memory.available;\nmsg3.topic = \"Available\";\n\nmsg4.payload = msg.payload.memory.buffers;\nmsg4.topic = \"Buffer\";\n\nmsg5.payload = msg.payload.memory.cached;\nmsg5.topic = \"Cache\";\n\nreturn [msg1, msg2, msg3, msg4, msg5];",
        "outputs": 5,
        "noerr": 0,
        "x": 600,
        "y": 1020,
        "wires": [
            [
                "7c34e872.609078"
            ],
            [
                "7c34e872.609078"
            ],
            [
                "7c34e872.609078"
            ],
            [
                "7c34e872.609078"
            ],
            [
                "7c34e872.609078"
            ]
        ],
        "icon": "node-red/batch.png"
    },
    {
        "id": "7c34e872.609078",
        "type": "ui_chart",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "a16c33ed.367dc",
        "order": 1,
        "width": "18",
        "height": "5",
        "label": "Memory",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 820,
        "y": 1020,
        "wires": [
            []
        ]
    },
    {
        "id": "807a99f3.a88b38",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "68da99b3.710ef8",
        "order": 4,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Uptime",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 820,
        "y": 840,
        "wires": []
    },
    {
        "id": "9eb36b99.8f9868",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "68da99b3.710ef8",
        "order": 5,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Idletime",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 820,
        "y": 880,
        "wires": []
    },
    {
        "id": "98f3bd0c.db8c8",
        "type": "ui_text",
        "z": "be6e7638.7b89e8",
        "group": "68da99b3.710ef8",
        "order": 6,
        "width": "6",
        "height": "1",
        "name": "",
        "label": "Netzwerk-Zeit",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 840,
        "y": 920,
        "wires": []
    },
    {
        "id": "863c3043.7d64f",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.uptime;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 840,
        "wires": [
            [
                "807a99f3.a88b38"
            ]
        ]
    },
    {
        "id": "15c9bc48.620514",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.idletime;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 880,
        "wires": [
            [
                "9eb36b99.8f9868"
            ]
        ]
    },
    {
        "id": "28c6fb77.3db614",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "DD:HH:MM:SS",
        "func": " var totalNumberOfSeconds = msg.payload.time;\n var days = parseInt( totalNumberOfSeconds / 86400 );\n var hours = parseInt (( totalNumberOfSeconds - ( days * 86400 )) / 3600  );\n var minutes = parseInt ((totalNumberOfSeconds - ((hours * 3600)+( days * 86400 ))) / 60 );\n var seconds = parseInt(totalNumberOfSeconds - ((hours * 3600) + (minutes * 60)+( days * 86400 )));\n var result = (days < 10 ? \"0\" + days : days) + \"D \" + (hours < 10 ? \"0\" + hours : hours) + \":\" + (minutes < 10 ? \"0\" + minutes : minutes) + \":\" + (seconds  < 10 ? \"0\" + seconds : seconds);\n msg.payload=result;\n return msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 620,
        "y": 920,
        "wires": [
            [
                "98f3bd0c.db8c8"
            ]
        ]
    },
    {
        "id": "86a8fff2.cf15",
        "type": "ui_chart",
        "z": "be6e7638.7b89e8",
        "name": "",
        "group": "1a297f3e.3639e1",
        "order": 1,
        "width": "18",
        "height": "5",
        "label": "CPU",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "",
        "ymax": "",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 810,
        "y": 1120,
        "wires": [
            []
        ]
    },
    {
        "id": "bbe9a0aa.cc15a",
        "type": "function",
        "z": "be6e7638.7b89e8",
        "name": "Convert",
        "func": "var msg1 = {};\n\nmsg1.payload = msg.payload.loadavg;\nmsg1.topic = \"CPU\";\n\nreturn [msg1];",
        "outputs": 1,
        "noerr": 0,
        "x": 600,
        "y": 1120,
        "wires": [
            [
                "86a8fff2.cf15"
            ]
        ],
        "icon": "node-red/batch.png"
    },
    {
        "id": "ae365d99.3c1e5",
        "type": "ui_group",
        "z": "",
        "name": "Clients",
        "tab": "ed482ee6.38ec8",
        "order": 3,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "244e4c30.951924",
        "type": "ui_group",
        "z": "",
        "name": "Traffic",
        "tab": "ed482ee6.38ec8",
        "order": 4,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "617262ba.cd435c",
        "type": "ui_group",
        "z": "",
        "name": "Gateway",
        "tab": "ed482ee6.38ec8",
        "order": 2,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "68da99b3.710ef8",
        "type": "ui_group",
        "z": "",
        "name": "System",
        "tab": "ed482ee6.38ec8",
        "order": 1,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "a16c33ed.367dc",
        "type": "ui_group",
        "z": "",
        "name": "Memory",
        "tab": "ed482ee6.38ec8",
        "order": 5,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "1a297f3e.3639e1",
        "type": "ui_group",
        "z": "",
        "name": "CPU",
        "tab": "ed482ee6.38ec8",
        "order": 6,
        "disp": true,
        "width": "18",
        "collapse": false
    },
    {
        "id": "ed482ee6.38ec8",
        "type": "ui_tab",
        "z": "",
        "name": "Freifunk",
        "icon": "dashboard",
        "order": 8,
        "disabled": false,
        "hidden": false
    }
]

Diskussion

Geben Sie Ihren Kommentar ein. Wiki-Syntax ist zugelassen:
Y Z K R C
 
faqs/router/freifunknodered.txt · Zuletzt geändert: 19/08/2019 20:29 von sandfrog