1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
package Ocsinventory::Agent::Backend::OS::BSD::Archs::I386;
# for i386 in case dmidecode is not available
use strict;
sub check{
my $arch;
chomp($arch=`sysctl -n hw.machine`);
return if (($arch ne "i386") && ($arch ne "amd64"));
# dmidecode must not be present
`dmidecode 2>&1`;
return if ($? >> 8)==0;
1;
}
sub run {
my $params = shift;
my $common = $params->{common};
my ($SystemSerial , $SystemModel, $SystemManufacturer, $BiosManufacturer, $BiosVersion, $BiosDate);
my ($processort , $processorn , $processors);
# use hw.machine for the system model
# TODO see if we can do better
chomp($SystemModel=`sysctl -n hw.machine`);
# number of procs with sysctl (hw.ncpu)
chomp($processorn=`sysctl -n hw.ncpu`);
# proc type with sysctl (hw.model)
chomp($processort=`sysctl -n hw.model`);
# XXX quick and dirty _attempt_ to get proc speed through dmesg
for (`dmesg`){
my $tmp;
if (/^cpu\S*\s.*\D[\s|\(]([\d|\.]+)[\s|-]mhz/i) { # XXX unsure
$tmp = $1;
$tmp =~ s/\..*//;
$processors=$tmp;
last
}
}
# Writing data
$common->setBios ({
SMANUFACTURER => $SystemManufacturer,
SMODEL => $SystemModel,
SSN => $SystemSerial,
BMANUFACTURER => $BiosManufacturer,
BVERSION => $BiosVersion,
BDATE => $BiosDate,
});
$common->setHardware({
PROCESSORT => $processort,
PROCESSORN => $processorn,
PROCESSORS => $processors
});
}
1;
|