Table of Contents

2024 Radio Topics

YaDDNet Data Backup

Offsite Text file backups of all DSC messages

YaDDNet UDP Send to Mirror

def send_to_mirror(data):
    log_data = "[log];"+data
    port = 2505
    host = "aaa.bbb.ccc.ddd.eee"
    host2 = "fff.ggg.hhh.iii"
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.sendto(log_data, (host, port))
    sock.sendto(log_data, (host2, port))
 
    return

Backup UDP receive and logrotate

UDP Listener

#!/usr/bin/env python
#
# udp_logger.py
#
 
import SocketServer
import socket
import threading
 
class ThreadedUDPRequestHandler(SocketServer.BaseRequestHandler):
 
    def handle(self):
        data = self.request[0].strip()
        socket = self.request[1]
        self.write_file(data)
 
    def write_file(self,text):
        filename = '/home/gm4slv/yaddlogs/yaddnet_udp_log.txt'
        f = open(filename, 'a+')
        log = text
        f.write(log+"\n")
        f.close()
        return
 
class ThreadedUDPServer(SocketServer.ThreadingMixIn, SocketServer.UDPServer):
    pass
 
if __name__ == "__main__":
    HOST, PORT = "", 2505
    server = ThreadedUDPServer((HOST, PORT), ThreadedUDPRequestHandler)
    ip, port = server.server_address
    server.serve_forever()
    # Start a thread with the server -- 
    # that thread will then start one
    # more thread for each request
    server_thread = threading.Thread(target=server.serve_forever)
    # Exit the server thread when the main thread terminates
    server_thread.daemon = True
    server_thread.start()
    server.shutdown()
[log];2024-04-19 08:43:06;NLD_MB_HF1;2187.5;SEL;002050480;COAST;205;Belgium;Ostende Radio;SAF;636092799;SHIP;636;Liberia;CISNES, D5HF4, Cargo;TEST;NOINF;--;--;REQ;OK
[log];2024-04-19 08:43:28;BDXC-Han-Remote;12577.0;SEL;002241022;COAST;224;Spain;Coruna Radio;SAF;538005991;SHIP;538;Marshall Islands;NAVIG8 VIOLETTE, V7IH3, Tanker;TEST;NOINF;--;--;REQ;OK

Logrotate

## CRONTAB ENTRY
 
00 00 * * * /home/gm4slv/bin/yaddlog_rotate.sh /dev/null 2>&1
#!/bin/bash
#
# yaddlog_rotate.sh
 
DROPBOX=/home/gm4slv/Dropbox/Yaddlogs/
DIR=/home/gm4slv/yaddlogs
 
INFILE=yaddnet_udp_log.txt
 
TIMESTAMP=`date +%Y%m%d_%H%M`
 
OUTFILE=$TIMESTAMP\_$INFILE
 
cp $DIR/$INFILE $DIR/$OUTFILE
cat /dev/null > $DIR/$INFILE
 
 
gzip $DIR/$OUTFILE
 
mv $DIR/$OUTFILE.gz $DROPBOX

Starting the UDP Listener at boot-up

#
# CRONTAB ENTRY
#
@reboot python /home/gm4slv/bin/udp_logger.py &

John Pumford-Green 19/04/24 09:31 BST

Last updated : 06/03/25 06:49 GMT

Further Information

YaDDNet