Skip to content

Latest commit

 

History

History
667 lines (475 loc) · 14.1 KB

netobj.adoc

File metadata and controls

667 lines (475 loc) · 14.1 KB

NetObj

Base class for all NetXMS objects.

Instance attributes

Note
Object custom attributes can be accessed in the same way as instance attribute. If name of the custom attribute overlaps with the instance attribute, method NetObj::getCustomAttribute() should be used instead.
alarms ⇒ array

List of active Alarms for this object.

alarmStats ⇒ array

Integer array that consists of 5 numbers - each number represents number of alarms for this and child objects for each of severity.

alias ⇒ String

Object alias. For interfaces it is automatically collected on configuration poll (e.g. from SNMP ifAlias).

asset ⇒ [class-asset]

Reference to asset class of asset linked to this object.

assetId ⇒ Integer

Id of linked asset object.

assetProperties ⇒ [class-assetproperties]

Reference to asset properties class of asset linked to this object.

backupZoneProxy ⇒ Node

Currently selected backup zone proxy (null if zoning is disabled or backup proxy is not assigned)

backupZoneProxyId ⇒ Integer

ID of currently selected backup zone proxy (0 if zoning is disabled or backup proxy is not assigned)

category ⇒ String

Object’s category name

categoryId ⇒ Integer

Object’s category ID

children ⇒ array

List of child objects (inherited from NetObj). Use [func-classof] to differentiate.

city ⇒ String

Postal address - city.

comments ⇒ String

Object comments.

country ⇒ String

Postal address - country.

creationTime ⇒ Integer64

Object creation time as UINX timestamp

customAttributes ⇒ HashMap

Hash map of object custom attributes.

district ⇒ String

Postal address - district.

geolocation ⇒ GeoLocation

Object geographical location.

guid ⇒ String

Object GUID as string.

id ⇒ Integer

Unique object identifier.

ipAddr ⇒ String

Primary IP address. Deprecated and will be removed in a future version, use ipAddress instead.

ipAddress ⇒ InetAddress

Primary IP address. This attribute was added in version 5.1

isInMaintenanceMode ⇒ Boolean

Maintenance mode indicator (true if object currently is in maintenace mode).

maintenanceInitiator ⇒ Integer

Maintenance initiator user id

mapImage ⇒ String

GUID of object image used for representation on the maps.

name ⇒ String

Object name.

nameOnMap ⇒ String

Object name displayed on map.

parents ⇒ array

List of direct parents for this object (inherited from NetObj, most likely either [class-container] or [class-cluster]).

postcode ⇒ String

Postal address - postal code.

primaryZoneProxy ⇒ Node

currently selected primary zone proxy (null if zoning is disabled or primary proxy is not assigned)

primaryZoneProxyId ⇒ Integer

ID of currently selected primary zone proxy (0 if zoning is disabled or primary proxy is not assigned)

region ⇒ String

Postal address - region.

responsibleUsers ⇒ Array

Array with user objects that are added as responsible users for this object. Objects are [class-user] or [class-usergroup]

state ⇒ Integer

Current object state. One of: [const-node-state], [const-cluster-state], [const-sensor-state]

status ⇒ Integer

Current object status.

streetAddress ⇒ String

Postal address - street.

type ⇒ Integer

Object type.

Instance methods

bind(childObject) ⇒ void
Note
This method is enabled by default, but can be disabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Bind childObject to the current object as a child.

Table 1. Parameters

object

NetObj

Object to bind as a child to the current object.

bindTo(parentObject) ⇒ void
Note
This method is enabled by default, but can be disabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Bind current object to parentObject as a child.

Table 2. Parameters

object

NetObj

Object to bind as a parent to the current object.

calculateDowntime(tag, periodStart, periodEnd) ⇒ Array

Calculate node downtime

Table 3. Parameters

tag

String

downtime tag

periodStart

Integer

Unix timestamp of the period start

periodEnd

Integer

Unix timestamp of the period end

Return

Array of [class-downtimeinfo] objects.

clearGeoLocation() ⇒ void

Clears GeoLocation data from the node

createUserAgentNotification(message, startTime, endTime, showOnStartup) ⇒ Integer

Send user agent notification

Table 4. Parameters

message

String

message to be sent

startTime

String

start time of message delivery

endTime

String

end time of message delivery

showOnStartup

String

TRUE to show message on startup (optional, defaults to false)

Return

Message id

createContainer(name) ⇒ void
Note
This function is disabled by default and should be explicitly enabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Create container under current object

Table 5. Parameters

name

String

New container’s name

createNode(name, primaryHostName, zoneUIN) ⇒ void
Note
This function is disabled by default and should be explicitly enabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Create node under current object

Table 6. Parameters

name

String

Name for new node

primaryHostName

String

Primary host name for new node (optional)

zoneUIN

Integer

zone UIN (optional)

delete() ⇒ void

Deletes current object.

deleteCustomAttribute(name) ⇒ void

Delete custom attribute.

Table 7. Parameters

name

String

Name of the attribute to delete.

getResponsibleUsers(level) ⇒ array

Returns responsible users that have escalation level equal to specified level.

Table 8. Parameters

level

Integer

Escalation level

Return

Array with user objects that are added as responsible users for this object. Objects are [class-user] or [class-usergroup]

isDirectChild(object) ⇒ Boolean

If provided object is direct child of this object

Table 9. Parameters

