#!/usr/local/bin/perl # This script was written for www.philforhumanity.com. # If you have any questions, issues, or enhancement requests, please contact us via the website. # Use this script at your own risk. # Define variables my $admin_view_name = "root_view"; my $AWK = "/bin/awk"; my $CT = "/usr/atria/bin/cleartool"; my $DF = "/bin/df"; my $each_item; my $EGREP = "/bin/egrep"; my $found; my @output; my @output2; my $PARTITION_ERROR_LIMIT = 90; # View storage partition full error limit my $PARTITION_WARNING_LIMIT = 80; # View storage partition full warning limit my $REGISTRY_CHECK = "/usr/atria/etc/rgy_check"; my $TAIL = "/bin/tail"; my @VALID_VOB_GROUPS = ("group1", "group2", "group3"); my @VALID_VOB_OWNERS = ("root", "admin", "clearcase_admin"); my @VALID_VOB_PATHS = ("/vob1", "/vob2", "/vob3"); my $vob_info; my $vob_group; my $vob_mounted; my $vob_owner; my $vob_path; my $vob_tag; my $vob_type; my $WINDOWS_REGION = "windows_region_name"; # Check each VOB at a time foreach $vob_info (`$CT lsvob`) { # Split each VOB info @output = split (/\s+/, $vob_info); # Parse the line variables $vob_mounted = @output[0]; $vob_tag = @output[1]; $vob_path = @output[2]; $vob_type = @output[3]; # If the VOB is not mounted, then mount it. if ($vob_mounted ne "*") { # Mount VOB @output = `$CT mount $vob_tag`; # Mounting a VOB does not produce any output, unless there is an error if (@output != ()) { print "ERROR: Unable to mount VOB: $vob_tag\n"; } else { $vob_mounted = "*"; } } # If the VOB is mounted, test using the VOB if ($vob_mounted eq "*") { # Test VOBs functionality, while searching for warning and error messages @output = `$CT setview -exec \"$CT ls -long $vob_tag\" $admin_view_name | $EGREP -i '(Error|warning|bad directory|MVFS|Device busy)' `; # If an error or warning was found while testing the VOB, then print an error if (@output != ()) { print "ERROR: While trying to use VOB $vob_tag, these issues were found:\n@output"; } } # Get VOB owner @output = `$CT describe vob:$vob_tag`; @output2 = grep (/^ owner /, @output); @output2 = split (/\s+/,@output2[0]); $vob_owner = @output2[2]; # Get VOB group @output2 = grep (/^ group /, @output); @output2 = split (/\s+/,@output2[0]); $vob_group = $output2[2]; # Check if the VOB's owner is valid $found = 0; foreach $each_item (@VALID_VOB_OWNERS) { if ($vob_owner =~ /$each_item/) { $found = 1; last; } } if ($found == 0) { print "WARNING: The VOB $vob_tag does not have a valid owner of $vob_owner.\n"; } # Check if the VOB's primary group is valid $found = 0; foreach $each_item (@VALID_VOB_GROUPS) { if ($vob_group =~ /$each_item/) { $found = 1; last; } } if ($found == 0) { print "WARNING: The VOB $vob_tag does not have a valid primary group of $vob_group.\n"; } # Check to make sure that each VOB type is public. # Some admins do allow private VOBs, however I have never found a good enough reason to support these VOB types. if ($vob_type ne "public") { print "WARNING: The VOB $vob_tag is not a public VOB.\n"; } # Check if the VOB's path is valid $found = 0; foreach $each_item (@VALID_VOB_PATHS) { if ($vob_path =~ /$each_item/) { $found = 1; last; } } if ($found == 0) { print "ERROR: The VOB $vob_tag does not have a valid network path.\n"; } # Before VOB Schema 54, the DB string file had an upper limit of 2 gigabytes. # So, we had a check if the DB string file was over 1.8 GB. # Since upgrading all VOBs to Schema 54, this is no longer necessary, however other admins of older VOBs may need this check. # # Check db string size is not over 1.8 Gigabytes # @output = `/bin/ls -l $path/db/vob_db.str_file | /bin/awk '{print \$5}' `; # my $found = eval(@output[0]); # if ($found > 1800000000) # { # print "ERROR: $vob_tag has db getting too large at $found bytes!\n"; # } # Unmount each VOB, if desired. # VOB and Views servers do not require all the VOBs to be mounted, especially since mounting uses system resources needlessly. # However, user servers require VOBs to be mounted. # # Don't bother checking if the unmount worked, since any user could be using the VOB thus preventing the unmount command from working. # `$CT umount $tag`; } # Check each partition if the disk space full is too high foreach $vob (@VALID_VOB_PATHS) { if (! -d $vob) { print "ERROR: Invalid VOB storage partition: $vob\n"; next; } # Get disk space used $found = eval `$DF -k $vob | $TAIL -1 | $AWK '{print \$1}' `; # Check percentage if ($found >= $PARTITION_ERROR_LIMIT) { # Print results print "ERROR: VOB Partition $vob is over $PARTITION_ERROR_LIMIT% full!\n $line"; } elsif ($found >= $PARTITION_WARNING_LIMIT) { # Print results print "WARNING: VOB Partition $vob is over $PARTITION_WARNING_LIMIT% full.\n $line"; } } # Checking for Windows based VOBs # Some admins do allow this, but I do not. I do not recommend allowing users to create local VOBs on their PCs. @output = `$CT lsvob -region $WINDOWS_REGION`; if (@output != ()) { # Print results print "WARNING: Windows VOBs found. They should not exist.\n @output\n"; } # Check registry @output = `$REGISTRY_CHECK -vobs`; if (@output[0] ne "No registry errors/inconsistencies detected.\n") { print "\n @output\n"; } # Exit exit 0;