diff --git a/bundles/vnstat/files/generate-vnstati b/bundles/vnstat/files/generate-vnstati index 797c10c..c1319d7 100644 --- a/bundles/vnstat/files/generate-vnstati +++ b/bundles/vnstat/files/generate-vnstati @@ -8,7 +8,9 @@ then exit 1 fi -vnstati --output "$TARGET/daily.png" --days -vnstati --output "$TARGET/monthly.png" --months +vnstati --output "$TARGET/summary.png" --summary +vnstati --output "$TARGET/top10.png" --top 10 +vnstati --output "$TARGET/hours.png" --hoursgraph +vnstati --output "$TARGET/daily.png" --days 30 +vnstati --output "$TARGET/monthly.png" --months 12 vnstati --output "$TARGET/yearly.png" --years -vnstati --output "$TARGET/top10.png" --top10 diff --git a/bundles/vnstat/files/index.html b/bundles/vnstat/files/index.html index 8f1892c..5027a38 100644 --- a/bundles/vnstat/files/index.html +++ b/bundles/vnstat/files/index.html @@ -6,11 +6,12 @@

${node.name} - ${interface}

-

TOP 10 Days

-

Statistics for yesterday

-

Daily Statistics

-

monthly Statistics

-

+

Short summary

+

Top 10 days

+

Statistics for last 24h

+

Statistics for last 30 days

+

Statistics for last 12 months

+

Yearly Statistics

All times in UTC

diff --git a/bundles/vnstat/files/vnstati.service b/bundles/vnstat/files/vnstati.service new file mode 100644 index 0000000..95410d0 --- /dev/null +++ b/bundles/vnstat/files/vnstati.service @@ -0,0 +1,8 @@ +[Unit] +Description=vnstati generator +After=network.target + +[Service] +User=root +Group=root +ExecStart=/usr/local/bin/generate-vnstati /var/www/vnstat diff --git a/bundles/vnstat/files/vnstati.timer b/bundles/vnstat/files/vnstati.timer new file mode 100644 index 0000000..9a8a3b8 --- /dev/null +++ b/bundles/vnstat/files/vnstati.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Generate vnstati graphs + +[Timer] +OnCalendar=*:0/10 +Persistent=false + +[Install] +WantedBy=timers.target diff --git a/bundles/vnstat/items.py b/bundles/vnstat/items.py index 7458341..cc9953d 100644 --- a/bundles/vnstat/items.py +++ b/bundles/vnstat/items.py @@ -1,4 +1,6 @@ files = { + '/etc/systemd/system/vnstati.service': {}, + '/etc/systemd/system/vnstati.timer': {}, '/etc/vnstat.conf': { 'content_type': 'mako', 'context': node.metadata['vnstat'], @@ -11,7 +13,7 @@ files = { }, } -if node.metadata['vnstat'].get('generate-web-dashboard', False): +if node.metadata.get('vnstat/generate-web-dashboard', False): files['/var/www/vnstat/index.html'] = { 'content_type': 'mako', 'context': node.metadata['vnstat'], @@ -24,4 +26,12 @@ svc_systemd = { '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), + }, } diff --git a/bundles/vnstat/metadata.py b/bundles/vnstat/metadata.py index 0b3699c..1b83dd7 100644 --- a/bundles/vnstat/metadata.py +++ b/bundles/vnstat/metadata.py @@ -34,27 +34,3 @@ def get_default_interface(metadata): } return {} - - -@metadata_reactor.provides( - 'cron', - 'nginx/vhosts/vnstat', -) -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_yesterday_graph': '0 0 * * * root /usr/bin/vnstati --output "/var/www/vnstat/yesterday.png" --hours > /dev/null 2>/dev/null', - 'vnstat_generate_web_dashboard': '*/10 * * * * root /usr/local/bin/generate-vnstati /var/www/vnstat > /dev/null 2>/dev/null', - }, - 'nginx': { - 'vhosts': { - 'vnstat': {}, - }, - }, - }