-
Notifications
You must be signed in to change notification settings - Fork 1
/
getfcs.awk
executable file
·66 lines (59 loc) · 2.05 KB
/
getfcs.awk
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
#!/usr/bin/awk -f
{
print "machine_type,machine_model,machine_sn,device_type,device_name,fru_number,location_code,wwn_number,ccid_number"
getline
while (1)
{
#####################################################
# fcs #
#####################################################
starthere=0
if ($0 ~ /^ fcs.*Adapter/)
{
device_name=$1
starthere=0
while (getline)
{
if ($0 ~ /FRU/) fru_number=substr($0,37,length($0)-36)
if ($0 ~ /Network Address/) wwn_number=substr($0,37,length($0)-36)
if ($0 ~ /Customer Card ID Number/) ccid_number=substr($0,37,length($0)-36)
if ($0 ~ /Hardware Location Code/) location_code=substr($0,37,length($0)-36)
if ($0 ~ /^ [a-zA-Z]/) { starthere=1;break }
}
print machine_type "," machine_model "," machine_sn "," "HBA" "," device_name "," fru_number "," location_code "," wwn_number "," ccid_number
}
else
{
if (starthere==0)
{
if (getline) {} else break
}
}
#####################################################
# ent #
#####################################################
starthere=0
if ($0 ~ /^ ent.*Adapter/)
{
print $0
device_name=$1
starthere=0
while (getline)
{
if ($0 ~ /FRU/) fru_number=substr($0,37,length($0)-36)
if ($0 ~ /Network Address/) wwn_number=substr($0,37,length($0)-36)
if ($0 ~ /Customer Card ID Number/) ccid_number=substr($0,37,length($0)-36)
if ($0 ~ /Hardware Location Code/) location_code=substr($0,37,length($0)-36)
if ($0 ~ /^ [a-zA-Z]/) { starthere=1;break }
}
print machine_type "," machine_model "," machine_sn "," "HBA" "," device_name "," fru_number "," location_code "," wwn_number "," ccid_number
}
else
{
if (starthere==0)
{
if (getline) {} else break
}
}
}
}