com.webos.service.sdkagent

Note
This API has been available since API level 22.

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/getConfig

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Gets configurations of the Telegraf service.

    Parameters

    None

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
    configOptionalObject

    Telegraf configurations, converted to a JSON object.

    Similar to telegraf.conf, available @ https://docs.influxdata.com/telegraf/v1.21/administration/configuration/.

    Note: Besides the configs that are configured using setConfig method, this method also returns some read-only configurations.

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3, 4Check error details

    For details of a specific error, see the API Error Codes Reference table.

    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.socket_listener": {
                "service_address": "unixgram:///tmp/telegraf.sock"
            },
            "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.system": {
            },
            "inputs.disk": {
                "ignore_fs": [
                    "tmpfs",
                    "devtmpfs",
                    "devfs",
                    "iso9660",
                    "overlay",
                    "aufs",
                    "squashfs"
                ]
            },
            "outputs.influxdb": {
                "database": "telegraf",
                "urls": [
                    "http://127.0.0.1:8086"
                ]
            },
            "global_tags": {
            },
            "inputs.mem": {
            },
            "inputs.swap": {
            },
            "webOS.webProcessSize": {
                "enabled": true
            },
            "webOS.processMonitoring":{
                "enabled":true,
                "process_name":["com.webos.app.home"]
            }
        }
    }

    collector/getData

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Gets data from the Telegraf service.

    Parameters

    Name

    Required

    Type

    Description

    inputsOptionalString 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.

    For more details:

    Note: The inputs can be different depending on the target device.

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
    dataArrayOptionalObject array

    JSON object with data about the specified input.

    More details on output data:

    For more details:

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3, 4Check error details

    For details of a specific error, see the API Error Codes Reference table.

    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"
                }
            }
        ]
    }

    collector/getStatus

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Gets status of the Telegraf service.

    Parameters

    None

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).
    statusRequiredString

    Indicates the status of the Telegraf service.

    Possible values are:

    • active: Service is running.
    • inactive: Service is not running.
    startOnBootOptionalBoolean

    Indicates whether the service is configured to start on booting up of device.

    Possible values are:

    • true: Configured to start on boot.
    • false: Not configured to start on boot.

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3Check error details

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/getStatus '{}'

    Response:

    {
        "returnValue": true,
        "status": "active",
        "startOnBoot": false
    }

    collector/restart

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Restarts the Telegraf service.

    Parameters

    None

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3Check error details.

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/restart '{}'

    Response:

    {
        "returnValue": true
    }

    collector/setConfig

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Sets configurations of the Telegraf service.

    Parameters

    Name

    Required

    Type

    Description

    agentOptionalObject: agent

    Config data for telegraf agent.

    Note:

    • At least one of the parameters must be provided.
    • The data object may be changed for each target platform, and wrong data values are not guaranteed by API. APIs only check the JSON form of data object.
    outputs.influxdbOptionalObject: outputs.influxdb

    Config data for influxdb on host.

    Note: 

    • At least one of the parameters must be provided.
    • The data object may be changed for each target platform, and wrong data values are not guaranteed by API. APIs only check the JSON form of data object.
    webOS.webProcessSizeOptionalObject: webOS.webProcessSize

    Config data for webProcessSize.

    Note: 

    • At least one of the parameters must be provided.
    • The data object may be changed for each target platform, and wrong data values are not guaranteed by API. APIs only check the JSON form of data object.
    webOS.processMonitoringOptionalObject: webOS.processMonitoring

    Config data for processMonitoring.

    Note: 

    • At least one of the parameters must be provided.
    • The data object may be changed for each target platform, and wrong data values are not guaranteed by API. APIs only check the JSON form of data object.

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    2, 3 ,4, 5Check error details

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -f -n 1 luna://com.webos.service.sdkagent/collector/setConfig '{
        "agent":{"flush_interval":"5s","interval":"5s"},
        "outputs.influxdb":{"database":"telegraf","urls":["http://192.168.0.6:8086"]},
        "webOS.webProcessSize":{"enabled":true},
        "webOS.processMonitoring":{"enabled":true,"process_name":["com.webos.app.home","com.webos.service.sdkagent"]}
    }'

    Response:

    {
        "returnValue": true
    }

    collector/start

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Starts the Telegraf service.

    Parameters

    None

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3Check error details

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/start '{}'

    Response:

    {
        "returnValue": true
    }

    collector/startOnBoot

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Automatically starts the Telegraf service on device boot-up and starts monitoring.

    Parameters

    Name

    Required

    Type

    Description

    enableRequiredBoolean

    Indicates if auto-start is enabled.

    Possible values are:

    • true: Auto-start is enabled.
    • false: Not enabled.

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    2, 3Check error details

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/startOnBoot '{"enable":true}'

    Response:

    {
        "returnValue": true
    }

    collector/stop

    ACG: sdkagent.collector
    • Added: API level 22

    Description

    Stops the Telegraf service.

    Parameters

    None

    Call Returns

    Name

    Required

    Type

    Description

    returnValueRequiredBoolean

    Indicates the status of the operation.

    Possible values are:

    • true: Successful.
    • false: Not successful. Check the method's 'Error Codes' section for failure details (errorCode and/or errorText).

    Error Codes Reference

    Error Code

    Error Text

    Error Description

    3Check error details

    For details of a specific error, see the API Error Codes Reference table.

    Example

    Example scenario

    # luna-send -n 1 -f luna://com.webos.service.sdkagent/collector/stop '{}'

    Response:

    {
        "returnValue": true
    }

    Objects

    agent

    Config data for telegraf agent.

    Name

    Required

    Type

    Description

    intervalOptionalString

    Indicates the interval time.

    flush_intervalOptionalString

    Indicates the flush interval time.

    outputs.influxdb

    Config data for influxdb on host.

    Name

    Required

    Type

    Description

    databaseOptionalString

    Indicates the database name.

    urlsOptionalString array

    Indicates the influxdb host urls.

    webOS.processMonitoring

    Config data for processMonitoring.

    Lists the background/foreground applications and their process IDs that are running on webOS platform.

    For more details: https://www.webosose.org/docs/reference/ls2-api/com-webos-service-applicationmanager/#running

    Name

    Required

    Type

    Description

    enabledOptionalBoolean

    Enables process monitoring data.

    process_nameOptionalString array

    Process names for monitoring.

    webOS.webProcessSize

    Config data for webProcessSize.

    Return the list of apps which the process is running and their size. For information, see com.webos.service.webappmanager/getwebprocesssize().

    Name

    Required

    Type

    Description

    enabledOptionalBoolean

    Enables webProcessSize data.

    API Error Codes Reference

    Error Code

    Error Text

    Error Description

    1Unknown error.

    Unknown error.

    2Invalid parameters.

    Occurs when parameters are incorrect.

    3Malformed json.

    Occurs when parameter has malformed JSON.

    4Invalid configurations.

    Occurs when Telegraf has invalid configurations.

    5Collector is active (running).

    Occurs when Telegraf is running.

    Contents