Skip to content

Commit

Permalink
Merge branch '2.2.x' into 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonéri Le Bouder committed Jul 22, 2012
2 parents 962fe8c + 87276e6 commit 05f892d
Show file tree
Hide file tree
Showing 17 changed files with 2,875 additions and 4,585 deletions.
19 changes: 19 additions & 0 deletions Changes
Expand Up @@ -11,6 +11,25 @@ BSD:
Linux:
* Megaraid controller support (Egor Morozov)

2.2.4 Sun, 22 Jul 2012 23:23:12 +0200
General:
* Fix: non blocking flock() on log file

MacOSX:
* Fix: STORAGES uses MiB instead GB
* Fix: add Fiber Channel storage support
* Fix: Don't ignore second screen, if both have the same name

Linux:
* Fix: collect qemu -drive information (Alexander Evseev)

Windows:
* Fix: OCS Inventory registry support
* Fix: some time the softwares were not collected

Solaris:
* Fix: Collect ZFS drives properly

2.2.3 Mon, 25 Jun 2012 21:36:29 +0200
General:
* Fix battery voltage and capacity retrieval
Expand Down
9 changes: 9 additions & 0 deletions lib/FusionInventory/Agent.pm
Expand Up @@ -133,8 +133,17 @@ sub init {
$logger->error("Can't load Proc::Daemon. Is the module installed?");
exit 1;
}

my $cwd = getcwd();
Proc::Daemon::Init();
$logger->debug("Daemon started");


# If we use relative path, we must stay in the current directory
if (substr( $params{libdir}, 0, 1 ) ne '/') {
chdir($cwd);
}

