Operating System - HP-UX
1826424 Members
3471 Online
109692 Solutions
New Discussion

Re: Get specific info and email

 
SOLVED
Go to solution
Ammar_4
Frequent Advisor

Get specific info and email

Hi
i want that if usage of any File system is more than 70% then it send email to me. i know that i got it from bdf but tell me how can i get that when File system using more than 70%

bye
5 REPLIES 5
Ammar_4
Frequent Advisor

Re: Get specific info and email

What type of script will be to complete that task?
Ammar_4
Frequent Advisor

Re: Get specific info and email

output of
bdf | awk '{print $1 " " $5}'
Filesystem %used
/dev/vg00/lvol3 64%
/dev/vg00/lvol1 82%
/dev/vg00/lvol8 44%
/dev/vg00/lvol7 75%
/dev/vg00/lvol4 2%
/dev/vg00/lvol6 85%
/dev/vg00/lvol5 28%

now i want to take percentage for each logical volume separately please tell me how can i get it?
Joseph Loo
Honored Contributor
Solution

Re: Get specific info and email

hi,

refer to this post:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=732203
especially the reply given by Sridhar Bhaskarla.

regards.
what you do not see does not mean you should not believe
Rajeev  Shukla
Honored Contributor

Re: Get specific info and email

Here is a perl script i got few days back from the forum which sends mails when the filesystem reaches more than 70%

#!/usr/bin/perl

$reportfull = 70;

my $temp_dir = "/var/tmp/diskspace_check.$$";
mkdir $temp_dir, 0700 or die "cannot create $temp_dir: $!";

$email_users = "Enter the Email address in the format abc\@xyz.com";

open OUTPUT, ">$temp_dir/bdf_check";

foreach (`bdf`)
{
chomp($line = $_ );
@fields = split /\s+/, $line;
$filesystem = $fields[0];
$kbytes = $fields[1];
$usedkbytes = $fields[2];
$availkbytes = $fields[3];
$percentused = $fields[4];
$mountpoint = $fields[5];
next if $filesystem eq "Filesystem";
next if $kbytes eq "";
if ( $usedkbytes / $kbytes * 100 > $reportfull )
{
select OUTPUT;
$| = 1;
printf "Filesystem mounted on %s is %d%% full.\n", $mountpoint, $percentused;
select STDOUT;
}
}

if (-s OUTPUT)
{
$machine = `uname -n`;
chomp($machine);
$subject = "$machine diskspace over ${reportfull}%";
system "elm -s \"$subject\" $email_users < $temp_dir/bdf_check >/dev/null 2>&1";
}
unlink glob "$temp_dir/* $temp_dir/.*";
rmdir $temp_dir;
Ammar_4
Frequent Advisor

Re: Get specific info and email

Thanks a lot