Skip to content

Commit

Permalink
Merge remote-tracking branch 'forge/2.3.x' into 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
guillomovitch committed Dec 18, 2012
2 parents 9390324 + f192eb4 commit 4db764b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Revision history for FusionInventory agent
2.3.0
General:
* various UTF8 encoding fixes
* Add DNS_DOMAIN and FQDN in OPERATINGSYSTEM section
* Add DNS_DOMAIN, BOOT_TIME and FQDN in OPERATINGSYSTEM section
* Collect public SSH keys

Windows:
Expand Down
5 changes: 4 additions & 1 deletion lib/FusionInventory/Agent/Task/Inventory/Input/BSD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ sub doInventory {
}
close $handle;

my $boottime = getFirstMatch(command => "sysctl -n kern.boottime", pattern => qr/sec = (\d+)/);

my $OSName = $OSNAME;
if (canRun('lsb_release')) {
$OSName = getFirstMatch(
Expand All @@ -58,7 +60,8 @@ sub doInventory {
NAME => $OSName,
VERSION => $OSVersion,
KERNEL_VERSION => $OSVersion,
FULL_NAME => $OSNAME
FULL_NAME => $OSNAME,
BOOT_TIME => getFormatedLocalTime($boottime)
});
}

Expand Down
5 changes: 4 additions & 1 deletion lib/FusionInventory/Agent/Task/Inventory/Input/Linux.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ sub doInventory {
my $oscomment = getFirstLine(command => 'uname -v');
my $systemId = _getRHNSystemId('/etc/sysconfig/rhn/systemid');

my $boottime = time - getFirstMatch(file => '/proc/uptime', pattern => qr/^(\d+)/);

$inventory->setHardware({
OSVERSION => $osversion,
OSCOMMENTS => $oscomment,
WINPRODID => $systemId,
});

$inventory->setOperatingSystem({
KERNEL_VERSION => $osversion
KERNEL_VERSION => $osversion,
BOOT_TIME => getFormatedLocalTime($boottime)
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ sub doInventory {

my $inventory = $params{inventory};

my $arch = getFirstLine(command => 'uname -m');
my $uptime = _getUptime(file => '/proc/uptime');
$inventory->setHardware({
DESCRIPTION => "$arch/$uptime"
$inventory->setOperatingSystem({
BOOT_TIME => "$uptime"
});
}

Expand All @@ -30,7 +29,7 @@ sub _getUptime {
);
return unless $uptime;

return getFormatedGmTime($uptime);
return getFormatedLocalTime(int(time - $uptime));
}

1;
4 changes: 3 additions & 1 deletion lib/FusionInventory/Agent/Task/Inventory/Input/MacOS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sub doInventory {
# never hurt
my $OSComment = getFirstLine(command => 'uname -v');
my $KernelVersion = getFirstLine(command => 'uname -r');
my $boottime = getFirstMatch(command => "sysctl -n kern.boottime", pattern => qr/sec = (\d+)/);

$inventory->setHardware({
OSNAME => $OSName,
Expand All @@ -45,7 +46,8 @@ sub doInventory {
NAME => "MacOSX",
VERSION => $OSVersion,
KERNEL_VERSION => $KernelVersion,
FULL_NAME => $OSName
FULL_NAME => $OSName,
BOOT_TIME => getFormatedLocalTime($boottime)
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ sub doInventory {
sub _scanOffice {
my ($key) = @_;

my %license = {
my %license = (
PRODUCTID => $key->{ProductID},
UPDATE => $key->{SPLevel},
OEM => $key->{OEM},
FULLNAME => encodeFromRegistry($key->{ProductName}) ||
encodeFromRegistry($key->{ConvertToEdition}),
NAME => encodeFromRegistry($key->{ProductNameNonQualified}) ||
encodeFromRegistry($key->{ProductNameVersion})
};
);

if ($key->{DigitalProductID}) {
$license{KEY} = parseProductKey($key->{DigitalProductID});
Expand Down
12 changes: 10 additions & 2 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Win32/OS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ sub doInventory {
foreach my $object (getWMIObjects(
class => 'Win32_OperatingSystem',
properties => [ qw/
OSLanguage Caption Version SerialNumber Organization \
RegisteredUser CSDVersion TotalSwapSpaceSize OSArchitecture
OSLanguage Caption Version SerialNumber Organization
RegisteredUser CSDVersion TotalSwapSpaceSize
OSArchitecture LastBootUpTime
/ ]
)) {

Expand Down Expand Up @@ -62,6 +63,12 @@ sub doInventory {
my $osArchitecture = $object->{OSArchitecture} || '32-bit';
$osArchitecture =~ s/ /-/; # "64 bit" => "64-bit"

my $boottime;
if ($object->{LastBootUpTime} =~
/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/) {
$boottime = getFormatedDate($1, $2, $3, $4, $5, 6);
}

$inventory->setOperatingSystem({
NAME => "Windows",
INSTALL_DATE => $installDate,
Expand All @@ -70,6 +77,7 @@ sub doInventory {
FULL_NAME => $object->{Caption},
SERVICE_PACK => $object->{CSDVersion},
ARCH => $osArchitecture,
BOOT_TIME => $boottime,
});
}

Expand Down
8 changes: 6 additions & 2 deletions lib/FusionInventory/Agent/Task/Inventory/Inventory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ my %fields = (
DEFAULTGATEWAY VMSYSTEM WINOWNER WINPRODID
WINPRODKEY WINCOMPANY WINLANG CHASSIS_TYPE/ ],
OPERATINGSYSTEM => [ qw/KERNEL_NAME KERNEL_VERSION NAME VERSION FULL_NAME
SERVICE_PACK INSTALL_DATE FQDN DNS_DOMAIN SSH_KEY
ARCH/ ],
SERVICE_PACK INSTALL_DATE FQDN DNS_DOMAIN
SSH_KEY ARCH BOOT_TIME/ ],
ACCESSLOG => [ qw/USERID LOGDATE/ ],
VIRTUALMACHINES => [ qw/MEMORY NAME UUID STATUS SUBSYSTEM VMTYPE VCPU
VMID MAC COMMENT OWNER/ ],
Expand Down Expand Up @@ -942,6 +942,10 @@ The operating system installation date.
Operating system architecture.
=item BOOT_TIME
The date of the boot of the computer, e.g: 2012-12-09 15:58:20
=back
=head2 MONITORS
Expand Down
2 changes: 2 additions & 0 deletions lib/FusionInventory/Agent/Tools.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ if ($OSNAME ne 'MSWin32') {
sub getFormatedLocalTime {
my ($time) = @_;

return unless $time;

my ($year, $month , $day, $hour, $min, $sec) =
(localtime ($time))[5, 4, 3, 2, 1, 0];

Expand Down

0 comments on commit 4db764b

Please sign in to comment.