Add install_collectd() function

This commit is contained in:
Lance Edgar 2023-02-19 10:38:43 -06:00
parent 6c78d3c1d5
commit bdd89db30d

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -24,12 +24,44 @@
Fabric library for collectd
"""
from rattail_fabric2 import make_deploy
from rattail_fabric2 import apt, make_deploy, sed
deploy = make_deploy(__file__)
def install_collectd(c, interval=None, rrdtool=None, restart_=False):
"""
Install the ``collectd`` service.
:param interval: Optional override for the collectd ``Interval``
setting.
"""
apt.install(c, 'collectd')
if interval:
sed(c, '/etc/collectd/collectd.conf',
r'^#? ?Interval\s+[0-9]+.*$',
'Interval {}'.format(interval),
use_sudo=True)
if rrdtool is not None:
sed(c, '/etc/collectd/collectd.conf',
r'^#? ?LoadPlugin rrdtool\s*$',
'{}LoadPlugin rrdtool'.format('' if rrdtool else '#'),
use_sudo=True)
if restart_:
restart(c)
def restart(c):
"""
Restart the collectd service.
"""
c.sudo('systemctl restart collectd')
def deploy_mountpoint_check_script(c, dest, **kwargs):
"""
Deploy generic mountpoint check script to specified destination.