- Node Reports
As we have all facts, classes and agents for nodes we can do some custom reporting on all of these.
The mc inventory tool is a generic node and network reporting tool, it has basic scripting abilities.
Note: This is an emerging feature, the scripting language is likely to change
To obtain a full inventory for a given node you can run mco inventory like this:
This gives you a good idea of all the details available for a node.
As of version 1.1.3 we have a concept of Subcollectives and you can use the inventory application to get a quick report on 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.
NOTE: This feature will only be in version 0.4.8
You can create little scriptlets and pass them into mco inventory with the –script option.
You have the following data available to your reports:
|time||The time the report was started, normal Ruby Time object|
|identity||The sender id|
|facts||A hash of facts|
|agents||An array of agents|
|classes||An array of CF Classes|
printf style reports
Lets say you now need a report of all your IBM hardware listing hostname, serial number and product name you can write a scriptlet like this:
And if saved as inventory.mc run it like this:
We’ll add more capabilities in the future, for now you can access facts as a hash, agents and classes as arrays as well as identity as a string.
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:
Writing these reports are pretty ugly I freely admit, however it avoids designing our own reporting engine and it’s pretty good for kicking out simple reports. You can see the perlform man page for details of the reporting layouts, ours is pretty close to that thanks to Formatr