Skip to content

Latest commit

 

History

History
220 lines (153 loc) · 4.45 KB

event.adoc

File metadata and controls

220 lines (153 loc) · 4.45 KB

Event

Represents NetXMS event object.

Instance attributes

code ⇒ Integer

Event code

customMessage ⇒ String

Custom message set in event processing policy by calling setMessage. Deprecated and will be removed in a future version.

dci ⇒ DCI

DCI object of class [class-dci] that is source for this event or NULL if generated not by threshold

dciId ⇒ Integer

DCI id that is source for this event or 0 if generated not by threshold

id ⇒ Integer

Unique event identifier.

lastAlarmKey ⇒ String

Key for last generated alarm for this event or null

message ⇒ String

Event message. Get/set attribute.

name ⇒ String

Event name.

origin ⇒ Integer

Origin of the event

  • 0 - SYSTEM

  • 1 - AGENT

  • 2 - CLIENT

  • 3 - SYSLOG

  • 4 - SNMP

  • 5 - NXSL

  • 6 - REMOTE_SERVER

originTimestamp ⇒ Integer

The time when the event was generated in the origin.

parameters ⇒ Array

List of event parameters. Starting index is 1.

parameterNames ⇒ Array

List of named event parameters (e.g. "dciId"), which can be accessed by object.parameterName.

rootId ⇒ Integer64

Id of event that is root cause of this event or 0 if there is no such event.

severity ⇒ Integer

Event severity code. Get/set attribute.

source ⇒ NetObj

Source object (inherited from [class-netobj], exact type can be checked with [func-classof] function) for the event.

sourceId ⇒ Integer

ID of the source object for the event.

tags ⇒ Array

Event tags as an array of strings.

tagList ⇒ String

Event tags as a coma separated list.

timestamp ⇒ Integer

Unix timestamp of the event.

$1…$n

Shortcut for parameters[n] (e.g. "$event.parameters[3]" can be replaced with "$event.$3").

$…

Named event parameters can be accessed directly by the name (e.g $event.dciId). List of available named parameters can be accessed with parameterNames attribute. Get/set attribute.

Instance methods

addParameter(name, value) ⇒ void

Set event parameter

Table 1. Parameters

name

String

Parameter name. Optional parameter.

value

String

Parameter value.

addTag(tag) ⇒ void

Set event tag, which can be later accessed via tags attribute.

Table 2. Parameters

tag

String tag

correlateTo(eventId) ⇒ void

Sets root cause id for the event

Table 3. Parameters

eventId

Root cause event id

expandString(string) ⇒ String

Expand string by replacing macros with their values.

Table 4. Parameters

string

String to expand

Return

Formated string

Example
>>> $event.expandString("%N")
SYS_THRESHOLD_REACHED
getParameter(name) ⇒ void

Get parameter value by name or by index

Table 5. Parameters

name

Parameter name or index

Return

Parameter value or null

hasTag(tag) ⇒ Boolean

Return if event has specific tag.

Table 6. Parameters

tag

String tag

removeTag(tag) ⇒ void

Remove tag from event tag list

Table 7. Parameters

tag

String tag

setMessage(message) ⇒ void

Set event message to message.

Table 8. Parameters

message

Message string

setNamedParameter(name, value) ⇒ void

Set named parameter or change value of existing named parameter

Table 9. Parameters

name

String name of parameter

value

String value of parameter

setParameter(index, value) ⇒ void

Set value of parameter or change value of existing parameter. If index corresponds to existing parameter, the value will be set. If index is higher then existing number of parameters, new parameter(s) will be added (if needed, parameters with empty values will be added to reach the number of parameters indicated by index).

Table 10. Parameters

index

Integer index of parameter

value

String value of parameter

setSeverity(severityCode) ⇒ void

Change event severity to severityCode.

Table 11. Parameters

severityCode

Numeric severity code

toJson() ⇒ String

Serialize object to JSON.

Return

String representation of the object in JSON format.