def check(args): """ Check if the server configuration is working. This command returns success if every checks pass, or failure if any of these fails """ if args.nagios: output.set_output_writer(output.NagiosOutputWriter()) servers = get_server_list(args) for name in sorted(servers): server = servers[name] # Validate the returned server if not manage_server_command(server, name, skip_inactive=False, skip_disabled=False, disabled_is_error=False): continue output.init('check', name, server.config.active, server.config.disabled) with closing(server): server.check() output.close_and_exit()
def show_server(args): """ Show all configuration parameters for the specified servers """ servers = get_server_list(args) for name in sorted(servers): server = servers[name] # Skip the server (apply general rule) if not manage_server_command(server, name, skip_inactive=False, skip_disabled=False, disabled_is_error=False): continue # If the server has been manually disabled if not server.config.active: name += " (inactive)" # If server has configuration errors elif server.config.disabled: name += " (WARNING: disabled)" output.init('show_server', name) with closing(server): server.show() output.close_and_exit()
def list_server(minimal=False): """ List available servers, with useful information """ # Get every server, both inactive and temporarily disabled servers = get_server_list() for name in sorted(servers): server = servers[name] # Exception: manage_server_command is not invoked here # Normally you would call manage_server_command to check if the # server is None and to report inactive and disabled servers, but here # we want all servers and the server cannot be None output.init('list_server', name, minimal=minimal) description = server.config.description or '' # If the server has been manually disabled if not server.config.active: description += " (inactive)" # If server has configuration errors elif server.config.disabled: description += " (WARNING: disabled)" # If server is a passive node if server.replica_node: description += ' (Passive)' output.result('list_server', name, description) output.close_and_exit()
def replication_status(args): """ Shows live information and status of any streaming client """ servers = get_server_list(args, skip_inactive=True) for name in sorted(servers): server = servers[name] # Skip the server (apply general rule) if not manage_server_command(server, name): continue with closing(server): output.init('replication_status', name, minimal=args.minimal) server.replication_status(args.target) output.close_and_exit()
def status(args): """ Shows live information and status of the MySQL server """ servers = get_server_list(args, skip_inactive=True) for name in sorted(servers): server = servers[name] # Skip the server (apply general rule) if not manage_server_command(server, name): continue output.init('status', name) with closing(server): server.status() output.close_and_exit()
def list_backup(args): """ List available backups for the given server (supports 'all') """ servers = get_server_list(args, skip_inactive=True) for name in sorted(servers): server = servers[name] # Skip the server (apply general rule) if not manage_server_command(server, name): continue output.init('list_backup', name, minimal=args.minimal) with closing(server): server.list_backups() output.close_and_exit()