Zabbix HTTP Agent LLD Rule Example

3 minute read

UPDATE: The DPM part of this whole ordeal was partially invalidated by the recent addition of event publishing for DPM. If you can, get the update and just setup windows event monitors for backup actions. Although in all honesty I don’t think I’d trust DPM’s events for critical monitoring, espceially since getting database info can let you build a backup reliability monitor instead of just a go/no-go monitor.

TL;WR: Built an asp.net API to query a DPM view and spit out JSON that Zabbix could handle for both discovery and data. Put this here because there weren’t many resources on the whole HTTP LLD deal.
- Build a datasource that takes an input and returns JSON
- Setup a discovery rule to query the datasource and put in your key as a macro https://blah.blah.blah/api/v1/things/{HOST.THINGNAME}
- Setup a dependant item, point it to the discovery rule and use the “JSON Path” preprocessor to select the value that you want
Jump to Zabbix Item Examples/Screenshots

Rough Draft, I built this whole project in about 5 hours. I imagine you’re here for the Zabbix HTTP Agent LLD stuff so I left the API part out. If you want the whole shebang (API, Code, Setup) let me know with a comment. I don’t want to clean up a whole project if it’s just going to rot in my corner of the internet.

We’ve been using DPM for our backups only to be thwarted in our monitoring attempts. We could have used Operations Manager but the problem was that we weren’t using OM for anything else. The only thing worse than an incomplete dashboard is two incomplete dashboards. So I bit the bullet and now we can finally monitor DPM with Zabbix.

DPM’s built in reporting was a royal pain and took too much manual review time. The email alerts were pretty much all or nothing and I’m loathe to contribute to alert blindness so I hammered this… thing… out.

I built a quick web API with two controllers, one to provide discovery data, and another for the details. The discovery URL (/api/DpmDiscovery/{HOST.NAME}) would hand back the LLD formatted JSON and the other URL (/api/DpmStatus/{#RECPOINT.BACKUPPATH}) would spit out details.

A call for https://dpmapi.contoso.ca/api/DpmDiscovery/file01 would return the following json.

{
    "data": [
        {
            "{#RECPOINT.STATUS}": 2,
            "{#RECPOINT.IDSN}": "D:\\",
            "{#RECPOINT.SERVERNAME}": "file01.contoso.ca",
            "{#RECPOINT.BACKUPPATH}": "file01.contoso.ca..D:..",
            "{#RECPOINT.CREATIONTIME}": "2019-04-25T00:05:28-06:00",
            "{#RECPOINT.UNIXTIME}": "1556172328"
        },
        {
            "{#RECPOINT.STATUS}": 2,
            "{#RECPOINT.IDSN}": "E:\\",
            "{#RECPOINT.SERVERNAME}": "file01.contoso.ca",
            "{#RECPOINT.BACKUPPATH}": "file01.contoso.ca..E:..",
            "{#RECPOINT.CREATIONTIME}": "2019-04-25T00:05:42-06:00",
            "{#RECPOINT.UNIXTIME}": "1556172342"
        },
        {
            "{#RECPOINT.STATUS}": 2,
            "{#RECPOINT.IDSN}": "System State",
            "{#RECPOINT.SERVERNAME}": "file01.contoso.ca",
            "{#RECPOINT.BACKUPPATH}": "file01.contoso.ca..System_State",
            "{#RECPOINT.CREATIONTIME}": "2019-04-25T02:10:59-06:00",
            "{#RECPOINT.UNIXTIME}": "1556179859"
        }
    ]
}

Then the LLD rule creates an HTTP Agent item to call https://dpmapi.contoso.ca/api/DpmStatus/file01.contoso.ca..System\_State

{
    "status": 2,
    "interpretedDsn": "System State",
    "serverName": "file01.contoso.ads",
    "backupPath": "file01.contoso.ads..System_State",
    "creationTime": "2019-04-25T02:10:59-06:00",
    "unixCreationTime": "1556179859"
}

Technically my API returned the data as application/json; however I had accidentally checked “Convert To JSON” so you’ll see a body element in the JSON path below (e.g. $.body.status). In theory I could uncheck that and remove the body element. In practice it works as-is so it’ll stay that way for now.

Example Screenshots

Zabbix Discovery Rule

Zabbix Discovery Rule for HTTP Agent showing the url ending in {HOST.NAME}.
Fig 1. The base rule that detects whether the host has backup data to retrieve.

Zabbix Data Item

APIMonitor showing the parameter object creation.
Fig 2. A data item prototype that uses the returned value from the discovery rule to pull all of the different properties for the discovered item.

Dependent Item

APIMonitor showing the parameter object creation.
Fig 3. A dependant item that extracts data from the ‘base’ item in Figure 2.

Preprocessing Rule

These dependent items use JSON Path processing to extract the actual data out of my details response.

APIMonitor showing the parameter object creation.
Fig 4. The Preprocessing step used to convert the ‘base’ item’s JSON response into keys that can be used by the dependant items.

(body element was inserted because I had checked “Convert to JSON”, if you uncheck “Convert to JSON” you can just do $.valueWeWant)

Citations and Nonsense:

DPM SQL View Documentation: https://docs.microsoft.com/en-us/previous-versions/system-center/data-protection-manager-2010/ff399120(v=technet.10)
Handy JSON validator: https://jsonformatter.curiousconcept.com/
Go-To JSON Browser: http://jsonviewer.stack.hu/