com.webos.service.sdkagent
API Summary
The sdkagent service controls Telegraf in webOS and communicates with SDK tools.
Operations:
- Start, stop, and restart the Telegraf service.
- Gets the status of the Telegraf service.
- Sets auto start on boot of Telegraf service.
- Sets and retrieves configuration of the Telegraf service.
- Gets monitoring data that is collected by the Telegraf service.
Note: Telegraf is open source resource monitoring tool.
Overview of the API
NA
Methods
collector/start
Description
Starts the Telegraf service.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/start '{}'
Response:
{
"returnValue": true
}
collector/stop
Description
Stops the Telegraf service.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/stop '{}'
Response:
{
"returnValue": true
}
collector/restart
Description
Restarts the Telegraf service.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/restart '{}'
Response:
{
"returnValue": true
}
collector/startOnBoot
Description
Automatically starts the Telegraf service on device boot-up and starts monitoring.
Parameters
Name | Required | Type | Description |
---|---|---|---|
enable | Required | Boolean | Indicates if auto-start is enabled. Possible values are:
|
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/startOnBoot '{"enable":true}'
Response:
{
"returnValue": true
}
collector/getStatus
Description
Gets status of the Telegraf service.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
status | Optional | String | Indicates the status of the Telegraf service. Possible values are:
|
startOnBoot | Optional | Boolean | Indicates whether the service is configured to start on booting up of device. Possible values are:
|
Example
Example scenario
# luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/getStatus '{}'
Response:
{
"returnValue": true,
"status": "active",
"startOnBoot": false
}
collector/getConfig
Description
Gets configurations of the Telegraf service.
Parameters
None
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
config | Optional | Object | Telegraf configurations, converted to a JSON object. Similar to telegraf.conf, available @ https://docs.influxdata.com/telegraf/v1.21/administration/configuration/. |
Example
Example scenario
# luna-send -f -n 1 luna://com.webos.service.sdkagent/collector/getConfig '{}'
Response:
{
"returnValue": true,
"config": {
"inputs.processes": {
},
"inputs.kernel": {
},
"inputs.cpu": {
"collect_cpu_time": false,
"totalcpu": true,
"percpu": true,
"report_active": false
},
"inputs.system": {
},
"agent": {
"omit_hostname": false,
"flush_jitter": "0s",
"round_interval": true,
"metric_buffer_limit": 10000,
"flush_interval": "10s",
"interval": "10s",
"collection_jitter": "0s",
"metric_batch_size": 1000,
"precision": "",
"hostname": ""
},
"inputs.diskio": {
},
"inputs.disk": {
"ignore_fs": [
"tmpfs",
"devtmpfs",
"devfs",
"iso9660",
"overlay",
"aufs",
"squashfs"
]
},
"outputs.influxdb": {
},
"global_tags": {
},
"inputs.mem": {
},
"inputs.swap": {
}
}
}
collector/setConfig
Description
Sets configurations of the Telegraf srevice.
Parameters
Name | Required | Type | Description |
---|---|---|---|
config | Required | Object | Telegraf configurations, as a JSON object. Possible values are:
For detail value, check the response of the getConfig method. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
Example
Example scenario
# luna-send -f -n 1 luna://com.webos.service.sdkagent/collector/setConfig '{"agent":{"flush_interval":"1s", "interval":"1s"}}'
Response:
{
"returnValue": true
}
collector/getData
Description
Gets data from the Telegraf service.
Parameters
Name | Required | Type | Description |
---|---|---|---|
inputs | Optional | String array | Indicates the inputs to get data from service. The inputs can be obtained from the "Input.*" of the collector/getConfig API. For example, the inputs can be as follows: {"processes", "kernel", "cpu", "system", "diskio", "disk", "mem", "swap"} If argument is empty, return all collected data Note: The inputs can be different depending on the target device. |
Call Returns
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorCode | Optional | Number | The error code for the failed operation. |
errorText | Optional | String | The reason for the failure of the operation. See the 'API Error Codes Reference' section for details. |
dataArray | Optional | Object array | JSON object with data about the specified input. |
Example
Example scenario
# luna-send -f -n 1 luna://com.webos.service.sdkagent/collector/getData '{"inputs": ["processes", "kernel"]}'
Response:
{
"returnValue": true,
"dataArray": [
{
"kernel": {
"data": {
"boot_time": "1667892733i",
"context_switches": "11538598i",
"entropy_avail": "256i",
"interrupts": "94685940i",
"processes_forked": "19231i"
},
"time": "166797999600000000",
"host": "qemux86-64"
}
},
{
"processes": {
"data": {
"total": "143i",
"unknown": "0i",
"dead": "0i",
"blocked": "0i",
"stopped": "0i",
"paging": "0i",
"zombies": "0i",
"sleeping": "97i",
"running": "0i",
"total_threads": "313i",
"idle": "46i"
},
"time": "166797999600000000",
"host": "qemux86-64"
}
}
]
}
API Error Codes Reference
Error Code | Error Text | Error Description |
---|---|---|
1 | Unknown error | Unknown error. |
2 | Invalid parameters | Occurs when parameters are incorrect. |
3 | Malformed json. | Occurs when parameter has malformed JSON. |
4 | Invalid configurations | Occurs when Telegraf has invalid configurations. |
5 | Invalid configuration file | Occurs when Telegraf configuration file is invalid. |