Prosjekt Velkomstskjerm

Fra Bitraf
Revisjon per 30. des. 2020 kl. 17:16 av Tingo (diskusjon | bidrag) (Vedlikehold: another restart of the telegraf service)
Hopp til navigering Hopp til søk
bilde av skjerm

Skjermen i hjørnet skal vise en velkomstmelding med kul grafikk når folk logger in med checkin.

Infoskjerm-grafana.jpg

Infoskjermen er nå operativ. Den kjører en webside som viser en playlist fra lokal grafana-server. For å redigere grafana-sidene logger du inn på http://iot2.bitraf.no:3000


Teknisk info

Løsningen består av to deler, En Raspberry Pi koblet til TV'en som viser en webside, og en server som står for alt det andre.

Raspberry Pi

navn: infoskjerm.local

This Pi runs Raspbian, autologins as the pi user (no, not with the default password) and starts the chromium browser pointing to the server. It (ab)uses LXDE's autostart script for this, like so

pi@infoskjerm:~ $ more /home/pi/.config/lxsession/LXDE-pi/autostart
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
@point-rpi

@chromium-browser --no-startup-window --kiosk

@/usr/bin/chromium-browser --start-maximized --kiosk --disable-infobars --noerrordialogs http://iot2.bitraf.no:3000/playlists/play/1?kiosk


@unclutter
@xset s off
@xset s noblank
@xset -dpms

xscreensaver is commented out, the command unclutter turns off the mouse, then xset turns off screen saver, blanking and DPMS just in case the screen supports that. Not sure why there is two lines to start chromium-browser.

point-rpi 
Locate the mouse pointer over the menu button

Server

navn: iot2.bitraf.no

Serveren kjører Grafana[1] (grafana-server), samt følgende komponenter fra TICK stack

  • Telegraf[2] - agent, datainnsamling
  • Influxdb[3] - database for tids-serie data
  • Kapacitor[4] - prosessering av data

Tjenestene har følgende navn

  • grafana-server.service
  • influxdb.service
  • kapacitor.service
  • telegraf.service

Chronograf[5] er ikke i bruk, siden vi benytter Grafana.

Databaser

Følgende databaser er definert i influxdb

> show databases
name: databases
name
----
_internal
telegraf
mqtt_bitraf
bitraf-maskiner

I mqtt_bitraf er følgende serier definert

> show series on mqtt_bitraf
key
---
bitraf_bool,host=iot2,topic=/bitraf/door/2floor/isopen
bitraf_bool,host=iot2,topic=/bitraf/door/3office/isopen
bitraf_bool,host=iot2,topic=/bitraf/door/3workshop/isopen
bitraf_bool,host=iot2,topic=/bitraf/door/4floor/isopen
bitraf_bool,host=iot2,topic=/bitraf/door/frontdoor/isopen
bitraf_int,host=iot2,topic=/bitraf/door/frontdoor/open
bitraf_int,host=iot2,topic=/public/chime/uptime
bitraf_string,host=iot2,topic=public/infoscreen/wtf
mqtt_consumer,host=iot2,topic=/public/smutcave/humidity
mqtt_consumer,host=iot2,topic=/public/smutcave/temperature
mqtt_consumer,host=iot2,topic=bitraf/currentsensor/shopbot
mqtt_consumer,host=iot2,topic=bitraf/humidity/1
mqtt_consumer,host=iot2,topic=bitraf/humidity/2/value
mqtt_consumer,host=iot2,topic=bitraf/temperature/1
mqtt_consumer,host=iot2,topic=bitraf/temperature/2/value
mqtt_consumer,host=iot2,topic=bitraf/temperature/3/value
ping,host=iot2,url=10.13.37.248
ping,host=iot2,url=10.13.37.47
ping,host=iot2,url=boxy3.local
ping,host=iot2,url=boxy4.local
ping,host=iot2,url=http://boxy3.local
ping,host=iot2,url=http://boxy4.local

I bitraf-maskiner er følgende serier definert

> show series on "bitraf-maskiner"
key
---
nvidia_smi,compute_mode=Default,host=Multimedia-maskin,index=0,name=GeForce\ GTX\ 570,pstate=P0,uuid=GPU-5566aa51-b932-0d56-cc06-b6ae94dc6e5f
nvidia_smi,compute_mode=Default,host=Multimedia-maskin,index=0,name=GeForce\ GTX\ 570,pstate=P12,uuid=GPU-5566aa51-b932-0d56-cc06-b6ae94dc6e5f
nvidia_smi,compute_mode=Default,host=Multimedia-maskin,index=0,name=GeForce\ GTX\ 570,pstate=P8,uuid=GPU-5566aa51-b932-0d56-cc06-b6ae94dc6e5f
win_cpu,host=Multimedia-maskin,instance=0,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=1,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=2,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=3,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=4,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=5,objectname=Processor
win_cpu,host=Multimedia-maskin,instance=_Total,objectname=Processor
win_disk,host=Multimedia-maskin,instance=C:,objectname=LogicalDisk
win_disk,host=Multimedia-maskin,instance=D:,objectname=LogicalDisk
win_disk,host=Multimedia-maskin,instance=E:,objectname=LogicalDisk
win_diskio,host=Multimedia-maskin,instance=0\ C:,objectname=PhysicalDisk
win_diskio,host=Multimedia-maskin,instance=1\ D:,objectname=PhysicalDisk
win_diskio,host=Multimedia-maskin,instance=2\ E:,objectname=PhysicalDisk
win_mem,host=Multimedia-maskin,objectname=Memory
win_net,host=Multimedia-maskin,instance=Realtek\ PCIe\ GBE\ Family\ Controller,objectname=Network\ Interface
win_perf_counters,host=Multimedia-maskin,instance=Realtek\ PCIe\ GBE\ Family\ Controller,objectname=Network\ Interface
win_swap,host=Multimedia-maskin,instance=_Total,objectname=Paging\ File
win_system,host=Multimedia-maskin,objectname=System

