nix/pkgs: add ap_install_collectd.sh

This commit is contained in:
Astro 2021-04-25 23:53:38 +02:00
parent d57496701d
commit 60758b448a
2 changed files with 37 additions and 0 deletions

34
nix/pkgs/ap_install_collectd.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
for HOST in $@ ; do
ssh root@$HOST \
"ash -e -x" <<__SSH__
opkg update
opkg install collectd collectd-mod-interface collectd-mod-load collectd-mod-cpu collectd-mod-iwinfo collectd-mod-network
cat > /etc/collectd.conf <<EOF
Hostname "\$HOSTNAME"
FQDNLookup false
Interval 10
BaseDir "/var/run/collectd"
Include "/etc/collectd/conf.d"
PIDFile "/var/run/collectd.pid"
PluginDir "/usr/lib/collectd"
TypesDB "/usr/share/collectd/types.db"
LoadPlugin cpu
LoadPlugin load
LoadPlugin interface
LoadPlugin iwinfo
LoadPlugin network
<Plugin network>
Server "{{STATS}}" "25826"
</Plugin>
EOF
/etc/init.d/collectd restart
/etc/init.d/collectd enable
__SSH__
done

View File

@ -37,6 +37,9 @@ let
pkgs.runCommandLocal "all-device-scripts" {} (
''
mkdir -p $out/bin
substitute ${./ap_install_collectd.sh} $out/bin/ap_install_collectd.sh \
--replace "{{STATS}}" "${config.site.net.serv.hosts6.dn42.stats}"
'' +
builtins.concatStringsSep "\n" (
map (hostname: