#!/usr/bin/perl ## ## Drano v0.1 written 032415 by Bowie Poag ## ## Drano makes sure the pipes are clear by reporting when network buffers have been depleted. ## This script is designed to be run as root on a VIO server. ## ## It also requires a little tuning on your part -- Replace any instance of "ent12" with the adapter of your choice. ## $DEBUG=0; $threshold=$ARGV[0] || 90; $problemTiny="NO"; $problemSmall="NO"; $problemMedium="NO"; $problemLarge="NO"; $problemHuge="NO"; print "\nDrano: Spinning up..\n"; print "Drano: Collecting netstat dump..\n"; print "Drano:\n"; @netstatDump=`netstat -v ent12 2>/dev/null`; foreach $item (@netstatDump) { chomp($item); $item=~s/^\s+//g; if ($item=~/Max Buffers/) { print "Drano: $item\n"; $item=~s/\s+/ /g; @line=split(" ",$item); $maxTiny=$line[2]; $maxSmall=$line[3]; $maxMedium=$line[4]; $maxLarge=$line[5]; $maxHuge=$line[6]; } if ($item=~/Allocated/ && $item!~/Max/) { print "Drano: $item\n"; $item=~s/\s+/ /g; @line=split(" ",$item); $alcTiny=$line[1]; $alcSmall=$line[2]; $alcMedium=$line[3]; $alcLarge=$line[4]; $alcHuge=$line[5]; } } print "Drano:\n"; $DEBUG && print "MxT:[$maxTiny] MxS:[$maxSmall] MxM:[$maxMedium] MxL:[$maxLarge] MxH:[$maxHuge]\n"; $DEBUG && print "AlT:[$alcTiny] AlS:[$alcSmall] AlM:[$alcMedium] AlL:[$alcLarge] AlH:[$alcHuge]\n"; print "Drano: Analyizing buffer stats..\n"; print "Drano:\n"; $conTiny=sprintf("%-2.2f",($alcTiny/$maxTiny)*100); $conSmall=sprintf("%-2.2f",($alcSmall/$maxSmall)*100); $conMedium=sprintf("%-2.2f",($alcMedium/$maxMedium)*100); $conLarge=sprintf("%-2.2f",($alcLarge/$maxLarge)*100); $conHuge=sprintf("%-2.2f",($alcHuge/$maxHuge)*100); if ($conTiny > $threshold) { $problemTiny="YES"; } if ($conSmall > $threshold) { $problemSmall="YES"; } if ($conMedium > $threshold) { $problemMedium="YES"; } if ($conLarge > $threshold) { $problemLarge="YES"; } if ($conHuge > $threshold) { $problemHuge="YES"; } printf("%-16s %16s %16s %11s\n","Drano: Buffer Size","Consumption (%)","Threshold (%)","Problem?"); printf("%-16s %16s %16s %11s\n","Drano: -----------","---------------","-------------","--------"); printf("%-16s %16f %16f %11s\n","Drano: Tiny","$conTiny","$threshold","$problemTiny"); printf("%-16s %16f %16f %11s\n","Drano: Small","$conSmall","$threshold","$problemSmall"); printf("%-16s %16f %16f %11s\n","Drano: Medium","$conMedium","$threshold","$problemMedium"); printf("%-16s %16f %16f %11s\n","Drano: Large","$conLarge","$threshold","$problemLarge"); printf("%-16s %16f %16f %11s\n","Drano: Huge","$conHuge","$threshold","$problemHuge"); print "Drano:\n"; if ($problemTiny ne "YES" && $problemSmall ne "YES" && $problemMedium ne "YES" && $problemLarge ne "YES" && $problemHuge ne "YES") { print "Drano: Everything looks fine. All your buffer consumption percentages are below the given threshold of $threshold"."%".".\n"; } else { print "Drano: Looks like you've run out of network buffers on one or more fronts. Time to tune up.\n"; system("logger Drano Warning - Partial network buffer overflow detected. Network interface requires additional tuning."); }