Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 5.86 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use IO::Pipe;
  5. use IO::Handle;
  6. use IO::File;
  7. my $system;
  8. my @systems = ( '3par-S400', '3par-E200' );
  9.  
  10.  
  11. open( MYFILE, '>>data.txt' );
  12. foreach my $system (@systems) {
  13.     my $output = run_command($system);
  14.     while (<$output>) {
  15.         next if (m/^$/);
  16.         next if (m/KBytes/);
  17.         next if (m/VVname/);
  18.         last if (m/^\-\-\-\-\-.*$/);
  19.         s/^ *//;
  20.         s/ +/\|/g;
  21.         print MYFILE $_;
  22.     }
  23. }
  24. close(MYFILE);
  25.  
  26. open( MYFILE, '<data.txt' );
  27. while (<MYFILE>) {
  28.     my $thisline = $_;
  29.     chomp($thisline);
  30.     my $gmetric="/usr/bin/gmetric";
  31.  ## This is what we grab and build the array
  32. ## 22:28:29|08/30/10|r/w|I/O|per|second|KBytes|per|sec|Svt|ms|IOSz|KB|
  33. ## VVname|Cur|Avg|Max|Cur|Avg|Max|Cur|Avg|Cur|Avg|Qlen
  34. ## This is the data we get per line
  35. ## racprod_data03_500G_tpvv|t|674|674|674|6782|6782|6782|3.6|3.6|10.1|10.1|2
  36.     my ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, $svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen)  = split /\|/, $thisline;
  37.     my @array= ( $VVname, $t, $ioCur, $ioAvg, $ioMax, $kbCur, $kbAvg, $kbMax, $svtCur, $svtAvg, $iokbCur, $iokbAvg, $Qlen);
  38.     foreach my $item (@array) {
  39.     print "$item \n";
  40.     }
  41.     print "test\n";
  42.     system($gmetric  "--name=VVname  --value=$VVname --type=uint32 --units=name");
  43.     system($gmetric  "--name=t  --value=$t --type=uint32 --units=t");
  44.     system($gmetric  "--name='I/O per second Cur'  --value=$ioCur --type=uint32 --units=ioCur");
  45.     system($gmetric  "--name='I/O per second Avg'  --value=$ioAvg --type=uint32 --units=ioAvg");
  46.     system($gmetric  "--name='I/O per second Max'  --value=$ioMax --type=uint32 --units=ioMax");
  47.     system($gmetric  "--name='KBytes per sec Cur'  --value=$kbCur --type=uint32 --units=kbCur");
  48.     system($gmetric  "--name='KBytes per sec Avg'  --value=$kbAvg --type=uint32 --units=kbAvg");
  49.     system($gmetric  "--name='KBytes per sec Max'  --value=$kbMax --type=uint32 --units=kbMax");
  50.     system($gmetric  "--name='Svt ms Cur'  --value=$svtCur --type=uint32 --units=svtCur");
  51.     system($gmetric  "--name='Svt ms Avg'  --value=$svtAvg --type=uint32 --units=svtAvg");
  52.     system($gmetric  "--name='IOSz KB Cur'  --value=$iokbCur --type=uint32 --units=iokbCur");
  53.     system($gmetric  "--name='IOSz KB Avg'  --value=$iokbAvg --type=uint32 --units=iokbAvg");
  54.     system($gmetric  "--name='IOSz KB Qlen'  --value=$Qlen --type=uint32 --units=Qlenq");
  55. }
  56. close(MYFILE);
  57.  
  58. sub run_command {
  59.     my $user      = 'gmon';
  60.     my $system    = shift;
  61.     my $protocol  = 'ssh';
  62.     my $ssh_flags = "-l $user";
  63.     my $command   = "statvv -ni";
  64.     my $space     = " ";
  65.     my $do_command = $protocol . $space . $ssh_flags . $space . $system . $space . $command;
  66.     my $cmd = IO::Pipe->new;
  67.     $cmd->reader($do_command);
  68.     return $cmd;
  69. }
  70.  
  71.  
  72.  
  73. ====================================================================
  74.  
  75.  
  76. Incorrect options supplied, exiting.
  77. exastore_data_500G.16
  78. t
  79. 101
  80. 101
  81. 101
  82. 4342
  83. 4342
  84. 4342
  85. 8.8
  86. 8.8
  87. 42.8
  88. 42.8
  89. 0
  90. test
  91. Incorrect options supplied, exiting.
  92. Incorrect options supplied, exiting.
  93. Incorrect options supplied, exiting.
  94. Incorrect options supplied, exiting.
  95. Incorrect options supplied, exiting.
  96. Incorrect options supplied, exiting.
  97. Incorrect options supplied, exiting.
  98. Incorrect options supplied, exiting.
  99. Incorrect options supplied, exiting.
  100. Incorrect options supplied, exiting.
  101. Incorrect options supplied, exiting.
  102. Incorrect options supplied, exiting.
  103. Incorrect options supplied, exiting.
  104. exastore_data_500G.17
  105. t
  106. 98
  107. 98
  108. 98
  109. 2626
  110. 2626
  111. 2626
  112. 10.0
  113. 10.0
  114. 26.8
  115. 26.8
  116. 1
  117. test
  118. Incorrect options supplied, exiting.
  119. Incorrect options supplied, exiting.
  120. Incorrect options supplied, exiting.
  121. Incorrect options supplied, exiting.
  122. Incorrect options supplied, exiting.
  123. Incorrect options supplied, exiting.
  124. Incorrect options supplied, exiting.
  125. Incorrect options supplied, exiting.
  126. Incorrect options supplied, exiting.
  127. Incorrect options supplied, exiting.
  128. Incorrect options supplied, exiting.
  129. Incorrect options supplied, exiting.
  130. Incorrect options supplied, exiting.
  131. exastore_data_500G.18
  132. t
  133. 71
  134. 71
  135. 71
  136. 3626
  137. 3626
  138. 3626
  139. 12.5
  140. 12.5
  141. 50.8
  142. 50.8
  143. 1
  144. test
  145. Incorrect options supplied, exiting.
  146. Incorrect options supplied, exiting.
  147. Incorrect options supplied, exiting.
  148. Incorrect options supplied, exiting.
  149. Incorrect options supplied, exiting.
  150. Incorrect options supplied, exiting.
  151. Incorrect options supplied, exiting.
  152. Incorrect options supplied, exiting.
  153. Incorrect options supplied, exiting.
  154. Incorrect options supplied, exiting.
  155. Incorrect options supplied, exiting.
  156. Incorrect options supplied, exiting.
  157. Incorrect options supplied, exiting.
  158. exastore_data_500G.19
  159. t
  160. 96
  161. 96
  162. 96
  163. 3681
  164. 3681
  165. 3681
  166. 10.1
  167. 10.1
  168. 38.5
  169. 38.5
  170. 0
  171. test
  172. Incorrect options supplied, exiting.
  173. Incorrect options supplied, exiting.
  174. Incorrect options supplied, exiting.
  175. Incorrect options supplied, exiting.
  176. Incorrect options supplied, exiting.
  177. Incorrect options supplied, exiting.
  178. Incorrect options supplied, exiting.
  179. Incorrect options supplied, exiting.
  180. Incorrect options supplied, exiting.
  181. Incorrect options supplied, exiting.
  182. Incorrect options supplied, exiting.
  183. Incorrect options supplied, exiting.
  184. Incorrect options supplied, exiting.
  185. exastore_data_500G.20
  186. t
  187. 77
  188. 77
  189. 77
  190. 5041
  191. 5041
  192. 5041
  193. 11.2
  194. 11.2
  195. 65.2
  196. 65.2
  197. 0
  198. test
  199. Incorrect options supplied, exiting.
  200. Incorrect options supplied, exiting.
  201. Incorrect options supplied, exiting.
  202. Incorrect options supplied, exiting.
  203. Incorrect options supplied, exiting.
  204. Incorrect options supplied, exiting.
  205. Incorrect options supplied, exiting.
  206. Incorrect options supplied, exiting.
  207. Incorrect options supplied, exiting.
  208. Incorrect options supplied, exiting.
  209. Incorrect options supplied, exiting.
  210. Incorrect options supplied, exiting.
  211. Incorrect options supplied, exiting.
  212. exastore_data_500G.21