Telegraf

Telegraf er konfigurert (via /etc/telegraf/telegraf.conf) til å lese følgende topics fra Bitraf's mqtt server:

format: value, type: float

   topics = [
     "bitraf/temperature/1",
     "bitraf/humidity/1",
     "bitraf/temperature/2/value",
     "bitraf/humidity/2/value",
     "bitraf/temperature/3/value",
     "bitraf/currentsensor/shopbot",
     "/public/smutcave/temperature",
     "/public/smutcave/humidity",
     "public/printerroom/tvoc",
     "public/printerroom/eco2",
     "public/printerroom/humidity",
     "public/printerroom/temperature",
     "public/lab/pm10",
     "public/lab/pm25",
     "public/laser/eco2",
     "public/laser/humidity",
     "public/laser/pm10",
     "public/laser/pm25",
     "public/laser/temperature",
     "public/laser/tvoc",
   ]

format: value, type: integer

        "/bitraf/door/frontdoor/open",
	"/public/chime/uptime",

format: value, type: boolean

        "/bitraf/door/frontdoor/isopen",
        "/bitraf/door/2floor/isopen",
        "/bitraf/door/3workshop/isopen",
        "/bitraf/door/3office/isopen",
        "/bitraf/door/4floor/isopen",

format: json

		"bitraf/octoprint/blackbot/progress/printing",

format: value, type: string

		"public/infoscreen/wtf",

den må oppdateres hvis flere ting skal inn. Ser ikke ut som om Telegraf støtter bruk av wildcards i mqtt topics.

Vedlikehold

2020-12-30 ; no data showing in Grafana, restarted the telegraf service as usual, via tingo@iot2:~$ sudo systemctl restart telegraf. Tingo (diskusjon) 30. des. 2020 kl. 17
15 (CET)
2020-10-27 
front door data was not showing in grafana, so I restarted the telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf as usual. Tingo (diskusjon) 27. okt. 2020 kl. 15:56 (CET)
2020-08-10 
some temperature sensors (Outside, 2nd floor, 4th floor) did not show in grafana, so I restarted the telegraf service (tingo@iot2:~$ sudo systemctl restart telegraf). Didn't seem to help, perhaps the sensors need to be fixed? Tingo (diskusjon) 10. aug. 2020 kl. 14:31 (CEST)
2020-06-19 
the browser wouldn't reconnect to the server (iot2) after it came back online, so I restarted the pi ('shutdown -r now') that fixed it. Tingo (diskusjon) 19. jun. 2020 kl. 12:55 (CEST)
2020-06-18 
environment sensors data was not showing in grafana, so I restarted the telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf as usual. Tingo (diskusjon) 19. jun. 2020 kl. 00:24 (CEST)
2020-06-03 
environment sensors data was not showing in grafana, so I restarted the telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf as usual. Tingo (diskusjon) 3. jun. 2020 kl. 13:11 (CEST)
2020-04-25
front door data was not showing in grafana, so I restarted the telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf as usual. Tingo (diskusjon) 25. apr. 2020 kl. 16:49 (CEST)
2020-02-20
environment sensors data was not showing in grafana again. Restarted the telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf. Tingo (diskusjon) 20. feb. 2020 kl. 19:16 (CET)
2020-02-06
added more sensors to /etc/telegraf/telegraf.conf:
     "public/laser/eco2",
     "public/laser/humidity",
     "public/laser/pm10",
     "public/laser/pm25",
     "public/laser/temperature",
     "public/laser/tvoc",

and reloaded telegraf with sudo systemctl reload telegraf. Tingo (diskusjon) 6. feb. 2020 kl. 09:46 (CET)

2020-01-30 
added more sensors to /etc/telegraf/telegraf.conf:
     "public/printerroom/tvoc",
     "public/printerroom/eco2",
     "public/printerroom/humidity",
     "public/printerroom/temperature",
     "public/lab/pm10",
     "public/lab/pm25",

and reloaded telegraf with sudo systemctl reload telegraf. Tingo (diskusjon) 30. jan. 2020 kl. 20:14 (CET)

