def collect_commands(): check_commands = {} for bundle, 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'] return check_commands pkg_apt = { 'gawk': {}, # needed by check_ram 'libwww-perl': {}, # needed by check_nginx_status 'sysstat': {}, # needed by check_cpu_stats 'monitoring-plugins': {}, } check_commands = collect_commands() 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', }, } for check in { 'cpu_stats', 'mounts', 'ram', 'http_url_for_string', 'https_certificate_at_url', 'http_wget', 'systemd_unit', }: files["/usr/local/share/icinga/plugins/check_{}".format(check)] = { 'mode': "0755", }