meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
groups:mg:private:resonatoren:mg:temperture_monitoring:start [2022/02/15 15:19] – [Mg-Server] fienegroups:mg:private:resonatoren:mg:temperture_monitoring:start [2024/03/20 09:37] (current) – Admin: Syntax-Update (Migration from deprecated "fontcolor" plugin to "color" plugin) klaus
Line 74: Line 74:
  
 <blockquote> <blockquote>
-<fc #008000>//#!/usr/bin/python3//</fc>+<color #008000>//#!/usr/bin/python3//</color>
  
-**<fc #008000>import</fc> <fc #6495ed>board</fc> \\ +**<color #008000>import</color> <color #6495ed>board</color> \\ 
-<fc #008000>import</fc> <fc #6495ed>busio</fc> \\ +<color #008000>import</color> <color #6495ed>busio</color> \\ 
-<fc #008000>import</fc><fc #6495ed> adafruit_bmp280</fc>**+<color #008000>import</color><color #6495ed> adafruit_bmp280</color>**
  
 i2c = busio.I2C(board.SCL, board.SDA)\\ i2c = busio.I2C(board.SCL, board.SDA)\\
 bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=0x76) bmp280 = adafruit_bmp280.Adafruit_BMP280_I2C(i2c, address=0x76)
  
-<fc #008000>print</fc>(<fc #ff0000>"Temperature: %0.1f C"</fc> % bmp280.temperature)\\ +<color #008000>print</color>(<color #ff0000>"Temperature: %0.1f C"</color> % bmp280.temperature)\\ 
-<fc #008000>print</fc>(<fc #ff0000>"Pressure: %0.1f hPa"</fc> % bmp280.pressure)+<color #008000>print</color>(<color #ff0000>"Pressure: %0.1f hPa"</color> % bmp280.pressure)
 </blockquote> </blockquote>
  
