This is a Python script to log network traffic from the smart house system HDL-BUS Pro.
To run the script just type python networklogger.py
.
By default it will listen for UDP packages on all available network interfaces on port 6000 and log the traffic to disk.
If you want to or need to configure the script you just create a new file called hdlconfig.py
. There's an example config file called hdlconfig-example.py
you should use as basis for your config. Please note that at this point the e-mail stuff is not in use.
The data from the HDL system is logged into a file (that will be created) called network.log
. If the script is running continuously the files will be rotated at midnight. By default files will be kept for a week. Make sure you have enough disk space for this.
First SSH into your Raspberry PI.
Then download the code:
cd ~
git clone https://github.com/roys/python-hdl-networklogger.git
It can be smart to check that the script is working and getting data:
cd python-hdl-networklogger
python networklogger.py
Use ctrl + c
to exit the script. Checkout if any data have been logged to a file called network.log
in the same directory.
If you want to make the script run on startup then skip to 2b. If you want to just run the script in the background (even afer you log out) you can enter the following
command:
nohup python networklogger.py &
The number that is printed out is the process number. You can use this number to stop the script.
If you don't have the process number you can find it using ps aux | grep networklogger
.
To kill/stop the script just enter the following command:
kill [process number]
The script can be run as a cron job that starts on reboot of the Raspberry PI.
To edit the cronjob:
crontab - e
Add the following line at the end:
@reboot /bin/sh ~/python-hdl-networklogger/launcher.sh
Use ctrl + x
to exit, press Y
to save the cron setup and enter
to confirm the filename.
Restart the device using sudo shutdown -r now
and check out if there's stuff going on in network.log
. launcher.log
will also contain output and any error messages running
the script.
You can easily tap in to what's going by running tail
:
tail -f network.log
This will let you follow the file and the contents that's written to it. To end the session just press ctrl + c
.
If you chose to do a git clone
in the first step you can just run git pull
inside the directory at ~/python-hdl-networklogger
. If you run the script at boot
time it is easiest to just reboot your Raspberry PI using sudo shutdown -r now
to ensure the latest version of the script is running.