Compare commits

...

2 Commits

Author SHA1 Message Date
d2ad5c31a8 remove deleted files 2025-02-24 01:07:52 -07:00
addd3f4e52 working :) 2025-02-24 01:03:33 -07:00
8 changed files with 51 additions and 92 deletions

View File

@ -1,26 +0,0 @@
{
admin :2019
servers :80 {
name static_site
metrics
}
servers :3000 {
name grafana
metrics
}
}
:80 {
root * /path/to/html
file_server
}
:3000 {
reverse_proxy grafana:3000
}
:3100 {
reverse_proxy loki:3100
}

View File

@ -1,7 +0,0 @@
# Host visability
I would recommend using [this dashboard](https://grafana.com/grafana/dashboards/1860-node-exporter-full/).
Use `docker compose -f node.yml up` on the devices you are monitoring
Use `docker compose up` for the server that's collecting all the logs.

View File

@ -1,12 +0,0 @@
services:
# monitor the host
node_exporter:
image: quay.io/prometheus/node-exporter:latest
command:
- '--path.rootfs=/host'
network_mode: host
# uses port 9100
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro'

View File

@ -1,20 +1,4 @@
services:
# r-proxy
caddy:
image: caddy:latest
restart: unless-stopped
ports:
# HTTP
- 80:80
- 443:443
- '443:443/udp'
# Grafana
- 3000:3000
# Loki
- 3100:3100
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
# Metrics collector
prometheus:
image: prom/prometheus:latest
@ -24,16 +8,8 @@ services:
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
# persist data
- prometheus_storage:/prometheus
depends_on:
- caddy
command: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml
loki:
image: grafana/loki:2.9.2
expose:
- 3100
command: -config.file=/etc/loki/local-config.yaml
# log viewer
grafana:
image: grafana/grafana:latest
@ -45,8 +21,8 @@ services:
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
expose:
- 3000
ports:
- 3000:3000
depends_on:
- prometheus

View File

@ -1,3 +0,0 @@
wget https://git.oliveratkinson.net/Oliver/linux-node-visability/raw/branch/master/compose-node.yml
sudo ufw allow from 10.50.50.0/24 to any port 9100
docker compose -f compose-node.yml up -d

View File

@ -13,12 +13,3 @@ datasources:
editable: false
jsonData:
httpMethod: GET
- name: Loki
type: loki
access: proxy
orgId: 1
url: http://loki:3100
basicAuth: false
isDefault: false
version: 1
editable: false

46
main.py Normal file
View File

@ -0,0 +1,46 @@
import time
import board
import adafruit_dht
from http.server import BaseHTTPRequestHandler, HTTPServer
sensor = adafruit_dht.DHT22(board.D21)
hostName = "0.0.0.0"
serverPort = 7070
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
try:
# Print the values to the serial port
temperature_c = sensor.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = sensor.humidity
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(bytes("# TYPE target_info gauge\n", "utf-8"))
self.wfile.write(bytes("humidity{{location=\"beddroom\"}} {}\n".format(humidity), "utf-8"))
self.wfile.write(bytes("# TYPE temperature gauge\n", "utf-8"))
self.wfile.write(bytes("temperature{{location=\"beddroom\"}} {}\n".format(temperature_f), "utf-8"))
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
self.send_response(500)
print(error.args[0])
except Exception as error:
self.send_response(500)
sensor.exit()
raise error
if __name__ == "__main__":
webServer = HTTPServer((hostName, serverPort), MyServer)
print("Server started http://%s:%s" % (hostName, serverPort))
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")

View File

@ -3,13 +3,7 @@ global:
query_log_file: /etc/prometheus/query.log
scrape_configs:
- job_name: caddy
- job_name: bedroom
static_configs:
- targets: ['caddy:2019']
- job_name: node
static_configs:
# put a list of all the nodes you are monitoring
- targets: ['10.0.0.92:9100']
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- targets: ['192.168.8.79:7070']