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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
|
package Ocsinventory::Agent::Backend::OS::Solaris::Slots;
use strict;
sub check {
my $params = shift;
my $common = $params->{common};
$common->can_run ("prtdiag")
}
sub run {
my $params = shift;
my $common = $params->{common};
my $description;
my $designation;
my $name;
my $status;
my @pci;
my $flag;
my $flag_pci;
my $model;
my $sun_class;
chomp($model = `uname -i`);
# debug print model
#print "Model: '$model'";
$sun_class = 0;
# we map (hopfully) our server model to a known class
if ($model =~ /SUNW,SPARC-Enterprise/) { $sun_class = 1; } # M9000
if ($model =~ /SUNW,SPARC-Enterprise-T\d/) { $sun_class = 22; } # T5220
if ($model =~ /SUNW,Sun-Fire-\d/) { $sun_class = 3; } # 280R, 480R
if ($model =~ /SUNW,Sun-Fire-V\d/) { $sun_class = 3; } # V490
if ($model =~ /SUNW,Sun-Fire-T\d/) { $sun_class = 4; } # T2000
if ($model =~ /SUNW,Sun-Blade-1500/) { $sun_class = 8; } # Blade 1500 workstation
if ($model =~ /i86pc/) { $sun_class = 21; } # x86 hardware
if ($model =~ /SUNW,T5/) { $sun_class = 22; } # T5240, T5440
if ($model =~ /sun4v/) { $sun_class = 22; } # T3-x, T4-x, T5-x
#Debug
#print "sun_class : $sun_class\n";
if ( $sun_class == 0 ) {
# Default class, probably doesn't work
foreach (`prtdiag `) {
last if(/^\=+/ && $flag_pci);
next if(/^\s+/ && $flag_pci);
if($flag && $flag_pci && /^(\S+)\s+/) {
$name = $1;
}
if($flag && $flag_pci && /(\S+)\s*$/) {
$designation = $1;
}
if($flag && $flag_pci && /^\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/) {
$description = $1;
}
if($flag && $flag_pci && /^\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/) {
$status = $1;
}
if($flag && $flag_pci) {
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if(/^=+\s+IO Cards/){$flag_pci = 1;}
if($flag_pci && /^-+/){$flag = 1;}
}
}
if ( $sun_class == 1 ) {
# M9000
#========================= IO Devices =========================
#
# IO Lane/Frq
#LSB Type LPID RvID,DvID,VnID BDF State Act, Max Name Model
#--- ----- ---- ------------------ --------- ----- ----------- ------------------------------ --------------------
# Logical Path
# ------------
#00 PCIx 0 8, 125, 1033 2, 0, 0 okay 133, 133 pci-pciexclass,060400 N/A
# /pci@0,600000/pci@0
#
foreach (`prtdiag -v`) {
last if(/^\=+/ && $flag_pci && $flag);
if ($flag && $flag_pci && /^(\d+)\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+((\S+)-\S+)\s+(\S+).*/ ) {
$designation = "LSB " . $1;
$status = $3;
$name = $4;
$description = "[$2] $5";
$description .= " ($6)" unless ($6=~/N\/A/);
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if(/^=+\S+\s+IO Devices/){$flag_pci = 1; }
if($flag_pci && /^-+/){$flag = 1;}
}
}
if ( $sun_class == 2 ) {
# to be checked
foreach (`prtdiag `) {
if (/pci/) {
@pci = split(/ +/);
$name=$pci[4]." ".$pci[5];
$description=$pci[0]." (".$pci[1].")";
$designation=$pci[3];
$status="";
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
}
}
if ( $sun_class == 3 ) {
# SUNW,Sun-Fire-480R
# ========================= IO Cards =========================
#
# Bus Max
# IO Port Bus Freq Bus Dev,
# Type ID Side Slot MHz Freq Func State Name Model
# ---- ---- ---- ---- ---- ---- ---- ----- -------------------------------- ----------------------
# PCI 8 B 3 33 33 3,0 ok SUNW,qlc-pci1077,2312.1077.101.2+
# PCI 8 B 3 33 33 3,1 ok SUNW,qlc-pci1077,2312.1077.101.2+
# PCI 8 B 5 33 33 5,0 ok pci-pci1011,25.4/pci108e,1000 PCI-BRIDGE
# PCI 8 B 5 33 33 0,0 ok pci108e,1000-pci108e,1000.1 device on pci-bridge
# PCI 8 B 5 33 33 0,1 ok SUNW,qfe-pci108e,1001 SUNW,pci-qfe/pci-bridg+
foreach (`prtdiag `) {
last if(/^\=+/ && $flag_pci && $flag); # End of IO Devices, next section starts here
if($flag && $flag_pci && /PCI/) {
@pci = split(/ +/);
$name=join(" ",@pci[9..$#pci]);
$description="[".$pci[0]."] ".$pci[8];
$designation=$pci[0]."/".$pci[1]."/".$pci[2]."/".$pci[3];
$status=$pci[7];
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if(/^=+\S+\s+IO Cards/){
$flag_pci = 1; # Start of IO Devices section, still header to skip
}
if($flag_pci && /^-+/){
$flag = 1; # End of IO Devices header, real info starts here
}
}
}
if ( $sun_class == 21 ) {
# x86 hardware
$flag = 0;
foreach (`/usr/sbin/smbios -t SMB_TYPE_SLOT`) {
if ($flag && /^ID.*/) {
# write current slot
$common->addSlot({
DESCRIPTION => "$description ($status)",
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
$flag = 0;
}
elsif(/\s+Location Tag:\s+(.*)$/) {
$description = $1;
}
elsif(/\s+Slot ID:\s+(.*)$/) {
$designation= $1;
}
elsif(/\s+Type:\s+\S+\s+\((.*)\)$/) {
$name= $1;
}
elsif(/\s+Usage:\s+\S+\s+\((.*)\).*$/) {
$status = $1;
}
$flag = 1;
}
# Finally add the last card
$common->addSlot({
DESCRIPTION => "$description ($status)",
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if ( $sun_class == 4 ) {
# SUNW,Sun-Fire-T200
#========================= IO Configuration =========================
#
# IO
#Location Type Slot Path Name Model
#----------- ----- ---- --------------------------------------------- ------------------------- ---------
#IOBD/PCIE0 PCIE 0 /pci@780/pci@0/pci@8/network@0 network-pciex8086,105e SUNW,pcie+
foreach(`prtdiag `) {
last if(/^\=+/ && $flag_pci && $flag); # End of IO Devices, next section starts here
if($flag && $flag_pci && /PCI/) {
@pci = split(/ +/);
$name=$pci[5];
$description="[".$pci[1]."] ".$pci[4];
$designation=$pci[0];
$status=" ";
if($flag && $flag_pci) {
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
}
if(/^=+\S+\s+IO Configuration/){
$flag_pci = 1; # Start of IO Devices section, still header to skip
}
if($flag_pci && /^-+/){
$flag = 1; # End of IO Devices header, real info starts here
}
}
}
if ( $sun_class == 8 ) {
# SUNW,Sun-Blade-1500
#================================= IO Devices =================================
#Bus Freq Slot + Name +
#Type MHz Status Path Model
#------ ---- ---------- ---------------------------- --------------------
#pci 33 MB isa/su (serial)
# okay /pci@1e,600000/isa@7/serial@0,3f8
foreach (`prtdiag `) {
last if(/^\=+/ && $flag_pci && $flag); # End of IO Devices, next section starts here
# pci 33 MB isa/su(serial) SUNW,xxx
if($flag && $flag_pci && /(\S+)\s+(\S+)\s+(\S+)\s+(\S+\s+\(\S+\))\s*(.*)/) {
$name = $5;
$designation = $3;
$description = "[$1] $4";
$status = " ";
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if(/^=+\S+\s+IO Devices/){
$flag_pci = 1; # Start of IO Devices section, still header to skip
}
if($flag_pci && /^-+/){
$flag = 1; # End of IO Devices header, real info starts here
}
}
}
if ( $sun_class == 22 ) {
# SUNW,T5440
#======================================== IO Devices =======================================
#Slot + Bus Name + Model Max Speed Cur Speed
#Status Type Path /Width /Width
#-------------------------------------------------------------------------------------------
#MB/HBA PCIE scsi-pciex1000,58 LSI,1068E -- --
# /pci@400/pci@0/pci@1/scsi@0
# SPARC T3-1
#================================= IO Devices =================================
#Slot + Bus Name + Model Speed
#Status Type Path
#------------------------------------------------------------------------------
#/SYS/MB/SASHBA0 PCIE scsi-pciex1000,72 LSI,2008 --
# /pci@400/pci@1/pci@0/pci@4/scsi@0
#/SYS/MB/RISER2/PCIE2PCIE network-pciex108e,abcd SUNW,pcie-qgc --
# /pci@400/pci@1/pci@0/pci@6/network@0
# SPARC T4-4
#======================================== IO Devices =======================================
#Slot + Bus Name + Model Max Speed Cur Speed
#Status Type Path /Width /Width
#-------------------------------------------------------------------------------------------
#/SYS/MB/REM0/SASHBA0 PCIE LSI,sas-pciex1000,72 LSI,2008 -- --
# /pci@400/pci@1/pci@0/pci@0/LSI,sas@0
#/SYS/RIO/NET0 PCIE network-pciex8086,10c9 -- --
# /pci@400/pci@1/pci@0/pci@2/network@0
#/SYS/RIO/NET1 PCIE network-pciex8086,10c9 -- --
# /pci@400/pci@1/pci@0/pci@2/network@0,1
#/SYS/PCI-EM2 PCIE SUNW,qlc-pciex1077,2532 QEM3572 -- --
# /pci@400/pci@1/pci@0/pci@4/pci@0/pci@2/SUNW,qlc@0
# SPARC T5-4
#======================================== IO Devices =======================================
#Slot + Bus Name + Model Max Speed Cur Speed
#Status Type Path /Width /Width
#-------------------------------------------------------------------------------------------
#/SYS/MB/USB_CTLR PCIE usb-pciexclass,0c0330 -- --
# /pci@300/pci@1/pci@0/pci@4/pci@0/pci@6/usb@0
#/SYS/RIO/XGBE0 PCIE network-pciex8086,1528 -- --
# /pci@300/pci@1/pci@0/pci@4/pci@0/pci@8/network@0
#/SYS/MB/SASHBA0 PCIE scsi-pciex1000,87 LSI,2308_2 -- --
# /pci@300/pci@1/pci@0/pci@4/pci@0/pci@c/scsi@0
foreach (`prtdiag `) {
last if(/^\=+/ && $flag_pci && $flag); # End of IO Devices, next section starts here
# Lazy match for $name due to differences in prtdiag output:
# * the "Model" column does not always have a value
# * 5-column output on Sol10, 6-column output on Sol11
if($flag && $flag_pci && /(\S+)\s+(\S+)\s+((\S+)-\S+)\s+(\S+)\s+.*/) {
$designation = $1;
$status = " ";
$name = $3;
$description = "[$2] $4";
$description .= " ($5)" unless ($5=~/.*GT\/?x\d+|--/);
$common->addSlot({
DESCRIPTION => $description,
DESIGNATION => $designation,
NAME => $name,
STATUS => $status,
});
}
if(/^=+\S+\s+IO Devices/){
$flag_pci = 1; # Start of IO Devices section, still header to skip
}
if($flag_pci && /^-+/){
$flag = 1; # End of IO Devices header, real info starts here
}
}
}
}
1;
|