diff --git a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm index 57ed0955ed..c0ccc714dc 100644 --- a/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm +++ b/lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm @@ -6,27 +6,12 @@ use warnings; use English qw(-no_match_vars); use UNIVERSAL::require; -use FusionInventory::Agent::Tools; +use FusionInventory::Agent::Tools::Generic; sub isEnabled { - if ($OSNAME eq 'MSWin32') { - # don't run dmidecode on Win2003 - # http://forge.fusioninventory.org/issues/379 - Win32->require(); - my @osver = Win32::GetOSVersion(); - return if - $osver[4] == 2 && - $osver[1] == 5 && - $osver[2] == 2; - } - - return unless canRun('dmidecode'); - - my $count = getLinesCount( - command => "dmidecode" - ); - return $count > 10; + return unless getDmidecodeInfos(); + } sub doInventory {} diff --git a/lib/FusionInventory/Agent/Tools/Generic.pm b/lib/FusionInventory/Agent/Tools/Generic.pm index 840e68c90e..137cc5ed5a 100644 --- a/lib/FusionInventory/Agent/Tools/Generic.pm +++ b/lib/FusionInventory/Agent/Tools/Generic.pm @@ -24,8 +24,18 @@ sub getDmidecodeInfos { @_ ); - my $handle = getFileHandle(%params); + if ($OSNAME eq 'MSWin32') { + # don't run dmidecode on Win2003 + # http://forge.fusioninventory.org/issues/379 + Win32->require(); + my @osver = Win32::GetOSVersion(); + return if + $osver[4] == 2 && + $osver[1] == 5 && + $osver[2] == 2; + } + my $handle = getFileHandle(%params); my ($info, $block, $type); while (my $line = <$handle>) { @@ -59,6 +69,8 @@ sub getDmidecodeInfos { } close $handle; + return if 2 > keys %$info; + return $info; }