Home About Blog pRojects

Monitoring R Applications with RZabbix

As R users we mostly perform analysis, produce reports and create interactive shiny applications. Those are rather one-time performances. Sometimes, however, the R developer enters the world of the real software development, where R applications should be distributed and maintained on many machines. Then one really appreciates the value of a proper applications monitoring. In this post I present my last package called RZabbix - the R interface to the Zabbix API data.

What is Zabbix?

According to the product overview

With Zabbix it is possible to gather virtually limitless types of data from the network. High performance real-time monitoring means that tens of thousands of servers, virtual machines and network devices can be monitored simultaneously. Along with storing the data, visualization features are available (overviews, maps, graphs, screens, etc), as well as very flexible ways of analyzing the data for the purpose of alerting.

This Ultimate Enterprise-class Monitoring Platform was nominated for the 2nd time among world’s best monitoring solutions according to Gartner

Zabbix can be used to Monitor everything - servers, network devices and applications, gathering accurate statistics and performance data.

Connect from R with RZabbix Star

I have created a simple R connector to Zabbix API, packed in the library and released it on Share Zabbix and also on CRAN.

You can install the package with

?ZabbixAPI # help manual page

and then connect to Zabbix API with

    body = 
      list(method = "user.login",
           params = jsonlite::unbox(
            data.frame(user = "Admin",
                       password = "zabbix")))
   ) -> auth

The authentication is required, because every other call need to use auth parameter in its body.

Base information of the API version can be checked with

    body = 
       list(method = "apiinfo.version"))

and the regular request to get history of an item of item_id number can be done as below

    body = 
       list(method = "history.get",
            params = jsonlite::unbox(
           data.frame(output = "extend",
                      itemids = "item_id",
                      history = 0,
                      sortfield = "clock",
                      sortorder = "DESC",
                      limit = 10)
               auth = auth))

The body parameter can be also passed as a JSON string - see example for getting event data for object with object_id number

    "method": "event.get",
    "params": {
        "output": "extend",
        "select_acknowledges": "extend",
        "objectids": "object_id",
        "sortfield": ["clock", "eventid"],
        "sortorder": "DESC"
    "auth": "', auth, '"
}') -> json_rpc

          body = fromJSON(json_rpc)) -> event.info

Methods and params to Zabbix API can be found in Method reference. It is a great date, because few days ago new version of Zabbix (3.2) was released.

You can try to set your own Zabbix Server from Docker container or you can use public test Zabbix on zabbix.org. If you are not yet motivated for using Docker then read my post from May R 3.3.0 is another motivation for Docker or join 10th Cracow R User Group meetup at the end of September where I will present Rocker: explanation and motivation for Docker containers usage in applications development (by R user, for R users)

Example of usage

Jan Garaj from Monitoring Artist has used RZabbix to provide Monitoring Analytics - R statistical computing and graphic tool for monitoring metrics from data scientists.

Monitoring Analytics

You can contribute!

RZabbix is still a young package and many can be done. If you would like to contribute then fill free to Fork the RZabbix repository. I am currently looking for examples on how to create a SLA overview for a specific host, calculate the amount of diskspace used by all active hosts and filesystems and create a overview of the most active triggers and I am thinking about adding tests.