2019-11-11 
front door activity was showing "no data points". restarted telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf, it is ok now. Tingo (diskusjon) 14. nov. 2019 kl. 11:27 (CET)
2019-09-05 
front door activity was showing "no data points". restarted telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf, hopefully it will work. Tingo (diskusjon) 5. sep. 2019 kl. 17:58 (CEST)
2019-08-27
environment sensors data was not showing in grafana again. Restarted the telegraf service. Tingo (diskusjon) 27. aug. 2019 kl. 11:39 (CEST)
2019-07-30 
the graphs didn't update on the Pi (update in Grafana was ok). Rebooted the Pi. Tingo (diskusjon) 30. jul. 2019 kl. 09:54 (CEST)
2019-07-26 
the graphs didn't update on the Pi (update in Grafana was ok). Rebooted the Pi. Tingo (diskusjon) 26. jul. 2019 kl. 12:36 (CEST)
2019-07-03 
the graphs didn't update on the Pi (update in Grafana was ok). Rebooted the Pi. Tingo (diskusjon) 3. jul. 2019 kl. 16:29 (CEST)
2019-07-01 
environment sensors data was not showing in grafana again. Restarted the telegraf service. Tingo (diskusjon) 3. jul. 2019 kl. 16:27 (CEST)
2019-06-21 
front door activity was showing "no data points". restarted telegraf service via tingo@iot2:~$ sudo systemctl restart telegraf, but that didn't have any effect. Tingo (diskusjon)
Ok, with patience the data shows up. Tingo (diskusjon) 21. jun. 2019 kl. 13:21 (CEST)
2019-05-09 
environment sensors data was not showing in grafana again. I had to restart the telegraf service via
tingo@iot2:~$ sudo systemctl restart telegraf
in addition, I had to refresh the browser window on the Pi (connected a keyboard and did Ctrl-R). Tingo (diskusjon) 9. mai 2019 kl. 19:48 (CEST)
2019-04-12 
environment sensors data was not showing in grafana again. As usual, a
tingo@iot2:~$ sudo systemctl restart telegraf
fixed the problem. Tingo (diskusjon) 12. apr. 2019 kl. 15:52 (CEST)
2019-01-29 
I also needed to restart the playlist on the welcome screen. Tingo (diskusjon) 29. jan. 2019 kl. 14:39 (CET)
environment sensors data was not showing in grafana again. The telegraf service reported
tingo@iot2:~$ systemctl status telegraf
● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
   Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-10-12 00:22:04 CEST; 3 months 18 days ago
     Docs: https://github.com/influxdata/telegraf
 Main PID: 448 (telegraf)
    Tasks: 18 (limit: 4915)
   CGroup: /system.slice/telegraf.service
           └─448 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/te

Jan 29 12:44:30 iot2 telegraf[448]: 2019-01-29T11:44:30Z E! Error in plugin [inputs.mqtt_consume
Jan 29 12:44:30 iot2 telegraf[448]: error: pingresp not received, disconnecting
Jan 29 12:44:30 iot2 telegraf[448]: MQTT Client will try to reconnect
Jan 29 12:44:30 iot2 telegraf[448]: 2019-01-29T11:44:30Z I! MQTT Client Connected
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailabl

so I restarted the service via

tingo@iot2:~$ sudo systemctl restart telegraf

it looks better now

tingo@iot2:~$ systemctl status telegraf
● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
   Loaded: loaded (/lib/systemd/system/telegraf.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-01-29 14:26:32 CET; 8s ago
     Docs: https://github.com/influxdata/telegraf
 Main PID: 29968 (telegraf)
    Tasks: 14 (limit: 4915)
   CGroup: /system.slice/telegraf.service
           ├─29968 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/
           └─29981 /bin/ping -c 1 -n -s 16 -i 1 -W 1 -w 10 10.13.37.47

Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! Loaded aggregators:
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! Loaded processors:
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! Loaded outputs: influxdb
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! Tags enabled: host=iot2
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! Agent Config: Interval:10s, Quiet:
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! MQTT Client Connected
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! MQTT Client Connected
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! MQTT Client Connected
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! MQTT Client Connected
Jan 29 14:26:33 iot2 telegraf[29968]: 2019-01-29T13:26:33Z I! MQTT Client Connected

Maybe telegraf needs to be restarted every time the mqtt server is restarted? Tingo (diskusjon) 29. jan. 2019 kl. 14:32 (CET)

2018-10-12 
grafana-server.service was not enabled on the server, so it didn't start automatically when the server got restarted. Fixed. --Tingo (diskusjon) 12. okt. 2018 kl. 09:16 (UTC)
2018-09-18 
measurement mqtt_consumer i mqtt_bitraf hadde data som ikke var oppdatert, selv om alle de andre i samme database var oppdatert. "Løst" ved å restarte telegraf vha. sudo systemctl restart telegraf. --Tingo (diskusjon) 18. sep. 2018 kl. 14:32 (UTC)

Referanser