AutoPatrol, Bureaucrats, Administrators
481
edits
(Created page with "= Introduction = NxShell is based on Jython and provide access to NetXMS Java API using interactive shell. NxShell is build as single jar file, which includes all required lib...") |
|||
Line 30: | Line 30: | ||
|- | |- | ||
|} | |} | ||
= Scripting = | |||
For details on API please refer to javadoc at http://www.netxms.org/documentation/javadoc/latest/. | |||
NxShell provide user with already connected and synchronised session to simplify scripting. Most required packages are imported as well to minimize typing. | |||
== Global Variables == | |||
{| class="wikitable" | |||
|- | |||
! Variable !! Type !! Notes | |||
|- | |||
| session || org.netxms.client.NXCSession || | |||
|- | |||
| s || org.netxms.client.NXCSession || Alias for "session" | |||
|- | |||
|} | |||
== Helper Functions == | |||
= Sample Scripts = | |||
== Create Container and some nodes == | |||
<pre>parentId = objects.GenericObject.SERVICEROOT # Infrastructure Services root | |||
cd = NXCObjectCreationData(objects.GenericObject.OBJECT_CONTAINER, "Sample Container", parentId); | |||
containerId = session.createObject(cd) # createObject return ID of newly created object | |||
print '"Sample Container" created, id=%d' % (containerId, ) | |||
flags = NXCObjectCreationData.CF_DISABLE_ICMP | \ | |||
NXCObjectCreationData.CF_DISABLE_NXCP | \ | |||
NXCObjectCreationData.CF_DISABLE_SNMP | |||
for i in xrange(0, 5): | |||
name = "Node %d" % (i + 1, ) | |||
cd = NXCObjectCreationData(objects.GenericObject.OBJECT_NODE, name, containerId); | |||
cd.setCreationFlags(flags); | |||
cd.setPrimaryName("0.0.0.0") # Create node without IP address | |||
nodeId = session.createObject(cd) | |||
print '"%s" created, id=%d' % (name, nodeId) | |||
</pre> |