grafana, prometheus

This commit is contained in:
bogale 2026-09-28 16:31:13 +09:00
commit 5ee0a9c5cf
6 changed files with 69 additions and 30 deletions

View file

@ -1,12 +1,36 @@
{ config, lib, pkgs, ... }:
{
services = {
prometheus = {
enable = true;
exporters.node.enable = true;
scrapeConfigs = [ {
job_name = "node";
static_configs = [ { targets = [
"localhost:${toString config.services.prometheus.exporters.node.port}"
]; } ];
} ];
};
grafana = {
enable = true;
settings = {
security.secret_key = "$__file{/secrets/grafana-key}";
server = {
enable_gzip = true;
protocol = "socket";
socket_mode = "0666";
root_url = "https://bogaledev.ru/grafana";
};
};
};
};
systemd = {
timers = {
tgbot-send = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*-*-01 16:00:00";
Persistent = true;
OnCalendar = "*-*-01 16:00:00";
};
};
network-watchdog = {
@ -35,7 +59,7 @@
network-watchdog = {
serviceConfig = {
Type = "oneshot";
LogLevelMax = "notice";
LogLevelMax = "warning";
};
script = ''
if [ ! -e /run/network.failures ] || [ ! -e /run/network.limit ] || \
@ -45,12 +69,11 @@
else
limit=$(cat /run/network.limit)
failures=$((1+$(cat /run/network.failures)))
[ $failures -gt 1 ] && echo "<5>failures = $failures"
fi
if [ $failures -ge $limit ]; then
echo "<4>restarting NetworkManager"
systemctl restart NetworkManager.service
[ $limit -lt 60 ] && limit=$((4*$limit/3))
[ $limit -lt 360 ] && limit=$((2*$limit))
failures=0
fi
echo $limit > /run/network.limit