See www.zabbix.com for the official Zabbix site.

Docs/protocols/zabbix proxy/3.0

From Zabbix.org
Jump to: navigation, search

Zabbix proxy protocol

Active proxy

Proxy configuration

Active proxy asks for configuration data:

{
        "request":"proxy config",
        "host":"Zabbix proxy"
}

An example of Zabbix 3.0 server sending configuration data to Zabbix proxy.

     
{
        "globalmacro" : {
                "fields" : ["globalmacroid","macro","value"],
                "data" : [
                        [2,"{$SNMP_COMMUNITY}","public"]
                ]
        },
        "hosts" : {
                "fields" : ["hostid","host","status","ipmi_authtype","ipmi_privilege","ipmi_username","ipmi_password","name"],
                "data" : [
                        [10084,"Zabbix server",0,-1,2,"","","Zabbix server"]
                ]
        },
        "interface" : {
                "fields" : ["interfaceid","hostid","main","type","useip","ip","dns","port","bulk"],
                "data" : [
                        [1,10084,1,1,1,"127.0.0.1","","11339",1]
                ]
        },
        "hosts_templates" : {
                "fields" : ["hosttemplateid","hostid","templateid"],
                "data" : [
                ]
        },
        "hostmacro" : {
                "fields" : ["hostmacroid","hostid","macro","value"],
                "data" : [
                ]
        },
        "items" : {
                "fields" : ["itemid","type","snmp_community","snmp_oid","hostid","key_","delay","status","value_type","trapper_hosts","snmpv3_securityname","snmpv3_securitylevel","snmpv3_authpassphrase","snmpv3_privpassphrase","lastlogsize","logtimefmt","delay_flex","params","ipmi_sensor","data_type","authtype","username","password","publickey","privatekey","mtime","flags","interfaceid","port","snmpv3_authprotocol","snmpv3_privprotocol","snmpv3_contextname"],
                "data" : [
                        [23661,7,"","",10084,"log[/tmp/logfile.txt,foo.*]",5,0,2,"","",0,"","",44,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23662,9,"","",10084,"web.test.in[example.com,,bps]",60,0,0,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23663,9,"","",10084,"web.test.fail[example.com]",60,0,3,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23664,9,"","",10084,"web.test.error[example.com]",60,0,1,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23665,9,"","",10084,"web.test.in[example.com,index,bps]",60,0,0,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23666,9,"","",10084,"web.test.time[example.com,index,resp]",60,0,0,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""],
                        [23667,9,"","",10084,"web.test.rspcode[example.com,index]",60,0,3,"","",0,"","",0,"","","","",0,0,"","","","",0,0,null,"",0,0,""]
                ]
        },
        "drules" : {
                "fields" : ["druleid","name","iprange","delay"],
                "data":[
                ]
        },
        "dchecks" : {
                "fields" : ["dcheckid","druleid","type","key_","snmp_community","ports","snmpv3_securityname","snmpv3_securitylevel","snmpv3_authpassphrase","snmpv3_privpassphrase","uniq","snmpv3_authprotocol","snmpv3_privprotocol","snmpv3_contextname"],
                "data" : [
                ]
        },
        "regexps" : {
                "fields" : ["regexpid","name"],
                "data" : [
                        [1,"File systems for discovery"],
                        [2,"Network interfaces for discovery"],
                        [3,"Storage devices for SNMP discovery"]
                ]
        },
        "expressions" : {
                "fields" : ["expressionid","regexpid","expression","expression_type","exp_delimiter","case_sensitive"],
                "data" : [
                        [1,1,"^(btrfs|ext2|ext3|ext4|jfs|reiser|xfs|ffs|ufs|jfs|jfs2|vxfs|hfs|ntfs|fat32|zfs)$",3,",",0],[2,2,"^lo$",4,",",1],
                        [3,3,"^(Physical memory|Virtual memory|Memory buffers|Cached memory|Swap space)$",4,",",1],
                        [4,2,"^Software Loopback Interface",4,",",1]
                ]
        },
        "groups" : {
                "fields" : ["groupid"],
                "data" : [
                        [5]
                ]
        },
        "config" : {
                "fields" : ["configid","refresh_unsupported","discovery_groupid","snmptrap_logging"],
                "data" : [
                        [1,1,5,1]
                ]
        },
        "httptest" : {
                "fields" : ["httptestid","name","delay","variables","agent","authentication","http_user","http_password","hostid","http_proxy","retries","ssl_cert_file","ssl_key_file","ssl_key_password","verify_peer","verify_host","headers"],
                "data" : [
                        [1,"example.com",60,"","Zabbix",0,"","",10084,"",1,"","","",0,0,""]
                ]
        },
        "httptestitem" : {
                "fields" : ["httptestitemid","httptestid","itemid","type"],
                "data" : [
                        [1,1,23662,2],
                        [2,1,23663,3],
                        [3,1,23664,4]
                ]
        },
        "httpstep" : {
                "fields" : ["httpstepid","httptestid","name","no","url","timeout","posts","required","status_codes","variables","follow_redirects","retrieve_mode","headers"],
                "data" : [
                        [1,1,"index",1,"http://example.com",15,"","","","",1,1,""]
                ]
        },
        "httpstepitem" : {
                "fields" : ["httpstepitemid","httpstepid","itemid","type"],
                "data" : [
                        [1,1,23665,2],
                        [2,1,23666,1],
                        [3,1,23667,0]
                ]
        }
}
Note: Groups and discovery group in the config table are not required by the proxy - they are only sent because that field can not be NULL in the database schema.

