bundles/vnstat: add flag to generate statistics images, add to home.router
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
2d856a1e9a
commit
7d78ac9db8
6 changed files with 73 additions and 9 deletions
14
bundles/vnstat/files/generate-vnstati
Normal file
14
bundles/vnstat/files/generate-vnstati
Normal 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
|
14
bundles/vnstat/files/index.html
Normal file
14
bundles/vnstat/files/index.html
Normal 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>
|
|
@ -46,16 +46,15 @@ HourlyRate 1
|
|||
SummaryRate 1
|
||||
SummaryLayout 1
|
||||
TransparentBg 0
|
||||
CBackground "FFFFFF"
|
||||
CEdge "AEAEAE"
|
||||
CHeader "606060"
|
||||
CHeaderTitle "FFFFFF"
|
||||
CHeaderDate "FFFFFF"
|
||||
CText "000000"
|
||||
CBackground "333333"
|
||||
CEdge "444444"
|
||||
CHeader "444444"
|
||||
CHeaderTitle "EDEDED"
|
||||
CHeaderDate "EDEDED"
|
||||
CText "EDEDED"
|
||||
CLine "B0B0B0"
|
||||
CLineL "-"
|
||||
CRx "92CF00"
|
||||
CTx "606060"
|
||||
CRx "009FC5"
|
||||
CTx "85BD00"
|
||||
CRxD "-"
|
||||
CTxD "-"
|
||||
|
||||
|
|
|
@ -6,6 +6,15 @@ files = {
|
|||
'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 = {
|
||||
|
|
|
@ -23,3 +23,23 @@ def get_default_interface(metadata):
|
|||
}
|
||||
|
||||
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': {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ nodes['home.router'] = {
|
|||
'bundles': {
|
||||
'iptables',
|
||||
'netdata',
|
||||
'nginx',
|
||||
'pppd',
|
||||
'radvd',
|
||||
'dhcpd',
|
||||
|
@ -59,6 +60,12 @@ nodes['home.router'] = {
|
|||
'enp1s0.42',
|
||||
},
|
||||
},
|
||||
'nginx': {
|
||||
'use_ssl_for_all_connections': False,
|
||||
'restrict-to-interfaces': {
|
||||
'enp1s0.42',
|
||||
},
|
||||
},
|
||||
'radvd': {
|
||||
'integrate-with-pppd': True,
|
||||
'interfaces': {
|
||||
|
@ -107,6 +114,7 @@ nodes['home.router'] = {
|
|||
},
|
||||
},
|
||||
'vnstat': {
|
||||
'generate-web-dashboard': True,
|
||||
'interface': 'enp1s0.100',
|
||||
},
|
||||
'vm': {
|
||||
|
|
Loading…
Reference in a new issue