#!/usr/bin/perl -w # # This script is part of DS4000 Monitoring for cacti. # It reads the output from SMcli and reports statistics # for a specified Controller / all Controllers. # # please configure Controllers and Paths ! # # # # # Ronny Becker, 11.2009 # # names / paths @all_controller=("CONTROLLER IN SLOT A","CONTROLLER IN SLOT B","CONTROLLER IN SLOT A","CONTROLLER IN SLOT B","CONTROLLER IN SLOT A","CONTROLLER IN SLOT B","CONTROLLER IN SLOT A","CONTROLLER IN SLOT B","CONTROLLER IN SLOT A","CONTROLLER IN SLOT B","CONTROLLER IN SLOT A","CONTROLLER IN SLOT B"); @data_files=("/var/cache/cacti/last_1_eg","/var/cache/cacti/last_1_eg","/var/cache/cacti/last_2_bu","/var/cache/cacti/last_2_bu","/var/cache/cacti/last_3_eg","/var/cache/cacti/last_3_eg","/var/cache/cacti/last_4_bu","/var/cache/cacti/last_4_bu","/var/cache/cacti/last_5_eg","/var/cache/cacti/last_5_eg","/var/cache/cacti/last_6_bu","/var/cache/cacti/last_6_bu"); $i=0; if ( "$ARGV[0]" ne "s" ) { # array begins at 0, Controller begins at 1 $i=$ARGV[0] - 1; # get data @data=`grep "$all_controller[$i]" $data_files[$i]`; # initial $totios=0; $readpercent=0; $cachehit=0; $currentkb=0; $maxkb=0; $currentio=0; $maxio=0; # get the average value foreach $line (@data) { (undef,$totios_tmp,$readpercent_tmp,$cachehit_tmp,$currentkb_tmp,$maxkb_tmp,$currentio_tmp,$maxio_tmp)=split(",", $line); $totios+=$totios_tmp; $readpercent+=$readpercent_tmp; $cachehit+=$cachehit_tmp; $currentkb+=$currentkb_tmp; $maxkb+=$maxkb_tmp; $currentio+=$currentio_tmp; $maxio+=$maxio_tmp; } # caclulate $totios=$totios / ($#data + 1); $readpercent=$readpercent / ($#data + 1); $cachehit=$cachehit / ($#data + 1); $currentkb=$currentkb / ($#data + 1); $maxkb=$maxkb / ($#data + 1); $currentio=$currentio / ($#data + 1); $maxio=$maxio / ($#data + 1); # output print "readpercent:$readpercent cachehit:$cachehit currentkb:$currentkb currentio:$currentio"; } else { # initial $totios=0; $readpercent=0; $cachehit=0; $currentkb=0; $maxkb=0; $currentio=0; $maxio=0; foreach $controller (@all_controller) { # get data @data=`grep "$controller" $data_files[$i]`; # get the average value foreach $line (@data) { (undef,$totios_tmp,$readpercent_tmp,$cachehit_tmp,$currentkb_tmp,$maxkb_tmp,$currentio_tmp,$maxio_tmp)=split(",", $line); $totios+=$totios_tmp; $readpercent+=$readpercent_tmp; $cachehit+=$cachehit_tmp; $currentkb+=$currentkb_tmp; $maxkb+=$maxkb_tmp; $currentio+=$currentio_tmp; $maxio+=$maxio_tmp; } # caclulate #$totios=$totios / ($#data + 1); $currentkb=$currentkb / 1024; #$maxkb=$maxkb / ($#data + 1); #$currentio=$currentio / ($#data + 1); #$maxio=$maxio / ($#data + 1); } # output print "readpercent:$readpercent cachehit:$cachehit currentkb:$currentkb currentio:$currentio"; }