U
usaims
Hello:
I am trying to write a small perl script that parses the "us"
column of the vmstat command and if that number is greater or equal to
3, it will notify me. The script does run, but I'm not getting any
output.
#!/usr/bin/perl
use strict;
use warnings;
my $test = 3;
my @memusage = `vmstat -n 1 | awk '{print \$14}'`;
foreach ( my $list = (@memusage) ) {
if ( $list <= $test ) {
print "Failure\n";
}
}
I can get vmstat to output to screen by using:
#!/usr/bin/perl
use strict;
use warnings;
my $test = 3;
my @memusage = system("vmstat -n 1 | awk '{print \$14}'");
foreach ( my $list = (@memusage) ) {
if ( $list <= $test ) {
print "Failure\n";
}
}
But it outputs the vmstat stats but it doesn't evaluate the foreach
statement. I have googled for "vmstat" in the perl group, but
didn't come up with anything. I have searched perldoc, didn't see
anything. Please direct me to a link or a perldoc source or suggest an
alternative. If I have missed something in FAQ, apologies in advance.
Thanks in advance.
usaims
I am trying to write a small perl script that parses the "us"
column of the vmstat command and if that number is greater or equal to
3, it will notify me. The script does run, but I'm not getting any
output.
#!/usr/bin/perl
use strict;
use warnings;
my $test = 3;
my @memusage = `vmstat -n 1 | awk '{print \$14}'`;
foreach ( my $list = (@memusage) ) {
if ( $list <= $test ) {
print "Failure\n";
}
}
I can get vmstat to output to screen by using:
#!/usr/bin/perl
use strict;
use warnings;
my $test = 3;
my @memusage = system("vmstat -n 1 | awk '{print \$14}'");
foreach ( my $list = (@memusage) ) {
if ( $list <= $test ) {
print "Failure\n";
}
}
But it outputs the vmstat stats but it doesn't evaluate the foreach
statement. I have googled for "vmstat" in the perl group, but
didn't come up with anything. I have searched perldoc, didn't see
anything. Please direct me to a link or a perldoc source or suggest an
alternative. If I have missed something in FAQ, apologies in advance.
Thanks in advance.
usaims