Skip to content

Commit

Permalink
Merge remote-tracking branch 'forge/2.2.x' into 2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Rousse authored and Guillaume Rousse committed Feb 1, 2012
2 parents a9ee803 + b495d1e commit aa708b9
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Expand Up @@ -2,7 +2,7 @@ maintainer:
Gonéri LE BOUDER <goneri@rulezlan.org>

Copyright 2006-2010 OCS Inventory contributors
Copyright 2010-2011 FusionInventory Team
Copyright 2010-2012 FusionInventory Team

Website: http://www.fusioninventory.org

Expand Down
2 changes: 1 addition & 1 deletion fusioninventory-agent
Expand Up @@ -649,7 +649,7 @@ http://forge.fusionInventory.org
=head1 COPYRIGHT
Copyright (C) 2006-2010 OCS Inventory contributors
Copyright (C) 2010-2011 FusionInventory Team
Copyright (C) 2010-2012 FusionInventory Team
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
Expand Down
2 changes: 1 addition & 1 deletion fusioninventory-injector
Expand Up @@ -2,7 +2,7 @@
###############################################################################
##Copyleft Pascal DANEK 2005
##Copyleft Goneri Le Bouder 2006
##Copyleft FusionInventory Project 2010-2011
##Copyleft FusionInventory Project 2010-2012
##Web : http://www.FusionInventory.org
##
##This code is open source and may be copied and modified as long as the source
Expand Down
Expand Up @@ -36,6 +36,9 @@ my @distributions = (
# mandrake-release contains something like "Mandrakelinux release 10.1 (Community) for i586"
[ '/etc/mandrake-release', 'Mandrake', 'release ([\d.]+)', '%s'],

# centos-release contains something like "CentOS Linux release 6.0 (Final)
[ '/etc/centos-release', 'CentOS', 'release ([\d.]+)', '%s' ],

# redhat-release contains something like "Red Hat Enterprise Linux Server release 5 (Tikanga)"
[ '/etc/redhat-release', 'RedHat', 'release ([\d.]+)', '%s' ],

Expand Down
Expand Up @@ -4,6 +4,7 @@ use strict;
use warnings;

use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::MacOS;

my $seen;

Expand Down
12 changes: 9 additions & 3 deletions lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/Uptime.pm
Expand Up @@ -21,14 +21,20 @@ sub doInventory {
});
}

sub _getUptime {
sub _getBootTime {
my $boottime = getFirstMatch(
pattern => qr/sec\s*=\s*(\d+)/,
pattern => qr/(\d+)$/,
@_,
);

return $boottime;
}

sub _getUptime {
my $boottime = _getBootTime(@_);
return unless $boottime;

my $uptime = $boottime - time();
my $uptime = time() - $boottime;
return getFormatedGmTime($uptime);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Bios.pm
Expand Up @@ -104,6 +104,14 @@ sub doInventory {
$inventory->setHardware ({
VMSYSTEM => 'VMware'
});
} elsif (
($bios->{SMANUFACTURER} eq 'Xen')
||
($bios->{BMANUFACTURER} eq 'Xen')
) {
$inventory->setHardware ({
VMSYSTEM => 'Xen'
});
}

}
Expand Down
67 changes: 57 additions & 10 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Softwares.pm
Expand Up @@ -46,8 +46,13 @@ sub doInventory {
softwares => $softwares64,
is64bit => 1
)) {
$inventory->addEntry(section => 'SOFTWARES', entry => $software);
_addSoftware(inventory => $inventory, entry => $software);
}
_processMSIE(
machKey => $machKey64,
inventory => $inventory,
is64bit => 1
);

my $machKey32 = $Registry->Open('LMachine', {
Access => KEY_READ | KEY_WOW64_32 ## no critic (ProhibitBitwise)
Expand All @@ -60,8 +65,15 @@ sub doInventory {
softwares => $softwares32,
is64bit => 0
)) {
$inventory->addEntry(section => 'SOFTWARES', entry => $software);
_addSoftware(inventory => $inventory, entry => $software);
}
_processMSIE(
machKey => $machKey64,
inventory => $inventory,
is64bit => 0
);


} else {
my $machKey = $Registry->Open('LMachine', {
Access => KEY_READ
Expand All @@ -74,8 +86,13 @@ sub doInventory {
softwares => $softwares,
is64bit => 0
)) {
$inventory->addEntry(section => 'SOFTWARES', entry => $software);
_addSoftware(inventory => $inventory, entry => $software);
}
_processMSIE(
machKey => $machKey,
inventory => $inventory,
is64bit => 0
);
}
}

Expand Down Expand Up @@ -103,10 +120,6 @@ sub _getSoftwares {
# odd, found on Win2003
next unless keys %$data > 2;

# See bug #927
# http://stackoverflow.com/questions/2639513/duplicate-entries-in-uninstall-registry-key-when-compiling-list-of-installed-soft
next if $data->{'/SystemComponent'};

my $guid = $rawGuid;
$guid =~ s/\/$//; # drop the tailing /

Expand All @@ -132,13 +145,47 @@ sub _getSoftwares {
# Workaround for #415
$software->{VERSION} =~ s/[\000-\037].*// if $software->{VERSION};

# avoid duplicates
next if $seen->{$software->{NAME}}->{$software->{VERSION} || '_undef_'}++;

push @softwares, $software;
}

return @softwares;
}

sub _addSoftware {
my %params = @_;

my $entry = $params{entry};

# avoid duplicates
return if $seen->{$entry->{NAME}}->{$entry->{IS64BIT}}{$entry->{VERSION} || '_undef_'}++;

$params{inventory}->addEntry(section => 'SOFTWARES', entry => $entry);
}

sub _processMSIE {
my %params = @_;

my $inventory = $params{inventory};
my $is64bit = $params{is64bit} || 0;
my $machKey = $params{machKey};

my $name = "Internet Explorer";
if ($is64bit) {
$name .= " (64bit)";
}
my $version = $params{machKey}->{"SOFTWARE/Microsoft/Internet Explorer/Version"};

_addSoftware(
inventory => $params{inventory},
entry => {
FROM => "registry",
IS64BIT => $is64bit,
NAME => $name,
VERSION => $version,
PUBLISHER => "Microsoft Corporation"
});

}


1;
20 changes: 20 additions & 0 deletions t/inventory/macos/uptime.t
@@ -0,0 +1,20 @@
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

use FusionInventory::Agent::Task::Inventory::Input::MacOS::Uptime;

my %tests = (
'1325070226' => '1325070226',
'sec = 1325070226' => '1325070226'
);

plan tests => scalar keys %tests;

foreach my $test (keys %tests) {
my $r = FusionInventory::Agent::Task::Inventory::Input::MacOS::Uptime::_getBootTime(string => $test);
ok($r eq $tests{$test});
}

0 comments on commit aa708b9

Please sign in to comment.