Hi Monks,
I have a data manipulation issue, and I'm sure it's a super-easy thing to do in Perl, I just can't get it to work... first is the data I am reading from a command output:
B group1 host1 ONLINE
B group1 host2 OFFLINE
B group2 host2 ONLINE
B group2 host3 OFFLINE
B group3 host3 ONLINE
B group4 host1 ONLINE
B group5 host3 ONLINE
...
G group2
G group3
Now, what this means is, the 'B' section is a list of which groups are running on which hosts. (This may seem familiar to anyone who has used VCS before), and the 'G' section later on in the same command output shows groups that are frozen.
What I'm looking for is to be able to say "GroupX is frozen on hostY".
What I've tried:
- Using hashes to store 'B' information as keys, and 'G' information as values
- Arrays with grep
- Complex grep/awk statements
- A few other things I can't recall offhand
I know there has to be a really simple solution to this, but I may be thinking about it too much. There is a caveat though. These checks are happening on multiple servers at once, so if host1, host2, and host3 are all in the same cluster, the same frozen group will get reported on all 3 hosts, so I want to only report the ones that have ONLINE in the 'B' section.
Hopefully that makes sense.
Thanks for any ideas you can provide!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.