logo elektroda
logo elektroda
X
logo elektroda

Inspecting OBK logs with ncat - shortcut without the Web application

max4elektroda 2004 4
ADVERTISEMENT
📢 Listen (AI):
  • Sometimes I like a short look in the logs of an OpenBeken device without starting the web app and open the "logs" menu.

    Or I like to save or filter the logs over a longer period.

    This can be easily achieved by the connecting to port 9000 of the device.

    I learned about this feature from a comment from @miegapele on git and would like to share it here.


    On linux you would probably use nc/netcat. So, e.g. when working on the Driver for DS1820, I used:

    max@max-PC:~$ nc 192.168.0.37 9000 | grep DS1820
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 




    On Windows (if you didn't install WSL) my preferred "swiss army knife" for tasks like this is a windows port of "busybox" (I get the binary from here).

    So you can just start a "shell" there with "busybox sh" and simply use the same command as above :-).

    Screenshot of a Windows console showing the use of busybox to analyze device logs.

    And if there are times, when you miss md5sum, awk or sed - it's also there in this useful little binary.

    The access to the network log is not a full replacement for the log on the hardware UART. But I really like it, especially when "waiting" for entries in the log.

    Cool? Ranking DIY
    About Author
    max4elektroda
    Level 24  
    Offline 
    max4elektroda wrote 746 posts with rating 184, helped 48 times. Been with us since 2024 year.
  • ADVERTISEMENT
  • #2 21246672
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14493
    Help: 651
    Rate: 12502
    Very nice method, even I was not aware about that! Still, it could be also good to have logs stored in LittleFS, maybe? At least for debugging purposes and with some filtering, so we don't wear out flash too fast.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21246726
    divadiow
    Level 38  
    Posts: 4933
    Help: 430
    Rate: 875
    Cool! You could also do it with PowerShell
    Code: Powershell
    Log in, to see the code


    Screenshot showing a PowerShell script for retrieving and filtering logs from a specified IP address and port. Screenshot of a Windows PowerShell window displaying MQTT logs.
  • ADVERTISEMENT
  • #4 21263048
    jkwim
    Level 13  
    Posts: 186
    Help: 4
    Rate: 25
    max4elektroda wrote:
    Sometimes I like a short look in the logs of an OpenBeken device without starting the web app and open the "logs" menu.

    Or I like to save or filter the logs over a longer period.

    This can be easily achieved by the connecting to port 9000 of the device.

    I learned about this feature from a comment from @miegapele on git and would like to share it here.


    On linux you would probably use nc/netcat. So, e.g. when working on the Driver for DS1820, I used:

    max@max-PC:~$ nc 192.168.0.37 9000 | grep DS1820
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 
    Info:CFG:DS1820 - High=1 Low=54 Val=310 Tc=1937  -- Read CRC=79 - calculated:79 
    Info:CFG:DS1820 - asked for conversion - Pin 2
    Info:CFG:DS1820 - Pin=2 temp=+19.37 


    I have CYGWIN in my Windows machine.
    Added nc and now it becomes very handy to filter log entries in real time.

    $ nc 192.168.1.250 9000 | awk '/SENSOR NOT/ {print}'
    Error:CMD:cmd SENSOR NOT found (args {"Time":"2024-10-14T21:50:14","ENERGY":{"Power": 1.210776,"ApparentPower": 40.349151,"ReactivePower": 40.330982,"Factor":0.030007,"Voltage":242.087265,"Current":0.166671,"ConsumptionTotal":2059.686523,"Yesterday": 423.476654,"ConsumptionLastHour":0.000000}})
    Error:CMD:cmd SENSOR NOT found (args {"Time":"2024-10-14T21:50:14","ENERGY":{"Power": 1.210776,"ApparentPower": 40.349151,"ReactivePower": 40.330982,"Factor":0.030007,"Voltage":242.087265,"Current":0.166671,"ConsumptionTotal":2059.686523,"Yesterday": 423.476654,"ConsumptionLastHour":0.000000}})
    


    $ nc 192.168.1.250 9000 | awk '/SENSOR NOT/ {gsub(/,/," ");print $16}'
    "ConsumptionTotal":2053.459472
    "ConsumptionTotal":2053.460449
    "ConsumptionTotal":2053.461181
    "ConsumptionTotal":2053.461914
    "ConsumptionTotal":2053.462646
    "ConsumptionTotal":2053.463623
    "ConsumptionTotal":2053.464111
    "ConsumptionTotal":2053.464843
    "ConsumptionTotal":2053.465820
    "ConsumptionTotal":2053.466552
    "ConsumptionTotal":2053.466796
    "ConsumptionTotal":2053.467285


    Complex filtering can be done on the command line to troubleshoot issues:

    $ nc 192.168.1.250 9000 | awk '/SENSOR NOT/ {gsub(/,/," ");print $16} /energycounter/ {gsub(/50-250/,"");print}'
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_last_hour/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_2_days_ago/get
    "ConsumptionTotal":2053.552246
    "ConsumptionTotal":2053.552978
    Info:MQTT:Publishing val 2023-09-13T16:31+05:30 to openbk7231N-NW/energycounter_clear_date/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_clear_date/get
    "ConsumptionTotal":2053.553955
    "ConsumptionTotal":2053.554687
    "ConsumptionTotal":2053.555175
    "ConsumptionTotal":2053.556396
    Info:MQTT:Publishing val 2053.556 to openbk7231N-NW/energycounter/get retain=0
    Info:MQTT:Publishing val 1615.548 to openbk7231N-NW/energycounter_today/get retain=0
    Info:MQTT:Publishing val 423.476 to openbk7231N-NW/energycounter_yesterday/get retain=0
    Info:MQTT:Publishing val 8.245 to openbk7231N-NW/energycounter_3_days_ago/get retain=0
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_today/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_yesterday/get
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic openbk7231N-NW/energycounter_3_days_ago/get
    "ConsumptionTotal":2053.556884
    "ConsumptionTotal":2053.557617
    "ConsumptionTotal":2053.558349
  • #5 21307105
    morgan_flint
    Level 14  
    Posts: 251
    Help: 4
    Rate: 59
    I've just tried this with PuTTy and works like a charm:
    Screenshot of PuTTY configuration with IP address and telnet port. Screenshot of a PuTTY session displaying TuyaMCU log data.
