This article covers creating custom driver table variables.
To start off, Custom Driver Tables enable you to extract structured data that is well-organized and easy to understand. On the other hand, Custom Driver Variables allow you to monitor scalar values.
For example, with the Custom Driver Table Variables you can display resource consumption statistics for the all running docker containers on the host devices. The table contains a unique identifier for each row, in this case the Docker Container ID, and columns in a table show your defined value, which is an instance of various key/value pairs.
How to create Custom Driver Table Variables
Through a simple JavaScript code, you can now create your Custom Driver Table Variables.

To start, you can define the communication protocol, for example SSH. You can do that, by creating an object and its properties such as command, username, password, timeout, and so on:
as in the example below:
var options = {
"command": "docker stats --no-stream --format \"table {{.Container}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemPerc}}\"",
"username": D.device.username(),
"password": D.device.password(),
"timeout": 5000
};
Then, define a variable and create a driver table, name it, and assign column labels as follows:
var MyTable = D.createTable("My Driver Table", [{"label": "Column A"}, {"label": "Column B", "unit": "%"}])
After parsing the response of the communication protocol variable, simply insert the result into the custom driver table object by:
MyTable.insertRecored(id, values)
and the final table and values will be send to the cloud with the D.success() callback implicitly.
D.success(MyTable)
Example: Docker Containers monitoring with Domotz Custom Driver Table
Below you can see a Custom Driver Table (with a 5 minute scheduled update). The Id column in this case is the Docker container ID, the column Name is the container name, the CPU and Memory column are self explanatory.
