Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

NMIS provides a number of different methods for managing your nodes, both GUI-based and commandline-oriented. This document describes the commandline tools present in versions 8.5.4 and newer.

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

Version 8.5.4G brings in a new, more fine-grained and capable tool: admin/node_admin.pl. It's scriptable and pipelineable, and can perform all node-related operations: creation, updating, renaming, exporting and deletion of nodes.

Basic Operation

Run the tool with no options or -? or -h and it'll display a simple help page:

Import nodes to NMIS9 from NMIS8

To import nodes from NMIS8 to NMIS9 copy /path/to/nmis8/conf/Nodes.nmis to /tmp/ on NMIS9 installation then:

Code Block
/usr/local/nmis9/admin/node_admin.pl act=import_bulk nodes="/tmp/Nodes.nmis"

Caveats: you can not import a node to a server if there is already a node existing with that name, you should rename the node before importing.

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

Version 8.5.4G brings in a new, more fine-grained and capable tool: admin/node_admin.pl. It's scriptable and pipelineable, and can perform all node-related operations: creation, updating, renaming, exporting and deletion of nodes.

Basic Operation

Run the tool with no options or -? or -h and it'll display a simple help page:

Code Block
./admin/node_admin.pl -h
Usage: 
Code Block
./admin/node_admin.pl -h
Usage: node_admin.pl act=[action to take] [extras...]
        node_admin.pl act=list
        node_admin.pl act={create|export|update|delete} node=nodeX
        node_admin.pl act=mktemplate [placeholder=1/0[action to take] [extras...]
        node_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 fromlist
        node_admin.pl act={create|export|update|delete} node=nodeX
        node_admin.pl act=mktemplate [placeholder=1/0]
        node_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 STDIN STDOUT if no file given)
deleteupdate: onlyupdates deletesexisting if 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

...

You can also use file=- to indicate that STDOUT should be used for export or STDIN be used for update/creation. The act=update operation doesn't create new  nodes, and it  replaces the whole set of node configuration settings with your new configuration input. So, if a property is not set, it will disappear. For change only one property, the operation "set" is more accurate. 

Creation of Nodes

The creation of nodes requires you to use a template (shown below) instead of using a command line argument; this is because NMIS requires numerous node properties to be set up correctly making it easy to miss some when operating via command line arguments. Node creation is triggered by the argument act=create, which behaves mostly like act=update, except that it doesn't touch existing nodes. To help you with starting a node configuration document from scratch (or in a scripted fashion), there is another command, act=mktemplate, which prints a blank but documented template which you can save and fill in. If you add placeholder=1 to the command line, then node_admin fills the template with easily matchable replacement placeholders, like so:

...

The node admin tool in NMIS9 brings some enhancements.

NMIS9 example of json format for a node

Code Block
# "/usr/local/nmis9/admin/node_admin.pl" act=export node=localhost
{
   "activated" : {
      "NMIS" : 1,
      "opConfig" : 1,
      "opEvents" : 1
   },
   "addresses" : [
      {
         "address" : "127.0.0.1"
      }
   ],
   "aliases" : [],
   "configuration" : {
      "active" : 1,
      "authkey" : "",
      "authpassword" : "",
      "authprotocol" : "md5",
      "businessService" : "",
      "calls" : 0,
      "cbqos" : "none",
      "collect" : 1,
      "community" : "nmisGig8",
      "context" : "",
      "customer" : "Opmantek",
      "depend" : [
         "N/A"
      ],
      "display_name" : "",
      "group" : "NMIS9",
      "host" : "127.0.0.1",
      "host_backup" : "",
      "location" : "Amsterdam",
      "max_msg_size" : 1472,
      "max_repetitions" : 0,
      "model" : "automatic",
      "netType" : "lan",
      "node_context_name" : "",
      "node_context_url" : "",
      "notes" : "",
      "ping" : 1,
      "polling_policy" : "default",
      "port" : 161,
      "privkey" : "",
      "privpassword" : "",
      "privprotocol" : "des",
      "remote_connection_name" : "",
      "remote_connection_url" : "",
      "roleType" : "distribution",
      "serviceStatus" : "Development",
      "services" : [
         "SNMP_Daemon",
         "http_server",
         "port22",
         "port25",
         "port80",
         "opmantek.pl",
         "mongo_daemon",
         "omkd check",
         "opchartsd",
         "opconfigd",
         "opeventsd",
         "nmis cgi",
         "nmis9d",
         "check_disk_write"
      ],
      "threshold" : 1,
      "timezone" : 0,
      "username" : "",
      "version" : "snmpv2c",
      "webserver" : 1,
      "wmipassword" : "",
      "wmiusername" : ""
   },
   "lastupdate" : 1592715346,
   "name" : "localhost",
   "overrides" : {}
}


Backup, Migrate or just play with a Node

...