object

NetObj

Object to check

Return

TRUE if provided object is direct child of this object

isDirectParent(object) ⇒ Boolean

If provided object is direct parent of this object

Table 10. Parameters

object

NetObj

Object to check

Return

TRUE if provided object is direct parent of this object

enterMaintenance() ⇒ void

Enable maintenance mode for the object.

expandString(string) ⇒ String

Expand string by replacing macros with their values.

Table 11. Parameters

string

String

String to expand

Return

Formated string

Example
>>> $node.expandString("%n")
My node name
getCustomAttribute(name) ⇒ String

Returns value of the custom attribute with the provided name.

Table 12. Parameters

name

String

Name of the attribute to get value from.

Alternatively, attributes can be accessed as instance attribues (with ., attribute should exist) or by using attribute@object notion (which will return null instead of runtime error if attribue is missing).

isChild(object) ⇒ Boolean

If provided object is child of this object

Table 13. Parameters

object

NetObj

Object to check

Return

TRUE if provided object is child of this object

isParent(object) ⇒ Boolean

If provided object is parent of this object

Table 14. Parameters

object

NetObj

Object to check

Return

TRUE if provided object is parent of this object

leaveMaintenance() ⇒ void

Disable maintenance mode for the object.

manage() ⇒ void

Sets object to managed state. Has no affect if object already managed.

readMaintenanceJournal(startTime, endTime) ⇒ Array

Read maintenance entries

Table 15. Parameters

startTime

Integer

Period start

endTime

Integer

Period end

Return

Array with [class-maintenancejournalrecord] objects

rename(name) ⇒ void

Rename object.

Table 16. Parameters

name

String

New object name

setAlias(name) ⇒ void

Set object alias name

Table 17. Parameters

name

String

New alias name

setCategory(idOrName) ⇒ void

Set object category id or name (used to get object display image)

Table 18. Parameters

idOrName

String

ID or name of category

setComments(comment, [isMarkdown]) ⇒ void

Set object comments

Table 19. Parameters

comment

String

Comment to be set

isMarkdown

Boolean

Optional second argument ( v 5.1.2 ). If it is logical "true", Markdown indicator will be added if not present already; if it is logical "false" (but not NULL), Markdown indicator will be removed if present; if it is NULL or omitted, comment will be set as is (retaining existing behavior).

setCustomAttribute(key, value, inherit=false) ⇒ void

Update or create custom attribute with the given key and value.

Table 20. Parameters

key

String

Attribute key

value

String

Attribute value

inherit

Boolean

Optional parameter. If not set - inheritance will not be changed. true to inherit, false not to inherit.

setGeoLocation(newLocation) ⇒ void

Sets node geographical location.

Table 21. Parameters

newLocation

[class-geolocation]

setMapImage(image) ⇒ void

Sets object image, that will be used to display object on network map

Table 22. Parameters

image

String

GUID or name of image from image library

setNameOnMap(name) ⇒ void

Sets object’s name, that will be used to display object on network map

Table 23. Parameters

name

String

New object’s name on map

setStatusCalculation(type, …​) ⇒ void

Sets status calculation method.

Table 24. Parameters

type

Integer

Status calculation type. One of Status callculation types

…​

Integer(s)

If single threshold or multiple thresholds type is selected, then threshold or thresholds in percentage should be provided as next parameters.

setStatusPropagation(type, …​) ⇒ void

Sets status propagation method.

Table 25. Parameters

type

Integer

Status propagation type. One of Status propagation types

…​

Integer(s)

For fixed value type - value ([const-object-status]) should be provided. For relative - offset should be provided. For severity - severity mapping should be provided (4 numbers [const-object-status]).

unbind(object) ⇒ void
Note
This method is enabled by default, but can be disabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Unbind provided object from the current object.

Table 26. Parameters

object

NetObj

Object to unbind from the current object.

unbindFrom(object) ⇒ void
Note
This method is enabled by default, but can be disabled by setting configuration parameter "NXSL.EnableContainerFunctions".

Unbind current object from the provided object.

Table 27. Parameters

object

NetObj

Object to unbind from the current object.

unmanage() ⇒ void

Set object into unmanaged state. Has no effect if object is already in unmanaged state.

writeMaintenanceJournal(description) ⇒ void

Add entry to maintenance journal

Table 28. Parameters

description

String

Message to be added

Constants

Table 29. Object Types
Code Description

0

Generic

1

Subnet

2

Node

3

Interface

4

Network

5

Container

6

Zone

7

Service Root

8

Template

9

Template Group

10

Template Root

11

Network Service

12

VPN Connector

13

Condition

14

Cluster

15

Business Service Prototype

16

Asset

17

Asset Group

18

Asset Root

19

Network Map Root

20

Network Map Group

21

Network Map

22

Dashboard Root

23

Dashboard

27

Business Service Root

28

Business Service

29

Collector

31

Mobile Device

32

Rack

33

Access Point

34

Wireless Domain

35

Chassis

36

Dashboard Group

37

Sensor

Table 30. Status callculation types
Code Description

0

Default

1

Most critical

2

Single threshold

3

Multiple thresholds

Table 31. Status propagation types
Code Description

0

Default

1

Unchanged

2

Fixed

3

Relative

4

Translated

Table 32. Status propagation types
Code Description

0

Default

1

Unchanged

2

Fixed

3

Relative

4

Translated