File Coverage

blib/lib/FusionInventory/Agent/Task/Inventory/BSD/MIPS.pm
Criterion Covered Total %
statement 12 30 40.0
branch 0 8 0.0
condition n/a
subroutine 4 6 66.6
pod 0 2 0.0
total 16 46 34.7


line stmt bran cond sub pod time code
1             package FusionInventory::Agent::Task::Inventory::BSD::MIPS;
2              
3 1     1   90652535 use strict;
  1         6  
  1         36  
4 1     1   10 use warnings;
  1         4  
  1         52  
5              
6 1     1   4 use Config;
  1         37  
  1         89  
7              
8 1     1   371 use FusionInventory::Agent::Tools;
  1         2  
  1         298  
9              
10             sub isEnabled {
11 0     0 0   return $Config{archname} =~ /^mips/;
12             }
13              
14             sub doInventory {
15 0     0 0   my (%params) = @_;
16              
17 0           my $inventory = $params{inventory};
18              
19 0           my $bios = {
20             SMANUFACTURER => 'SGI',
21             };
22              
23             # sysctl infos
24              
25             # example on NetBSD: SGI-IP22
26             # example on OpenBSD: SGI-O2 (IP32)
27 0           $bios->{SMODEL} = getFirstLine(command => 'sysctl -n hw.model');
28              
29 0           my $count = getFirstLine(command => 'sysctl -n hw.ncpu');
30              
31             # dmesg infos
32              
33             # I) Indy
34             # NetBSD:
35             # mainbus0 (root): SGI-IP22 [SGI, 6906e152], 1 processor
36             # cpu0 at mainbus0: MIPS R4400 CPU (0x450) Rev. 5.0 with MIPS R4010 FPC Rev. 0.0
37             # int0 at mainbus0 addr 0x1fbd9880: bus 75MHz, CPU 150MHz
38             #
39             # II) O2
40             # NetBSD:
41             # mainbus0 (root): SGI-IP32 [SGI, 8], 1 processor
42             # cpu0 at mainbus0: MIPS R5000 CPU (0x2321) Rev. 2.1 with built-in FPU Rev. 1.0
43             # OpenBSD:
44             # mainbus0 (root)
45             # cpu0 at mainbus0: MIPS R5000 CPU rev 2.1 180 MHz with R5000 based FPC rev 1.0
46             # cpu0: cache L1-I 32KB D 32KB 2 way, L2 512KB direct
47              
48 0           my $cpu;
49 0           foreach my $line (getAllLines(command => 'dmesg')) {
50 0 0         if ($line =~ /$bios->{SMODEL}\s*\[\S*\s*(\S*)\]/) { $bios->{SSN} = $1; }
  0            
51 0 0         if ($line =~ /cpu0 at mainbus0:\s*(.*)$/) { $cpu->{NAME} = $1; }
  0            
52 0 0         if ($line =~ /CPU\s*.*\D(\d+)\s*MHz/) { $cpu->{SPEED} = $1; }
  0            
53             }
54              
55 0           $inventory->setBios($bios);
56              
57 0 0         return if $params{no_category}->{cpu};
58              
59 0           while ($count--) {
60 0           $inventory->addEntry(
61             section => 'CPUS',
62             entry => $cpu
63             );
64             }
65             }
66              
67             1;