Skip to content

Latest commit

 

History

History
264 lines (245 loc) · 6.96 KB

File metadata and controls

264 lines (245 loc) · 6.96 KB

DataCollectionTarget

Abstract class that represents any object that can collect data. Extends [class-netobj].

Instance attributes

templates: Array

Returns array of templates ([class-template]) applied on this object. Return value also affected by trusted nodes settings.

// Log names and ids of all accessible templates for current node
templates = $node.templates;
for (t : templates)
{
	trace(1, "Template object: name='" .. t.name .. "' id=" .. t.id);
}

Instance methods

applyTemplate(template): void

Apply template to node

Table 1. Parameters

template

[class-template]

Template object to apply

createDCI(origin, name, description, dataType, pollingInterval, retentionTime) ⇒ [class-dci]

Create a new data collection item on this object.

Table 2. Parameters

origin

String or Integer

Data origin. Possible values: "agent", "snmp", "internal", "push", "websvc", "winperf", "script", "ssh", "mqtt", "driver", "modbus", "ethernetip". Alternatively, you can use Data origin constants.

name

String

Name of the metric (e.g. "Agent.Version").

description

String

Human readable description.

dataType

String or Integer

Type of the collected data. Possible values: "int32", "uint32", "int64", "uint64", "counter32", "counter64", "float", "string". Alternatively, you can use DCI data type constants.

pollingInterval

String

Polling interval in seconds or null for server-default value. Optional.

retentionTime

String

Retention time in days, "0" for "Do not save collected data to database" or null for server-default value. Optional.

Return

Instance of newly created [class-dci] or null if failed (e.g. invalid origin or data type).

Added in version 6.2

dci = $node.createDCI("agent", "Agent.Version", "Agent Version", "string");
println(dci.id);
enableConfigurationPolling(flag): void

Enable or disable configuration polling for a node

Table 3. Parameters

flag

Boolean

If configuration polling should be enabled.

enableDataCollection(flag): void

Enable or disable data collection polling for a node.

Table 4. Parameters

flag

Boolean

If data collection polls should be enabled.

enableStatusPolling(flag): void

Enable or disable status polling for a node.

Table 5. Parameters

flag

Boolean

If status polls should be enabled.

findAllDCIs(name, description, tag, relatedObject) ⇒ Array

Find all DCIs matching the given filters. All parameters are optional; omitted or null parameters are not used for filtering. Name, description and tag support glob patterns.

Table 6. Parameters

name

String

Name filter (glob pattern). Optional.

description

String

Description filter (glob pattern). Optional.

tag

String

User tag filter (glob pattern). Optional.

relatedObject

[class-netobj] or Integer

Related object or object ID. Optional.

Return

Array of [class-dci] objects matching the filters.

Added in version 6.2

// Find all CPU-related DCIs
dcis = $node.findAllDCIs("System.CPU.*");
for (d : dcis)
   println(d.name .. " = " .. d.cachedValue);
findDCIById(id) ⇒ [class-dci]

Find a DCI on this object by its unique ID.

Table 7. Parameters

id

Integer

DCI ID.

Return

[class-dci] object or null if not found.

Added in version 6.2

findDCIByName(name) ⇒ [class-dci]

Find a DCI on this object by parameter name (exact match).

Table 8. Parameters

name

String

Parameter name of the DCI.

Return

[class-dci] object or null if not found.

Added in version 6.2

dci = $node.findDCIByName("System.CPU.Usage");
if (dci != null)
   println("CPU Usage: " .. dci.cachedValue);
findDCIByDescription(description) ⇒ [class-dci]

Find a DCI on this object by description (exact match).

Table 9. Parameters

description

String

Description of the DCI.

Return

[class-dci] object or null if not found.

Added in version 6.2

findDCIByTag(tag) ⇒ [class-dci]

Find a DCI on this object by user tag (exact match).

Table 10. Parameters

tag

String

User tag value.

Return

[class-dci] object or null if not found.

Added in version 6.2

findDCIByTagPattern(pattern) ⇒ [class-dci]

Find a DCI on this object by user tag using a glob pattern.

Table 11. Parameters

pattern

String

Glob pattern to match against user tags.

Return

[class-dci] object or null if not found. Returns the first matching DCI.

Added in version 6.2

pushDCIData(dciId, value, timestamp) ⇒ Boolean

Push a new value to a DCI from script. The DCI’s data source must be set to "Push" or "OTLP".

Table 12. Parameters

dciId

Integer

DCI ID.

value

String

New value for the DCI.

timestamp

Integer

Timestamp in milliseconds since epoch. Optional, current time is used if not specified.

Return

true on success, false on failure (DCI not found, wrong data source, or not a single value DCI).

Added in version 6.2

dci = $node.findDCIByName("My.Push.Metric");
$node.pushDCIData(dci.id, "42");
readInternalParameter(name): String

Reads object internal metric (metric with source "Internal").

Table 13. Parameters

name

String

Metric name.

readInternalTable(name): String

Reads object internal table metric (metric with source "Internal").

Table 14. Parameters

name

String

Metric name.

removeTemplate(template): void

Remove template from node

Table 15. Parameters

template

[class-template]

Template object to remove