I am attempting to write a script that will gather stats from a 3par storage unit that does not run a unix like operating system. What I am attempting to do is ssh into the device with an ssh key and issue 3par commands to the unit and awk the results. I am trying to take the output and put them into various variables which I will then feed to gmetric to graph in ganglia.
The problem is this: the 3par commands are continuous and only stop when you press the 'enter' key. Getting this data into a variable array would be easy but for the fact that the commands are continuous.
Here's what I came up with, but this needs to be tweaked to take the above fact into account:
#!/usr/bin/perl
use strict;
use warnings;
#`/bin/echo "SNMP 3PAR DISK STATS start executed on: `date +%D' at '%l
+:%M:%S`" >> /var/log/snmp-3par-disk-stats.log`
push my @vluns,`ssh -l gmon 3par-S400 statvv -ni | awk '{print $1 }'`;
foreach my $vlun (@vluns) {
if ($vlun ne "Press") {
print "$vlun \n";
}
else {
last;
}
}
push my @vluns2,`ssh -l gmon 3par-E200 statvv -ni | awk '{print $1 }'`
+;
foreach my $vlun2 (@vluns2) {
if ($vlun2 ne "Press") {
print "$vlun2 \n";
}
else {
last;
}
}
But it keeps throwing this error:
[gmon@cc126-200 ~]$ ./3par-disk-stats.pl
Use of uninitialized value in concatenation (.) or string at ./3par-di
+sk-stats.pl line 7.
It seems that it is choking on the $1 that I am passing to awk. I could use some help passing the right variable.
Also this is a sample of the text I am trying to parse:
Press
16:34:19
VVname
mgmain_data
mgnote01_redo1
mgnote01_redo2
mgtool02_data_110G
mgtool02_redo1_3G
mgtool02_redo2_3G
mgnote01_data_85G
rcat11_data
racprod_redo1a_tpvv
racprod_redo1b_tpvv
And this is the output I would like to omit at the end:
----------------------------------------------------------------------
+---------------------
total t 5766 5777 601349 585394 8.4
+ 8.6 104.3 101.3 67
Press the enter key to stop...
But most importantly I am looking for a way to exit when it hits the output "press the enter key to stop..."
I'd certainly appreciate any guidance the wise monks may have, here. Thanks!
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.