Layoutbyorngjce223,CC-BY
NLZGG bijeenkomst - 12 feb. 2015
---
Raymond Kuiper
Automating interactions with
Layoutbyorngjce223,CC-BY
quick introduction
Raymond Kuiper
“I do something with computers”
(Fanatical) Zabbix user since 2006
Layoutbyorngjce223,CC-BY
sysadmins <3 automation
Layoutbyorngjce223,CC-BY
the sysadmin vs monitoring
Layoutbyorngjce223,CC-BY
automation in Zabbix
Layoutbyorngjce223,CC-BY
how to automate via the API?
Layoutbyorngjce223,CC-BY
API bash script using Curl
Pros:
Seems nice and easy at first
You can show off your mad coding skills
Layoutbyorngjce223,CC-BY
API bash script using Curl
Cons:
No object awareness
Honestly, it's a PITA
Layoutbyorngjce223,CC-BY
Develop an API based tool
Pros:
Perfect solution to your problem
Highly efficient code
Layoutbyorngjce223,CC-BY
Develop an API based tool
Cons:
Takes time and effort to develop (and
debug) a fitting solution
Not very flexible unless you invest heavily
in development (monolithic)
Gets very complex, very fast. You might
need a developer to maintain it
Layoutbyorngjce223,CC-BY
Use a CLI tool
(Zabcon and friends)
Pros:
Can be used in shell scripts
Can be used quickly, no need for direct
API code
Layoutbyorngjce223,CC-BY
Use a CLI tool
(Zabcon and friends)
Cons:
Learning a new CLI language
Limited to the functionality the developer
thought was useful
Layoutbyorngjce223,CC-BY
my solution?
Layoutbyorngjce223,CC-BY
*nix
The IT swiss army knife
Layoutbyorngjce223,CC-BY
*nix
The IT swiss army knife
“The whole is greater than the sum of its
parts.”
― Aristotle
Layoutbyorngjce223,CC-BY
Introducing:
the Zabbix Gnomes
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
https://github.com/q1x/zabbix­gnomes
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
user@localhost$ ./zghostfinder.py ­­help
usage: zghostfinder.py [­h] [­u USERNAME] [­p PASSWORD]
[­a API] [­­no­verify] [­c CONFIG] 
[­n] [­e] hostgroup
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
 ~/.zbx.conf
 [Zabbix API]
 username=johndoe
 password=verysecretpassword
 api=https://zabbix.mycompany.com/path/to/zabbix/frontend/
 no_verify=true
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
user@localhost$ ./zghostfinder.py 'Linux Servers'
Wakizashi
Kodachi
Katana
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
user@localhost$ ./zhgraphfinder.py ­e Kodachi
568:Network traffic on eth0
555:CPU jumps
556:CPU load
557:CPU utilization
558:Swap usage
569:Disk space usage /
560:Memory usage
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
user@localhost$ ./zgetgraph.py ­f graph.png 557
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
Making them work together
Layoutbyorngjce223,CC-BY
Zabbix Gnomes
#!/bin/bash
# This scripts downloads the 'CPU utilisation' 
# graphs for a group of Zabbix hosts.
#
# Find hosts in group 'Linux Servers'
for host in $(./zghostfinder.py 'Linux Servers'); do
# Get Graphid 
graphid=$(./zhgraphfinder.py ­e $host | 
grep 'CPU utilization' | cut ­d ':' ­f 1)
# Download graph
./zgetgraph.py ­f $host.png $graphid
done 
Layoutbyorngjce223,CC-BY
Questions?
Layoutbyorngjce223,CC-BY
Zabbix Events
Zabbix Professional Training
13-17 april 2015
http://www.zabbix.com/training.php
Zabbix Conference 2015
11-12 september 2015
http://www.zabbix.com/lv/newsletters/2015/newsletter_january_15.html

Automating interactions with Zabbix (Raymond Kuiper / 12-02-2015)