NXShell Reference

This page provides a reference for NXShell command-line options, Java properties, and API classes.

For installation, usage examples, and practical scripts, see NXShell.

Command-Line Options

Option Description

-H, --host

NetXMS server address (can be in host:port form)

-u, --user

Login username. Default: admin.

-P, --password

User password. Default: empty.

-p, --port

TCP port for connection. Default: 4701.

-C, --classpath

Additional Java class path.

-D, --debug

Show additional debug output.

-n, --no-sync

Do not synchronize objects on connect.

-t, --token

Login using authentication token.

-r, --properties

File with additional Java properties.

-v, --version

Display version information.

-j, --jre

Specify JRE location.

-h, --help

Display help message.

Java Properties

Property Default

netxms.server

127.0.0.1

netxms.port

4701

netxms.login

admin

netxms.password

(empty)

netxms.token

(none) — when set, token authentication is used and no login/password prompt appears

netxms.enableCompression

true

netxms.syncObjects

true

nxshell.interactive

(auto) — force interactive mode

Additional properties can be loaded from a file named by the nxshell.properties system property.

Running NXShell

NXShell can be run as an installed binary or as a standalone JAR file.

Start an interactive session:

nxshell -H server_address -u admin -P password

Run a script file:

nxshell -H server_address -u admin -P password script.py

Using the JAR file directly:

java -jar nxshell-VERSION.jar

When started, NXShell reads server address, login, and password from Java properties. In interactive mode, the user is prompted for missing details.

java -Dnetxms.server=127.0.0.1 -Dnetxms.login=admin -jar nxshell-VERSION.jar
Passing passwords on the command line exposes them in shell history and process listings. For non-interactive use (scripts), prefer token authentication (-t option). For interactive use, omit -P to be prompted for the password securely.

Session API

NXShell provides access to the NetXMS session object, pre-initialized when the shell starts and bound as both session and the short alias s.

Commonly used org.netxms.base, org.netxms.client, and org.netxms.client.* subpackages (objects, datacollection, events, constants, users, topology, maps, and others) are wildcard-imported at startup, so class names like NXCObjectModificationData resolve without explicit imports. NXShell embeds Jython 2.7 (Python 2 syntax), and __name__ is set to __nxshell__ — if __name__ == "__main__": guards will not fire in nxshell scripts.

Object Methods

Method Description

session.findObjectByName(name)

Find object by name

session.findObjectById(id)

Find object by numeric ID

session.getAllObjects()

Get all objects

session.createObject(creationData)

Create a new object

session.modifyObject(modificationData)

Modify object properties

session.deleteObject(objectId)

Delete an object

Data Collection Methods

Method Description

session.openDataCollectionConfiguration(nodeId)

Open the DCI configuration for a node

session.getLastValues(nodeId)

Get last DCI values for a node

session.getCollectedData(nodeId, dciId, from, to, maxRows, valueType)

Get historical DCI data as a DataSeries (use .getValues() for the rows)

Alarm Methods

Method Description

session.getAlarms()

Get all active alarms

session.acknowledgeAlarm(alarmId)

Acknowledge an alarm

session.resolveAlarm(alarmId)

Resolve an alarm

session.terminateAlarm(alarmId)

Terminate an alarm

Action Methods

Method Description

session.executeAction(nodeId, action, args)

Execute agent action

session.executeScript(objectId, script, parameters, listener)

Execute NXSL script in the context of an object

Helper Classes

Class Description

NXCObjectCreationData

Data holder for creating new objects. Pass object class, object name, and parent ID.

NXCObjectModificationData

Data holder for modifying existing objects. Pass object ID.