Update:
==
The log file size and contents can vary so capturing specific lines each time may not work, searching the entries only option.
System : system001-server
(System name differs by number only system001..., system002..., system
+003 e.t.c)
Box : HW a2b 1234Mb 123.4, address is 0012.d345.1234 (abc 0012.d123 +.
+4567)
(Box name relatively static, capturing between the HW a2b to the brack
+eted data would get everything relevant)
ByteIn : 3385567095904
(ByteIn varies)
Byteout : 5816943852464
(Byteout varies)
Description : example_system_server_round
(Description name varies, capturing the name after "Description" only
+way)
==
Hello, hoping someone can help. I'm looking to get a few scripts off the ground to help me with a laborious "log" culling, but my knowledge is a bit limited regarding perl and so am learning as I go. I had been experimenting with grep and while loops e.g.
while (<IN>) {
if (m/Server*Example/ig) {
print OUT $_, "\n";
print $_; }
}
But had been falling short on how to specify each specific part. Out of all the log files I would ideally love to extract the following snippets - System, Box, ByteIn, Bytesout, Description From the log example below the data would be:
System : system001-server
Box : HW a2b 1234Mb 123.4, address is 0012.d345.1234 (abc 0012.d123 +.
+4567)
ByteIn : 3385567095904
Byteout : 5816943852464
Description : example_system_server_example
Once the file data had been extracted from the .txt file --> output to a new CSV format file so I could read it into spreadsheets, example - System Box ByteIn Byteout Description:
system001-server,HW a2b 1234Mb 123.4, address is 0012.d345.1234 (abc 0
+ +012.d123.4567),3385567095904,5816943852464,example_system_server_ex
+am +ple
This would be the ideal outcome, any help in how to do this properly would be_VERY_ much appreciated. Cas.
log example (from .txt file):
system001-server
GigabitEthernet7/1 is up, line protocol is up (connected)
HW a2b 1234Mb 123.4, address is 0012.d345.1234 (abc 0012.d123.4567)
Description: example_system_server_example
MTU 1234 bytes, BW 12345678 Kbit, DLY 10 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 1000Mb/s, media type is 10/100/1000BaseT
input flow-control is off, output flow-control is on
Input queue: 0/2000/249/0 (size/max/drops/flushes); Total output drops
+: 9725919
5 minute input rate 1918000 bits/sec, 166 packets/sec
5 minute output rate 659000 bits/sec, 154 packets/sec
3448177417 packets input, 3385567095904 bytes, 0 no buffer
Received 8858 broadcasts (285 multicasts)
4942780696 packets output, 5816943852464 bytes, 0 underrun
GigabitEthernet7/2 is up, line protocol is up (connected)
HW a2b.........
==