AutoPatrol, Bureaucrats, Administrators
481
edits
m (Text replacement - "^" to "{{deprecated}}") |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
= Introduction = | {{deprecated}}= 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 libraries. | 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 libraries. | ||
Line 229: | Line 229: | ||
else: | else: | ||
print 'No connection found' | print 'No connection found' | ||
</syntaxhighlight> | |||
== Reset retention time for all DCIs on all nodes to default == | |||
<syntaxhighlight lang="python"> | |||
from org.netxms.client.datacollection import DataCollectionConfiguration, DataCollectionObject | |||
from org.netxms.client.objects import Node, Template | |||
for o in filter(lambda x: (isinstance(x, Node) or isinstance(x, Template)), session.allObjects): | |||
config = session.openDataCollectionConfiguration(o.objectId) | |||
for dc in config.items: | |||
if dc.templateId == 0: | |||
dc.setRetentionTime(0) | |||
config.modifyObject(dc) | |||
config.close() | |||
print "%s %s updated" % ("Node" if isinstance(o, Node) else "Template", o.objectName) | |||
</syntaxhighlight> | |||
== List Inventory Software for all nodes == | |||
<syntaxhighlight lang="python"> | |||
for node in [o for o in s.getAllObjects() if isinstance(o, objects.Node)]: | |||
print 'Node: ', node.getObjectName() | |||
try: | |||
for package in s.getNodeSoftwarePackages(node.getObjectId()): | |||
print package.getName() | |||
except: | |||
print "No package found" | |||
</syntaxhighlight> | |||
== Enter/Leave Maintenance for node == | |||
<syntaxhighlight lang="python"> | |||
from org.netxms.client.objects import Node | |||
import org.netxms.client.NXCSession | |||
NETXMS_NODE = "__NodeName__" | |||
STATE = False or True | |||
node = session.findObjectByName(NETXMS_NODE.strip()) | |||
if node: | |||
session.setObjectMaintenanceMode(node.getObjectId(), STATE) | |||
</syntaxhighlight> | </syntaxhighlight> |