/
rustwizard
/
pgtrace
Обзор
Документация
Войти
/
rustwizard
/
pgtrace
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
deploy/systemd/pgtrace.service
56 строк
2 KB
Rust Wizard
feat: systemd unit for the agent with journald insight logging
08 авг 2026, 11:26
Верифицирован
08 авг 2026, 11:26
5847ae8
Код
Авторство
О чём код?
# pgtrace agent systemd unit. # # Install: # sudo install -m 644 deploy/systemd/pgtrace.service /etc/systemd/system/ # sudo install -m 755 bin/pgtrace /usr/local/bin/pgtrace # sudo systemctl daemon-reload # sudo systemctl enable --now pgtrace # # Configure via EnvironmentFile=/etc/pgtrace.env (created by you): # PGT_DATABASE_URL=postgres://postgres@localhost/pgbench # PGT_THRESHOLD=1ms # PGT_OFFCPU_THRESHOLD=500us # PGT_WINDOW=10s # PGT_HTTP_ADDR=:9092 [Unit] Description=PostgreSQL Kernel Tracer (pgtrace agent) Documentation=https://github.com/rustwizard/pgtrace After=network.target postgresql.service Wants=postgresql.service [Service] Type=simple # BPF tracing needs root (CAP_BPF/CAP_PERFMON on modern kernels). User=root Group=root EnvironmentFile=-/etc/pgtrace.env Environment=PGT_DATABASE_URL=postgres://localhost/postgres Environment=PGT_THRESHOLD=1ms Environment=PGT_OFFCPU_THRESHOLD=500us Environment=PGT_WINDOW=10s Environment=PGT_HTTP_ADDR=:9092 ExecStart=/usr/local/bin/pgtrace agent \ --dsn "${PGT_DATABASE_URL}" \ --threshold "${PGT_THRESHOLD}" \ --offcpu-threshold "${PGT_OFFCPU_THRESHOLD}" \ --window "${PGT_WINDOW}" \ --http "${PGT_HTTP_ADDR}" Restart=on-failure RestartSec=5s # Journald captures stdout/stderr; insight lines land in the journal. StandardOutput=journal StandardError=journal # Sandboxing (kept compatible with BPF which needs /sys, /proc and tracefs). NoNewPrivileges=yes ProtectSystem=full ProtectHome=yes PrivateTmp=yes [Install] WantedBy=multi-user.target