📢 Listen (AI):

FAQ

TL;DR: OpenBeken exposes logs on TCP port 9000, and one user said it "works like a charm." This shortcut helps Linux, Windows, Cygwin, PowerShell, and PuTTY users inspect, save, or filter OBK logs without opening the web app, especially for long-running checks such as DS1820 debugging. [#21307105]

Why it matters: Direct TCP log streaming gives faster, scriptable troubleshooting when you only need live output, filtering, or capture.

Method Platform Typical command or action Best use
nc / netcat Linux nc <IP> 9000 \| grep DS1820 Fast live filtering
BusyBox sh + nc Windows Same nc command inside BusyBox shell Windows without WSL
PowerShell Windows TcpClient + keyword filter loop Interactive filtering
Cygwin + nc + awk Windows nc <IP> 9000 \| awk ... Complex parsing
PuTTY Windows Raw TCP session to port 9000 Quick manual viewing

Key insight: Port 9000 log streaming is excellent for waiting on specific events and filtering them live, but it does not replace the hardware UART log for full debugging coverage.

Quick Facts

  • OpenBeken devices in the thread stream logs over TCP port 9000, which lets users inspect output without opening the web application's Logs page. [#21244934]
  • A Linux example filters DS1820 activity live with nc 192.168.0.37 9000 | grep DS1820, showing repeated messages such as Pin 2 and temp=+19.37. [#21244934]
  • Windows users reported three working paths: BusyBox, PowerShell, and PuTTY; each connects to the same log stream on port 9000. [#21246726]
  • A Cygwin example parsed energy-related lines that included 242.087265 V, 0.166671 A, and 1.210776 W, showing that command-line tools can extract specific values in real time. [#21263048]

How do I inspect OpenBeken logs directly with ncat or netcat without opening the Web application?

Connect directly to the device on TCP port 9000 and read the live stream. 1. Find the device IP, such as 192.168.0.37. 2. Run nc 192.168.0.37 9000. 3. Add a filter like | grep DS1820 if needed. This avoids opening the web UI and works well for short checks or long captures. [#21244934]

What is the OpenBeken log stream on port 9000, and how does it differ from the logs shown in the web UI?

The port 9000 stream is a direct network log feed from the device. It lets you read logs without starting the web application or opening its Logs menu. The thread presents it as a faster shortcut for live monitoring and filtering, not as a separate log format. Its key difference is access method: TCP client instead of browser UI. [#21244934]

Why is port 9000 useful for monitoring OBK logs over a longer period or filtering them in real time?

Port 9000 is useful because you can leave a TCP client running and pipe output into filters or files. That makes long waits easier when you need one event, one driver message, or one keyword. The thread explicitly recommends it for saving logs and filtering them over longer periods. [#21244934]

What's the best way to filter OpenBeken logs for DS1820 messages on Linux using nc and grep?

Use nc <device-ip> 9000 | grep DS1820 on Linux. The shared example was nc 192.168.0.37 9000 | grep DS1820, and it returned repeated DS1820 lines such as Pin 2 and temp=+19.37. That gives a narrow, readable stream while the device keeps sending other log lines. [#21244934]

How can I view OpenBeken logs on Windows without WSL by using BusyBox and a netcat-style command?

Run BusyBox for Windows, open its shell with busybox sh, and use the same nc command used on Linux. The thread describes BusyBox as a convenient Windows workaround when WSL is not installed. That means nc <device-ip> 9000 works from the BusyBox shell without the OBK web page. [#21244934]

What is BusyBox for Windows, and why do users call it a 'swiss army knife' for tools like nc, awk, sed, and md5sum?

BusyBox for Windows is a compact command-line bundle that groups many Unix-style utilities into one binary. In the thread, it is called a “swiss army knife” because it provides nc, awk, sed, and md5sum together, so one download covers several troubleshooting tasks on Windows. [#21244934]

How do I use PowerShell to connect to an OpenBeken device on port 9000 and filter log lines by keyword?

Use a PowerShell script that opens a System.Net.Sockets.TcpClient to the device IP on port 9000, reads each line, and prints only matches. The shared script prompts for the IP, sets $port = 9000, then asks for a keyword until you type exit. That gives interactive filtering without installing grep or awk. [#21246726]

Why isn't the network log on port 9000 a full replacement for the hardware UART log in OpenBeken debugging?

The port 9000 stream is helpful, but it does not replace the hardware UART log. The thread states this limit directly and still recommends network logging for waiting on specific entries. "UART is a hardware logging interface that exposes device output directly, with access independent of the web app or TCP viewer." Use UART when you need the fuller debugging path. [#21244934]

What is LittleFS, and how could storing filtered debug logs there help with OpenBeken troubleshooting?

LittleFS was suggested as a place to store filtered logs for debugging. "LittleFS is a storage layer mentioned for keeping selected debug logs on-device, with filtering to reduce write load and avoid wearing flash too fast." In the thread, this idea would help when you need logs preserved beyond the live port 9000 stream. [#21246672]

How can I use Cygwin with nc and awk to filter OpenBeken log entries in real time on Windows?

Install nc in Cygwin, then pipe the port 9000 stream into awk. One reported example was nc 192.168.1.250 9000 | awk '/SENSOR NOT/ {print}'. Another version added gsub and field extraction, proving Cygwin can do real-time filtering and parsing on Windows without the web UI. [#21263048]

Why does awk filtering for 'SENSOR NOT' in OBK logs show lines like 'cmd SENSOR NOT found', and what does that indicate?

It shows those lines because the filter matches the exact text SENSOR NOT wherever it appears. In the shared output, the device emitted Error:CMD:cmd SENSOR NOT found, so awk printed it. That indicates your pattern is broad, and it can capture error messages as well as sensor-related lines. [#21263048]

How do I extract a specific field such as ConsumptionTotal from OpenBeken energy logs using awk on the command line?

Use awk to normalize separators, then print the field position that contains the value. The thread's example was nc 192.168.1.250 9000 | awk '/SENSOR NOT/ {gsub(/,/," ");print $16}', which returned values like "ConsumptionTotal":2053.459472. That method works when the log line structure stays consistent. [#21263048]

What are the differences between PuTTY, PowerShell, netcat, and Cygwin for viewing OpenBeken logs on Windows?

PuTTY is the quickest manual viewer, PowerShell adds an interactive keyword loop, BusyBox or native netcat gives simple stream access, and Cygwin adds richer parsing with awk. All four approaches target the same port, 9000. Choose PuTTY for quick viewing, PowerShell for prompts, and Cygwin or netcat for repeatable command-line filters. [#21307105]

Which approach works better for OpenBeken troubleshooting: streaming logs over TCP port 9000 or reading logs from the hardware UART?

Use TCP port 9000 for convenience, but use hardware UART when you need the fuller debugging path. The thread strongly praises the network stream for waiting on entries and filtering them live. It also states clearly that the network log is not a full replacement for the hardware UART log. [#21244934]

What troubleshooting steps should I try if I connect to an OpenBeken device with nc or PuTTY on port 9000 and no logs appear?

First, verify the device IP and port 9000, because every working example used a direct IP such as 192.168.0.37 or 192.168.1.250. Second, remove filters like grep DS1820 or awk '/SENSOR NOT/', which can hide unrelated output. Third, try another client, such as PuTTY or PowerShell, to rule out a tool issue. If you still see nothing, switch to hardware UART because port 9000 is not a complete replacement. [#21244934]
Generated by the language model.
ADVERTISEMENT