...
opConfig and opEvents provide a number of different methods for managing nodes, both GUI-based and commandline-oriented. This document describes the available commandline tools.
Bulk Import and Export
For importing lots of nodes in one go from a CSV file, NMIS has been providing admin/import_nodes.pl
for a long time. There is also a sibling admin/export_nodes.pl
tool, and both are documented on the Bulk Import page. The main benefit of these tools is utmost simplicity, but at the cost of some flexibility: import_nodes
does not make all common node properties controllable or accessible.
Node administration with node_admin.pl
...
Node administration with opnode_admin.pl
/usr/local/omk/bin/opnode_admin.pl is scriptable and pipelineable, and can perform all node-related operations: creation, updating, renaming, exporting and deletion of nodes.
...
Run the tool with no options or -? or -h and it'll display a simple help page:
Code Block |
---|
./adminbin/nodeopnode_admin.pl -h Usage: nodeopnode_admin.pl act=[action to take] [extras...] nodeopnode_admin.pl act=list nodeopnode_admin.pl act={create|export|update|delete}} node=nodeX opnode_admin.pl act=delete node=nodeX [deletedata=0/1] opnode_admin.pl act=show node=nodeX opnode_admin.pl act=set node=nodeX entry.propname=value... opnode_admin.pl act=mktemplate [placeholder=1/0] nodeopnode_admin.pl act=rename old=nodeX new=nodeY mktemplate: prints blank template for node creation, optionally with __REPLACE_XX__ placeholder create: requires file=NewNodeDef.json export: exports to file=someFile.json (or STDOUT if no file given) update: updates existing node from file=someFile.json (or STDIN) delete: only deletes if confirm=yes (in uppercase) is given extras: deletedata=<true,false> which makes delete also delete all RRD files for the node. default is false. extras: conf=<configname> to use different configuration extras: debug={1..9,verbose} sets debugging verbosity extras: info=1 sets general verbosity |
...
node events and config information are deleted only if deletedata
is 1 or true.
show: prints the nodes properties in the same format as set
set: adjust one or more node properties |
Node Listing and Exporting
Given the argument act=list
, nodeopnode_admin
will simply print a list of all known node names.To see or
Version 2.70.0 onwards prints its two lines of header only when displaying to a terminal; with older versions you'll have to exclude these lines if you want to reuse the data.
To save a node's config information, run admin/nodeopnode_admin.pl act=export node=somenodename
, and it'll print the node's configuration in JSON format to your console. If you want to save that data in a file, either add the argument file=somefilename.json
or redirect the output with > somefile
. Here is an example of what to expect:
Code Block |
---|
./admin/node_admin.pl act=export node=mytestbox { "active" : "true", "businessService" : "my own test system", "collect" : "true", "community" : "verySecETr", "group" : "HQDev", "host" : "mytestbox.opmantek.com", "location" : "office", "model" : "automatic", "name" : "mytestbox", "netType" : "lan", "notes" : "there are no notes for this baby", "ping" : "true", "roleType" : "access", "version" : "snmpv2c" }fixme example |
Node Updating
Naturally node_admin
does not just export node data but also consumes it for modifying a node in place and for creation of new nodes.
...