Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.2.x' into 2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonéri Le Bouder committed Mar 13, 2012
2 parents c391f5b + 132c67a commit 0144c49
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 78 deletions.
89 changes: 51 additions & 38 deletions README
Expand Up @@ -26,6 +26,57 @@ Additional optional programs:
- dmidecode, for hardware inventory
- lspci, for hardware inventory

Usage
-----
They are two different ways to run the agent:
- as a temporary process, exiting after completing its run
- as a permanent process, staying in memory permanently (daemon under Unix,
service under Windows)

In the first case, the agent execution scheduling is controlled from local
system, and the memory footprint between agent executions is zero.

In second case, the agent execution scheduling is controlled from GLPI server,
as the agent runs regulary according to a parameter initially set in its
configuration (delaytime), overrided by the server at the first connection
(PROLOG_FREQ). Additionaly, the server may also initiate additional
out-of-schedule executions by sending HTTP requests if the web interface is
used. However, it also mean you have a full perl interpreter loaded in memory
constantly, and a network port open on your system with a process running with
full system privileges attached to it.

If you don't need to control agent execution from the server, and if you're
able to periodically launch the agent without resorting to its internal
scheduler, through cron on Unix systems, or scheduled tasks on Windows, you'd
better use first execution mode. The various installation procedure may offer
limited choice about initial configuration, but you should always be able to
change it thereafter.

When executing, the agent tries to runs every available task for every
configured target. A task is a specific kind of work to perform (local
inventory, network discovery, wake on lan, etc...), while a target is both a
recipient for the result and a controller for this work (an OCS server, a GLPI
server, a local directory, etc...). Only the local inventory task is compatible
with all kind of targets, tough, all others require a GLPI server target, and
will get discarded for other kind of target.

System-specific informations
----------------------------
On Solaris/SPARC, you must install sneep and record the Serial Number with it.
Download it from http://www.sun.com/download/products.xml?id=4304155a.

On Windows, we use an additional dmidecode binary shipped in the windows
distribution to retrieve many informations not available otherwise, including
fine-grained multi-cores CPUs identification. Unfortunatly, this binary is not
reliable enough to be used on Windows 2003, leading to less precise
inventories.

On any system, the privilege level used to run the agent will change inventory
results. Generally speaking, this means less results when run with lesser
privileges. On Windows, tough, running agent with SYSTEM privileges, which is
implicit if running as a service, does sometimes gives less results, especially
for shared printers only visible from a user account.

SSL support
-----------
LWP (also known as libwww-perl) is able to use either Crypt::SSLeay or
Expand Down Expand Up @@ -56,41 +107,3 @@ The available workaround:
openssl and its perl bindings (Net::SSLeay)
- disable server certificate checking on client

System-specific informations
----------------------------
On Solaris/SPARC, you must install sneep and record the Serial Number with it.
Download it from http://www.sun.com/download/products.xml?id=4304155a.

The Windows installer will run the agent with the SYSTEM account. If you use
an user GPO to configure the printer, the information will hidden and so not
collected.
To avoid this situation, you can turn off the server, and run the agent with
user privilege, for example during the login.

On Windows, if you don't want to use the installer for Windows you can follow
the installation process avalailable from
http://forge.fusioninventory.org/projects/fusioninventory-agent/wiki/RunAgentWin32.

Usage
-----
They are two different ways to run the agent:
- as a temporary process, exiting after completing its run
- as a permanent process, staying in memory permanently (daemon under Unix,
service under Windows)

In the first case, the agent execution scheduling is controlled from local
system, through cron under Unix, or scheduled tasks under Windows. In second
case, the agent execution scheduling is controlled from GLPI server, as the
agent runs regulary according to a parameter initially set in its
configuration (delaytime), overrided by the server at the first connection
(PROLOG_FREQ). Additionaly, the server may also initiate additional
out-of-schedule executions by sending HTTP requests if the web interface is
used.

When executing, the agent tries to runs every available task for every
configured target. A task is a specific kind of work to perform (local
inventory, network discovery, wake on lan, etc...), while a target is both a
recipient for the result and a controller for this work (an OCS server, a GLPI
server, a local directory, etc...). Only the local inventory task is compatible
with all kind of targets, tough, all others require a GLPI server target, and
will get discarded for other kind of target.
12 changes: 11 additions & 1 deletion lib/FusionInventory/Agent/Storage.pm
Expand Up @@ -75,7 +75,17 @@ sub restore {
my $file = $self->_getFilePath(%params);

return unless -f $file;
return retrieve($file);

my $result;
eval {
$result = retrieve($file);
};
if ($EVAL_ERROR) {
$self->{logger}->error("Can't read corrupted $file, removing it");
unlink $file;
}

return $result;
}

