Pandora: Documentation en: Inventory

From Pandora FMS Wiki
Revision as of 08:59, 22 October 2019 by Laura.cano (talk | contribs) (Inventory Module within UNIX Systems by a Software Agent)
Jump to: navigation, search

Go back to Pandora FMS documentation index

Template wip.png

We are working on the translation of the Pandora FMS documentation. Sorry for any inconvenience.


1 Inventory

1.1 Introduction

Pandora FMS Enterprise Version allows you to keep an inventory of the devices monitored by Pandora FMS. Thanks to this inventory, it is possible to keep a list which contains the CPU, expansion cards, memory, patches, software, etc. or the company's servers.

The inventory is independent from the monitoring and could be obtained either locally (by Pandora FMS Agents) or remotely.

1.2 Data Collection for the Inventory

Data collection for system inventory is carried out in two different ways: Remotely through inventory modules, through scripts integrated within Pandora FMS which perform WMI queries or through scripts executed by means of SSH along with 'Expect' or similar methods.

Locally using the Pandora FMS Agent, through agent plugins.

1.2.1 Inventory Modules

Inventory modules are remote modules that execute a command against a remote machine. These modules work in a similar way as a plugin does. The same modules could be defined as 'locals' if they obtain data through an agent.

In the User and Password parameters the following macros can be used:

  • _agentcustomfield_n_: Agent number custom field.

1.2.2 Remote Inventory Creating remote modules

The creation of a remote inventory module by an administrator is seen as unusual. These inventory modules are already 'preconfigured' in Pandora FMS Enterprise. Pandora FMS also allows you to create your own inventory modules or modify the already existing ones by using the Inventory Module Editor.

In order to create a remote module, go to 'Configuration' -> 'Inventory Modules' where all created inventory modules appear.


In order to create a new module, click on the 'Create' button.


Name: The module name field.

Description: Module description field.

OS: The operative system the module is created for.

Interpreter: Field featuring the command interpreter to be used within the module. It can be Shell Script, Perl or any other valid interpreter for the Inventory Server which is executed on a Linux system.

Format: It shows the fields returned by the module separated by the ';' character.

Code: Module code. It is usually Perl or Shell Script. If you intend to use binary code here, it will require a different loading procedure which is required to be entered by peripheral scripts.

Template warning.png

It is very important to choose the operative system correctly, because when adding inventory modules to an agent, only those whose module operating system and agent operating system match will appear.


Once the module is created, click on “Create”.

In3.png Editing Remote Modules

In order to edit a remote module, click on 'Configuration' and 'Inventory Modules'. It is the location where all the inventory modules created so far are listed. Click on the module you intend to edit or on the wrench icon located at the right as shown below.


The module creation window will appear again.


Edit the desired fields and click on the 'Update' button. Deleting remote modules

In order to delete a remote module, click on 'Configuration' > 'Inventory Modules' where all the inventory modules created so far are listed. Click on the trash icon located at the right side of the module you intend to delete.

In6.png Assigning remote modules

Inventory module assignment is done in the within the agent's administration tab.

Click on the "Inventory" tab.


This is the menu where you may add the new inventory modules.


These are the fields that must be filled out when adding an inventory module.

  • Module: Choose the inventory module you intend to add. Only the modules that match the agent's operating system will appear.
  • Target: The IP or server name you intend to obtain the inventory from.
  • Interval: Time interval when the inventory module will be executed.
  • Username: User used to execute the inventory module.
  • Password: The user's password which is going to be used to execute the inventory module.

Once the form has been filled out, click on the 'Add' button in order to add the new module to the other inventory modules.


From version v7.0NG.724 onwards, it is possible to define fields instead of the user and password fields that normally exist. To do that, the following checkbox must be activated:

Custom fields checkbox.png

After doing this, a control to add new fields will appear:

Inventory module new custom field.png

In this control, enter the desired name before adding it. If you indicate that the field will contain a password, the value will be saved in the database in a obfuscated way.

