Alarm

Represents NetXMS alarm.

Instance attributes

ackBy: int

ID of user who acknowledged this alarm, or -1 if the alarm was not acknowledged.

ackByUser ⇒ UserDBObject

User who acknowledged this alarm (class User or UserGroup, both derived from UserDBObject), or null if the alarm was not acknowledged or the user does not exist.

categories: Array

Array with alarm category names.

creationTime: int

Unix timestamp of the alarm creation time.

dciId: int

If alarm was created as a result of DCI threshold violation, this attribute will contain ID of the DCI.

eventCode: int

Event code of originating event.

eventId: int

ID of originating event.

eventName: String

Name of originating event. If the event template no longer exists, contains the event code.

eventTagList: String

List of event tags as a comma separated string

helpdeskReference: String

Helpdesk system reference (e.g. issue ID).

helpdeskState: int

Helpdesk state:

  • 0 = Ignored

  • 1 = Open

  • 2 = Closed

id: int

Unique identifier of the alarm.

impact: String

Alarm impact text

key: String

Alarm key.

lastChangeTime: int

Unix timestamp of the last update.

message: String

Alarm message.

originalSeverity: int

Original severity of the alarm.

parentId: int

Parent alarm id

repeatCount: int

Repeat count.

resolvedBy: int

ID of user who resolved this alarm, or -1 if the alarm was not resolved.

resolvedByUser ⇒ UserDBObject

User who resolved this alarm (class User or UserGroup), or null if the alarm was not resolved or the user does not exist.

rcaScriptName: String

Name of root cause analysis script

relatedEvents: Array

Array with related event IDs.

Added in version 6.0

ruleGuid: String

GUID of the event processing policy rule that created the alarm.

ruleDescription: String

Description of the event processing policy rule that created the alarm.

severity: int

Current alarm severity.

sourceObject: int

ID of the object where alarm is raised.

state: int

Alarm state (see alarm state values):

  • 0 = Outstanding

  • 1 = Acknowledged

  • 2 = Resolved

  • 3 = Terminated

  • 17 = Sticky acknowledged

Instance methods

acknowledge(includeSubordinates): bool

Acknowledge alarm.

Table 1. Parameters

includeSubordinates

Boolean

Optional. If true, subordinate alarms of this alarm are acknowledged as well. false by default.

Return

true on success, false on failure.

addComment(commentText, syncWithHelpdesk): int

Add new alarm comment.

Table 2. Parameters

commentText

String

Text of the new alarm comment.

syncWithHelpdesk

Boolean

Optional. If true, the comment is also sent to the linked helpdesk issue. true by default.

Return

Id of the newly created alarm comment, or null on failure.

closeHelpdeskIssue(): bool

Mark helpdesk issue linked to this alarm as closed. Helpdesk reference is kept, helpdesk state changes to Closed. Alarm must be in helpdesk state Open.

Return

true on success, false if helpdesk state is not Open or the alarm no longer exists.

getComments(): Array

Get array of alarm comments.

Return

Array of AlarmComment objects.

requestAiAssistantComment(): String

Request an AI assistant comment for this alarm.

Return

String containing the AI assistant’s response, or null if the source object no longer exists or the AI assistant returned no response. The response is not added to the alarm as a comment.

resolve(includeSubordinates): bool

Resolve alarm.

Table 3. Parameters

includeSubordinates

Boolean

Optional. If true, subordinate alarms of this alarm are resolved as well. false by default.

Return

true on success, false on failure.

setHelpdeskReference(reference): bool

Link this alarm to an external helpdesk issue without going through the helpdesk integration module. Sets helpdesk reference and changes helpdesk state to Open. Alarm must be in helpdesk state Ignored (not yet linked).

Table 4. Parameters

reference

String

Helpdesk system reference (e.g. issue ID). Must not be empty.

Return

true on success, false if the alarm is already linked to a helpdesk issue, reference is empty, or the alarm no longer exists.

alarm = FindAlarmByKey("DISK_FULL_" .. $node.id);
if (alarm != null && alarm.helpdeskState == 0)
{
   if (!alarm.setHelpdeskReference("TICKET-4711"))
      trace(2, "Cannot set helpdesk reference for alarm " .. alarm.id);
}
terminate(includeSubordinates): bool

Terminate alarm.

Table 5. Parameters

includeSubordinates

Boolean

Optional. If true, subordinate alarms of this alarm are terminated as well. false by default.

Return

true on success, false on failure.

unlinkFromHelpdesk(): bool

Remove helpdesk link from this alarm. Clears helpdesk reference and resets helpdesk state to Ignored. Works in any helpdesk state.

Return

true on success, false if the alarm no longer exists.