I have some netstat output I'm scripting and want to parse. What's the most efficient way of parsing values from the output below? It's important to point out that I'm using the old /bin/sh
shell and not bash
I'm generating this output from the command: netstat -d -K O30S1O1
MVS TCP/IP NETSTAT CS V1R11 TCPIP Name: NCDTCP 10:12:39
DevName: OSAQO130 DevType: MPCIPA
DevStatus: Ready CfgRouter: Non ActRouter: Non
LnkName: O30S1O1 LnkType: IPAQENET LnkStatus: Ready
Speed: 0000001000
IpBroadcastCapability: No
ArpOffload: Yes ArpOffloadInfo: Yes
ActMtu: 8992
VLANid: None VLANpriority: Disabled
ReadStorage: GLOBAL (4096K) InbPerf: Balanced
ChecksumOffload: Yes SegmentationOffload: Yes
SecClass: 255 MonSysplex: No
Routing Parameters:
MTU Size: 1500 Metric: 10
DestAddr: 0.0.0.0 SubnetMask: 255.255.255.192
Multicast Specific:
Multicast Capability: Yes
Group RefCnt SrcFltMd
----- ------ --------
224.0.0.5 0000000001 Exclude
SrcAddr: None
224.0.0.1 0000000001 Exclude
SrcAddr: None
Link Statistics:
BytesIn = 13545386
Inbound Packets = 129630
Inbound Packets In Error = 0
Inbound Packets Discarded = 0
Inbound Packets With No Protocol = 0
BytesOut = 81424019
Outbound Packets = 520188
Outbound Packets In Error = 0
Outbound Packets Discarded = 0
IPv4 LAN Group Summary
LanGroup: 00006
Name Status ArpOwner VipaOwner
---- ------ -------- ---------
O30S1O1 Active O30S1O1 Yes
For example, let's say I want to fetch several values such as DevName
, BytesIn
and BytesOut
. I plan on running the netstat command every minute or so on four interfaces and writing the output to a csv file for importing to excel.