2021-01-16 21:21:27 +00:00
|
|
|
from os.path import join
|
|
|
|
|
2021-02-12 19:37:36 +00:00
|
|
|
check_commands = {}
|
2020-11-09 19:31:06 +00:00
|
|
|
|
2021-02-12 19:37:36 +00:00
|
|
|
for _, bundle_config in node.metadata.get('icinga2_api', {}).items():
|
|
|
|
for service, service_config in bundle_config.get('services', {}).items():
|
|
|
|
# The default for check_command is also set in metadata.py
|
|
|
|
# and in icinga2 bundle
|
|
|
|
if (
|
|
|
|
service_config.get('check_command', 'sshmon') == 'sshmon' and
|
|
|
|
'vars.sshmon_command' in service_config and
|
|
|
|
'command_on_monitored_host' in service_config
|
|
|
|
):
|
|
|
|
check_commands[service_config['vars.sshmon_command']] = service_config['command_on_monitored_host']
|
2020-11-09 19:31:06 +00:00
|
|
|
|
|
|
|
|
2021-01-16 21:21:27 +00:00
|
|
|
users = {
|
|
|
|
'sshmon': {
|
|
|
|
'password_hash': 'x',
|
|
|
|
'home': '/home/sshmon',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
with open(join(repo.path, 'data', 'sshmon', 'sshmon.pub'), 'r') as fp:
|
|
|
|
pubkey = fp.read().strip()
|
|
|
|
|
2020-11-09 19:31:06 +00:00
|
|
|
files = {
|
|
|
|
'/etc/sshmon.cfg': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'check_commands': check_commands,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/etc/sudoers.d/sshmon': {
|
|
|
|
'source': 'sudoers',
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'check_commands': check_commands,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/usr/local/sbin/sshmon': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2021-01-16 21:21:27 +00:00
|
|
|
'/home/sshmon/.ssh/authorized_keys': {
|
|
|
|
'content': 'command="/usr/local/sbin/sshmon" {}\n'.format(pubkey),
|
|
|
|
'owner': 'sshmon',
|
|
|
|
'mode': '0400',
|
|
|
|
},
|
2020-11-09 19:31:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for check in {
|
|
|
|
'cpu_stats',
|
|
|
|
'mounts',
|
|
|
|
'ram',
|
2020-11-21 19:03:50 +00:00
|
|
|
'github_for_new_release',
|
2020-11-09 19:31:06 +00:00
|
|
|
'http_url_for_string',
|
|
|
|
'https_certificate_at_url',
|
|
|
|
'http_wget',
|
|
|
|
'systemd_unit',
|
|
|
|
}:
|
|
|
|
files["/usr/local/share/icinga/plugins/check_{}".format(check)] = {
|
|
|
|
'mode': "0755",
|
|
|
|
}
|
2021-06-28 17:59:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
if node.has_bundle('pacman'):
|
|
|
|
symlinks['/usr/lib/nagios/plugins'] = {
|
|
|
|
'target': '/usr/lib/monitoring-plugins',
|
|
|
|
'needs': {
|
|
|
|
'pkg_pacman:monitoring-plugins',
|
|
|
|
},
|
|
|
|
}
|