Skip to main content

Zabbix 2.2.x Web Monitoring

·3 mins

Update6: Zabbix 2.4 has been released, here the steps to do the upgrade without loosing data.
Update5: Patches for versions 2.2.5 and 2.2.6
Update4: This feature has been implemented and will be released in the next upcoming version (2.4). You can test the alpha prerelease from http://www.zabbix.com/rn2.3.1.php. I will give instructions to migrate to new version keeping web scenarios configured with this patch, stay tuned!

Update3: Fixed incorrect behaviour. Previous headers were kept between http steps.

Update2: Added patches for version 2.2.3 and added template support.

Update1: I have updated both patches because an obvious memory leak, sorry but I am not an experienced C programmer :-(.Thanks to Alexei Vladishev for reporting it.

  We use zabbix monitoring system at work and we love it. However it lacks some basic functionality in its web monitoring implementation that makes this feature almost useless for us. For example, you can’t modify HTTP Headers like “Content-Type”, needed if you want to use JSON or monitor SOAP web services.

Some people are requesting this feature (ZBXNEXT-282) but, as you can see, there is no plan to implement it for now because it is not part of the roadmap.

This weekend I tried to implement this feature because I thougth it shouldn’t be very difficult and I must admit that it was easier than I expected. I felt very comfortable with the code and I also added some additional HTTPS features we need at work.

This patch applies to version 2.2.0,2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.2.6, and provides the following features:

  • Use of custom HTTP Headers
  • Select a certificate and key in outgoing HTTPS connections and set the key password if needed.
  • Verify if the server certificate is signed by a trusted CA and/or the server certificate matches the server name.
  • Select a custom directory that contains our trusted CAs (you must run c_rehash dir to work properly).
  • Template support.
  • Macro support for all new features.
  • Automatic database upgrade if you upgrade from zabbix 2.0.
  • Database changes included in schema if you install it from scratch.

Requirements. #

You will need libcurl compiled with openssl support, in debian:

apt-get build-dep zabbix-server-mysql
apt-get install libcurl4-openssl-dev

General Instructions #

Build and install the patched source code

svn co svn://svn.zabbix.com/tags/2.2.6
cd 2.2.6
wget http://mamux.org/wp-content/uploads/2014/09/zabbix-web-patch-2.2.6.txt
cat zabbix-web-patch-2.2.6.txt | patch -p0
sh bootstrap.sh
./configure --enable-server --with-mysql --with-libcurl ...
make dbschema
make 
sudo make install

Now you have 3 choices

  • If you are upgrading zabbix from 2.0 you don’t have to worry because the zabbix server will perform the database upgrade.

  • If you are installing from scratch, create your database and import sql files as usual:

        cat database/mysql/{schema,images,data}.sql | mysql -u zabbix -p zabbix
    
  • If you already have Zabbix 2.2 you will need to execute the following SQL in your zabbix database:

    ALTER TABLE zabbix.httpstep ADD headers TEXT NOT NULL;
    ALTER TABLE zabbix.httptest ADD (
      `certfile`               varchar(255)    DEFAULT ''                NOT NULL,
      `keyfile`                varchar(255)    DEFAULT ''                NOT NULL,
      `keypass`                varchar(64)     DEFAULT ''                NOT NULL,
      `capath`                 varchar(255)    DEFAULT ''                NOT NULL,
      `verifypeer`             integer         DEFAULT '0'               NOT NULL,
      `verifyhost`             integer         DEFAULT '0'               NOT NULL
    );
    

As final step don’t forget to install/update zabbix frontend with the modified version.

Enjoy!