Leverage Zabbix to Monitor DB2

Zabbix logo

Recently I have been building and configuring an open source product by the name of Zabbix. Zabbix is an enterprise level software designed for monitoring availability and  performance of IT infrastructure components.

One of our customers would like to use Zabbix to monitor an IBM DB2 database with minimal configuration. What is meant by minimal configuration is that the customer would like to utilise an existing Zabbix template for DB2 and hopefully not spend any time developing a custom script for this purpose.

Out of the box Zabbix provides a sizeable number of templates for monitoring different aspects of IT infrastructure such as Windows OS and Linux OS. Each template may contain entities such as items, triggers, graphs and various others. However there was no template for DB2 provided out of the box. As Zabbix is open source it is possible through use of custom scripts to monitor pretty much anything you can think of as long as you are willing to spend a large chunk of time creating scripts.

However, time is a precious commodity to myself and I see no reason to reinvent the wheel if someone has already put the time and effort to create a DB2 template.

A quick Google brought up the following web page:


This webpage provided a link to download the template, the link itself is from a out of date Zabbix wiki (the new Wiki does not contain this template). The template was unzipped, imported and the instructions followed to the letter from the accompanying readme.

The template was deployed to the server where the DB2 database resides. It was on viewing the host in the GUI that I realised all was not well in this template.

db2 JSON problem edit no name

From the above image under the “Info” column you can see a red cross, by hovering the mouse on the cross this informs me what the problem is.

JSON problem

The problem is identified as “Value should be a JSON object”. What this means is that the JSON object used to return DB2 objects to Zabbix is malformed. This meant that the discovery was not completing.  By cranking up the Zabbix Agent log to debug level 4 I can view the JSON being passed back to the server.

JSON problem in log

After peering for what seemed like an age at this JSON object (but in reality was minutes) I spotted the culprit. There was a “,” (comma) on the line that specified the “{#TSTYPE}” object.

To send the JSON objects back to the server a script was placed on the server where the Zabbix agent that monitors the DB2 database resides. The script was named db2_parser.pl and was part of the DB2 template that was downloaded.

On examining the script in vi, the offending block of code was quickly identified.


This line:

print “\t\t\”{#TSTYPE}\”:\”$ts_type\”,\n”;

Needed to be changed to:

print “\t\t\”{#TSTYPE}\”:\”$ts_type\”\n”;

With the comma removed the changes to db2_parser.pl were saved.

On viewing the Zabbix agent log I can see that the JSON object now has the correct format (comma has been removed).

JSON log fixed

On viewing the host in the GUI I can also see that the red cross is no longer present in the “Info” column.

JSON fixxed DB2 template editNow that the discovery is working I can see the various Items that have been created based on the DB2 tablespaces from the DB2 database.

DB2_items_test edit

Future blogs will explore other monitoring capabilities of Zabbix covering areas such as SNMP and Service Now integration.


Views: 1258