[prev in list] [next in list] [prev in thread] [next in thread] 

List:       toasters
Subject:    RE: since we're broaching the subject of qtree quota reporting...
From:       "Hackworth, Brian" <brian.hackworth () netapp ! com>
Date:       2002-03-27 23:49:09
[Download RAW message or body]

: I have some things that I've been working on that would make my quota
: monitoring much easier but I don't have the skill required to finish
: it.  I'm hoping someone here has both the skill *and* the 
: inclination to
: help me out.  What I have is attached and goes something like this....

Your script uses DataFabric Manager to generate the qtree
data, so there are some even easier scripting things you
can do to satisfy your requirements.

Attached is a test-qtree.pl based on your test-qtree.sh; this
perl script fetches the qtree data from DFM and generates mail
with the usage is above the 85% threshold.  This uses the idfile
format that the awk script used.

Any place where you run DFM will necessarily have perl, so this
seemed like a fair replacement for the awk script.

Adjust to your own requirements, of course.

--
Brian Hackworth                 hackwort@netapp.com
Network Appliance               408.822.6654
Sunnyvale, CA  USA


["test-qtree.pl" (application/octet-stream)]

#!/usr/bin/perl

$maillist = 'idfile';

$threshold = '85';
$for_real = 1;

%Id;

#
#  Get the qtree data from DFM in perl format.  This fills
#  in the reportKeys and reportData perl variables, among 
#  others.
#
#  Save the file in the current directory, too, to make
#  debugging easier.
#
sub get_qtree {
	system("dfm report -F perl qtrees-capacity >qtreefile");
	`cat qtreefile`;
}

#
#  Send a warning email message, using the list of 
#  qtree owners we read in at the beginning.
#
#  Customize the email message to taste.
#
sub send_mail {
	my $qtree = shift;
	my $usage = shift;

	if ($Id{$qtree}) {
		my $email = $Id{$qtree}->{'email'};
		my $name = $Id{$qtree}->{'name'};

		if ($for_real) {
			open(P, "| /usr/lib/sendmail -t") || die "Can't invoke sendmail: $!";
		}
		else {
			open(P, "| cat");
		}
		print P "To: ${name} <${email}>\n";
		print P "From: root\@buddha.lab.netapp.com\n";
		printf P "Subject: $qtree is %.1f%% full\n", $usage;
		print P "\n";
		print P "Insert your message here.\n";
		close(P);
		printf STDOUT "Notified $name about $qtree (%.1f%% full).\n",
				$usage;
	}
	else {
		printf STDERR "Error: Missing email for qtree $qtree ".
			"(%.1f%% full).\n", $usage;
	}
}

#
#  Read in the qtree-to-email mappings from $maillist.
#

open(E, $maillist) && do {
	while (<E>) {
		chop;
		split(/:/);
		$Id{$_[0]}->{'email'} = $_[1];
		$Id{$_[0]}->{'name'} = $_[2];
	}
	close(E);
};

eval &get_qtree;

my $cnt = 0;
my $over = 0;

for my $qtree (@reportKeys) {

	$cnt++;
	my $usage = $reportData{$qtree}->{'qtreeKBytesPercent'};
	if ($usage > $threshold) {
		$over++;
		& send_mail($reportData{$qtree}->{'objName'}, $usage);
	}
}

printf "Checked $cnt qtrees; $over were over threshold.\n";

["idfile" (application/octet-stream)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic