Difference between revisions of "Pandora: Documentation en: Inventory"

From Pandora FMS Wiki
Jump to: navigation, search
(Editing an assigned Inventory Module)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Pandora:Documentation_en|Go back to Pandora FMS documentation index]]
 
[[Pandora:Documentation_en|Go back to Pandora FMS documentation index]]
 
{{WIP}}
 
  
 
= Inventory =
 
= Inventory =
Line 155: Line 153:
 
</center>
 
</center>
  
==== Deleting an assigned Inventory Module ====
+
==== Deleting an assigned inventory module ====
  
It's possible to delete inventory modules. This deletion process is conducted on the same page on which they've been created before.
+
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, please click on the trash icon which is located on the right side of the module's name.
+
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 ====
+
==== Complete example of a remote inventory module ====
  
Just imagine for a moment you're required to obtain a list of physical addresses from a server - in this case, a UNIX server. This is usually achieved by the command of 'arp -a -n'. If we're executing it on a server, it's going to give us something back like this:
+
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:
  
  
Line 175: Line 173:
  
  
What we're looking for is the IP address, the MAC address and the adapter's name.
+
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 in the below mentioned way. We're using " " to separate the fields:
+
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 }'
 
  arp -a -n | sort | grep -v incomplete | awk '{ print $2,$4,$7 }'
  
  
We have almost all the necessary data to 'import' this information into the remote Pandora FMS Inventory Server. To do so, we're going to use the 'CPU' remote inventory module as a basis and we're also going to change it slightly. This script is connected to the destination server via SSH and executes the command. The command's execution should return each file, separated by the ';' character.
+
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're required to have some knowledge of programming to produce your own scripts. Although they're not very complex, the remote inventory scripts require you to possess some knowledge of Perl, shell scripts or other languages. You're also able to write them in Java or C++ and to call up their execution from the module as long as you return the values of each field separated by the ';' character and take a new line for each line of data.
+
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.
  
  
Line 246: Line 244:
  
  
In order for the SSH connection to work automatically, you're required to copy the user's public key, which requires 'root' privileges from the Pandora FMS Server on the destination server. Imagine this command to be executed on '192.168.50.10'. Please follow the below mentioned steps.
+
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 '192.168.50.10'. Follow the below mentioned steps.
  
  
'''1.''' Please create a new key on the Pandora FMS Server as 'root' by the following command:
+
'''1.''' Create a new key on the Pandora FMS Server as 'root'.
 
    
 
    
 
  ssh-keygen
 
  ssh-keygen
  
  
'''2.''' Please use the command 'ssh-copy-id' to copy the the destination server's public key of '192.168.50.10' along with the destination user (in this case, it's the user 'artica') by the command below:
+
'''2.''' Use the command 'ssh-copy-id' to copy the public key on the target server '192.168.50.10' along with the target user (in this case, the user 'artica'):
  
  
Line 260: Line 258:
  
  
You're also required to enter the user password 'artica' once on '192.168.50.10' in order to install the public key on the destination user.
+
Enter the user password 'artica' once on '192.168.50.10' in order to install the public key on the target user.
  
'''3.''' Now try to establish a connection. It should connect to it without asking for the password:
+
'''3.''' Try to establish a connection. It should connect to it without asking for the password:
  
  
Line 268: Line 266:
  
  
'''4.''' If the process was successful, the inventory module is going to follow the same process. Please try to execute it from the command line and save the previous script to the disk (temporal.pl) and execute it along with the IP and the user as parameters in the following way:
+
'''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 (temporal.pl) and execute it along with the IP and the user as parameters:
  
  
Line 276: Line 274:
  
  
Please keep in mind that the script remotely calls to '/usr/sbin/arp'. The command should be present within this path - if not, please change the script. As you've also certainly noticed, we call up our script by the 'perl' command which is usually located at '/usr/bin/perl'. In the moment of defining a module, this is exactly how it should be, as you can see below.
+
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.
  
 
<center>
 
<center>
Line 282: Line 280:
 
</center>
 
</center>
  
When applying it to an agent, please make sure the operating systems are the same. If you encounter different operating systems, you're required to create a different module for each one of them, because the one which was shown here is not going to work for all of them.
+
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.
  
 
<center>
 
<center>
Line 288: Line 286:
 
</center>
 
</center>
  
Once this module has been executed, the result could look like the one shown on the picture below.
+
Once this module has been executed, the result should look like the one shown on the picture below.
  
 
<center>
 
<center>
Line 294: Line 292:
 
</center>
 
</center>
  
=== Local Inventory by Software Agents ===
+
=== Local inventory through software agents ===
  
It's also possible to obtain the inventory data from a machine by using Software Agents. You're only required to apply the appropriate inventory modules within the software agent's configuration. Like in the remote modules, it's also necessary to add these modules as an inventory module under 'Operation' -> 'Manage Modules' and 'Inventory Modules'.
+
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 ====
 
==== Creating Local Modules ====
  
In order to create a local module, please click on 'Administration' -> 'Manage Modules' and 'Inventory Modules'. This is the location in which all inventory modules created so far are listed. You're required to create all modules which are defined within the agent.
+
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.
  
 
<center>
 
<center>
Line 306: Line 305:
 
</center>
 
</center>
  
In order to create a new module, please click on the 'Create' button.
+
In order to create a new module, click on the 'Create' button.
  
 
<center>
 
<center>
Line 312: Line 311:
 
</center>
 
</center>
  
It's not necessary for the remote modules to complete all the fields. Now we're going to describe the fields you're encountering there:
+
It is not necessary to fill out all the fields for remote modules.
  
* '''Name:''' The field to insert the module's name.
+
* '''Name:''' The field to enter the module's name.
 
* '''Description:''' The field to insert the module's description.
 
* '''Description:''' The field to insert the module's description.
* '''OS:''' The combo to pick the operating system the module is intended for. For the location of modules, we recommend to use the option named 'Agent'.
+
* '''OS:''' Choose the operating system the module is intended for.
* '''Format:''' The field in which to insert the fields separated by the ';' character the module is going to return.
+
* '''Format:''' It writes the fields returned by the module separated by the ";" character.
  
Once you have created the module, please click on the 'Create' button.
+
Once you have created the module, click on the 'Create' button.
  
 
<center>
 
<center>
Line 325: Line 324:
 
</center>
 
</center>
  
==== Inventory Module by Software Agents within Windows Systems ====
+
==== 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 http://pandorafms.com/Library/Library/) through the collections.
 +
 
 +
{{Tip|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:
 +
 
 +
{{Tip|From version 7 onwards, there is no need to add it. Just uncomment the existing plugins in the agent configuration file.}}
 +
 
 +
<pre>
 +
 
 +
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cpuinfo.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
The Windows Software Agent Module utilizes locally predefined WMIs to collect information about the machine's different software and hardware aspects.
+
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\moboinfo.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
The module syntax is the following:
+
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\diskdrives.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
<center>
+
#module_begin
[[image:in25.png]]
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\cdromdrives.vbs"
</center>
+
#module_crontab * 12-15 * * 1
 +
#module_end
  
Now we're going to describe the fields you're required to fill out to add an inventory module within Windows-based machines:
+
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\videocardinfo.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_begin:'''
+
#module_begin
The beginning of any module of a software agent.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\ifaces.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_name:'''
+
#module_begin
The field into which the module's name is inserted. In this case, it's 'Inventory'.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\monitors.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_interval:'''
+
#module_begin
The field which determines the module execution interval (in days). In this example, we're going to take '3 days'. Be mindful of errors within certain other documentations. It's not the module named 'module_inventory_interval', it's 'module_interval'. If the value is '0', the information will be sent on every execution of the agent.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\printers.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_type generic_data_string'''
+
#module_begin
The value which defines data type in Pandora FMS. The of data for the inventory modules is 'generic_data_string'.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\raminfo.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_inventory CDROM Patches Software'''
+
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\software_installed.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
The field where the inventory objects which we intend to collect are defined. In this example, we've collected 'CDROM', 'Patches' and 'Software'. In this field, the different parameters where the inventory objects which we intend to collect are defined. In order to add more objects, you're required to insert its name into the module named 'line_inventory'. It's possible to collect the following objects:
+
#module_begin
 +
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\userslogged.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
* '''CPU:''' It obtains information about the CPUs.
+
#module_begin
* '''RAM:''' It obtains information about the RAM modules.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productkey.vbs"
* '''CDROM:''' It obtains information about the CDROMs.
+
#module_crontab * 12-15 * * 1
* '''Video:''' It obtains information about the VGAs.
+
#module_end
* '''Hds:''' It obtains information about the hard drives.
 
* '''Patches:''' It obtains information about the installed patches.
 
* '''Software:''' It obtains information about the installed software.
 
* '''Services:''' It obtains information about the services installed on the machine (no matter whether they're running or not).
 
* '''NIC:''' It obtains information about network interface controllers.
 
  
'''module_description'''
+
#module_begin
The field in which to insert the module's description. In this example, it's 'Inventory'.
+
#module_plugin cscript.exe //B //t:20 "%PROGRAMFILES%\Pandora_Agent\util\productID.vbs"
 +
#module_crontab * 12-15 * * 1
 +
#module_end
  
'''module_end'''
 
It's the end of any software agent's module. In order to activate the inventory module, you're required to copy the previously described code into the software agent's file named 'pandora_agent.conf'. This activation can be achieved locally on the machine or remotely from the agent's remote configuration.
 
  
<center>
+
</pre>
[[image:in26.png|500px]]
 
</center>
 
  
==== Inventory Module within UNIX Systems by a Software Agent ====
+
==== Inventory module within UNIX systems through software agent ====
  
The UNIX software agent module locally utilizes a plug in to obtain information about different aspects of the machine from software and hardware.
+
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.
 
The module's syntax is shown below.
  
<center>
+
<pre>
[[image:in27.png]]
+
module_plugin inventory 1 cpu ram video nic hd cdrom software init_services filesystem users route
</center>
+
</pre>
  
 
The module consists of one line and the following parameters:
 
The module consists of one line and the following parameters:
Line 387: Line 419:
 
* Module activation
 
* Module activation
  
<center>
+
" '''''module_plugin inventory''''' " 1 cpu ram video nic hd cdrom software init_services filesystem users route
[[image:in28.png]]
 
</center>
 
  
* The field which determines how often the module will be executed (in days). If the value is '0', the inventory information is going to be sent on every agent execution.
+
* 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.
  
<center>
+
module_plugin inventory " '''''1''''' " cpu ram video nic hd cdrom software init_services filesystem users route
[[image:in29.png]]
 
</center>
 
  
* The field in which the defined inventory objects are collected.
+
* Field where the defined inventory objects are collected.
  
<center>
+
module_plugin inventory 1 " '''''cpu ram video nic hd cdrom software init_services filesystem users route''''' "
[[image:in30.png]]
 
</center>
 
  
Just like in the Windows agent, it's possible to collect the following objects:
+
Just like in the Windows agent, it is possible to collect the following objects:
  
 
* '''CPU:''' It obtains information about CPUs.
 
* '''CPU:''' It obtains information about CPUs.
Line 410: Line 436:
 
* '''hd:''' It obtains information about hard drives.
 
* '''hd:''' It obtains information about hard drives.
 
* '''nic:''' It obtains information about network interface controllers.
 
* '''nic:''' It obtains information about network interface controllers.
* '''Patches:''' It obtains information about the installed patches.
+
* '''patches:''' It obtains information about the installed patches.
 
* '''software:''' It obtains information about the installed software.
 
* '''software:''' It obtains information about the installed software.
* '''process:''' The processes in execution on the server in this moment.
 
 
* '''ram:''' It obtains information about the RAM modules.
 
* '''ram:''' It obtains information about the RAM modules.
 
* '''filesystem:''' It obtains information about the system's partitions.
 
* '''filesystem:''' It obtains information about the system's partitions.
 
* '''users:''' It obtains information about the users.
 
* '''users:''' It obtains information about the users.
 
* '''init_services:''' It obtains information about the initiated services.
 
* '''init_services:''' It obtains information about the initiated services.
 +
* ''Route:'' It collects information about the system path table.
  
You can find the plug in which collects the inventory in the directory named '/etc/pandora/plugins'.
+
You may find the plugin that collects the inventory in the directory named '/etc/pandora/plugins'.
 
 
<center>
 
[[image:in31.png]]
 
</center>
 
  
It's also possible to set the plug in to gather all available information. In this example, the plug in is going to obtain all daily information on the inventory:
+
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 an inventory on the agent (Pandora FMS Enterprise Version only)
+
  # Plugin for inventory on the agent (Only Enterprise)
 
  module_plugin inventory 1
 
  module_plugin inventory 1
  
In order to activate the inventory module, you're required to copy the previously described code within the 'pandora_agent.conf' from the software agent's file. This activation could be achieved locally on the machine or remotely from the agent's remote configuration.
+
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.
  
 
<center>  
 
<center>  
Line 437: Line 459:
 
==== Assigning Local Modules ====
 
==== 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.
+
It is not necessary to activate the modules in the agents defined within the console. If the modules have been created in ''Configuration'' > ''Inventory Modules'', the OS matches and the execution is defined in the software agent configuration file, the collected data will appear directly on the ''view'' > ''inventory'' section of the console agent.
  
 
<center>
 
<center>
Line 443: Line 465:
 
</center>
 
</center>
  
==== Creation of Local Inventory Modules (which are executed from within the Agent) ====
+
==== Creating local inventory modules (software 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:
+
In addition to the default inventory systems, you may create inventory modules for UNIX and Windows-based systems easily.  
 +
Create a script that generates an XML file with the following structure:
  
  
Line 460: Line 483:
 
</pre>
 
</pre>
  
Under 'INVENTORY_MODULE_NAME' you're required to use the exact module name which is going to be registered under Pandora FMS.
+
'''"INVENTORY_MODULE_NAME"''': The name should match that of the module that registered the inventory modules in Pandora FMS console.
Under 'DATA1;DATA2 ...' the data you intend to obtain is going to be located.
+
'''"DATA1;DATA2..."''': The data you intend to retrieve, which have been defined in the inventory module.
  
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'.
+
Supposing you intend to get an ARP table and the IPs along with their interfaces (see the previous example regarding remote inventory modules). Use the command ''arp -a'' and clean out the output to obtain the desired data.
  
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:
+
This time, it will be developed in Windows; the 'C:\tmp\windows_arp_inventory.bat' script with the following definition:
  
  
Line 481: Line 504:
 
</pre>
 
</pre>
  
You're required to modify the 'pandora_agent.conf' and insert the following line:
+
Modify the 'pandora_agent.conf' and add the following line:
  
 
  module_plugin cmd.exe /C C:\tmp\windows_arp_inventory.bat
 
  module_plugin cmd.exe /C C:\tmp\windows_arp_inventory.bat
 
<br>
 
<br>
{{Warning|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.}}
+
{{Warning|This script is executed every five minutes (the default agent interval). If you want it to be executed every X minutes, implement that logic into the script itself or use the[[Pandora:Documentation_en:Operations|programmed monitoring]].}}
  
In order to inherit the changes, please keep in mind to create an inventory module within Pandora FMS before restarting the agent.
+
In order for the local script execution to store inventory information, it must have an inventory module defined in the console, specifying the OS, the module's name and the data to be stored separated by ";". Do not forget to create the inventory module in Pandora FMS before restarting the Pandora FMS agent, so that it inherits the changes.
  
 
<center>
 
<center>
Line 493: Line 516:
 
</center>
 
</center>
  
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.
+
Make sure that when it is a local module it has the "interpreter" and "code" fields empty and the OS one filled out.
  
The results obtained here are the same as the ones we've got for the remote module's equivalent under Linux:
+
The results obtained here are the same as the ones for the remote module's equivalent under Linux:
  
 
<center>
 
<center>
Line 501: Line 524:
 
</center>
 
</center>
  
There are a lot more local and remote inventory modules available for download within the [http://pandorafms.com/library/ '''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.
+
There are a lot more local and remote inventory modules available for download within the [http://pandorafms.com/library/ '''Pandora FMS Module Library.'''] You may also easily develop your own, as seen throughout this chapter.
 
 
== 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.
 
 
 
=== 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.
+
== Data display for the inventory ==
 
 
<center>
 
[[image:in34.png|550px]]
 
</center>
 
  
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 data that have been locally or remotely collected from a system can be viewed from the agent or the console's inventory menu.
 
 
<center>
 
[[image:Inventory search 403.png|550px]]
 
</center>
 
  
 
=== Inventory Data Display in the Inventory Menu ===
 
=== 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 [http://en.wikipedia.org/wiki/Comma-separated_values '''CSV'''] file.
+
By clicking on 'Monitoring' -> 'Inventory', it is possible to view all agent inventory data, search and export data to a CSV.
  
 
<center>
 
<center>
Line 531: Line 540:
 
The fields which could be used for searches are the following:
 
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.
+
* '''Group:''' Choose the agent group you intend to filter by.
* '''Module:''' The combo in which you're able to pick the inventory module you intend to filter by.
+
* '''Module:''' Choose 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.
+
* '''Agent:''' Type in the agent 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.
+
* '''Search:''' Type in a text in order to search by 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 is also possible to see all module agents which have an inventory by selecting 'All' within the search options and clicking on 'Search'.
  
 
<center>
 
<center>
Line 542: Line 551:
 
</center>
 
</center>
  
It's also possible to search on a specific module in all agents with inventory by selecting the module and clicking on 'Search'.
+
Or a specific module in all agents with inventory by selecting the module and clicking on 'Search'.
  
 
<center>
 
<center>
 
[[image:in39.png|550px]]
 
[[image:in39.png|550px]]
 
</center>
 
</center>
 +
 +
===Inventory dates and changes ===
 +
 +
In the detail view of an inventory agent, you may choose the specific inventory report date you want to see through a selector:
 +
 +
<center>
 +
[[Image:Vista_inventario_diff.png]]
 +
</center>
 +
 +
If you see there are dates missing, it is likely to be due to data changes regarding the last inventory execution. That means, Pandora FMS only stores inventory data when these change compared to the last execution.
  
 
=== Exporting the Inventory Data to CSV ===
 
=== 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 [http://en.wikipedia.org/wiki/Comma-separated_values '''CSV'''] file.
+
By clicking on 'Monitoring' and 'Inventory' it's possible to export 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'.
+
Choose the filter and once there is any data, click on 'Export to CSV'.
  
 
<center>
 
<center>
Line 558: Line 577:
 
</center>
 
</center>
  
It has created a file which contains the inventory data, separated by a semicolon.
+
It creates a file containing inventory data, separated by semicolon.
  
=== Diff view and Block mode===
+
=== Inventory version differences ===
  
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.
+
'''Block mode'''
  
Plugin we use in this chapter can be downloaded from official module library at [http://pandorafms.com/index.php?sec=Library&sec2=repository&lng=es&action=view_PUI&id_PUI=607]
+
From Pandora FMS version 5.1, inventory information can be viewed in two columns so differences can be spotted easily. Block mode specifies that the result of an inventory module is a single element, instead of interpreting each line as a different element of the same type, as it has been done in the previously seen inventory modules.
  
Inventory module Block mode is configured when you define a remote inventory module:
+
Block mode is configured when defining a remote or local inventory module:
  
 
<center>
 
<center>
Line 572: Line 591:
 
</center>
 
</center>
  
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:
+
When there is a module with block mode enabled, it allows seeing the divided view (to visually see the changes):
  
 
<center>
 
<center>
Line 578: Line 597:
 
</center>
 
</center>
  
In the two column view all differences are shown between one inventory version and another. We can even set a different date.
+
In the two column view, all differences between one inventory version and another are shown. Even the date filtering version can be seen.
  
 
<center>
 
<center>
Line 584: Line 603:
 
</center>
 
</center>
  
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.
+
Remember each time an inventory module change is detected, a new event will be generated.
 +
 
 +
<center>
 +
[[image:Events inv.png|799px]]
 +
</center>
 +
<br>
  
  

Latest revision as of 11:06, 22 October 2019

Go back to Pandora FMS documentation index

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

1.2.2.1 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.

In1.png

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

In2.png


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

1.2.2.2 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.

In4.png

The module creation window will appear again.

In5.png

Edit the desired fields and click on the 'Update' button.

1.2.2.3 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

1.2.2.4 Assigning remote modules

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

Click on the "Inventory" tab.

In8.png

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

In9.png

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.

In10.png

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



1.2.2.5 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

1.2.2.6 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.

1.2.2.7 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
? (192.168.70.74) at 08:00:27:39:BF:6F [ether] on eth2
? (192.168.70.162) at B4:74:9F:94:98:84 [ether] on eth2
? (192.168.50.30) at 08:00:27:10:D1:1A [ether] on eth0
? (192.168.70.90) at 98:0C:82:54:2F:DE [ether] on eth2
? (192.168.50.2) at 08:00:27:EA:B2:FF [ether] on eth0
? (192.168.70.135) at C8:60:00:4B:96:67 [ether] on eth2
? (192.168.60.182) 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.


#!/usr/bin/perl
##########################################################################
# pandora_linux_arptable.pl
##########################################################################
# 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
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# 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 '192.168.50.10'. Follow the below mentioned steps.


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

ssh-keygen


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


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


Enter the user password 'artica' once on '192.168.50.10' 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 (temporal.pl) and execute it along with the IP and the user as parameters:


perl temporal.pl 192.168.50.10 artica
(192.168.50.1);00:0f:ea:27:ba:f0;eth0
(192.168.50.3);08:00:27:98:f8:48;eth0


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.

800

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'.

1.2.3.1 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.

In22.png

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

In23.png

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

1.2.3.2 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 http://pandorafms.com/Library/Library/) through the collections.

Info.png

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:

Info.png

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

 


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

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

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

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

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

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

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

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

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

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

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

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

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


1.2.3.3 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

1.2.3.4 Assigning Local Modules

It is not necessary to activate the modules in the agents defined within the console. If the modules have been created in Configuration > Inventory Modules, the OS matches and the execution is defined in the software agent configuration file, the collected data will appear directly on the view > inventory section of the console agent.

In33.png

1.2.3.5 Creating local inventory modules (software agent)

In addition to the default inventory systems, you may create inventory modules for UNIX and Windows-based systems easily. Create a script that generates an XML file 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>

"INVENTORY_MODULE_NAME": The name should match that of the module that registered the inventory modules in Pandora FMS console. "DATA1;DATA2...": The data you intend to retrieve, which have been defined in the inventory module.

Supposing you intend to get an ARP table and the IPs along with their interfaces (see the previous example regarding remote inventory modules). Use the command arp -a and clean out the output to obtain the desired data.

This time, it will be developed in Windows; the 'C:\tmp\windows_arp_inventory.bat' script with the following definition:


@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^>

Modify the 'pandora_agent.conf' and add the following line:

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


Template warning.png

This script is executed every five minutes (the default agent interval). If you want it to be executed every X minutes, implement that logic into the script itself or use theprogrammed monitoring.

 


In order for the local script execution to store inventory information, it must have an inventory module defined in the console, specifying the OS, the module's name and the data to be stored separated by ";". Do not forget to create the inventory module in Pandora FMS before restarting the Pandora FMS agent, so that it inherits the changes.

Inventory sample4 .png

Make sure that when it is a local module it has the "interpreter" and "code" fields empty and the OS one filled out.

The results obtained here are the same as the ones 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. You may also easily develop your own, as seen throughout this chapter.

1.3 Data display for the inventory

Inventory data that 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 Inventory Menu

By clicking on 'Monitoring' -> 'Inventory', it is possible to view all agent inventory data, search and export data to a CSV.

In37.png

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

  • Group: Choose the agent group you intend to filter by.
  • Module: Choose the inventory module you intend to filter by.
  • Agent: Type in the agent name you intend to filter by.
  • Search: Type in a text in order to search by all inventory fields.

It is also possible to see all module agents which have an inventory by selecting 'All' within the search options and clicking on 'Search'.

In38.png

Or a specific module in all agents with inventory by selecting the module and clicking on 'Search'.

In39.png

1.3.2 Inventory dates and changes

In the detail view of an inventory agent, you may choose the specific inventory report date you want to see through a selector:

Vista inventario diff.png

If you see there are dates missing, it is likely to be due to data changes regarding the last inventory execution. That means, Pandora FMS only stores inventory data when these change compared to the last execution.

1.3.3 Exporting the Inventory Data to CSV

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

Choose the filter and once there is any data, click on 'Export to CSV'.

In40.png

It creates a file containing inventory data, separated by semicolon.

1.3.4 Inventory version differences

Block mode

From Pandora FMS version 5.1, inventory information can be viewed in two columns so differences can be spotted easily. Block mode specifies that the result of an inventory module is a single element, instead of interpreting each line as a different element of the same type, as it has been done in the previously seen inventory modules.

Block mode is configured when defining a remote or local inventory module:

Block mode setup.png

When there is a module with block mode enabled, it allows seeing the divided view (to visually see the changes):

Diff inventory.png

In the two column view, all differences between one inventory version and another are shown. Even the date filtering version can be seen.

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

Remember each time an inventory module change is detected, a new event will be generated.

Events inv.png



Go back to Pandora FMS Documentation Index