Node-RED/flow: Systemprotokoll im Dashboard anzeigen

Node-RED als CCU3/RaspberryMatic Addon, WebApp, HomeKit, ...

Moderator: Co-Administratoren

Antworten
Benutzeravatar
Henke
Beiträge: 1498
Registriert: 27.06.2022, 20:51
System: CCU
Hat sich bedankt: 133 Mal
Danksagung erhalten: 302 Mal

Node-RED/flow: Systemprotokoll im Dashboard anzeigen

Beitrag von Henke » 22.11.2022, 22:24

Um das Systemprotokoll direkt als Anzeige im Dashboard zu bekommen ist eigentlich nicht viel nötig, jedoch sind ein paar kleine Hürden dabei aufgetreten. Der angefügte flow löst die Probleme und ich nutze die Gelegenheit um die unterschiedlichen Möglichkeiten bei der Anzeige der debug Node zu demonstrieren.
Ich hoffe, es ist für den einen oder der anderen nützlich.
Screenshot 2022-11-22 215805.jpg
Anzeige im Dashboard
Screenshot 2022-11-22 220714.jpg
Flow Übersicht

Code: Alles auswählen

[
    {
        "id": "81a2830dc6ac9829",
        "type": "group",
        "z": "427fc89b.e34038",
        "style": {
            "stroke": "#999999",
            "stroke-opacity": "1",
            "fill": "none",
            "fill-opacity": "1",
            "label": true,
            "label-position": "nw",
            "color": "#a4a4a4"
        },
        "nodes": [
            "ea9fb70de4cabeb6",
            "6fe77d28d5619f41",
            "ba4585988a9d01d5",
            "0a62e336b8cef9ec",
            "5892ad1a2e13accd",
            "36ccb226efb33379",
            "8d8a33b53d24f8a1",
            "4ed36e5825429f12",
            "68e016f7caf0fabf",
            "20296a42de944739"
        ],
        "x": 934,
        "y": 4459,
        "w": 812,
        "h": 302
    },
    {
        "id": "ea9fb70de4cabeb6",
        "type": "watch",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "",
        "files": "/var/log/messages",
        "recursive": "",
        "x": 1050,
        "y": 4560,
        "wires": [
            [
                "6fe77d28d5619f41",
                "0a62e336b8cef9ec"
            ]
        ]
    },
    {
        "id": "6fe77d28d5619f41",
        "type": "debug",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "Dateiname",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": " payload & \" - \" & $round(size/1024, 2) & \" kb\"\t ",
        "targetType": "jsonata",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1230,
        "y": 4500,
        "wires": []
    },
    {
        "id": "ba4585988a9d01d5",
        "type": "ui_template",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "group": "a056eb41d025837e",
        "name": "Syslog",
        "order": 1,
        "width": 0,
        "height": 0,
        "format": "<style>\n    #mylog {\n        min-height: 300px;\n        max-height: 500px;\n        padding: 0;\n        white-space: pre;\n    }\n</style>\n\n<!-- contenteditable=\"true\"  -->\n<div id=\"mylog\" ng-bind=\"msg.payload\"><!-- file contents will go here --></div>\n",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 1670,
        "y": 4560,
        "wires": [
            []
        ]
    },
    {
        "id": "0a62e336b8cef9ec",
        "type": "trigger",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "",
        "op1": "",
        "op2": "true",
        "op1type": "nul",
        "op2type": "bool",
        "duration": "5",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1220,
        "y": 4560,
        "wires": [
            [
                "5892ad1a2e13accd"
            ]
        ]
    },
    {
        "id": "5892ad1a2e13accd",
        "type": "exec",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "command": "tail -n 300 /var/log/messages",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "10",
        "winHide": true,
        "oldrc": false,
        "name": "",
        "x": 1280,
        "y": 4620,
        "wires": [
            [
                "68e016f7caf0fabf",
                "20296a42de944739"
            ],
            [
                "8d8a33b53d24f8a1"
            ],
            [
                "4ed36e5825429f12"
            ]
        ]
    },
    {
        "id": "36ccb226efb33379",
        "type": "inject",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "Start",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 1030,
        "y": 4620,
        "wires": [
            [
                "5892ad1a2e13accd"
            ]
        ]
    },
    {
        "id": "8d8a33b53d24f8a1",
        "type": "debug",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "Anzahl Error",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "counter",
        "x": 1530,
        "y": 4660,
        "wires": []
    },
    {
        "id": "4ed36e5825429f12",
        "type": "debug",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "Rückgabe",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "\"code: \" & payload.code",
        "targetType": "jsonata",
        "statusVal": "\"code: \" & payload.code & \" ,size: \" & size",
        "statusType": "auto",
        "x": 1520,
        "y": 4720,
        "wires": []
    },
    {
        "id": "68e016f7caf0fabf",
        "type": "function",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "reverse lines",
        "func": "var lineBreak = \"\\n\";\nvar text = msg.payload;\nmsg.payload = text.split(lineBreak).reverse().join(lineBreak).substr (1);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1530,
        "y": 4560,
        "wires": [
            [
                "ba4585988a9d01d5"
            ]
        ]
    },
    {
        "id": "20296a42de944739",
        "type": "debug",
        "z": "427fc89b.e34038",
        "g": "81a2830dc6ac9829",
        "name": "Anzahl Ok",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "counter",
        "x": 1530,
        "y": 4600,
        "wires": []
    },
    {
        "id": "a056eb41d025837e",
        "type": "ui_group",
        "name": "Syslog",
        "tab": "8153eb0.fe96118",
        "order": 5,
        "disp": true,
        "width": "40",
        "collapse": true,
        "className": ""
    },
    {
        "id": "8153eb0.fe96118",
        "type": "ui_tab",
        "name": "Funk",
        "icon": "dashboard",
        "order": 3
    }
]

Antworten

Zurück zu „RedMatic“