bundlewrap/bundles/vnstat/metadata.py

46 lines
1.1 KiB
Python

defaults = {
'apt': {
'packages': {
'vnstat': {},
'vnstati': {},
},
},
'vnstat': {
'bandwidth': '1000',
},
}
@metadata_reactor
def get_default_interface(metadata):
interfaces = sorted(metadata.get('interfaces', {}).keys())
if len(interfaces):
return {
'vnstat': {
'interface': interfaces[0],
},
}
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_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': {},
},
},
}