SQLite durch PostgreSQL + TimescaleDB ersetzt
- Backend DB komplett auf PostgreSQL 17 + TimescaleDB 2.25.1 umgestellt - pgx pure-Go Driver (kein CGO), modernc/sqlite entfernt - Hypertable 'metrics' fuer Time-Series Daten - Automatische Metrik-Extraktion bei jedem Heartbeat: CPU, RAM, Uptime, Disk, Network-Traffic, Gateway RTT/Loss - Retention Policy: 90 Tage, Compression nach 7 Tagen - Neue API-Endpoints: GET /metrics (raw) + GET /metrics/summary (aggregiert) - time_bucket() Aggregation (5min, 1h, etc.) - config.yaml: database-Block statt db_path - docs/POSTGRES_SETUP.md: Installationsanleitung - README aktualisiert
This commit is contained in:
@@ -3,15 +3,17 @@ package config
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/cynfo/rmm-backend/db"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ListenAddr string `yaml:"listen_addr"`
|
||||
TLSCert string `yaml:"tls_cert"`
|
||||
TLSKey string `yaml:"tls_key"`
|
||||
APIKeys []string `yaml:"api_keys"`
|
||||
DBPath string `yaml:"db_path"`
|
||||
ListenAddr string `yaml:"listen_addr"`
|
||||
TLSCert string `yaml:"tls_cert"`
|
||||
TLSKey string `yaml:"tls_key"`
|
||||
APIKeys []string `yaml:"api_keys"`
|
||||
Database db.DBConfig `yaml:"database"`
|
||||
}
|
||||
|
||||
func Load(path string) (*Config, error) {
|
||||
@@ -19,7 +21,14 @@ func Load(path string) (*Config, error) {
|
||||
ListenAddr: ":8443",
|
||||
TLSCert: "certs/server.crt",
|
||||
TLSKey: "certs/server.key",
|
||||
DBPath: "rmm.db",
|
||||
Database: db.DBConfig{
|
||||
Host: "127.0.0.1",
|
||||
Port: 5432,
|
||||
User: "rmm",
|
||||
Password: "",
|
||||
DBName: "rmm",
|
||||
SSLMode: "disable",
|
||||
},
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(path)
|
||||
@@ -41,8 +50,11 @@ func Load(path string) (*Config, error) {
|
||||
if v := os.Getenv("RMM_TLS_KEY"); v != "" {
|
||||
cfg.TLSKey = v
|
||||
}
|
||||
if v := os.Getenv("RMM_DB_PATH"); v != "" {
|
||||
cfg.DBPath = v
|
||||
if v := os.Getenv("RMM_DB_HOST"); v != "" {
|
||||
cfg.Database.Host = v
|
||||
}
|
||||
if v := os.Getenv("RMM_DB_PASSWORD"); v != "" {
|
||||
cfg.Database.Password = v
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user