our
$VERSION
=
'1.16.0'
;
my
%HW_PROVIDER
;
sub
register_hardware_provider {
my
(
$class
,
$service_name
,
$service_class
) =
@_
;
$HW_PROVIDER
{
"\L$service_name"
} =
$service_class
;
return
1;
}
sub
get {
my
(
$class
,
@modules
) =
@_
;
my
%hardware_information
;
if
(
"all"
eq
"\L$modules[0]"
) {
@modules
=
qw(Host Kernel Memory Network Swap VirtInfo)
;
push
(
@modules
,
keys
(
%HW_PROVIDER
) );
}
for
my
$mod_string
(
@modules
) {
Rex::Commands::profiler()->start(
"hardware: $mod_string"
);
my
$mod
=
"Rex::Hardware::$mod_string"
;
if
(
exists
$HW_PROVIDER
{
$mod_string
} ) {
$mod
=
$HW_PROVIDER
{
$mod_string
};
}
Rex::Logger::debug(
"Loading $mod"
);
eval
"use $mod"
;
if
($@) {
Rex::Logger::info(
"$mod not found."
);
Rex::Logger::debug(
"$@"
);
next
;
}
$hardware_information
{
$mod_string
} =
$mod
->get();
Rex::Commands::profiler()->end(
"hardware: $mod_string"
);
}
return
%hardware_information
;
}
1;