Line 246: Line 246:
  
  
- +===== IQ-Server ===== 
-==== IQ-Server ==== +Only Admins are allowed to create a database and users on the institute's server. \\
-Only Admins are allowed to create a database and users on the institute's server.  +
-==== Configure CollectD ====+
 You have to write the login data you receive from your admin and the hostname (probably "https://log.iqo.uni-hannover.de" in the configfile for collectd, e.g. with\\ You have to write the login data you receive from your admin and the hostname (probably "https://log.iqo.uni-hannover.de" in the configfile for collectd, e.g. with\\
 ''sudo nano /etc/collectd/collectd.conf''\\ ''sudo nano /etc/collectd/collectd.conf''\\
Line 256: Line 254:
 The rest of collectd.conf is identical to the one for working with the Mg-Server (only Plugins used are syslog, network and python). You can find more information [[https://collectd.org/wiki/index.php/Networking_introduction|here]]. The rest of collectd.conf is identical to the one for working with the Mg-Server (only Plugins used are syslog, network and python). You can find more information [[https://collectd.org/wiki/index.php/Networking_introduction|here]].
  
-==== Configure InfluxDB ==== + 
-Enter your security level, database name, port, directory of saved data and additional configurations in ''sudo nano /etc/influxdb/influxdb.conf'' in the paragraph [[collectd]]. An example for InfluxDB v1.6.4 can be found below.+==== Configuring for collectd ==== 
 + 
 +Stop the influxdb server by running: 
 +<code> 
 +sudo systemctl stop influxd 
 +</code> 
 + 
 +The configuration file is ''/etc/influxdb/influxdb.conf''. The documentation can be found here: [[https://docs.influxdata.com/influxdb/v1.6/administration/config/]] 
 + 
 +The config file for the Mg-Server is {{ :groups:mg:mg:influxdb.txt |here}}. 
 + 
 +The interesting part is: 
 +<code> 
 +[[collectd]] 
 +  enabled = true 
 +  bind-address = ":25826" 
 +  database = "collectd_test" 
 +  security-level = "encrypt" 
 +  auth-file = "/etc/influxdb/auth_file_collectd" 
 +</code> 
 + 
 +This enables the collectd plugin for influx and writes to the database we specify with credentials requiredCommunication is done encrypted. 
 + 
 +Now create a new file name ''/etc/influxdb/auth_file_collectd'' 
 +<code> 
 +magnesium: influxMG 
 +</code> 
 +This is the username and password for any external collectd services to authenticate with the influxdb database.\\ 
 +To load InfluxDB with your new configurations, enter 
 + 
 +<code> 
 +echo $INFLUXDB_CONFIG_PATH /etc/influxdb/influxdb.conf 
 +</code> 
 + 
 +and start the process with ''influxd'' or - as a second option - start the process always with ''influxd -config /etc/influxdb/influxdb.conf''
 + 
 +=== types.db === 
 + 
 +The collectd plugin for InfluxDB requires a types.db document. Copy this from ''/usr/share/collectd/'' on the raspberry pi to ''/usr/local/share/collectd/'' on the server running influxDB. 
 + 
 +=== Restarting the server === 
 + 
 +Start the server by typing <code>influxd</code> and leave the terminal open. If there are any errors, these should be displayed now. 
 + 
 +To check if there are values being written into the database, use another terminal or ssh to log into influx: 
 +<code> 
 +influx 
 +</code> 
 +and check for values in the database: 
 +<code> 
 +USE collectd_test 
 +SHOW SERIES 
 +</code> 
 + 
 +If something is displayed, try listing those values by using 
 +<code> 
 +SELECT * FROM <name of the time series> 
 +</code> 
 ==== Automated Backups ==== ==== Automated Backups ====
  
Line 393: Line 449:
  
 <blockquote> <blockquote>
-<fc #008000>//#!/usr/bin/python3//</fc>+<color #008000>//#!/usr/bin/python3//</color>
  
-**<fc #008000>import</fc> <fc #6495ed>board</fc> \\ +**<color #008000>import</color> <color #6495ed>board</color> \\ 
-<fc #008000>import</fc> <fc #6495ed>busio</fc> \\ +<color #008000>import</color> <color #6495ed>busio</color> \\ 
-<fc #008000>import</fc><fc #6495ed>adafruit_bmp280</fc>\\ +<color #008000>import</color> <color #6495ed>adafruit_bmp280</color>\\ 
-<fc #008000>import</fc><fc #6495ed>sys</fc>\\ +<color #008000>import</color> <color #6495ed>sys</color>\\ 
-<fc #008000>import</fc><fc #6495ed>Adafruit_DHT</fc>\\+<color #008000>import</color> <color #6495ed>Adafruit_DHT</color>\\
  
 i2c = busio.I2C(board.SCL, board.SDA)\\ i2c = busio.I2C(board.SCL, board.SDA)\\
Line 410: Line 466:
  
 \\ \\
-**<fc #008000>print</fc>(<fc #ff0000>"Pressure: %0.1f hPa"</fc> % pressure)**\\+**<color #008000>print</color>(<color #ff0000>"Pressure: %0.1f hPa"</color> % pressure)**\\
 \\ \\
-**<fc #008000>if</fc> humidity <fc #008000>is not</fc> <fc #ff00ff>None</fc> <fc #008000>and</fc> temperature <fc #008000>is not</fc> <fc #ff00ff>None</fc>: **\\+**<color #008000>if</color> humidity <color #008000>is not</color> <color #ff00ff>None</color> <color #008000>and</color> temperature <color #008000>is not</color> <color #ff00ff>None</color>: **\\
 \\ \\
 **temperature = (bmp280.temperature + temperature)/2\\ **temperature = (bmp280.temperature + temperature)/2\\
-<fc #008000>print</fc>(<fc #ff0000>"Temperature: %0.1f C"</fc> % temperature)\\ +<color #008000>print</color>(<color #ff0000>"Temperature: %0.1f C"</color> % temperature)\\ 
-<fc #008000>print</fc>(<fc #ff0000>"Humidity: %0.1f g/m3"</fc> % humidity)**\\+<color #008000>print</color>(<color #ff0000>"Humidity: %0.1f g/m3"</color> % humidity)**\\
 \\ \\
-**<fc #008000>else</fc>:\\+**<color #008000>else</color>:\\
 \\ \\
-      print(<fc #ff0000>"Failed to read AM2302 sensor! Check connections!"</fc>)\\+      print(<color #ff0000>"Failed to read AM2302 sensor! Check connections!"</color>)\\
       sys.exit(1)**\\       sys.exit(1)**\\
          
Line 435: Line 491:
   </Plugin>   </Plugin>
  
-CollectD paragraph in influxdb.conf:\\ 
- 
- [[collectd]] 
-   enabled = true 
-          bind-address = ":25826" 
-   database = "magnesium" 
-   retention-policy = "" 
-   typesdb = "/usr/local/share/main" 
-   security-level = "sign" 
-   username = "magnesium" 
-   password = "BttDFrUqEm" 
  
        
Line 451: Line 496:
  
   * if bind address already in use find PID with ''netstat -tulpn'' and kill process e.g. with ''sudo kill 1258''   * if bind address already in use find PID with ''netstat -tulpn'' and kill process e.g. with ''sudo kill 1258''
-  * TSM files safed in /var/lib/influxdb/data +  * types db file in /usr/local/share/collectd needs to be copied to server! otherwise influxd won't even start and listens to server forever
-  * types db file in /usr/local/share/collectd ([[https://github.com/collectd/collectd/blob/master/src/types.db|example]])+