Coder Social home page Coder Social logo

api-zabbix's Introduction

Zabbix API

Codes for use Zabbix API

  • ack_event_zabbix.py
  • itservices_zabbix.py
  • auto-add-hosts.py

Installation

You need lib zabbix-api and pip

# apt-get install python-pip git
# pip install zabbix-api

$ git clone https://github.com/janssenlima/api-zabbix

How to use - examples

auto-add-hosts.py

Change the file path in the code

Structure hosts.csv file

hostautomatico1;192.168.0.1
hostautomatico2;192.168.0.2
hostautomatico3;192.168.0.3
hostautomatico4;192.168.0.4
hostautomatico5;192.168.0.5
.
.
.
hostautomatico100;192.168.0.100

Just run

$ python auto-add-hosts.py

ack_event_zabbix.py

Inform the Event ID generated in Zabbix as a parameter

$ python ack_event_zabbix.py <event.id>

itservices_zabbix.py

Inform the function to be used

list groups

Syntaxy: get_hostgroups()

By default, it returns all groups. Optionally, you can enter a name to search for the group, including using the wildcard *.

$ python -c "execfile('itservices_zabbix.py'); get_hostgroups()"
$ python -c "execfile('itservices_zabbix.py'); get_hostgroups('Linux servers')"
$ python -c "execfile('itservices_zabbix.py'); get_hostgroups('*servers*')"
list hosts of specific group

Syntax: get_hosts('<name_of_group>')" Returns all active hosts in a given group. Search only for the exact name of the group.

$ python -c "execfile('itservices_zabbix.py');  get_hosts('Linux servers')"
list items of a specific host that has associated trigger

Syntax: get_items_hosts('<name_of_host>')"

$ python -c "execfile('itservices_zabbix.py');  get_items_hosts('Apache Web Server')"
list triggers of a specific host

Syntax: get_triggers_hosts('<name_of_host>')"

$ python -c "execfile('itservices_zabbix.py');  get_triggers_hosts('Apache Web Server')"
delete full service tree

Syntax: delete_tree_itservices()

Deletes the entire tree

$ python -c "execfile('itservices_zabbix.py');  delete_tree_itservices()"

You can pass groups separated by commas.

$ python -c "execfile('itservices_zabbix.py');  delete_tree_itservices('Linux servers, Zabbix servers')"
automatically create service tree

Syntax: mk_populate()

Included all groups that have enabled hosts, with items and triggers.

$ python -c "execfile('itservices_zabbix.py');  mk_populate()"

You can pass groups separated by commas.

$ python -c "execfile('itservices_zabbix.py');  mk_populate('Linux servers, Zabbix servers')"

Development

Want to contribute? Great!

Send suggestions, problems, errors etc for [email protected]

Todos

  • Create menu for selecting options and call the internal modules
  • Create Docker image
  • And others

api-zabbix's People

Contributors

janssenlima avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.