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

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

Copyt trusty code

File size: 2.7 KB
Line 
1package Ocsinventory::Agent::Backend::OS::BSD::Archs::Sparc;
2
3use strict;
4
5sub check{
6    my $arch;
7    chomp($arch=`sysctl -n hw.machine`);
8    $arch =~ /^sparc/;
9}
10
11sub run {
12  my $params = shift;
13  my $common = $params->{common};
14
15  my( $SystemSerial , $SystemModel, $SystemManufacturer, $BiosManufacturer,
16    $BiosVersion, $BiosDate);
17  my ( $processort , $processorn , $processors );
18
19  ### Get system serial with "sysctl kern.hostid"
20  #
21  # sysctl -n kern.hostid gives e.g. 0x807b65c on NetBSD
22  # and 2155570635 on OpenBSD; we keep the hex form
23
24  chomp ($SystemSerial = `sysctl -n kern.hostid`);
25  if ( $SystemSerial =~ /^\d*$/ ) { # convert to NetBSD format
26      $SystemSerial = sprintf ("0x%x",$SystemSerial);
27  }
28  $SystemSerial =~ s/^0x//; # remove 0x to make it appear as in the firmware
29 
30  ### Get system model and processor type in dmesg
31  #
32  # cannot use "sysctl hw.model" to get SystemModel
33  # because it gives only the CPU on OpenBSD/sparc64
34  #
35  # Examples of dmesg output :
36  #
37  # I) SPARC
38  # a) NetBSD
39  # mainbus0 (root): SUNW,SPARCstation-20: hostid 72362bb1
40  # cpu0 at mainbus0: TMS390Z50 v0 or TMS390Z55 @ 50 MHz, on-chip FPU
41  # b) OpenBSD
42  # mainbus0 (root): SUNW,SPARCstation-20
43  # cpu0 at mainbus0: TMS390Z50 v0 or TMS390Z55 @ 50 MHz, on-chip FPU
44  #
45  # II) SPARC64
46  # a) NetBSD
47  # mainbus0 (root): SUNW,Ultra-1: hostid 807b65cb
48  # cpu0 at mainbus0: SUNW,UltraSPARC @ 166.999 MHz, version 0 FPU
49  # b) OpenBSD
50  # mainbus0 (root): Sun Ultra 1 SBus (UltraSPARC 167MHz)
51  # cpu0 at mainbus0: SUNW,UltraSPARC @ 166.999 MHz, version 0 FPU
52  # c) FreeBSD
53  # cpu0: Sun Microsystems UltraSparc-I Processor (167.00 MHz CPU)
54
55  for (`dmesg`) {
56      if (/^mainbus0 \(root\):\s*(.*)$/) { $SystemModel = $1; }
57      if (/^cpu[^:]*:\s*(.*)$/i) { $processort = $1 unless $processort; }
58  }
59  $SystemModel || chomp ($SystemModel = `sysctl -n hw.model`); # for FreeBSD
60  $SystemManufacturer = "SUN";
61  # some cleanup
62  $SystemModel =~ s/SUNW,//;
63  $SystemModel =~ s/[:\(].*$//;
64  $SystemModel =~ s/^\s*//;
65  $SystemModel =~ s/\s*$//;
66  $processort =~ s/SUNW,//;
67  $processort =~ s/^\s*//;
68  $processort =~ s/\s*$//;
69 
70  # number of procs with "sysctl hw.ncpu"
71  chomp($processorn=`sysctl -n hw.ncpu`);
72  # XXX quick and dirty _attempt_ to get proc speed
73  if ( $processort =~ /(\d+)(\.\d+|)\s*mhz/i ) { # possible decimal point
74      $processors = sprintf("%.0f", "$1$2"); # round number
75  }
76
77# Writing data
78  $common->setBios ({
79      SMANUFACTURER => $SystemManufacturer,
80      SMODEL => $SystemModel,
81      SSN => $SystemSerial,
82      BMANUFACTURER => $BiosManufacturer,
83      BVERSION => $BiosVersion,
84      BDATE => $BiosDate,
85    });
86
87  $common->setHardware({
88
89      PROCESSORT => $processort,
90      PROCESSORN => $processorn,
91      PROCESSORS => $processors
92
93    });
94
95
96}
97
981;
Note: See TracBrowser for help on using the repository browser.