Features Integrations

Customizing inventory with your own scripts in Pandora FMS

December 17, 2012

Customizing inventory with your own scripts in Pandora FMS

Inventory is an awesome enterprise feature in Pandora, but is not common to hear customers that they doesn’t use it because doesn’t know well. Okay, this is a brief overview, not about how use it, not… it’s about how to use your own scripts to do exactly what you do !… custom scripting, here we go !

Beside the inventory systems that comes “by default” in the agent, you can easily create (much more easily than the remote modules),inventory modules for Unix and Windows systems. You have to create a script which generates a XML with the following structure:

<inventory>
<inventory_module>
<name>INVENTORY_MODULE_NAME</name>
<type>generic_data_string</type>
<datalist>
    <data>DATA1;DATA2;DATA3....</data>
</datalist>
</inventory_module>
</inventory>

Where is written “INVENTORY_MODULE_NAME” it should be written the same name of the module that will be registered in pandora Where is written DATA1;DATA2…are the data you want to get.

Supposing that you want to get an ARP table and IP with their interfaces (see the previous example of the remote inventory modules). This is basically the exit of the command arp -a modified a little. For this example, we are going to develop the script in Windows, the little script that you need, and we are going to save it at “C:\tmp\windows_arp_inventory.bat” that is the following:

@echo off
echo ^<inventory^>
echo ^<inventory_module^>
echo ^<name^>ARP_Table^</name^>
echo ^<type^>generic_data_string^</type^>
echo ^<datalist^>
arp -a | sort | grep "[0-9]"  | grep -v ":" | gawk "{ print \"^<data^>\" $1\";\"$2\";\"$3 \"^</data^>\" }"
echo ^</datalist^>
echo ^</inventory_module^>
echo ^</inventory^>

Now you need to modify pandora_agent.conf, and add the following line:

module_plugin cmd.exe /C C:\tmp\windows_arp_inventory.bat

You get a nice table with the MAC addresses and IP on that system local ARP table:

Of course that information is searchable by using the inventory search tool. So you can search for a IP address in all MAC tables of all your systems. Just as quick as that, or using the default software inventory present in all agents (linux and windows) you can see in what systems you have installed VNC:

Don’t forget that you can even code your own remote scripts for getting inventory information. In the official documentation you have information and full examples for Linux and Windows, and of course, you can use the actual scripts/code to create your own scripts.

 


    Written by:



    Leave a comment

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.