Zabbix integration

It is possible to connect to Zabbix servers and import information about monitored hosts.

Setting up a connection

To set a connection up it is necessary to perform few steps.

Step 1: check a connection from the system server to the Zabbix server

To check availability of Zabbix API the following command to be run in the command line of the system, having replaced http://192.168.1.215 with your Zabbix installation file api_jsonrpc.php address:

$curl -H "Content-Type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"apiinfo.version","id":1,"auth":null,"params":{}}' http://192.168.1.215/zabbix/api_jsonrpc.php

If the Zabbix server is available, it will reply with a message like this:

{"jsonrpc":"2.0","result":"3.2.1","id":1}

Step 2: add a user to Zabbix

Add a new user to Zabbix with the access to read the hosts or groups of hosts, the data from which need to be imported. The user’s login and password are required to connect to the Zabbix server on the 4th step.

Step 3: create an object for import

On the server of the system create the object, which the data will be imported into. In the Parameters section copy the ID of the object - it will be needed on the 4th step.

Step 4: enable import on the system server

Open the server configuration file /etc/saymon/saymon-server.conf and add the following block to it:

"zabbix" : [{
    "url" : "http://192.168.1.215/zabbix/api_jsonrpc.php",
    "user" : "saymon",
    "password" : "saymon_user_password",
    "parent_id" : "58b586d5c3a2f96642e25537"
}]

where

  • url is the address of the file api_jsonrpc.php of your Zabbix installation which has been checked on the 1st step, for example http://192.168.1.215/zabbix/api_jsonrpc.php;

  • user is the login of the Zabbix user which has been created on the 2nd step;

  • password is the password of the Zabbix user which has been created on the 2nd step;

  • parent_id is the ID of the object which has been created on the 3rd step.

In order to use another Zabbix installation add another JSON document with connection parameters as follows:

"zabbix" : [
    {
        "url" : "http://192.168.1.215/zabbix/api_jsonrpc.php",
        "user" : "saymon",
        "password" : "saymon_user_password",
        "parent_id" : "58b586d5c3a2f96642e12345"
    },
    {
        "url" : "http://192.168.1.180:8020/zabbix/api_jsonrpc.php",
        "user" : "saymon",
        "password" : "saymon_user_password",
        "parent_id" : "58b586d5c3a2f966427abcde"
    }
]

Step 5: apply settings

In order to apply connection settings, the saymon-server service must be restarted:

$sudo service saymon-server restart

Update interval of the data import

By default, the data on the server is updated every 2 minutes.

To change the update interval, open the Zabbix section of the server configuration file /etc/saymon/saymon-server.conf and add there the polling_period parameter with the value of the update interval (in milliseconds). For example:

"zabbix" : [{
    "url" : "http://192.168.1.215/zabbix/api_jsonrpc.php",
    "user" : "saymon",
    "password" : "saymon_user_password",
    "parent_id" : "58b586d5c3a2f96642e25537",
    "polling_period": 30000
}]

To apply changes the saymon-server service must be restarted:

$sudo service saymon-server restart

Modification of the standard options in Zabbix requests

It is possible to modify options for the requests for

  • hosts,

  • triggers,

  • data

All of the available filter fields are represented in the Zabbix API documentation:

"zabbix" : [{
...
       "request_options": {
          "hosts": {
            "filter":  {
               ...
            }
          },
          "triggers": {
            "filter": {
                ...
             }
           },
           "data": {
            "filter": {
                ...
             }
           }
        }
...
}]

In order to remove the filter from the request option, it is necessary to set the value null to the parameter filter.

Example (remove the filter field from the triggers request options of Zabbix):

"zabbix" : [{
...
    "triggers": {
       "filter": null
    }
...
}]

Mapping Zabbix metrics to the object classes

By default the INFO class is assigned to the discovered objects. In order to assign another class to the new objects, it is necessary to set the zabbix.classes dict and specify correspondences between class IDs and Zabbix objects' names:

"zabbix": [{
...
        "classes": {
            "4": "CPU",
            "619503be0ffb595aebe22222": "Memory|General"
         },
...
}]

The order of the rules applying is not guaranteed.

If the same regular expressions are assigned to two different classes or the expression "*" (any text) has been used, then in cannot be guaranteed that the rule which is higher in the list will be applied first.

This mapping is set up individually for each Zabbix connection. Regular expressions in values (object names) are not case sensitive.

If the single class needs to be connected to several Zabbix names it is possible to set all of the names in one regular expression using the OR operator. Otherwise only one correspondence will be applied.

Logging

In order to record parameters and request results into the log file, it is necessary to set the zabbix.debug parameter with the value true:

"zabbix" : [{
   ...
   "debug": true,
   ...
   }
]