How show a log flow from journald on UI Dashboard

I try to get data from journalctl into into the Dashboard.
with e.g. systemd-cat -t NAME -p4 I put several outputs of several shell scripts into journald.

now I try to get this data out from jounrald into /ui
the bash script: journalctl -t NAME -o cat -f -n1 -p4 |grep -v "EXCLUDE1" | grep -v "EXCLUDE2" |grep ...
I have two problems:

  1. It seems Exec note do not rescive the data. (it seems a problem of PID?)
  2. I do not have a solution to get aflow that show me only the last 20 lines.

Any Idea?

What error are you seeing? Have you checked all three outputs of the exec node?

Show us how you have configured the exec node.

Does that command work if you run it in a terminal?

Nodered

[{"id":"96985776.50d0c8","type":"debug","z":"81da06dc.48fab","name":"direct-stdout","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":340,"wires":[]},{"id":"afe6bf414a20ace8","type":"debug","z":"81da06dc.48fab","name":"stderr","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":380,"wires":[]},{"id":"38d950c4f69ac025","type":"debug","z":"81da06dc.48fab","name":"stdreturn","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":420,"wires":[]},{"id":"0a9729d044157f88","type":"exec","z":"81da06dc.48fab","command":"/home/pi/journal-hp.bash","addpay":"","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"journalctl -f","x":290,"y":360,"wires":[["95a1bd0afaf622a7","96985776.50d0c8"],["afe6bf414a20ace8"],["38d950c4f69ac025"]]},{"id":"8f439de10cba349a","type":"inject","z":"81da06dc.48fab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":130,"y":360,"wires":[["0a9729d044157f88"]]}]

Bash

#!/bin/bash
export SYSTEMD_COLORS=false
journalctl -t Scan -o cat -f -n1 -p4 | grep -v "Reading data" | grep -v "BLOB"

It is important to try to answer all questions. You have not answered:

I note that you have not set the set the debug nodes to output the full message object. That is important.

  • I do not see any feedback on any node.
  • The above script work if I run it in a terminal.
  • I changed the Debug node to full message object -> Still no output.

Are you sure that running journal-hp.bash manually works? I can't run exactly the journalctl command that you are as it doesn't produce any output, but if, instead I put in the bash script
journalctl -f -n1 -u nodered -o cat
then your flow does work. Similarly if I use
journalctl -f -n1 -u nodered -o cat | grep "info"
then it still works.

In case you didn't know, if you configure an Inject node to send msg.kill as an empty string to the exec node you can use it to kill the current process to make testing easier.

[Edit] A thought, are you running a Docker install of node-red?

Yes I'm sure It runs locally

start in one terminal

journalctl -t scan -o cat -f -n1 -p5 

then open a second terminal

echo hallo welt 4 |systemd-cat -t scan -p4
echo hallo welt 5 |systemd-cat -t scan -p5
echo hallo welt 6 |systemd-cat -t scan -p6

you see that all journal entries with level 5 or lower appear in the other terminal

No.
I run node-red on a "Raspberry Pi 2 Model B Rev 1.1" with Raspbian. I used Running on Raspberry Pi : Node-RED to install node-red.

If you run your script /home/pi/journal-hp.bash in a terminal and in a second terminal window use one of your example commands
echo hallo welt 4 |systemd-cat -t scan -p4
does the result show up in the terminal window running the bash script?

Does it work for you if you use the examples I suggested?

@zenofmud yes of course. As I described above.

I found out:
The exec node shows the pid 1386 ps aux |grep 1386 show me the bash script. But If I grep for journalctl ps aux|grep journalctl I get the pid 1387.

@Colin It seems we crossposted. I tested your case. And I found two interesting behavior.

  1. grep -v "TEXT" seems the culprit. If I use somewhere It not anymore work.
  2. msg.kill only kill the bash script but not the journalctl -t ... process. This process still running.

It seems I have to filter excluding text with nodered.

journalctl -f -n1 -u nodered -o cat | grep "info"
works ok for me. Does that not work for you? Do you need to put it in a bash script? Can you put the command directly in the exec node?

normal grep works |grep "TEXT" but not if I wish to exclude e.g. with |grep -v "TEXT"

It is a buffering issue of some sort. If you use, in the bash script
journalctl -f -n1 -u nodered -o cat | grep -v "Stop"
and redeploy node-red a few times, and then kill the process and journalctl then all the lines appear.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.