Qualidade de Vida
with Zabbix and API
Zabbix Meetup RJ – 2017
meetup-rj@senac:$ whoami
Luiz Sales
DevOps at O2B
Zabbix Specialist and Professional
Automatizar
”Automatizar é melhorar a qualidade de vida da
sua equipe. Automatizando o processo, voce
consegue garantir uma boa noite de sono para
os seus amigos.”
Domingos Neto, Gerente TIVIT
Index
Index
• Sync AD with Zabbix
• Templates Reports
• Hosts Report
• Unsupported items
• Agents w/ Error
• Auto Ack
• Icons Import
• Web Scenarios
• Maintenance
– Host
– It Services
– Trigger
Sync AD with Zabbix
• ldapsearch
Sync AD with Zabbix
• ldapsearch
• method: user.object
– user.get
– user.create
– user.update
Template Reports
Print
"TEMPLATE;TIPO;ITEM;CHAVE;TRIGGER;TRESHOLD;SEVERID
ADE”
templates = zapi.template.get({ "output" : "extend",
"selectDiscoveries" : "extend" })
items = zapi.item.get({ "output" : "extend", "templateids" :
tId, "webitems": "1", "selectDiscoveryRule" : "extend",
"selectItemDiscovery": "extend" })
triggers = zapi.trigger.get({ "selectDependencies" :"extend" ,
"output" : "extend", "itemids": iId, "expandExpression" :
"extend" })
iLLD = zapi.itemprototype.get({ "output": "extend",
"discoveryids": iDiscoveryRule })
iLLD = zapi.itemprototype.get({ "output": "extend",
"discoveryids": iDiscoveryRule })
trLLD = zapi.triggerprototype.get({"expandExpression" :
"extend", "output": "extend", "discoveryids": iDiscoveryRule
})
Template Reports
Host Reports
Host Reports
Unsupported items
item_get = zapi.item.get({ "output" :
"extend","hostids" : hostId, "filter" : { "state" : 1 ,
"status" : 0 } })
for y in item_get:
iname = y[u'name']
ikey = y[u'key_']
ierror = y[u'error']
print hhost + ";" + hname + ";" + iname + ";" +
ikey + ";" + ierror
Agents w/ Error
hosts = zapi.host.get({ "output": ["host",
"name", "description", "status","proxy_hostid",
"error" ], "filter": { "available": 2 } } )
print "HOST;NOME;STATUS;ERROR"
for y in hosts:
proxyid = y[u'proxy_hostid']
host = y[u'host']
name = y[u'name']
error = y[u'error']
status = y[u'status']
.....
print "%s;%s;%s;%s" % (host,name,st,error)
Auto Ack
ack = zapi.event.acknowledge({ "eventids" : EVENTID,
"message" : "teste de msg glpi", "action" : 0 })
Auto Ack
ack = zapi.event.acknowledge({ "eventids" : EVENTID,
"message" : "teste de msg glpi", "action" : 0 })
Icons Import
ImportIconFile_v05.py
python ImportIconFile_v05.py Wer.zip W3R
API Method:
image.create({ "imagetype": 1, "name": nome,
"image" : b64encode })
Web Scenarios
USO : HBBABEP120 Portal
http://www.portalsap.com.br"
"method": "httptest.create",
"params": {
"name": "$NAME",
"hostid": "$HOSTID",
"retries" : "3",
"applicationid" : "1960",
"steps": [
{
"name": "$NAME",
"url": "$SITE",
"status_codes": "200",
"no": "1"
....
Maintenance
Maintenance
• Host
"jsonrpc": "2.0",
"method": "maintenance.create",
"params": {
"name": "$CRQNUMBER",
"active_since": "$DATETIME_INICIO",
"active_till": "$DATETIME_FINAL",
"hostids": [
"$HOSTID"
],
"timeperiods": [
{
"timeperiod_type": "0",
"every": "1",
"dayofweek": "64",
"start_time": "$DATETIME_INICIO",
"period": "$PERIOD"
Maintenance
• Host
• IT Services
"jsonrpc": "2.0",
"method": "service.addtimes",
"params": {
"serviceid": "$SERVICEID",
"type": "2",
"ts_from": "$DATETIME_INICIO",
"ts_to": "$DATETIME_FINAL",
"note": "$CRQNUMBER"
....
Maintenance
• Host
• IT Services
• Triggers
item_get = zapi.item.get({ "output": "extend",
"selectTriggers" : "extend", "hostids" : hId,
"search" : { "key_" : CHAVE } })
for w in item_get:
trig = w[u'triggers']
for a in trig:
trId = a[u'triggerid']
trigger_update = zapi.trigger.update({
"triggerid" : trId, "status": 1 })
Top 100 Triggers
IT Services
Finish
Thank u!
https://lsa1es.github.io
luiz@lsales.biz
in/lsa1es

Qualidade de vida: Com Zabbix e API

  • 1.
    Qualidade de Vida withZabbix and API Zabbix Meetup RJ – 2017
  • 2.
    meetup-rj@senac:$ whoami Luiz Sales DevOpsat O2B Zabbix Specialist and Professional
  • 3.
  • 4.
    ”Automatizar é melhorara qualidade de vida da sua equipe. Automatizando o processo, voce consegue garantir uma boa noite de sono para os seus amigos.” Domingos Neto, Gerente TIVIT
  • 6.
  • 7.
    Index • Sync ADwith Zabbix • Templates Reports • Hosts Report • Unsupported items • Agents w/ Error • Auto Ack • Icons Import • Web Scenarios • Maintenance – Host – It Services – Trigger
  • 8.
    Sync AD withZabbix • ldapsearch
  • 9.
    Sync AD withZabbix • ldapsearch • method: user.object – user.get – user.create – user.update
  • 10.
    Template Reports Print "TEMPLATE;TIPO;ITEM;CHAVE;TRIGGER;TRESHOLD;SEVERID ADE” templates =zapi.template.get({ "output" : "extend", "selectDiscoveries" : "extend" }) items = zapi.item.get({ "output" : "extend", "templateids" : tId, "webitems": "1", "selectDiscoveryRule" : "extend", "selectItemDiscovery": "extend" }) triggers = zapi.trigger.get({ "selectDependencies" :"extend" , "output" : "extend", "itemids": iId, "expandExpression" : "extend" }) iLLD = zapi.itemprototype.get({ "output": "extend", "discoveryids": iDiscoveryRule }) iLLD = zapi.itemprototype.get({ "output": "extend", "discoveryids": iDiscoveryRule }) trLLD = zapi.triggerprototype.get({"expandExpression" : "extend", "output": "extend", "discoveryids": iDiscoveryRule })
  • 11.
  • 12.
  • 13.
  • 14.
    Unsupported items item_get =zapi.item.get({ "output" : "extend","hostids" : hostId, "filter" : { "state" : 1 , "status" : 0 } }) for y in item_get: iname = y[u'name'] ikey = y[u'key_'] ierror = y[u'error'] print hhost + ";" + hname + ";" + iname + ";" + ikey + ";" + ierror
  • 15.
    Agents w/ Error hosts= zapi.host.get({ "output": ["host", "name", "description", "status","proxy_hostid", "error" ], "filter": { "available": 2 } } ) print "HOST;NOME;STATUS;ERROR" for y in hosts: proxyid = y[u'proxy_hostid'] host = y[u'host'] name = y[u'name'] error = y[u'error'] status = y[u'status'] ..... print "%s;%s;%s;%s" % (host,name,st,error)
  • 16.
    Auto Ack ack =zapi.event.acknowledge({ "eventids" : EVENTID, "message" : "teste de msg glpi", "action" : 0 })
  • 17.
    Auto Ack ack =zapi.event.acknowledge({ "eventids" : EVENTID, "message" : "teste de msg glpi", "action" : 0 })
  • 18.
    Icons Import ImportIconFile_v05.py python ImportIconFile_v05.pyWer.zip W3R API Method: image.create({ "imagetype": 1, "name": nome, "image" : b64encode })
  • 19.
    Web Scenarios USO :HBBABEP120 Portal http://www.portalsap.com.br" "method": "httptest.create", "params": { "name": "$NAME", "hostid": "$HOSTID", "retries" : "3", "applicationid" : "1960", "steps": [ { "name": "$NAME", "url": "$SITE", "status_codes": "200", "no": "1" ....
  • 20.
  • 21.
    Maintenance • Host "jsonrpc": "2.0", "method":"maintenance.create", "params": { "name": "$CRQNUMBER", "active_since": "$DATETIME_INICIO", "active_till": "$DATETIME_FINAL", "hostids": [ "$HOSTID" ], "timeperiods": [ { "timeperiod_type": "0", "every": "1", "dayofweek": "64", "start_time": "$DATETIME_INICIO", "period": "$PERIOD"
  • 22.
    Maintenance • Host • ITServices "jsonrpc": "2.0", "method": "service.addtimes", "params": { "serviceid": "$SERVICEID", "type": "2", "ts_from": "$DATETIME_INICIO", "ts_to": "$DATETIME_FINAL", "note": "$CRQNUMBER" ....
  • 23.
    Maintenance • Host • ITServices • Triggers item_get = zapi.item.get({ "output": "extend", "selectTriggers" : "extend", "hostids" : hId, "search" : { "key_" : CHAVE } }) for w in item_get: trig = w[u'triggers'] for a in trig: trId = a[u'triggerid'] trigger_update = zapi.trigger.update({ "triggerid" : trId, "status": 1 })
  • 24.
  • 25.
  • 26.
  • 28.