Browse Source

collectweather.sh gets weather data from Dark Sky API

master
n 1 month ago
parent
commit
b33e48307b
2 changed files with 18 additions and 0 deletions
  1. 1
    0
      README.md
  2. 17
    0
      monitoring/collectweather.sh

+ 1
- 0
README.md View File

@@ -37,6 +37,7 @@ Monitoring
37 37
   * [collectd_ntppool_score](https://forge.tourmentine.com/n/scripts/src/master/monitoring/collectd_ntppool_score) => Same as [check_ntppool_score](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_ntppool_score) but for collectd graphing.
38 38
   * [check_postgresql_replication.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/check_postgresql_replication.sh) => check postgresql's replication lag.
39 39
   * [GonKyrellM](https://forge.tourmentine.com/n/scripts/src/master/monitoring/GonKyrellM) => Conky, GKrellM style - with "invisible" theme (well, sort of)
40
+  * [collectweather.sh](https://forge.tourmentine.com/n/scripts/src/master/monitoring/collectweather.sh) => get weather data from https://darksky.net/ and feed collectd with it. needs jq as Dark Sky provides data in json format.
40 41
 
41 42
 Attic
42 43
 -----

+ 17
- 0
monitoring/collectweather.sh View File

@@ -0,0 +1,17 @@
1
+#!/bin/sh
2
+
3
+HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
4
+INTERVAL="${COLLECTD_INTERVAL:-300}"
5
+FILE="/tmp/weather.json"
6
+
7
+# get $FILE using a cronjob (no more than 1000 requests per day for free - one every 5 minutes is fine) like
8
+#curl "https://api.darksky.net/forecast/<your api key>/<latitude>,<longitude>?lang=<language>&units=si" -o $FILE -s
9
+
10
+while sleep "$INTERVAL"; do
11
+	for field in precipIntensity precipProbability temperature apparentTemperature dewPoint humidity pressure windSpeed windGust windBearing cloudCover uvIndex visibility ozone;do 
12
+		echo "PUTVAL $HOSTNAME/weather/gauge-${field} interval=$INTERVAL N:`jq .currently.${field} $FILE`" ;
13
+	done 
14
+	for field in summary icon ;do 
15
+		echo "PUTVAL $HOSTNAME/weather/string-${field} interval=$INTERVAL N:`jq .currently.${field} $FILE`" ;
16
+	done 
17
+done

Loading…
Cancel
Save