I have been reading for a few hours trying to educate myself enough to accomplish this task, so please know I have performed some research. Unfortunately, I am not a *NIX scripting expert, or a coder. I come from a network background instead.
SO, here is my desired outcome. I have some Cisco CSS boxes I am trying to organize data off of into a more useful format for mass migrations. I will give some sample of my raw / formatted data, and the way I would like to end up formatting it.
Here is the data (there are literally hundreds of the following data blocks in a text file. I have also changed the IP, and name for protection):
Name: vcstest019-asdfghjkl-9-www Index: 51
Type: Local State: Down
Rule ( 10.1.1.9 ANY ANY )
Session Redundancy: Disabled
Redirect Domain:
Redirect String:
Keepalive: (HTTP-80:HEAD: 5 3 5 )
Keepalive Error: Not reachable failure
Keepalive Encryption: Disabled
Last Clearing of Stats Counters: 03/03/2009 00:24:17
Mtu: 1500 State Transitions: 0
Total Local Connections: 0 Total Backup Connections: 0
Current Local Connections: 0 Current Backup Connections: 0
Total Connections: 0 Max Connections: 65534
Total Reused Conns: 0 Weight Reporting: None
Weight: 1 Load: 255
What I *WANT* to grab from it is the Name, State and Total Connections number. I accomplished this via "grep -e Name -e "Total Connections" -e Type data
However, that will display it as such:
Name: vcstest004-asdfghjkl-2-direct Index: 2
Type: Local State: Suspended
Total Connections: 0 Max Connections: 65534
Name: vcstest004-asdfghjkl21-2-https Index: 3
Type: Local State: Suspended
Total Connections: 0 Max Connections: 65534
What I really WANT this to look like, is something like this:
Name: vcstest004-asdfghjkl-2-direct State: Suspended Total Connections: 0
Name: vcstest004-asdfghjkl21-2-direct State: Suspended Total Connections: 0
I am not sure how to parse through the data to yield the desired result.
Now, to FURTHER complicate things, I want to take a SECOND set of data and add it into the mix, correlating the information.
###################
The second data set will look something like this (again, with hundreds, if not thousands of entries, and some of the names have been changes/ips, etc..)
content vcstest013-asdf-3-www
add service vcstest019-szvmHELLO-2-www
vip address 10.10.1.3
protocol tcp
port 80
active
content vcstest013-asdf1-4-www
add service vcstest019-szaloha225-3-www
vip address 10.10.1.4
protocol tcp
port 80
active
content vcstest013-asdf2-5-www
add service vcstest019-szwowser225-4-www
vip address 10.10.1.5
protocol tcp
port 80
active
content vcstest019-agh-3-https
add service vcstest019-szjeemonie225-2-https
vip address 10.10.1.3
port 443
protocol tcp
active
The "service" identifier, matches up with the "content" identifier right above it. SO.... At the end of the day, I would like something to provide me with the following information:
CONTENT Information
Service Information
What is the current State? (from first file)
WHat is the number of Total Connections? (from first file)
I hope this makes sense. I'm just not sure how to further narrow down the amount of data. I'm just grabbing the information off of the devices and dumping them to text files. I *REALLY* do appreciate anyone's help here. I have been working on this for a few hours, but am at a loss.