Influx-DB frequency logger with JDS6600 signal generator
A simple python script to write measured frequency values into a Influx-DB database.
The Code is hosted on Github:
Python installation on Ubuntu
sudo apt-get update
sudo apt-get install python3
sudo apt-get install python3-pip
Python Dependencies:
pip install pyserial
pip install influxdb
running the script (automatically)
The script is auto-detecting the USB-port, where the signal generator is connected to. After that it connects to a Influx-DB-server and then publishes the measured frequency value every second to this server. Make sure to fill your login credentials into the influxdb_config.py
-file.
To auto start the script at the sotartup of the server we configure a systemd-service. I assume the repository with this script is cloned into the home directory of one user.
sudo nano /etc/systemd/system/readfreq_influxdb.service
Write into this file:
[Unit]
Description=readfreq_influxdb python script
After=multi-user.target
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/bin/python3 -u /home/user/software_python/readfreq_influxdb.py
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target
No the autostart can be activated:
sudo systemctl enable readfreq_influxdb.service
sudo systemctl start readfreq_influxdb.service
sudo systemctl status readfreq_influxdb.service
To deactivate it, use the command sudo systemctl disable readfreq_influxdb.service
.
Sources/useful links:
- Python Lib (MIT License): https://github.com/on1arf/jds6600_python
- https://github.com/thomaseichhorn/funcgen
- https://www.thomaschristlieb.de/ein-python-script-mit-systemd-als-daemon-systemd-tut-garnicht-weh/
This work by Dustin Brunner is licensed under CC BY 4.0
Dieses Werk von Dustin Brunner ist lizenziert unter einer Creative Commons Namensnennung 4.0 International Lizenz.
0 Kommentare