Skip to content

Instantly share code, notes, and snippets.

@isaqueprofeta
Last active July 10, 2020 18:28
Show Gist options
  • Save isaqueprofeta/75ea9a10d1edead94dc61eca83ec953e to your computer and use it in GitHub Desktop.
Save isaqueprofeta/75ea9a10d1edead94dc61eca83ec953e to your computer and use it in GitHub Desktop.
Usando a API do zabbix rapidamente em python

Instalar Python e o Pip:

sudo apt-get install python3 python3-pip

Criar pasta de projeto e instalar as dependências:

mkdir api_zabbix
cd api_zabbix
pip install pyzabbix

Criar o script com o conteúdo mínimo:

# Carrega bibliotecas
from pyzabbix import ZabbixAPI
# Carrega credenciais
url_api = 'http://servidor.zabbix/api_jsonrpc.php'
usuario_api = 'Admin';
senha_api = 'zabbix';

# Cria a conexão e loga
api = ZabbixAPI(url_api)
api.login(user, password)

# Daqui para a frente é com você!!!
grupos = api.hostgroup.get(output='extend');
print(grupos);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment