def show_groups(): groups_data = agent.get_agent_groups().to_dict() print("Groups ({0}):".format(groups_data['total_affected_items'])) for g in groups_data['affected_items']: print(" {0} ({1})".format(g['name'], g['count'])) print("Unassigned agents: {0}.".format(agent.get_agents(q='id!=000;group=null').to_dict()['total_affected_items']))
def show_group(agent_id): agent_info = agent.get_agents(agent_list=[agent_id]).to_dict() if agent_info['total_affected_items'] == 0: print(list(agent_info['failed_items'].keys())[0]) else: agent_info = agent_info['affected_items'][0] str_group = ', '.join(agent_info['group']) if 'group' in agent_info else "Null" print("The agent '{0}' with ID '{1}' belongs to groups: {2}.".format(agent_info['name'], agent_info['id'], str_group))
#!/usr/bin/env python ### # Copyright (C) 2015-2020, Wazuh Inc.All rights reserved. # Wazuh.com # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public # License (version 2) as published by the FSF - Free Software # Foundation. ### # Instructions: # - Use the embedded interpreter to run the script: {wazuh_path}/framework/python/bin/python3 get_agents.py import json import wazuh.agent as agent if __name__ == "__main__": result = agent.get_agents() print(json.dumps(result.render(), indent=4, sort_keys=True, default=str))