- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- awk help to get stale path information
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:18 AM
тАО03-19-2008 06:18 AM
Please can someone help me with awk syntax ...
I have a report that details servers / fibre cards and whether there are any stale paths. I want the awk sytax to only report on the server, disk and stale paths when the string "stale is present" here is a snippit from my report:
Start task on cgcu180a
# START OUTPUT SANCheck
cgcu180a.eu.unilever.com
hwmgr: Refresh component database operation was successful
hwmgr: Refresh component database operation was successful
hwmgr: Refresh component database operation was successful
hwmgr: Refresh component database operation was successful
hwmgr: Refresh SCSI database operation was successful
ADAPTER LINK LINK FABRIC SCSI CARD
HWID: NAME STATE TYPE STATE BUS MODEL
--------------------------------------------------------------------------------
47: emx0 up point-to-point attached scsi3 FCA-2354
49: emx2 up point-to-point attached scsi4 FCA-2354
65: emx3 up point-to-point attached scsi5 FCA-2354
67: emx4 up point-to-point attached scsi6 FCA-2354
--------------------------------------------------------------------------------
STALE Paths
-----------------------
4 PATHS to dsk11132 (HWID:514)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11078 (HWID:517)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11079 (HWID:518)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
2 PATHS to dsk11135 (HWID:519)
2 to SCSI: 6 valid
8 PATHS to dsk3806 (HWID:521)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 valid
2 to SCSI: 6 valid
8 PATHS to dsk14001 (HWID:70)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 valid
2 to SCSI: 6 valid
8 PATHS to dsk14002 (HWID:71)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 valid
2 to SCSI: 6 valid
8 PATHS to dsk14003 (HWID:72)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 valid
2 to SCSI: 6 valid
8 PATHS to dsk14004 (HWID:73)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 valid
2 to SCSI: 6 valid
10 PATHS to dsk14005 (HWID:74)
2 to SCSI: 3 valid
2 to SCSI: 4 valid
2 to SCSI: 5 stale
2 to SCSI: 5 valid
2 to SCSI: 6 valid
2 PATHS to dsk11137 (HWID:606)
2 to SCSI: 6 valid
4 PATHS to dsk11050 (HWID:406)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11051 (HWID:407)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11052 (HWID:408)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11054 (HWID:410)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11055 (HWID:411)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11056 (HWID:412)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11062 (HWID:415)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11063 (HWID:416)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11064 (HWID:417)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11065 (HWID:418)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11066 (HWID:419)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11070 (HWID:421)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11071 (HWID:422)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
4 PATHS to dsk11072 (HWID:423)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
# END OUTPUT SANCheck
End task on cgcu180a.eu.unilever.com
Start task on cgcu370a.eu.unilever.com
# START OUTPUT SANCheck
so I am looking for the below output only to report on the disk with stale paths
cgcu180a
4 PATHS to dsk11072 (HWID:423)
2 to SCSI: 5 stale
2 to SCSI: 6 valid
I am working this out slowly but not getting very far ....
the problem I have is for awk to identify stale then report the disk section ....
any help is greatly appreciated as always :-)
Thanks
Chris
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:35 AM
тАО03-19-2008 06:35 AM
Re: awk help to get stale path information
awk '/START OUTPUT SANCheck/,/END OUTPUT SANCheck/ {if($1 ~ /^cgcu.*$/) print $1};{if($0 ~ /stale/) print}' stuff.dat
cgcu180a.eu.unilever.com
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
2 to SCSI: 5 stale
cgcu370a.eu.unilever.com
2 to SCSI: 0 stale
2 to SCSI: 0 stale
cgcu005a.eu.unilever.com
cgcu007a.eu.unilever.com
cgcu008a.eu.unilever.com
cgcu009a.eu.unilever.com
cgcu010a.eu.unilever.com
cgcu012a.eu.unilever.com
cgcu018a.eu.unilever.com
1 to SCSI: 2 stale
not quite there yet ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:37 AM
тАО03-19-2008 06:37 AM
Re: awk help to get stale path information
Thanks,
let me see if I can incorporate that with each server listed.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:40 AM
тАО03-19-2008 06:40 AM
Re: awk help to get stale path information
...and I missed the the host identifier in the output, do:
# awk '/START/ {getline;print};/PATHS/ {LAST=$0};/stale/ {print LAST;print $0;getline;print $0}' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2008 06:44 AM
тАО03-19-2008 06:44 AM
Re: awk help to get stale path information
it works a treat ...
I am still working on awk programming but not finding much time however I have come up with some syntax for easier tasks thanks to the information you provide ( and other ITRC users )
so much appreciated!
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-21-2008 08:09 PM
тАО03-21-2008 08:09 PM
Re: awk help to get stale path information
You could do it like C, if that's a help.
>JRF: print LAST;print $0;getline;print $0
I'm not sure why you are printing one entry after the stale entry. This wouldn't handle stale being last. If there were multiple stale entries, you would repeat the disk.
The following only prints the stale entries:
awk '
BEGIN { last = "" }
/START OUTPUT SANCheck/ {
getline
print $0
}
/PATHS/ {
last = $0
}
/stale/ {
if (last != "") {
print last
last = ""
}
print $0
}' file