An example template:
{ "sensors": [ { "name": "opcua_node_aa", "monitoringService": "python /usr/local/teamviewer-iot-agent/monitoring/opc-ua/opc_ua_connect.py", "monitoringParams": "--url opc.tcp://myopcuahost:26543 --nodeId "opcua_node_id" --frequency 2", "metrics": [ { "name": "opcua_node_id", "key": "opcua_node_id", "valueType": "double", "valueAnnotation": "" } ] }, ... ] }
After the sensor/metric is registered by the agent, the agent auto-generates the parameters sensorId
and metricId
and adds them as properties to the configuration file.
📌Notes:
sensorId
or metricId
after they are added to the configuration file.Monitoring frequency can be controlled either by the agent’s Monitoring Configuration File (parameterfrequency
) or by your custom script. In the JSON Sensor (see example below), the frequency is specified by the configuration property, causing the agent to run your script every 10 seconds.
{ "sensors": [{ "name": "temperature_humidity_sensor1", "monitoringService": "/usr/local/teamvieweriot/sensors/temperature_humidity/monitor.sh", "monitoringParams": "sensor1 sdkCredential", "frequency": 10, "metrics": [{ "name": "Temperature", "key": "temperature", "valueType": "double", "valueAnnotation": "C" }, { "name": "Humidity", "key": "humidity", "valueType": "double", "valueAnnotation": "" }] }, ... ] }
There may be scenarios where the frequency of the data collection should be set by your script rather than specified in the agent’s Monitoring Configuration File. In these scenarios, the parameter frequency
in the configuration file should be left blank.
stdout
.Generic example:
var queue = new Queue(); queue.openConnection(); queue.createSubscription(callback); function callback(value) { print {"key":value}; }
Although this can be done by configuring the parameter frequency
in the agent’s Monitoring Configuration File, an optimal solution may be to use a loop in your script to print new metric values every second.
Generic example:
var networkObject = new NetworkObject(); networkObject.openConnection(); try { while (true) { var value = networkObject.getValue(); print {"key":value}; sleep(1000); } } finally { connection.close() }