No description
Find a file
2020-05-25 14:44:30 +00:00
aggregateweather.py Fix dates 2020-05-23 15:57:33 +00:00
check_rainfall.sh Add nagios plugin 2020-05-22 17:29:46 +02:00
getweather.py Add human readable station name 2020-05-23 17:14:16 +02:00
grafana_dashboard.json Add cumulative graph 2020-05-25 14:43:56 +00:00
LICENSE Initial commit 2020-05-22 16:18:20 +02:00
README.md Add crontab example 2020-05-23 18:28:53 +02:00
requirements.txt Collection of data and aggregation to mysql works 2020-05-22 16:21:18 +02:00
weather.ini Add grafana dashboard 2020-05-23 16:26:45 +00:00
weather.sql Add human readable station name 2020-05-23 17:14:16 +02:00

weather

Some pythonscripts that get weather data from SMHI and calculates evapotranspiration. Create a user to run scripts:

useradd -s /usr/sbin/nologin -r -M -d /opt/weather weather

Clone repo:

git clone https://github.com/mickenordin/weather.git /opt/weather

Chown:

chown -R weather:weather /opt/weather

Create mysql database:

mysql -e "CREATE DATABASE weather"
mysql -e "CREATE USER 'weather'@'localhost' IDENTIFIED BY 'password'"
mysql -e "GRANT ALL PRIVILEGES ON weather.* TO 'weather'@'localhost'"
mysql weather < /opt/weather/weather.sql

Install requirements:

sudo -u  weather pip3 install -r /opt/weather/requirements.txt

Configure and run:

vim /opt/weather/weather.ini
/opt/weather/getweather.py
/opt/weather/aggregateweather.py

Example crontab entry for weather user:

# m h  dom mon dow   command
15 * * * * /opt/weather/getweather.py
30 * * * * /opt/weather/getweather.py --station 97280
45 2,14 * * * /opt/weather/aggregateweather.py
45 3,15 * * * /opt/weather/aggregateweather.py --station 97280