#!/usr/bin/perl use strict; use warnings; use IO::Pipe; use IO::Handle; use IO::File; my $system; my @systems = ( '3par-S400', '3par-E200' ); open( MYFILE, '>>data.txt' ); foreach $system (@systems) { my $output = run_command($system); while (<$output>) { next if (m/^$/); next if (m/KBytes/); next if (m/VVname/); last if (m/^\-\-\-\-\-.*$/); s/^ *//; s/ +/\|/g; print MYFILE $_; } } close(MYFILE); open( MYFILE, ') { my $thisline = $_; chomp($thisline); my ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, $svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen) = split /\|/, $thisline; print "$VVname $ioCur $ioAvg $ioMax $kbCur $kbAvg $kbMax $svtCur $svtAvg $iokbCur $iokbAvg $Qlen\n"; } close(MYFILE); open( MYFILE, ') { my $gmetric="/usr/bin/gmetric"; my $gmetric_conf="-c /etc/gmond.conf"; my $thisline = $_; chomp($thisline); my ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, $svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen) = split /\|/, $thisline; $gmetric $gmetric_conf "--name=VVname --value=$pVVname --type=uint32 --units=name"; $gmetriC $gmetric_conf "--name=t --value=$t --type=uint32 --units=t"; $gmetric $gmetric_conf "--name='I/O per second Cur' --value=$ioCur --type=uint32 --units=ioCur"; $gmetric $gmetric_conf "--name='I/O per second Avg' --value=$ioAvg --type=uint32 --units=ioAvg"; } close(MYFILE); sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $space = " "; my $do_command = $protocol . $space . $ssh_flags . $space . $system . $space . $command; my $cmd = IO::Pipe->new; $cmd->reader($do_command); return $cmd; }