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 #!/bin/bash
TARGET=$1 set -xeuo pipefail
if [[ -z "$TARGET" ]] TARGET="/var/www/vnstat"
then
echo "Usage: $0 <TARGET_DIR>"
exit 1
fi
vnstati --output "$TARGET/summary.png" --summary vnstati --output "$TARGET/summary.png" --summary
vnstati --output "$TARGET/top10.png" --top 10 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 = { files['/etc/systemd/system/vnstat.override.d/bundlewrap.conf'] = {
'/etc/systemd/system/vnstati.service': { 'source': 'override.conf',
'triggers': { 'triggers': {
'action:systemd-reload', 'action:systemd-reload',
}, 'svc_systemd:vnstat:restart',
},
'/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',
}, },
} }
if node.metadata.get('vnstat/generate-web-dashboard', False): files['/etc/vnstat.conf'] = {
files['/var/www/vnstat/index.html'] = { 'content_type': 'mako',
'content_type': 'mako', 'context': node.metadata['vnstat'],
'context': node.metadata['vnstat'], 'triggers': {
} 'svc_systemd:vnstat:restart',
},
svc_systemd = { }
'vnstat': {
'needs': { files['/usr/local/bin/generate-vnstati'] = {
'pkg_apt:vnstat', 'mode': '0755',
'file:/etc/vnstat.conf', }
},
}, files['/var/www/vnstat/index.html'] = {
'vnstati.timer': { 'content_type': 'mako',
'needs': { 'context': node.metadata['vnstat'],
'file:/etc/systemd/system/vnstati.service', }
'file:/etc/systemd/system/vnstati.timer',
}, svc_systemd['vnstat'] = {
'running': node.metadata.get('vnstat/generate-web-dashboard', False), 'needs': {
'enabled': node.metadata.get('vnstat/generate-web-dashboard', False), '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': { 'vnstat': {
'bandwidth': '1000', 'bandwidth': '1000',
}, },

View file

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