Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/planetteamspeakk/metrics
Source code for my Grafana metrics
https://github.com/planetteamspeakk/metrics
Last synced: about 2 months ago
JSON representation
Source code for my Grafana metrics
- Host: GitHub
- URL: https://github.com/planetteamspeakk/metrics
- Owner: PlanetTeamSpeakk
- Created: 2022-07-18T14:16:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-21T19:50:25.000Z (12 months ago)
- Last Synced: 2024-05-01T14:52:35.189Z (8 months ago)
- Language: Python
- Homepage: https://graphs.planetteamspeak.dev
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Metrics
Source code of my metrics scripts for Grafana.Instruments used:
- [Raspberry Pi 4B 4gb](https://www.raspberrypi.com/products/raspberry-pi-4-model-b/) to run the scripts and power the instruments
- [Adafruit DHT22](https://www.adafruit.com/product/385) for temperature and humidity
- [Winsen MH-Z19C (with pins)](https://www.winsen-sensor.com/sensors/co2-sensor/mh-z19c.html) for carbon dioxide levels
- [Shelly Plug S](https://shelly.cloud/products/shelly-plug-s-smart-home-automation-device/) for power usage# Why?
Honestly just because I could.
The Pi is used for multiple things (like hosting some of my sites), not just metrics. The metrics, however, are mostly for fun.# Creds
For obvious reasons, there are some secret constants in this project, these are stored in a file in the root directory named `creds.py`
which looks like this:
```py
DB_USER = "grafana-write"
DB_PASS = "password"
DB_HOST = "localhost"
DB_NAME = "grafana"CF_API_KEY = "key" # CurseForge API key: https://console.curseforge.com/?#/api-keys
SHELLY_IP = "ip" # IP address of the Shelly Plug S
SHELLY_AUTH = "base64 encoded username:password"OWM_API_KEY = "key" # OpenWeatherMap API key: https://home.openweathermap.org/api_keys
LAT = "latitude" # Home latitude, from Google Maps
LON = "longitude" # Home longitude, from Google Maps
```# Tables
Every module has its own table, so here's a table of all tables:
| Module | Table | Query |
|-------------- |-------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CF Downloads | cf_downloads | `CREATE TABLE cf_downloads (time timestamp NOT NULL DEFAULT current_timestamp(), downloads int(11) DEFAULT NULL, KEY time (time))` |
| CO2 | co2 | `CREATE TABLE co2 (time timestamp NOT NULL DEFAULT current_timestamp(), co2 int(11) NOT NULL, KEY time (time))` |
| Humitemp | humitemp | `CREATE TABLE humitemp (time timestamp NOT NULL DEFAULT current_timestamp(), temperature float DEFAULT NULL, humidity float DEFAULT NULL, KEY time (time))` |
| Pi Temp | pi_temp | `CREATE TABLE pi_temp (time timestamp NOT NULL DEFAULT current_timestamp(), temp float NOT NULL, KEY time (time))` |
| Weather | weather | `CREATE TABLE weather (time timestamp NOT NULL DEFAULT current_timestamp(), description text NOT NULL, temp float NOT NULL, feels_like float NOT NULL, temp_min float NOT NULL, temp_max float NOT NULL, pressure smallint(6) NOT NULL, humidity tinyint(4) NOT NULL, wind_speed float NOT NULL, wind_angle smallint(6) NOT NULL, clouds tinyint(4) NOT NULL, icon char(3) NOT NULL, sunrise timestamp NOT NULL, sunset timestamp NOT NULL, timezone smallint(6) NOT NULL, KEY time (time))` |
| Power | power | `CREATE TABLE power (time timestamp NOT NULL DEFAULT current_timestamp(), power_use float NOT NULL, used float NOT NULL, KEY time (time))` |