sub remove {
Expand Down
Expand Up @@ -9,7 +9,9 @@ use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Unix;

sub isEnabled {
return canRun('ps');
return
$OSNAME ne 'MSWin32' &&
canRun('ps');
}

sub doInventory {
Expand Down
19 changes: 5 additions & 14 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Networks.pm
Expand Up @@ -98,17 +98,17 @@ sub _getInterfaces {

foreach my $object (getWmiObjects(
class => 'Win32_NetworkAdapter',
properties => [ qw/Index PNPDeviceId Speed MACAddress PhysicalAdapter
properties => [ qw/Index PNPDeviceID Speed MACAddress PhysicalAdapter
AdapterType/ ]
)) {
# http://comments.gmane.org/gmane.comp.monitoring.fusion-inventory.devel/34
next unless $object->{PNPDeviceId};
next unless $object->{PNPDeviceID};

my $interface = $interfaces[$object->{Index}];

$interface->{SPEED} = $object->{Speed};
$interface->{MACADDR} = $object->{MACAddress};
$interface->{PNPDEVICEID} = $object->{PNPDeviceId};
$interface->{PNPDEVICEID} = $object->{PNPDeviceID};

# PhysicalAdapter only work on OS > XP
if (defined $object->{PhysicalAdapter}) {
Expand All @@ -119,7 +119,7 @@ sub _getInterfaces {
&& $interface->{DESCRIPTION} =~ /Adapter/i) {
$interface->{VIRTUALDEV} = 1;
} else {
$interface->{VIRTUALDEV} = $object->{PNPDeviceId} =~ /^ROOT/ ? 1 : 0;
$interface->{VIRTUALDEV} = $object->{PNPDeviceID} =~ /^ROOT/ ? 1 : 0;
}

if (defined $object->{AdapterType}) {
Expand All @@ -130,16 +130,7 @@ sub _getInterfaces {

# exclude pure virtual interfaces
return
grep {
ref($_) eq 'HASH' &&
(
(defined($_->{IPADDRESS}) && $_->{IPADDRESS})
||
(defined($_->{IPADDRESS6}) && $_->{IPADDRESS6})
||
(defined($_->{MACADDR}) && $_->{MACADDR})
)
}
grep { $_->{IPADDRESS} || $_->{IPADDRESS6} || $_->{MACADDR} }
@interfaces;

}
Expand Down
36 changes: 17 additions & 19 deletions t/inventory/windows/networks.t
Expand Up @@ -21,36 +21,34 @@ use FusionInventory::Agent::Task::Inventory::Input::Win32::Networks;
my %tests = (
7 => [
{
'dns' => '192.168.0.254',
'IPMASK6' => [
'64'
],
'IPMASK' => [
'255.255.255.0'
],
'IPGATEWAY' => '192.168.0.254',
'dns' => '192.168.0.254',
IPMASK6 => [ '64' ],
IPMASK => [ '255.255.255.0' ],
IPGATEWAY => '192.168.0.254',
MACADDR => 'F4:6D:04:97:2D:3E',
STATUS => 'Up',
'IPADDRESS6' => [
'fe80::311a:2127:dded:6618'
],
IPADDRESS6 => [ 'fe80::311a:2127:dded:6618' ],
IPDHCP => '192.168.0.254',
'IPSUBNET' => [
'192.168.0.0'
],
IPSUBNET => [ '192.168.0.0' ],
MTU => undef,
'IPSUBNET6' => [],
IPSUBNET6 => [],
DESCRIPTION => 'Realtek PCIe GBE Family Controller',
'IPADDRESS' => [
'192.168.0.1'
]
IPADDRESS => [ '192.168.0.1' ],
VIRTUALDEV => 0,
SPEED => 100000000,
PNPDEVICEID => 'PCI\VEN_10EC&DEV_8168&SUBSYS_84321043&REV_06\4&87D54EE&0&00E5',
TYPE => 'Ethernet'
},
{
MTU => undef,
MACADDR => '00:26:83:12:FB:0B',
STATUS => 'Up',
DESCRIPTION => "Périphérique Bluetooth (réseau personnel)",
IPDHCP => undef
IPDHCP => undef,
VIRTUALDEV => 0,
PNPDEVICEID => 'BTH\MS_BTHPAN\7&42D85A8&0&2',
TYPE => 'Ethernet',
SPEED => 0
},
],
);
Expand Down
10 changes: 5 additions & 5 deletions tools/createExtLinks.sh
Expand Up @@ -6,16 +6,16 @@ for task in Deploy SNMPQuery NetDiscovery ESX; do
taskLcName=`perl -e" print lc \"$task\""`
taskFile=$PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task.pm
taskDir=$PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task
if [ -f $taskFile ] && [ ! -e lib/FusionInventory/Agent/Task/$task.pm ]; then
if [ -f "$taskFile" ] && [ ! -e lib/FusionInventory/Agent/Task/$task.pm ]; then
echo "create link for $task"
ln -s $PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task.pm lib/FusionInventory/Agent/Task/
if [ -d $taskDir ] && [ ! -e lib/FusionInventory/Agent/Task/$task ]; then
ln -s $PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task lib/FusionInventory/Agent/Task/
ln -s "$PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task.pm" lib/FusionInventory/Agent/Task/
if [ -d "$taskDir" ] && [ ! -e lib/FusionInventory/Agent/Task/$task ]; then
ln -s "$PWD/../agent-task-$taskLcName/lib/FusionInventory/Agent/Task/$task" lib/FusionInventory/Agent/Task/$task
fi
fi
done
if [ ! -e lib/FusionInventory/VMware ]; then
ln -s $PWD/../agent-task-esx/lib/FusionInventory/VMware lib/FusionInventory/
ln -s "$PWD/../agent-task-esx/lib/FusionInventory/VMware" lib/FusionInventory/VMware
fi
if [ ! -e lib/FusionInventory/Agent/SNMP.pm ]; then
ln -s $PWD/../agent-task-netdiscovery/lib/FusionInventory/Agent/SNMP.pm lib/FusionInventory/Agent/SNMP.pm
Expand Down

0 comments on commit 0144c49

Please sign in to comment.