Sending host availability data

Proxy sends host availability data in a separate request. A single dataset will be sent right after proxy startup, containing information about all hosts and all availability types (agent, SNMP, JMX, IPMI). Similarly, if a new host has been added, full availability information about this host will be sent initially.

{
        "request" : "host availability",
        "host" : "Zabbix proxy",
        "data" : [
                {
                        "hostid":10084,
                        "available":1,
                        "snmp_available":0,
                        "ipmi_available":0,
                        "jmx_available":0,
                        "error":"",
                        "snmp_error":"",
                        "ipmi_error":"",
                        "jmx_error":""
                }
        ]
}

When host availability changes later, only the changed fields are sent. When ever there is a connection error, the server is notified instantly:

{
        "request" : "host availability",
        "host" : "Zabbix proxy",
        "data" : [
                {
                        "hostid":10084,
                        "error":"Get value from agent failed: cannot connect to [[127.0.0.1]:11339]: [111] Connection refused"
                }
        ]
}

After few attempts also an availability state changes:

{
        "request" : "host availability",
        "host" : "Zabbix proxy",
        "data" : [
                {
                        "hostid":10084,
                        "available":2
                }
        ]
}

If everything is well, server responds with:

{
        "response" : "success"
}

In case of failure (for example, proxy hostname not matching) server responds with:

{
        "response" : "failed",
        "info" : "proxy \"Zabbix proxy\" not found"
}

Sending historical data

{
        "request" : "history data",
        "host" : "Zabbix proxy",
        "clock" : 1423755919,
        "ns" : 909069388,
        "data" : [
                {
                        "host":"Zabbix server",
                        "key":"web.test.in[example.com,index,bps]",
                        "clock":1423755915,
                        "ns":146648341,
                        "value":"0.000000"
                },
                {
                        "host":"Zabbix server",
                        "key":"web.test.time[example.com,index,resp]",
                        "clock":1423755915,
                        "ns":146648341,
                        "value":"0.259713"
                },
                {
                        "host":"Zabbix server",
                        "key":"web.test.rspcode[example.com,index]",
                        "clock":1423755915,
                        "ns":146648341,
                        "value":"200"
                },
                {
                        "host":"Zabbix server",
                        "key":"web.test.in[example.com,,bps]",
                        "clock":1423755915,
                        "ns":147651918,
                        "value":"0.000000"
                },
                {
                        "host":"Zabbix server",
                        "key":"web.test.fail[example.com]",
                        "clock":1423755915,
                        "ns":147651918,
                        "value":"0"
                },
                {
                        "host":"Zabbix server",
                        "key":"system.uptime",
                        "clock":1423755918,
                        "ns":860945743,"value":"896015"
                 },
                 {
                        "host":"Zabbix server",
                        "key":"net.tcp.service[http]",
                        "clock":1423755919,
                        "ns":859762630,
                        "value":"1"
                },
                {
                        "host":"Zabbix server",
                        "key":"log[/tmp/logfile.txt]",
                        "clock":1423755910,
                        "ns":818174373,
                        "value":"access denied",
                        "lastlogsize":64,
                        "mtime":0
                },
                {
                        "host":"Zabbix server",
                        "key":"log[/tmp/logfile.txt]",
                        "clock":1423755910,
                        "ns":818301627,
                        "value":
                        "foo and bar denied",
                        "lastlogsize":83,
                        "mtime":0
                }
        ]
}

