Download - Qualidade de vida: Com Zabbix e API
Qualidade de Vida
with Zabbix and API
Zabbix Meetup RJ – 2017
meetup-rj@senac:$ whoami
Luiz SalesDevOps at O2BZabbix 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 ReportsPrint "TEMPLATE;TIPO;ITEM;CHAVE;TRIGGER;TRESHOLD;SEVERIDADE”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• Triggersitem_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