bundles/vnstat: rework bundle
This commit is contained in:
parent
9c8523ab49
commit
f790e2cee0
5 changed files with 48 additions and 47 deletions
|
@ -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
|
||||
|
|
6
bundles/vnstat/files/override.conf
Normal file
6
bundles/vnstat/files/override.conf
Normal 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
|
|
@ -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',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
|
|
|
@ -161,7 +161,6 @@ nodes['home.router'] = {
|
|||
},
|
||||
},
|
||||
'vnstat': {
|
||||
'generate-web-dashboard': True,
|
||||
'interface': 'enp1s0.100',
|
||||
},
|
||||
'vm': {
|
||||
|
|
Loading…
Reference in a new issue