Server response:

{
        "response" : "success",
        "info" : "Processed 9 Failed 0 Total 9 Seconds spent 0.000462"}

In case of major failure (for example, proxy hostname not matching) server responds with:

{
        "response" : "failed",
        "info" : "proxy \"Zabbix proxy\" not found"
}

Sending discovery data

{
        "ns" : 713446421,
        "request" : "discovery data",
        "host":"Zabbix proxy",
        "clock" : 1424340627,
        "data" : [
                {
                        "dns" : "",
                        "drule" : 2,
                        "status" : 1,
                        "ip" : "192.168.0.10",
                        "port" : 10050,
                        "key" : "system.uname",
                        "dcheck" : 2,
                        "clock" : 1424340624,
                        "type" : 9
                },
                {
                        "dns" : "",
                        "drule" : 2,
                        "dcheck" : null,
                        "status" : 1,
                        "ip" : "192.168.0.10",
                        "clock" : 1424340624,
                        "type" : -1
                },
                {
                        "dns" : "zeus.example.lan",
                        "drule" : 2,
                        "status" : 0,
                        "ip" : "192.168.0.11",
                        "port" : 10050,
                        "key" : "system.uname",
                        "dcheck" : 2,
                        "clock" : 1424340627,
                        "type" : 9
                },
                {
                        "dns" : "zeus.example.lan",
                        "drule" : 2,
                        "dcheck" : null,
                        "status" : 0,
                        "ip" : "192.168.0.11",
                        "clock" : 1424340627,
                        "type" : -1
                }
        ]
}

dcheck is check ID for services and null for hosts. Status 0 is up and 1 is down.

If everything is well, server responds with:

{
        "response" : "success"
}

In case of failure (for example, proxy hostname not matching) server responds with:

{
        "response" : "failed",
        "info" : "proxy \"Zabbix proxy\" not found"
}

Sending heartbeat data

{
        "request" : "proxy heartbeat",
        "host" : "Zabbix proxy"
}

If everything is well, server responds with:

{
        "response" : "success"
}

In case of failure (for example, proxy hostname not matching) server responds with:

{
        "response" : "failed",
        "info" : "proxy \"Zabbix proxy\" not found"
}

Sending auto-registration data

{
   "ns" : 933446046,
   "request" : "auto registration",
   "clock" : 1424350144,
   "data" : [
      {
         "dns" : "localhost",
         "ip" : "127.0.0.1",
         "clock" : 1424350144,
         "port" : "11339",
         "host" : "Zabbix server"
      }
   ],
   "host" : "Zabbix proxy"
}

If everything is well, server responds with:

{
        "response" : "success"
}

In case of failure (for example, proxy hostname not matching) server responds with:

{
        "response" : "failed",
        "info" : "proxy \"Zabbix proxy\" not found"
}

Passive proxy

When server connects to the passive proxy to send configuration data, the contents are exactly as the ones sent to the active proxy, except they are wrapped in a "proxy config" request and data array:

{
        "request" : "proxy config",
        "data" : {
                "globalmacro" : {
...
                }
        }
}

If everything is well, proxy responds with:

{
        "response" : "success"
}

If server attempts to send configuration data in this manner to the active proxy, active proxy responds with:

{
        "info" : "misconfiguration error: the proxy is running in the active mode but server sends requests to it as to proxy in passive mode",
        "response" : "failed"
}

For availability data, server sends to the proxy:

{
        "request" : "host availability"
}

If everything is well, proxy responds with availability data:

{
        "data" : [
                {
                        "hostid":10108,
                        "available":1,
                        "snmp_available":0,
                        "ipmi_available":0,
                        "jmx_available":0,
                        "error":"",
                        "snmp_error":"",
                        "ipmi_error":"",
                        "jmx_error":""
                }
        ]
}

If there are no availability changes, proxy responds with empty data:

{
        "data" : []
}

If server attempts to ask for the availability data in this manner from the active proxy, active proxy sends empty response, which server considers to be a success and tries to respond with:

{
        "response" : "success"
}

which proxy never receives because by that time it has already closed the connection.