You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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.

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.

Basic Operation

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

./bin/opnode_admin.pl 
Usage: opnode_admin.pl act=[action to take] [extras...]
        opnode_admin.pl act=list
        opnode_admin.pl act={create|export|update} 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]
        opnode_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
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, opnode_admin will print a list of all known node names.

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/opnode_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. Here is an example of what to expect:

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.

To change a node's configuration (except node renaming!), simply dump the node configuration with act=export, then edit the node with act=update. Both require that you give the node name in question, and both work either from files (with a file=somefile.json argument), or via STDOUT/STDIN/pipeline.

For example, this pipelined invocation would change the node from the example above to a less misspelled community:

./admin/node_admin.pl act=export node=mytestbox | sed -e 's/verySecETr/veryVerySecret/' | ./admin/node_admin.pl act=update node=mytestbox

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.

Creation of Nodes

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:

./admin/node_admin act=mktemplate placeholder=1
// ... some comments
{
   "active" : "__REPLACE_ACTIVE__",
   "collect" : "__REPLACE_COLLECT__",

This makes it very easy to fill in the template with a script or some other external tool.

Node Renaming

To rename nodes you should use act=rename which requires both old and new node names with arguments old and new, respectively. This operation first changes the node name (which is the primary name the node is known to and displayed by NMIS, and which is NOT necessarily the hostname or ip address of the node), and then adjusts all files related to the node in question:

  • all RRD database files are renamed,
  • and the node-related state files in /usr/local/nmis8/var are also renamed.

Deleting Nodes

To remove a node (but not its historic data) simply run node_admin with the argument act=delete node=ripnode, plus the option confirm=YES (must be uppercase) to make node_admin actually perform the deletion.

This removes only the node configuration record but not RRD database files or state files in var. To delete these as well, you can add the option deletedata=1 to the command, and all data related to this node will be removed permanently.

Node Properties

NMIS uses a subset of the node properties of the commercial Opmantek tools. node_admin.pl act=mktemplate includes a very brief listing of the most essential ones from NMIS' perspective, and the Common Node Properties wiki page describes most of the important ones in greater detail.

  • No labels