The purpose of the template is to automate the monitoring of the servers of the video surveillance system based on Trassir recorders under the control of the linux-based software of the same name through the SDK web server.
Trassir SDK is enabled in the web server settings, you must also specify a password. According to the
manufacturer’s documentation, it’s not necessary to create a separate account for taking server readings.
Trassir SDK offers access to server status via request
https://{ip }:{ }/health?password={ SDK}
When you open this link through a browser, a message appears stating that the certificate used is not secure and you must follow the instructions of the browser to continue.
')
For a specific example in the response body we get the following:
{ "disks": "1", "database": "1", "channels_total": "13", "channels_online": "13", "uptime": "882232", "cpu_load": "33.96", "network": "1", "automation": "1", "disks_stat_main_days": "16.41", "disks_stat_priv_days": "0.00", "disks_stat_subs_days": "16.41" } /* Meanings of values: -1 - undefined value 0 - bad health (error) 1 - good health (ok) Values for channels are channel counters. Value of cpu_load is given in percents.
The first part of the output from the character {to the character} corresponds to the documentation and is a standardized JSON output, which corresponds to the documentation, and then comes the description of the output that does not fit the standard.
Previously, in order to use such a conclusion in the Zabbix monitoring system, it was necessary to write your own script, which would be used on the agent and received the necessary data. With this approach, you either need to store the response file and monitor its relevance, or request each element separately, i.e. use 11 queries instead of 1.
In the Zabbix 4.0 version, an HTTP data element type agent appeared that allows you to receive data using the http and https protocols and process them, as well as dependent elements that are calculated from the main ones.
The idea is to get the server response to a text data element and then select the necessary data elements from it.
Initially, we define port number and password macros for the versatility and security of our template.
Create a template and add a data element with the type “HTTP agent”, a key as desired, the URL https: // {HOST.IP}: {$ TRASSIR_SDK_PORT} / health and the request field password {$ TRASSIR_SDK_PASS}. Here {HOST.IP} is a macro which, when a template is added to a node, will be converted to the IP address of the host.
As we have already experimentally found out, this request does not fully comply with the JSON format and it’s impossible to extract data from it just like that.
We will use the new Zabbix functional and in the “preprocessing” tab of the data item template we will add the regular expression \ {(\ n |.) * \} With the output \ 0 which will return only the JSON data.
Who cares why this is soDeveloping similar expressions for newbies is much easier in the
visual editor . In this expression, we are looking for a specific symbol of the opening brace, and since these expressions are used in regular expressions, you must use a backslash before the symbol. In JSON data, there can be any (in fact, not, but omit this point) characters, as well as a newline. These variants of characters that indicate a dot or a control line feed character \ n are indicated in parentheses through the vertical line. Behind the brackets is an asterisk that says that the found character or line feed can be repeated an infinite number of times. Next comes the closing brace. The output \ 0 means that all found sequences will be displayed.
Next, a dependent data element is created for which the main data element specifies the previously received response in JSON format and indicates preprocessing with the “JSON Path” step, which allows you to access any data element by specifying the JSON path. In our example, all the data is at the top level, so we specify $ .disks and so on for all elements.
It remains only to create triggers that will check for the availability of new data, their entry into the normal ranges, as well as optional graphics.
It turns out that we received data from an external system very easily and quickly using Zabbix standard methods, the output of which does not fully comply with the standard. The absence of external scripts simplifies the understanding of the monitoring system and increases the simplicity of its maintenance.
The specified template
is available on the share.zabbix.com exchange portal .