May 2024 Milwaukee Linux Users Group (MLUG) Meeting

15 views
Skip to first unread message

Roger M. Jenson

unread,
May 2, 2024, 6:59:01 AMMay 2
to Milwaukee Linux Users Group


Does anyone have a favorite project, product demonstration, discussion
topic for the May 2024 MLUG Meeting?

Best Regards,
Roger M. Jenson


Tom

unread,
May 3, 2024, 12:58:50 PMMay 3
to Milwau...@googlegroups.com
I'm trying to read status from a NAS device and lo! there's an XML interface that spews forth all the data anyone would ever want, at port 5000, in XML format.
 
Here's the problem. Both wget and netcat (nc) yank the data down for me just fine:
 
nc wiget.tpeters.org 5000 > widget.xml
 
But the thing is designed to dump the data, pause 10 seconds, then dump it all again, in case anything changed. Lather, rinse, repeat, forever. It never terminates.
 
I do know that the file starts with
<nul><soh><nul<soh>DRINASDM<?xml version="1.0" encoding="utf-8"?>
<ESATMUpdate>
 
and ends with
</ESATMUpdate><nul>
 
There are non-printables in the preamble, and a null at the very end.
 
Anyone know how I can grab this data and make it terminate when it's pulled down one bucketful?
 
-Tom

James Meyer

unread,
May 4, 2024, 10:37:53 PMMay 4
to Milwau...@googlegroups.com, Tom
assuming this is a straight socket read and not http, the following program should do what you want

Change the 3 lines below to fit your env.
Most likely start will be  <ESATMUpdate>
End will be </ESATMUpdate>

This has extra debugging output, and also print the raw list.  
having it print the list to a file or in string format is straight forward.




#!/usr/bin/env python3
import socket
import time
import bufsock

# Give the server time to start up.
time.sleep(1)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# We use port 4444 so we don't need to be root to run this.

#set the host and port socket to read from
s.connect(("192.168.1.131", 4452)) #<=====adjust this line


bs = bufsock.bufsock(s)

#set the start and ending string to capture between
startmatch="<startmatch>" #<=======adjust this line
endmatch="<endmatch>" #<=======adjust this line


full_bucket=[]
add_to_bucket = False
while True:

    data = bs.readto('\n')
    decoded_data=data.decode("utf-8")
    #this print is debugging only
    #prints whats received from the socket
    print(decoded_data)
    if  startmatch in decoded_data:
        add_to_bucket = True
        print("found start")
   
   
    if add_to_bucket:
        print("adding to bucket")
        full_bucket.append(decoded_data)
   
    if  endmatch in decoded_data:
        print("found end match, stopping")
        add_to_bucket = False

        break

#print the bucket contents
print(full_bucket)





--
Homepage: http://www.milwaukeelug.org/home
This forum online: https://groups.google.com/forum/#!forum/MilwaukeeLUG
---
You received this message because you are subscribed to the Google Groups "Milwaukee Linux User's Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to MilwaukeeLUG...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/MilwaukeeLUG/5701.101640238.1714755525%40gmail.com.

James Meyer

unread,
May 4, 2024, 10:45:44 PMMay 4
to Milwau...@googlegroups.com, Tom
This is what i used to replicate the continuous output of the NAS.
instead of 10 seconds sleep, it's 2 seconds and includes data that is not wanted (occurs outside the start/end string)

 jams@ace:~> cat a.sh
#!/bin/bash
while [ "x"="x" ]
do
        echo "<startmatch>"
        date
        sleep 2
        echo "<endmatch>"
        date
        date
        date
        date
        cat /etc/group
done

#start on port 4452 and run /home/jams/a.sh to provide data to the socket
#The contents never end
jams@ace:~> socat TCP-LISTEN:4452,fork EXEC:/home/jams/a.sh

Tom

unread,
May 10, 2024, 10:54:32 AMMay 10
to Milwau...@googlegroups.com
So I'm trying to run a thing, and like I always do when I see something cool on youtube, I got into trouble. As you will see from the below, I know almost nothing about docker.
 
The guy shows on his video, type git clone https://github.com/plaintextpackets/netprobe_lite
and then type docker compose up and goodness will ensue.
 
It doesn't work that way on my machines. I tried on a Fedora 36 machine (docker 20.10.21) and also on a Fedora 39 machine (docker 24.0.5) and in both cases:
 
# docker compose up
docker: 'compose' is not a docker command.
 
I also tried this, which is NOT what the guy on the video typed:
 
# docker-compose up
ERROR: The Compose file './compose.yml' is invalid because:
'name' does not match any of the regexes: '^x-'
 
You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
 
When he does it on the video, five different processes start up.
The git clone results in the following files being present:
 
├── compose.yml
├── config
│   ├── grafana
│   │   ├── dashboards
│   │   │   ├── main.yml
│   │   │   └── netprobe.json
│   │   └── datasources
│   │   └── automatic.yml
│   ├── __init__.py
│   ├── prometheus
│   │   └── prometheus.yml
│   └── redis
│   └── redis.conf
├── Dockerfile
├── entrypoint.sh
├── helpers
│   ├── http_helper.py
│   ├── input_helper.py
│   ├── logging_helper.py
│   ├── network_helper.py
│   ├── __pycache__
│   │   └── network_helper.cpython-312.pyc
│   └── redis_helper.py
├── logs
├── netprobe.py
├── presentation.py
├── README.md
└── requirements.txt
 
I should point out that both these machines are headless and one of them is virtual. I could attach a keyboard & mouse to the Fedora 39 machine and run some GUI management tool, but I don't know what. I seem to have Whaler on here, but it doesn't run- complains about not being root.
 
 
Reply all
Reply to author
Forward
0 new messages