def check_cluster_status(): # Get cluster config cluster_config = read_config() if not cluster_config or cluster_config['disabled'] == 'yes': raise WazuhException(3013) # Validate cluster config check_cluster_config(cluster_config) status = get_status_json() if status["running"] != "yes": raise WazuhException(3012)
cluster_config = read_config() except WazuhException as e: cluster_config = None if not cluster_config or cluster_config['disabled'] == 'yes': print("Error: The cluster is disabled") exit(1) # Validate cluster config try: check_cluster_config(cluster_config) except WazuhException as e: clean_exit(reason="Invalid configuration: '{0}'".format(str(e)), error=True) status = get_status_json() if status["running"] != "yes": print("Error: The cluster is not running") exit(1) is_master = cluster_config['node_type'] == "master" # get arguments parser = get_parser(cluster_config['node_type']) args = parser.parse_args() if args.debug: logging.getLogger('').setLevel(logging.DEBUG) #10 try: if args.list_agents:
'--list-nodes', action='store_const', const='list_nodes', help='List nodes') exclusive.add_argument('-i', '--health', action='store', nargs='?', const='health', help='Show cluster health') args = parser.parse_args() logging.basicConfig(level=logging.DEBUG if args.debug else logging.ERROR, format='%(levelname)s: %(message)s') cluster_status = cluster.get_status_json() if cluster_status['enabled'] == 'no' or cluster_status['running'] == 'no': logging.error("Cluster is not running.") sys.exit(1) cluster_config = cluster.read_config() cluster.check_cluster_config(config=cluster_config) try: if args.filter_status and not args.list_agents: logging.error("Wrong arguments.") parser.print_help() sys.exit(1) elif args.list_agents: my_function, my_args = print_agents, ( args.filter_status,