I have had a number of requests for this today; in fact I thought that I had
posted it already on the CCIUG. In any event, I couldn't find that post
anywhere, so here it is again. (It is a bit excessive, but it gets the job
done!)
HTH.
Best regards,
Scott
#!/apps/gnu/bin/perl
#
# Program Name: check_space_alarm.prl: or iteration thereof
#
# This program executes the CC program "space" on all public
# vobs. Output to ~smccadm/VOB_SPACE.LOG.
#
#############################################################
# Builds an associative array consisting of any public
# vob-storage-dir-pname
#############################################################
open(LSVOB,"/usr/atria/bin/cleartool lsvob|") || die "Can not open process:
$!";
while (<LSVOB>) {
next if ((index($_, " private")) >= $[);
$lastspace=0; $stlastspace=0;$firstslash=0; $nextspace=0; $length=0;
$lastspace=rindex($_, ' ');
$stlastspace=rindex($_, ' ', $lastspace-1);
$length=$lastspace-$stlastspace;
$vob_path=substr($_, $stlastspace, $length);
$firstslash=index($vob_path, '/',9);
$length=$firstslash-0;
$concat=substr($vob_path, 0, $length);
$firstslash=0; $nextspace=0; $length=0;
$firstslash=index($_, '/');
$nextspace=index($_, ' ', $firstslash);
$length=$nextspace-$firstslash;
$vob_tag=substr($_, $firstslash, $length);
$incl = $vob_tag;
$incls{$concat} .= $incl . ' ';
}
close(LSVOB);
#############################################################
# Uses associative array from previous block and records
# only the unique vob-storage-dir-pname (in VOB tag-name form)
# for cleartool space check (next block)
#############################################################
$i=0;
foreach $target (sort keys(%incls)) {
$temp= $incls{$target};
foreach $tempa (split(/ /, $temp)) {
#print "$target ::: $tempa\n";
$vobs_to_check[$i]=$tempa;
}
$i++;
}
#############################################################
# Using a VOB tag-name from previous block, checks unique
# vob-storage-dir-pname and mails USER if $maximum disk
# usage space is exceeded
#############################################################
$maximum=85;
$j=0;
foreach $vob_tag (@vobs_to_check) {
$j=0;
# print "HERE: $vob_tag\n";
open(VOBSPACE,"/usr/atria/bin/cleartool space $vob_tag|") || die "Can not
open process: $!";
while (<VOBSPACE>) {
$vobspace[$j++]=$_;
$total_line = $_ if ((index($_, "capacity")) >= $[) ;
}
$percent_sign=index($total_line, '%');
$percentage=substr($total_line, $percent_sign-2, 2);
@fs=split(/ +/, $total_line);
$file_sys=$fs[4];
if ($percentage > $maximum) {
open(MAIL,"|/bin/mailx -s \"ClearCase VOB free space alarm report
\($maximum\)\" smccadm ") || die "Can not open process: $!";
print MAIL " Use(Mb) %Use Directory\n";
print MAIL " ------- ---- ---------\n";
print MAIL "$total_line";
print MAIL "\n \n";
print MAIL "Usage is $percentage% ";
print MAIL "for these VOB(s):\n ";
foreach $target (sort keys(%incls)) {
$target_1=$target;
$target=substr($target,1);
if ($target eq $file_sys) {
$vob_list=$incls{$target_1};
@targs=split(/ /,$vob_list);
$l=@targs;
$elem=0;
while ($elem <= $l) {
print MAIL "$targs[$elem]\n";
$elem++;
}
}
}
print MAIL "on this filesystem: $file_sys\n";
close (MAIL);
}
@vob_space="";
}
close(VOBSPACE);
exit;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This archive was generated by hypermail 2b29 : Sun May 06 2001 - 00:23:31 EDT