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