def do_status_events_list(sc, args): """List all events.""" arg_names = ['host_name', 'service_description', 'event_type', 'start_time', 'end_time', 'page_size', 'page', 'live_query'] arg = _dict_from_args(args, arg_names) events = sc.status.events.list(**arg) if args.json: print(utils.json_formatter(events)) else: cols = utils.get_columns(events, ['host_name', 'service_description', 'event_type']) formatters = reduce(_create_format, cols, {}) utils.print_list(events, cols, formatters=formatters)
def do_status_host_show(sc, args): host = sc.status.hosts.get(args.host_name) if args.json: print(utils.json_formatter(host)) elif host: hostProperties = [ 'host_name', 'address', 'state', 'last_check', 'last_state_change', 'long_output', 'description', 'acknowledged', 'plugin_output', 'services', 'childs', 'parents', ] utils.print_item(host, hostProperties)
def do_config_command_show(sc, args): """Show a specific command.""" command = sc.config.commands.get(args.command_name) if args.json: print(utils.json_formatter(command)) elif command: """ Specify the shown order and all the properties to display """ command_properties = [ 'command_name', 'command_line' ] utils.print_item(command, command_properties)
def do_config_host_show(sc, args): """Show a specific host.""" host = sc.config.hosts.get(args.host_name) if args.json: print(utils.json_formatter(host)) elif host: """ Specify the shown order and all the properties to display """ hostProperties = [ 'host_name', 'address', 'check_period', 'contact_groups', 'contacts', 'custom_fields', 'max_check_attempts', 'notification_interval', 'notification_period', 'use' ] utils.print_item(host, hostProperties)
def do_config_host_list(sc, args): """List all config hosts.""" hosts = sc.config.hosts.list() if args.json: print(utils.json_formatter(hosts)) else: cols = [ 'host_name', 'address', ] formatters = { 'host_name': lambda x: x.get('host_name', ''), 'address': lambda x: x.get('address', '') } utils.print_list(hosts, cols, formatters=formatters)
def do_config_command_list(sc, args): """List all config commands.""" commands = sc.config.commands.list() if args.json: print(utils.json_formatter(commands)) else: cols = [ 'command_name', 'command_line' ] formatters = { 'command_name': lambda x: x.get('command_name', ''), 'command_line': lambda x: x.get('command_line', ''), } utils.print_list(commands, cols, formatters=formatters)
def do_host_list(sc, args): """List all hosts.""" hosts = sc.hosts.list() if args.json: print(utils.json_formatter(hosts)) else: cols = [ 'host_name', 'address', ] formatters = { 'host_name': lambda x: x['host_name'], 'address': lambda x: x['address'], } utils.print_list(hosts, cols, formatters=formatters)
def do_config_checkmodulation_list(sc, args): """List all config check modulations.""" checkmodulations = sc.config.checkmodulations.list() if args.json: print(utils.json_formatter(checkmodulations)) else: cols = [ 'check_command', 'check_period', 'checkmodulation_name' ] formatters = { 'check_command': lambda x: x.get('check_command', ''), 'check_period': lambda x: x.get('check_period', ''), 'checkmodulation_name': lambda x: x.get('checkmodulation_name', ''), } utils.print_list(checkmodulations, cols, formatters=formatters)
def do_status_metrics_show(sc, args): """Give the last status metrics.""" arg_names = ['host_name', 'metric_name', 'service_description', ] arg = _dict_from_args(args, arg_names) metrics = sc.status.hosts.metrics.get(**arg) if args.json: print(utils.json_formatter(metrics)) else: if isinstance(metrics, dict): metrics = [metrics] cols = utils.get_columns(metrics, ['metric_name', ]) formatters = reduce(_create_format, cols, {}) utils.print_list(metrics, cols, formatters=formatters)
def do_status_metrics_list(sc, args): """List all status metrics.""" arg_names = ['host_name', 'metric_name', 'start_time', 'end_time', 'service_description', 'live_query', 'page_size', 'page', ] arg = _dict_from_args(args, arg_names) metrics = sc.status.hosts.metrics.list(**arg) if args.json: print(utils.json_formatter(metrics)) else: cols = utils.get_columns(metrics, []) formatters = reduce(_create_format, cols, {}) utils.print_list(metrics, cols, formatters=formatters)
def do_config_service_list(sc, args): """List all config services.""" services = sc.config.services.list() if args.json: print(utils.json_formatter(services)) else: cols = [ 'host_name', 'service_description', 'check_period', 'contact_groups', ] formatters = { 'service_description': lambda x: x.get('service_description', ''), 'host_name': lambda x: x.get('host_name', ''), 'check_period': lambda x: x.get('check_period', ''), 'contact_groups': lambda x: x.get('contact_groups', ''), } utils.print_list(services, cols, formatters=formatters)
def do_status_service_list(sc, args): """List all status services.""" services = sc.status.services.list() if args.json: print(utils.json_formatter(services)) else: cols = [ 'host_name', 'service_description', 'state', 'last_check', 'plugin_output', ] formatters = { 'host_name': lambda x: x.get('host_name', ''), 'service_description': lambda x: x.get('service_description', ''), 'state': lambda x: x.get('state', ''), 'last_check': lambda x: x.get('last_check', ''), 'plugin_output': lambda x: x.get('plugin_output', '')[0:30], } utils.print_list(services, cols, formatters=formatters)
def do_status_host_list(sc, args): """List all status hosts.""" services = sc.status.hosts.list() if args.json: print(utils.json_formatter(services)) else: cols = [ 'host_name', 'address', 'state', 'last_check', 'plugin_output', ] formatters = { 'host_name': lambda x: x.get('host_name', ''), 'address': lambda x: x.get('address', ''), 'state': lambda x: x.get('state', ''), 'last_check': lambda x: x.get('last_check', ''), 'plugin_output': lambda x: x.get('plugin_output', '')[0:30] + '...', } utils.print_list(services, cols, formatters=formatters)