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
nxshell [<options>] [<script>]
Without a script file, an interactive Python console is started.
| Option | Description |
|---|---|
|
NetXMS server host name or IP address, optionally in |
|
Server TCP port. Default: the port from |
|
Login user name. Default: |
|
User password, in clear text or encrypted with nxencpasswd for the login given with |
|
Log in using the given authentication token instead of user name and password. |
|
Do not synchronize objects and the user database on connect. Lookups in the local object cache, such as |
|
File with additional Java properties (see Java Properties). |
|
Additional Java class path. |
|
JRE location. By default, the Java runtime is located automatically. |
|
Show additional debug output. Use twice for extra output (JNI and class loading). |
|
Display version information and exit. |
|
Display help message and exit. |
Java Properties
NXShell takes its connection settings from Java properties.
The nxshell launcher sets them from its command-line options; when the JAR file is started directly, pass them with -D.
| Property | Description |
|---|---|
|
Server address, optionally in |
|
Server TCP port; overrides a port given in |
|
Login user name. Default: |
|
User password. Default: empty. |
|
Authentication token. When set, token authentication is used and login and password are neither used nor prompted for. |
|
Enable protocol compression. Default: |
|
Synchronize objects and the user database on connect. Default: |
|
When set to any value, forces interactive mode (prompts for missing connection details, shows the console prompt). By default, interactive mode is used when standard input is a terminal. |
|
When set to any value, enables debug-level logging of the client library to the console. Set by |
|
Write the client library log, at debug level, to this file instead of the console. The file is rotated daily, and 30 days are kept. |
|
Name of a file with additional properties. Set by |
Properties are loaded in this order, later sources overriding earlier ones:
-
Java system properties, including those set by the
nxshelllauncher from its command-line options -
nxshell.propertieson the class path or in the current directory -
The file named by the
nxshell.propertiesproperty
As a result, a property file overrides the corresponding command-line options.
Running NXShell
NXShell can be run with the nxshell launcher or by starting its JAR file directly.
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
The JAR file nxshell-VERSION.jar is installed in the NetXMS Java library directory together with the jars it depends on, which its manifest references:
java -jar nxshell-VERSION.jar
When started this way in interactive mode, NXShell prompts for the server address (and port), login, and password if they are not given as Java properties.
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). When running from a terminal, omit -P to be prompted for the password.
|
Session API
NXShell provides access to the NetXMS session object (org.netxms.client.NXCSession), connected and logged in 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 |
|---|---|
|
Find object by name (case-insensitive) in the local object cache. If several objects have the same name, any one of them is returned; |
|
Find object by numeric ID in the local object cache |
|
Get all objects from the local object cache |
|
Create a new object; returns the ID of the new object |
|
Modify object properties |
|
Delete an object |
Data Collection Methods
| Method | Description |
|---|---|
|
Open the DCI configuration for a node |
|
Get last DCI values for a node |
|
Get historical DCI data as a |
Alarm Methods
| Method | Description |
|---|---|
|
Get all active alarms as a map of alarm ID to alarm object (terminated alarms are not included) |
|
Acknowledge an alarm |
|
Resolve an alarm |
|
Terminate an alarm |