As we can retrieve all facts, classes, and agent plugins for all nodes, we can do some custom reporting on all of these.
The mco inventory tool is a generic node and network reporting tool. It also has basic scripting abilities.
Single Node View
To obtain a full inventory for a given node you can run mco inventory <name> and receive a report about the node’s details:
MCollective nodes can be assigned to any number of Subcollectives, and you can use the inventory application to get an overview of all known collectives:
You can also create a DOT format graph of your collective:
The graph will be a simple dot graph that can be viewed with Graphviz, Gephi or
other compatible software.
You can create little scriptlets and pass them into mco inventory with the –script option.
You have the following data available to your reports:
The time the report was started (normal Ruby Time object)
The sender id
A hash of facts
An array of agents
An array of CF Classes
Printf Style Reports
Say you need a report of all your IBM hardware listing hostname, serial number, and product name. You can write a scriptlet like this:
Assuming you saved the file as inventory.mc, run the inventory application like this:
Perl Format Style Reports
To use this you need to install the formatr gem; once that’s installed you can create a report scriptlet like below:
Here we create a paged report — 20 nodes per page — with a heading section and a 2 line report per node with identity, customer, distribution, and processor.
The output looks like this:
Perl-style reports are a somewhat old and awkward format, but they fit well into a CLI environment and work reasonably well for simple reports. You can see the perlform man page for details of how to write reporting layouts; the Formatr gem stays pretty close to the original implementation. See Formatr’s documentation for info on any differences.