#!/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 LUN. # # # Ronny Becker, 11.2009 # use POSIX; $hourmin=POSIX::strftime("%H%M", localtime(time())); # paths $path_to_files="/var/cache/cacti/last*"; $log_drive=$ARGV[0]; # get data @data=`grep -h " $log_drive," $path_to_files`; # 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; } if ( ! @data ) { if ( "$hourmin" == "0800" ) { `logger -p local6.warn -t "cacti_ds_perfmon" "Unknown Logical Drive $log_drive - please delete Graph"`; } } else { # 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 "totios:$totios readpercent:$readpercent cachehit:$cachehit currentkb:$currentkb maxkb:$maxkb currentio:$currentio maxio:$maxio"; }