source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/BSD/CPU.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 929 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::BSD::CPU;
2use strict;
3
4sub check {
5  return unless -r "/dev/mem";
6
7  `which dmidecode 2>&1`;
8  return if ($? >> 8)!=0;
9  `dmidecode 2>&1`;
10  return if ($? >> 8)!=0;
11  1;
12}
13
14sub run {
15  my $params = shift;
16  my $common = $params->{common};
17
18  my $processort;
19  my $processorn;
20  my $processors;
21 
22  my $family;
23  my $manufacturer;
24
25# XXX Parsing dmidecode output using "type 4" section
26# for nproc type and speed
27# because no /proc on *BSD
28
29#TODO: enhance this part to get speed everytime and support for multi CPUs
30  my $flag=0;
31  my $status=0; ### XXX 0 if Unpopulated
32  for(`dmidecode`){
33    $status = 1 if $flag && /^\s*status\s*:.*enabled/i;
34    $processors = $1 if $flag && /^\s*current speed\s*:\s*(\d+).+/i;
35  }
36 
37  $processorn = `sysctl -n hw.ncpu`;
38  $processort = `sysctl -n hw.model`;
39
40  $common->addCPU({
41      TYPE => $processort,
42      SPEED => $processors
43    });
44
45}
461;
Note: See TracBrowser for help on using the repository browser.