After creating the fields, give them a value and finally add the module. These fields will be applied in order of creation in the execution of the remote inventory script.

Inventory module with custom fields.png Editing an assigned inventory module

You may also edit the inventory modules. This editing is carried out on the same page where they were previously created. In order to edit an inventory module, click on the module's name or on the key icon which is shown on the picture below.

In20.png Deleting an assigned inventory module

It is possible to delete inventory modules. This deletion process is carried out on the same page where they have been previously created. In order to delete an inventory module, click on the trash icon located at the right side of the module's name. Complete example of a remote inventory module

Suppose you are required to obtain a list of physical addresses from a server - in this case a UNIX server. This is usually achieved through the 'arp -a -n' command. If executed on a server, it will return something like this:

[email protected]:~$ arp -a -n
? ( at 08:00:27:39:BF:6F [ether] on eth2
? ( at B4:74:9F:94:98:84 [ether] on eth2
? ( at 08:00:27:10:D1:1A [ether] on eth0
? ( at 98:0C:82:54:2F:DE [ether] on eth2
? ( at 08:00:27:EA:B2:FF [ether] on eth0
? ( at C8:60:00:4B:96:67 [ether] on eth2
? ( at FE:26:C5:91:B1:DA [ether] on tap0

What you are looking for is the IP and the MAC addresses and the adapter's name.

This could be achieved by using a shell script like this, using " " to separate the fields:

arp -a -n | sort | grep -v incomplete | awk '{ print $2,$4,$7 }'

You have almost all the necessary data to 'import' this information into the remote Pandora FMS Inventory Server. To do so, use the 'CPU' remote inventory module as a basis and change it slightly. This script is connected to the destination server via SSH and executes the command. The command's output should return each file separated by the ';' character.

At this point, you need some programming knowledge to develope your own scripts or modify some. Although remote inventory scripts are not very complex, they require some knowledge of Perl, Shellscript or other interpreted languages. You may also write them in Java or C++ and call up their execution from the module as long as it returns the values of each field separated by the ';' character and takes a new line for each line of data.

# Copyright (c) 2012 Sancho Lerena <[email protected]>
#           (c) 2012 Artica Soluciones Tecnologicas S.L
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

use strict;
use warnings;

# Check for ssh
my $ssh_client = "ssh";
if (system("$ssh_client -v > /dev/null 2>&1") >> 8 != 255) {
	print "[error] $ssh_client not found.\n";
	exit 1;

if ($#ARGV < 1) {
	print "Usage: $0 <target ip> <username>\n";
	exit 1;

my $target_ip = $ARGV[0];
my $username = $ARGV[1];

# Retrieve ARP table
my ($ip, $mac, $iface);
my $command = '/usr/sbin/arp -a -n | sort | grep -v incomplete | awk \'{ print \$2,\$4,\$7 }\'';

my @info = `$ssh_client $username\@$target_ip "$command" 2> /dev/null`;
foreach my $line (@info) {
	if ($line =~ /^(.+)\s(.+)\s(.+)/) {
		$ip = $1;
		$mac = $2;
		$iface = $3;
		print "$ip;$mac;$iface\n";
exit 0;

In order for the SSH connection to work automatically, copy the "root" user's public key, which requires 'root' privileges from the Pandora FMS Server to the target server. Imagine this command is executed on ''. Follow the below mentioned steps.

1. Create a new key on the Pandora FMS Server as 'root'.


2. Use the command 'ssh-copy-id' to copy the public key on the target server '' along with the target user (in this case, the user 'artica'):

ssh-copy-id -i /root/.ssh/ [email protected]

Enter the user password 'artica' once on '' in order to install the public key on the target user.

3. Try to establish a connection. It should connect to it without asking for the password:

ssh [email protected]

4. If the process was successful, the inventory module will follow the same process. Try to execute it from the command line and save the previous script on the disk ( and execute it along with the IP and the user as parameters:

perl artica

Notice that the script remotely calls to '/usr/sbin/arp'. The command should be present within this path - if not, change the script. As you may have noticed, the script is called through the 'perl' command which is usually located at '/usr/bin/perl'. This is what you should configure when defining the module, as you can see below.

Inventory sample1 .png

When applying it to an agent, make sure the operating systems match. If you have different operating systems, create a different module for each one of them, because the same code will not work on all of them.

Inventory sample2 .png

Once this module has been executed, the result should look like the one shown on the picture below.


1.2.3 Local inventory through software agents

It is also possible to obtain the inventory data from a machine by using Software Agents. Just apply the appropriate inventory modules within the software agent's configuration. Like in remote modules, it is also necessary to add these modules as an inventory module under 'Configuration' > 'Inventory Modules'. Creating Local Modules

In order to create a local module, go to 'Configuration' > 'Inventory Modules' where all inventory modules created so far are listed. Create all modules to be defined within the agent setup. The OS assigned to the console agent must match that of the created module.


In order to create a new module, click on the 'Create' button.


It is not necessary to fill out all the fields for remote modules.

  • Name: The field to enter the module's name.
  • Description: The field to insert the module's description.
  • OS: Choose the operating system the module is intended for.
  • Format: It writes the fields returned by the module separated by the ";" character.

Once you have created the module, click on the 'Create' button.

In24.png Local inventory setup for software agents

To adapt the software agent setup to the new version: 1. Deploy the script collection (download it from the Pandora FMS library through the collections.


From version 7 onwards, these plugins have agent installation by default, although they are commented in the configuration file.


2. Configure the local inventory script programmed execution in the pandora_agent.conf file, adding this information at the end:


From version 7 onwards, there is no need to add it. Just uncomment the existing plugins in the agent configuration file.


#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs"
#module_crontab * 12-15 * * 1

#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs"
#module_crontab * 12-15 * * 1
#module_end Inventory module within UNIX systems through software agent

The UNIX software agent module locally uses a plugin to retrieve information about different aspects of the machine, both software and hardware related.

The module's syntax is shown below.

module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route

The module consists of one line and the following parameters:

  • Module activation
" module_plugin inventory " 1 cpu ram video nic hd cdrom software init_services filesystem users route
  • Field where it is set how often the module will be executed (in days). If the value is '0', the inventory information will be sent on every agent execution.
module_plugin inventory " 1 " cpu ram video nic hd cdrom software init_services filesystem users route
  • Field where the defined inventory objects are collected.
module_plugin inventory 1 " cpu ram video nic hd cdrom software init_services filesystem users route "

Just like in the Windows agent, it is possible to collect the following objects:

  • CPU: It obtains information about CPUs.
  • cdrom: It obtains information about CDROMs.
  • video: It obtains information about VGAs.
  • hd: It obtains information about hard drives.
  • nic: It obtains information about network interface controllers.
  • patches: It obtains information about the installed patches.
  • software: It obtains information about the installed software.
  • ram: It obtains information about the RAM modules.
  • filesystem: It obtains information about the system's partitions.
  • users: It obtains information about the users.
  • init_services: It obtains information about the initiated services.
  • Route: It collects information about the system path table.

You may find the plugin that collects the inventory in the directory named '/etc/pandora/plugins'.

It is also possible to set the plugin to gather all available information. In this example, the plugin will obtain all daily information on the inventory:

# Plugin for inventory on the agent (Only Enterprise)
module_plugin inventory 1

In order to activate the inventory module, copy the previously described code within the software agent 'pandora_agent.conf' file. This activation could be achieved locally on the machine or remotely from the agent's remote configuration.

In32.png Assigning Local Modules

It's not necessary to activate the modules in the agents defined within the console. If the modules have been created by clicking on 'Configuration' -> 'Inventory Modules' and configured in the software agent, they're going to appear directly within the agent in the console.

In33.png Creation of Local Inventory Modules (which are executed from within the Agent)

In addition to the inventory systems which come 'by default' within the agent, you may create inventory modules for UNIX and Windows-based systems a lot easier than the remote modules. You're required to create a script which generates an XML file with the following structure:


Under 'INVENTORY_MODULE_NAME' you're required to use the exact module name which is going to be registered under Pandora FMS. Under 'DATA1;DATA2 ...' the data you intend to obtain is going to be located.

Supposing that you intend to get an ARP table and the IPs along with their interfaces (please review the previous example regarding the remote inventory modules). This is basically a slightly modified exit of the command 'arp -a'.

This time, we're going to develop a small script that's required under Windows. We're going to save it within the path named 'C:\tmp\windows_arp_inventory.bat'. The script consists of 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^>

You're required to modify the 'pandora_agent.conf' and insert the following line:

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

Template warning.png

This script is going to be executed every five minutes, which represents the default agent's interval. If it has to be executed within another interval, you're required to code that logic into the script for yourselves.


In order to inherit the changes, please keep in mind to create an inventory module within Pandora FMS before restarting the agent.

Inventory sample4 .png

Please keep in mind that it's a local module. It neither has the field named 'interpreter' nor the 'code' fields filled out, but it already holds information about the operating system.

The results obtained here are the same as the ones we've got for the remote module's equivalent under Linux:

Inventory sample5 .png

There are a lot more local and remote inventory modules available for download within the Pandora FMS Module Library. Within this library, there are also a lot of modules which have been specifically designed for Pandora FMS, as you certainly have seen within this section.

1.3 Data Display for the Inventory

The inventory data which have been locally or remotely collected from a system can be viewed from the agent or the console's inventory menu.

1.3.1 Inventory Data Display in the Agent

To review the agent's collected data including its inventory, please go to the agent's 'Operation' menu and click on the 'Inventory' flap.


It's possible to filter the information by the inventory or a free-text search. Since Pandora FMS versions 4 and above, the searches include custom fields. It's very useful to search e.g. for a specific version of a software:

Inventory search 403.png

1.3.2 Inventory Data Display in the Inventory Menu

By clicking on 'Monitoring' -> 'Inventory', it's possible to view all agents inventory data, to conduct searches and to export data to a CSV file.


The fields which could be used for searches are the following:

  • Group: The combo in which you're able to pick the group of agents you intend to filter by.
  • Module: The combo in which you're able to pick the inventory module you intend to filter by.
  • Agent: The field in which you're able to insert the agent's name you intend to filter by.
  • Search: The field in which you're able to insert a text in order to conduct a search by using all inventory fields.

It's also possible to see all agent's modules which have an inventory by selecting 'All' within the search options and clicking on 'Search'.


It's also possible to search on a specific module in all agents with inventory by selecting the module and clicking on 'Search'.


1.3.3 Exporting the Inventory Data to CSV

By clicking on 'Monitoring' and 'Inventory' it's possible to export the inventory data which are the result of a filtering to a CSV file.

Please pick the filter. Once there is any data present, please click on 'Export to CSV'.


It has created a file which contains the inventory data, separated by a semicolon.

1.3.4 Diff view and Block mode

From version 5.1 of Pandora FMS the inventory information can be viewed in two columns so differences can be spotted easily. This only works when you are using remote inventory modules with "block mode" enabled. This mode is used to set the module to report all information as a single piece of information, instead a list of small items of information, like a list of packages in the server. Instead processing each line as a single entity, it process the whole report as a single item.

Plugin we use in this chapter can be downloaded from official module library at [1]

Inventory module Block mode is configured when you define a remote inventory module:

Block mode setup.png

To access this feature you must click on the icon that appears in the following image. All other inventory modules WITHOUT that mode, will not allow you to have "diff view". In this screenshot, the only moduel with diffview enabled is the third one:

Diff inventory.png

In the two column view all differences are shown between one inventory version and another. We can even set a different date.

Pandora FMS - the Flexible Monitoring System - 2014-07-01 19.09.10.png

Remember each time an inventory module detect a change it reports an event. In block mode, that event will not contain the changes, because could be very extense.

Go back to Pandora FMS Documentation Index