if ($self->_isAlreadyRunning()) {
$logger->debug("An agent is already runnnig, exiting...");
exit 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/FusionInventory/Agent/Logger/File.pm
Expand Up @@ -39,7 +39,7 @@ sub addMessage {
if (open $handle, '>>', $self->{logfile}) {

# get an exclusive lock on log file
flock($handle, LOCK_EX)
flock($handle, LOCK_EX|LOCK_NB)
or die "can't get an exclusive lock on $self->{logfile}: $ERRNO";

print {$handle}
Expand Down
7 changes: 6 additions & 1 deletion lib/FusionInventory/Agent/Task/Inventory/Input/Linux/LVM.pm
Expand Up @@ -71,6 +71,11 @@ sub _getPhysicalVolumes {
while (my $line = <$handle>) {
my @infos = split(/\s+/, $line);

my $pe_size;
if ($infos[7] && $infos[7]>0) {
$pe_size = int($infos[4] / $infos[7]);
}

push @volumes, {
DEVICE => $infos[1],
FORMAT => $infos[2],
Expand All @@ -79,7 +84,7 @@ sub _getPhysicalVolumes {
FREE => int($infos[5]||0),
PV_UUID => $infos[6],
PV_PE_COUNT => $infos[7],
PE_SIZE => int($infos[4] / $infos[7]),
PE_SIZE => $pe_size,
VG_UUID => $infos[8]
};
}
Expand Down
12 changes: 8 additions & 4 deletions lib/FusionInventory/Agent/Task/Inventory/Input/MacOS/Storages.pm
Expand Up @@ -37,8 +37,8 @@ sub _getStorages {
# └── key:value

my @storages;

foreach my $busName (qw/ATA SERIAL-ATA USB FireWire/) {
my @section = ('ATA', 'SERIAL-ATA', 'USB', 'FireWire', 'Fibre Channel');
foreach my $busName (@section) {
my $bus = $infos->{$busName};
next unless $bus;
foreach my $controllerName (keys %{$bus}) {
Expand Down Expand Up @@ -96,9 +96,13 @@ sub _getStorage {
if ($storage->{DISKSIZE}) {
#e.g: Capacity: 320,07 GB (320 072 933 376 bytes)
$storage->{DISKSIZE} =~ s/\s*\(.*//;
$storage->{DISKSIZE} =~ s/ GB//;
$storage->{DISKSIZE} =~ s/,/./;
$storage->{DISKSIZE} = int($storage->{DISKSIZE} * 1024);

if ($storage->{DISKSIZE} =~ s/\s*TB//) {
$storage->{DISKSIZE} = int($storage->{DISKSIZE} * 1000 * 1000);
} elsif ($storage->{DISKSIZE} =~ s/\s+GB$//) {
$storage->{DISKSIZE} = int($storage->{DISKSIZE} * 1000 * 1000);
}
}

if ($storage->{MODEL}) {
Expand Down
Expand Up @@ -40,7 +40,6 @@ sub _getDisplays {

foreach my $videoName (keys %{$infos->{'Graphics/Displays'}}) {
my $videoCardInfo = $infos->{'Graphics/Displays'}->{$videoName};

foreach my $displayName (keys %{$videoCardInfo->{Displays}}) {
next if $displayName eq 'Display Connector';
next if $displayName eq 'Display';
Expand Down
22 changes: 9 additions & 13 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Solaris/Drives.pm
Expand Up @@ -50,8 +50,6 @@ sub doInventory {
my @filesystems =
# exclude solaris 10 specific devices
grep { $_->{VOLUMN} !~ /^\/(devices|platform)/ }
# keep physical devices or swap
grep { $_->{VOLUMN} =~ /^(\/|swap)/ }
# exclude cdrom mount
grep { $_->{TYPE} !~ /cdrom/ }
# get all file systems
Expand All @@ -68,22 +66,21 @@ sub doInventory {
next;
}

my $line = getFirstLine(
command => "zfs get creation $filesystem->{VOLUMN}"
# use -H to exclude headers
my $zfs_line = getFirstLine(
command => "zfs get -H creation $filesystem->{VOLUMN}"
);

if ($line && $line =~ /creation\s+(\S.*\S+)\s*-/) {
if ($zfs_line && $zfs_line =~ /creation\s+(\S.*\S+)\s*-/) {
$filesystem->{FILESYSTEM} = 'zfs';
next;
}

if ($fsTypeFromMount{$filesystem->{VOLUMN}}) {
$filesystem->{FILESYSTEM} = $fsTypeFromMount{$filesystem->{VOLUMN}};
next;
# call fstype, and set filesystem type unless the output matches
# erroneous result
my $fstyp_line = getFirstLine(command => "fstyp $filesystem->{VOLUMN}");
if ($fstyp_line && $fstyp_line !~ /^fstyp/) {
$filesystem->{FILESYSTEM} = $fstyp_line;
}

$filesystem->{FILESYSTEM} =
getFirstLine(command => "fstyp $filesystem->{VOLUMN}");
}

# add filesystems to the inventory
Expand All @@ -94,5 +91,4 @@ sub doInventory {
);
}
}

1;
Expand Up @@ -28,7 +28,7 @@ sub doInventory {
)) {
# match only if an qemu instance
next unless
$process->{CMD} =~ /(qemu|kvm|qemu-kvm) .* -([fhsv]d[a-d]|cdrom)/x;
$process->{CMD} =~ /(qemu|kvm|qemu-kvm) .* -([fhsv]d[a-z]|cdrom|drive)/x;

my $name;
my $mem = 0;
Expand Down
70 changes: 46 additions & 24 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/Registry.pm
Expand Up @@ -4,13 +4,10 @@ use strict;
use warnings;

use English qw(-no_match_vars);
use Win32::TieRegistry (
Delimiter => "/",
ArrayValues => 0,
qw/KEY_READ/
);

use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Win32;


my @hives = qw/
HKEY_CLASSES_ROOT
Expand All @@ -27,12 +24,17 @@ sub isEnabled {
return $params{registry};
}

sub doInventory {
sub _getRegistryData {
my (%params) = @_;

my $inventory = $params{inventory};
my @data;

my @registrys = ref($params{registry}->{PARAM}) eq 'ARRAY' ?
@{$params{registry}->{PARAM}} :
($params{registry}->{PARAM});

foreach my $option (@registrys) {

foreach my $option (@{$params{registry}}) {
my $name = $option->{NAME};
my $regkey = $option->{REGKEY};
my $regtree = $option->{REGTREE};
Expand All @@ -41,28 +43,48 @@ sub doInventory {
# This should never append, err wait...
next unless $content;

my $machKey = $Registry->Open(
$hives[$regtree], { Access => KEY_READ }
) or die "Can't open $hives[$regtree]: $EXTENDED_OS_ERROR";

my $values = $machKey->{$regkey};
$regkey =~ s{\\}{/}g;
my $value = getRegistryValue(
path => $hives[$regtree]."/".$regkey."/".$content,
logger => $params{logger}
);

if ($content eq '*') {
foreach my $keyWithDelimiter ( keys %$values ) {
next unless $keyWithDelimiter =~ /^\/(.*)/;
$inventory->addRegistry({
NAME => $name,
REGVALUE => $1."=".$values->{$keyWithDelimiter}."\n"
});
if (ref($value) eq "HASH") {
foreach ( keys %$value ) {
my $n = encodeFromRegistry($_) || '';
my $v = encodeFromRegistry($value->{$_}) || '';
push @data, { section => 'REGISTRY', entry => {
NAME => $name,
REGVALUE => "$n=$v"
}
};
}
} else {
$inventory->addRegistry({
NAME => $name,
REGVALUE => $values->{$content}
});
push @data, {section => 'REGISTRY', entry => {
NAME => $name,
REGVALUE => encodeFromRegistry($value)
}
};
}
}


return @data;
}

sub doInventory {
my (%params) = @_;

return unless $params{registry}->{NAME} eq 'REGISTRY';

foreach my $data (_getRegistryData(
registry => $params{registry},
logger => $params{logger}))
{
$params{inventory}->addEntry(%$data);
}


}

1;
7 changes: 7 additions & 0 deletions lib/FusionInventory/Agent/Tools/MacOS.pm
Expand Up @@ -75,6 +75,13 @@ sub getSystemProfilerInfos {

# create a new node, and push it to the stack
my $parent_node = $parents[-1]->[0];

my $i;
my $keyL = $key;
while (defined($parent_node->{$key})) {
$key = $keyL . '_' . $i++;
}

$parent_node->{$key} = {};
push (@parents, [ $parent_node->{$key}, $level, $key ]);
}
Expand Down
14 changes: 12 additions & 2 deletions lib/FusionInventory/Agent/Tools/Win32.pm
Expand Up @@ -127,7 +127,17 @@ sub getRegistryValue {
root => $root,
keyName => $keyName
);
return $key->{"/$valueName"};

if ($valueName eq '*') {
my %ret;
foreach (keys %$key) {
s{^/}{};
$ret{$_}=$key->{"/$_"};
}
return \%ret;
} else {
return $key->{"/$valueName"};
}
}

sub getRegistryKey {
Expand Down Expand Up @@ -273,7 +283,7 @@ E.g: HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/ProductName
=head2 getRegistryKey(%params)
Returns a key from the registry.
Returns a key from the registry. If key name is '*', all the keys of the path are returned as a hash reference.
=over
Expand Down
36 changes: 36 additions & 0 deletions resources/macos/system_profiler/10.6.5-dual-monitor
@@ -0,0 +1,36 @@
Graphics/Displays:

ATI Radeon HD 5770:

Chipset Model: ATI Radeon HD 5770
Type: GPU
Bus: PCIe
Slot: Slot-1
PCIe Lane Width: x16
VRAM (Total): 1024 MB
Vendor: ATI (0x1002)
Device ID: 0x68b8
Revision ID: 0x0000
ROM Revision: 113-C0160C-155
EFI Driver Version: 01.00.436
Displays:
E2441:
Resolution: 1920 x 1080 @ 60 Hz
Pixel Depth: 32-Bit Color (ARGB8888)
Display Serial Number:
Main Display: Yes
Mirror: Off
Online: Yes
Rotation: Supported
Television: Yes
E2441:
Resolution: 1920 x 1080 @ 60 Hz
Pixel Depth: 32-Bit Color (ARGB8888)
Display Serial Number:
Mirror: Off
Online: Yes
Rotation: Supported
Television: Yes
Display Connector:
Status: No Display Connected

0 comments on commit 05f892d

Please sign in to comment.