-
Notifications
You must be signed in to change notification settings - Fork 0
/
anal-about-moreText.pl
executable file
·63 lines (53 loc) · 1.62 KB
/
anal-about-moreText.pl
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
#!/usr/bin/perl
$output = `sudo -A dmidecode --type 17`;
@lines = split "\n", $output;
@results = ();
$dict = undef;
foreach $line (@lines) {
if ($line =~ m/^Memory Device/) {
if ($dict) {
push @results, $dict;
}
$dict = {};
} elsif ($line =~ m/^\s+Size: (.+)/) {
$dict->{'size'} = $1;
} elsif ($line =~ m/^\s+Form Factor: (.+)/) {
$dict->{'formFactor'} = $1;
} elsif ($line =~ m/^\s+Locator: (.+)/) {
$dict->{'locator'} = $1;
} elsif ($line =~ m/^\s+Type: (.+)/) {
$dict->{'type'} = $1;
} elsif ($line =~ m/^\s+Type Detail: (.+)/) {
$dict->{'typeDetail'} = $1;
} elsif ($line =~ m/^\s+Speed: (.+)/) {
$dict->{'speed'} = $1;
} elsif ($line =~ m/^\s+Manufacturer: (.+)/) {
$dict->{'manufacturer'} = $1;
} elsif ($line =~ m/^\s+Serial Number: (.+)/) {
$dict->{'serialNumber'} = $1;
} elsif ($line =~ m/^\s+Asset Tag: (.+)/) {
$dict->{'assetTag'} = $1;
} elsif ($line =~ m/^\s+Part Number: (.+)/) {
$partNumber = $1;
$partNumber =~ s/\s+$//;
$dict->{'partNumber'} = $partNumber;
} elsif ($line =~ m/^\s+Configured Memory Speed: (.+)/) {
$dict->{'configuredMemorySpeed'} = $1;
}
}
push @results, $dict;
print <<EOF;
Memory:
EOF
@results = sort { $a->{'locator'} cmp $b->{'locator'} } @results;
foreach $elt (@results) {
print <<EOF;
Slot: $elt->{'locator'}
Size: $elt->{'size'}
Type: $elt->{'type'}
Speed: $elt->{'speed'}
Manufacturer: $elt->{'manufacturer'}
Asset Tag: $elt->{'assetTag'}
Part Number: $elt->{'partNumber'}
EOF
}