forked from zentralwerk/network
nixos-module/collectd: add unbound.rb
This commit is contained in:
parent
52cac17f16
commit
e79bb4e297
|
@ -66,6 +66,10 @@ in
|
|||
in ''
|
||||
Exec "collectd" "${pkgs.ruby}/bin/ruby" "${./dhcpcount.rb}" "${toString maxTimeout}"
|
||||
'';
|
||||
}) (lib.optionalAttrs config.services.unbound.enable {
|
||||
exec = ''
|
||||
Exec "collectd" "${pkgs.ruby}/bin/ruby" "${./unbound.rb}"
|
||||
'';
|
||||
}) ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
loop do
|
||||
`/run/current-system/sw/bin/unbound-control stats_noreset`
|
||||
.lines
|
||||
.filter { |l| l =~ /^total\./ }
|
||||
.each { |l|
|
||||
if l =~ /total\.(.+?)=([\d\.]+)/
|
||||
name = $1
|
||||
value = $2.to_f
|
||||
if name =~ /\.avg$/ || name =~ /\.median$/ || name =~ /\.max$/ || name =~ /\.min$/
|
||||
ty = "gauge"
|
||||
else
|
||||
ty = "derive"
|
||||
value = value.to_i
|
||||
end
|
||||
puts "PUTVAL dnscache/unbound/#{ty}-#{name} N:#{value}"
|
||||
end
|
||||
}
|
||||
|
||||
sleep 10
|
||||
end
|
|
@ -19,6 +19,10 @@ lib.mkIf config.site.hosts.${hostName}.services.dnscache.enable {
|
|||
"127.0.0.0/8"
|
||||
];
|
||||
extraConfig = ''
|
||||
remote-control:
|
||||
control-enable: yes
|
||||
control-use-cert: no
|
||||
|
||||
forward-zone:
|
||||
name: "."
|
||||
forward-tls-upstream: yes
|
||||
|
|
Loading…
Reference in New Issue