bundles/vnstat: add flag to generate statistics images, add to home.router
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2020-11-16 17:07:05 +01:00
parent 2d856a1e9a
commit 7d78ac9db8
Signed by: kunsi
GPG key ID: 12E3D2136B818350
6 changed files with 73 additions and 9 deletions

View file

@ -0,0 +1,14 @@
#!/bin/bash
TARGET=$1
if [[ -z "$TARGET" ]]
then
echo "Usage: $0 <TARGET_DIR>"
exit 1
fi
vnstati --output "$TARGET/daily.png" --days
vnstati --output "$TARGET/monthly.png" --months
vnstati --output "$TARGET/yearly.png" --years
vnstati --output "$TARGET/top10.png" --top10

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>${node.name} - ${interface}</title>
</head>
<body style="background-color: #333333; color: #FFFFFF; text-align: center;">
<h1>${node.name} - ${interface}</h1>
<p><img src="/top10.png" alt="TOP 10 Days"></p>
<p><img src="/daily.png" alt="Daily Statistics"></p>
<p><img src="/monthly.png" alt="monthly Statistics"></p>
<p><img src="/yearly.png" alt=""></p>
<p>All times in UTC</p>
</body>
</html>

View file

@ -46,16 +46,15 @@ HourlyRate 1
SummaryRate 1 SummaryRate 1
SummaryLayout 1 SummaryLayout 1
TransparentBg 0 TransparentBg 0
CBackground "FFFFFF" CBackground "333333"
CEdge "AEAEAE" CEdge "444444"
CHeader "606060" CHeader "444444"
CHeaderTitle "FFFFFF" CHeaderTitle "EDEDED"
CHeaderDate "FFFFFF" CHeaderDate "EDEDED"
CText "000000" CText "EDEDED"
CLine "B0B0B0" CLine "B0B0B0"
CLineL "-" CLineL "-"
CRx "92CF00" CRx "009FC5"
CTx "606060" CTx "85BD00"
CRxD "-" CRxD "-"
CTxD "-" CTxD "-"

View file

@ -6,8 +6,17 @@ files = {
'svc_systemd:vnstat:restart', 'svc_systemd:vnstat:restart',
}, },
}, },
'/usr/local/bin/generate-vnstati': {
'mode': '0755',
},
} }
if node.metadata['vnstat'].get('generate-web-dashboard', False):
files['/var/www/vnstat/index.html'] = {
'content_type': 'mako',
'context': node.metadata['vnstat'],
}
svc_systemd = { svc_systemd = {
'vnstat': { 'vnstat': {
'needs': { 'needs': {

View file

@ -23,3 +23,23 @@ def get_default_interface(metadata):
} }
return {} return {}
@metadata_reactor
def nginx_dashboard(metadata):
if not node.has_bundle('nginx'):
raise DoNotRunAgain
if not metadata.get('vnstat/generate-web-dashboard', False):
return {}
return {
'cron': {
'vnstat_generate_web_dashboard': '*/10 * * * * root /usr/local/bin/generate-vnstati /var/www/vnstat',
},
'nginx': {
'vhosts': {
'vnstat': {},
},
},
}

View file

@ -5,6 +5,7 @@ nodes['home.router'] = {
'bundles': { 'bundles': {
'iptables', 'iptables',
'netdata', 'netdata',
'nginx',
'pppd', 'pppd',
'radvd', 'radvd',
'dhcpd', 'dhcpd',
@ -59,6 +60,12 @@ nodes['home.router'] = {
'enp1s0.42', 'enp1s0.42',
}, },
}, },
'nginx': {
'use_ssl_for_all_connections': False,
'restrict-to-interfaces': {
'enp1s0.42',
},
},
'radvd': { 'radvd': {
'integrate-with-pppd': True, 'integrate-with-pppd': True,
'interfaces': { 'interfaces': {
@ -107,6 +114,7 @@ nodes['home.router'] = {
}, },
}, },
'vnstat': { 'vnstat': {
'generate-web-dashboard': True,
'interface': 'enp1s0.100', 'interface': 'enp1s0.100',
}, },
'vm': { 'vm': {