bundles/vnstat: rework bundle

This commit is contained in:
Franzi 2022-12-12 07:56:23 +01:00
parent 9c8523ab49
commit f790e2cee0
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 48 additions and 47 deletions

View file

@ -1,12 +1,8 @@
#!/bin/bash
TARGET=$1
set -xeuo pipefail
if [[ -z "$TARGET" ]]
then
echo "Usage: $0 <TARGET_DIR>"
exit 1
fi
TARGET="/var/www/vnstat"
vnstati --output "$TARGET/summary.png" --summary
vnstati --output "$TARGET/top10.png" --top 10

View file

@ -0,0 +1,6 @@
[Service]
ExecStart=
# --nodaemon is default. We also want --alwaysadd to include newly
# created interfaces, for example when adding vlans to the machine.
ExecStart=/usr/sbin/vnstatd --alwaysadd --nodaemon

View file

@ -1,45 +1,32 @@
files = {
'/etc/systemd/system/vnstati.service': {
'triggers': {
'action:systemd-reload',
},
},
'/etc/systemd/system/vnstati.timer': {
'triggers': {
'action:systemd-reload',
},
},
'/etc/vnstat.conf': {
'content_type': 'mako',
'context': node.metadata['vnstat'],
'triggers': {
'svc_systemd:vnstat:restart',
},
},
'/usr/local/bin/generate-vnstati': {
'mode': '0755',
files['/etc/systemd/system/vnstat.override.d/bundlewrap.conf'] = {
'source': 'override.conf',
'triggers': {
'action:systemd-reload',
'svc_systemd:vnstat:restart',
},
}
if node.metadata.get('vnstat/generate-web-dashboard', False):
files['/var/www/vnstat/index.html'] = {
'content_type': 'mako',
'context': node.metadata['vnstat'],
}
svc_systemd = {
'vnstat': {
'needs': {
'pkg_apt:vnstat',
'file:/etc/vnstat.conf',
},
},
'vnstati.timer': {
'needs': {
'file:/etc/systemd/system/vnstati.service',
'file:/etc/systemd/system/vnstati.timer',
},
'running': node.metadata.get('vnstat/generate-web-dashboard', False),
'enabled': node.metadata.get('vnstat/generate-web-dashboard', False),
files['/etc/vnstat.conf'] = {
'content_type': 'mako',
'context': node.metadata['vnstat'],
'triggers': {
'svc_systemd:vnstat:restart',
},
}
files['/usr/local/bin/generate-vnstati'] = {
'mode': '0755',
}
files['/var/www/vnstat/index.html'] = {
'content_type': 'mako',
'context': node.metadata['vnstat'],
}
svc_systemd['vnstat'] = {
'needs': {
'file:/etc/systemd/system/vnstat.override.d/bundlewrap.conf',
'file:/etc/vnstat.conf',
'pkg_apt:vnstat',
},
}

View file

@ -14,6 +14,19 @@ defaults = {
},
},
},
'nginx': {
'vhosts': {
'vnstat': {},
},
},
'systemd-timers': {
'timers': {
'vnstat-generate-vnstati': {
'when': '*:0/10',
'command': '/usr/local/bin/generate-vnstati',
},
},
},
'vnstat': {
'bandwidth': '1000',
},

View file

@ -161,7 +161,6 @@ nodes['home.router'] = {
},
},
'vnstat': {
'generate-web-dashboard': True,
'interface': 'enp1s0.100',
},
'vm': {