AutoPatrol, Bureaucrats, Administrators
481
edits
m (Text replacement - "^" to "{{deprecated}}") |
|||
(3 intermediate revisions by 2 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 237: | Line 237: | ||
from org.netxms.client.objects import Node, Template | from org.netxms.client.objects import Node, Template | ||
for o in filter(lambda x: (isinstance(x, Node) or isinstance(x, Template)), session. | for o in filter(lambda x: (isinstance(x, Node) or isinstance(x, Template)), session.allObjects): | ||
config = session.openDataCollectionConfiguration(o. | config = session.openDataCollectionConfiguration(o.objectId) | ||
for dc in config. | for dc in config.items: | ||
if dc. | if dc.templateId == 0: | ||
dc.setRetentionTime(0) | dc.setRetentionTime(0) | ||
config.modifyObject(dc) | config.modifyObject(dc) | ||
config.close() | config.close() | ||
print "%s %s updated" % ("Node" if isinstance(o, Node) else "Template", o.getObjectName()) | 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> |