Why I built a Zabbix Agent 2 Plugin for SAP HANA
One of the most frustrating parts of any monitoring gig is realizing that the necessary tool doesn’t exist. There’s always something that kind of fits the bill, but not really. It really feels like things could be better, but not yet. This is exactly the situation I found myself in when I was asked to monitor yet another SAP HANA database.
In the beginning, there were UserParameters
Now, don’t get me wrong, I like scripts, and I’ve written a lot of them myself over the years. Also, UserParameters have been around for a very long time and they are great. But especially for databases, we need something better, for several reasons:
- Credential handling is suboptimal.
- No connection pooling.
- Limited concurrency, which can slow down monitoring if you have many checks.
- High overhead, as every metric usually involves a script execution.
- They require a database client installed locally to the Zabbix agent.
Then came ODBC
The next best thing is ODBC. Personally, I am not a big fan, but it was specifically designed to monitor databases and it clearly handles things better than scripts once you have it configured. In fact, it is mentioned as the very first option in the post Out-of-the-box database monitoring on the official Zabbix blog.
However, it can be painful to configure initially (especially the ODBC driver) and still requires you to manually write queries for every metric. This is not ideal, especially if those queries need to be used as input in any kind of low-level discovery logic. Given that the Zabbix products integration page is very lacking when it comes to SAP HANA monitoring, the only option out there seems to be the zbx_sap_hana_odbc GitHub project, which unfortunately isn’t very feature rich and hasn’t been updated for a long time.
Finally, Zabbix Agent 2 Plugins
You would think that SAP HANA, being one of the big players among other databases like PostgreSQL, MySQL, and Oracle, would be supported just right after the release of Zabbix Agent 2 plugins. However, SAP HANA is unfortunately not even mentioned in the blog post Database Monitoring using Zabbix agent 2 – Part 1, SQL on the official Zabbix website.
I am not sure about the reason, but one thing I am sure of is that I’ve seen many companies need it; this can even be a big showstopper if you need to move, let’s say, from Nagios to Zabbix. Yes, monitoring SAP HANA with Nagios is not ideal (metrics are aggregated, no low-level discovery), but it’s still better than nothing. So you are either stuck with Nagios or you move to Zabbix, and then suddenly your SAP HANA database is an information vacuum for your monitoring team, and you are left with expensive external consultants that you get to call when it’s already too late because the system is not operating properly.
I saw all of this and decided to do something about it.
Developing the Zabbix Agent 2 Plugin for SAP HANA
I’ve been working with Zabbix for a very long time. I use it on my own infra, I know the ins and outs, and I’ve even written patches for it for some companies I was employed at for both the Windows agent and Linux server components.
So when I decided to write a Zabbix Agent 2 Plugin, I was quite confident that I could pull it off. It wasn’t easy, as the landscape of Golang development was kind of new for me at the time. Fortunately, I found the Zabbix SDK to be very well-written and easy to work with. However, it still took me weeks of work to have something that could be packaged and shipped. What helped me was knowing exactly what I wanted:
- Better credential handling (same as for existing Zabbix Agent 2 plugins for other database systems).
- Connection pooling.
- Something performant with low overhead, compared to the usual UserParameter scripts.
- No need to install database clients or ODBC drivers.
- No need to write a single SQL query (unless you want to, in which case you can run your own from .sql files).
- Low-level discovery of tenants and other metrics out of the box.
All of this is built in as a native package that is easily installable with your usual package manager (well, at least for Debian and RedHat derivatives) and includes XML templates ready to be imported on every major Zabbix server version. This gets you started with your SAP HANA monitoring in minutes with little to no effort.
If you want to give it a try, I put up a getting started page on the website and if you are interested to see quick demo feel free to contact me.
