#!/usr/bin/perl -w

use strict;

#-----------------------------------------------------------------------------#
# Copyright (C) 2001 - 2002 Multi-Tech Systems Inc., USA
# All Rights Reserved
# Multi-Tech Systems, Inc., 2205, Woodale Dr, Mounds View MN USA
#-----------------------------------------------------------------------------#
# Module Name: Web GUI - Interface
#  Version: 3.25
# Date   : 2005-09-22
# Author : Niranjan M M
# Reviewed By: ---
# Modification History - Begin
                                                                                                                             
# Modification History - End
                                                                                                                             
# Description:   This script is responsible to check if the disk usage is more
#                than 80%. If so, it will send a notification mail to the Administrator.
#                When it reaches 90%, appropriate action will be taken to clean
#                up the non-critical stuff from Compact Flash.
# 		 This script should be executed from cron job in the name of check_diskspace

#*********************************
#
# Database Modules for PostGRES.
#
#*********************************
use DBI;
use MDB;

#*******************
#
# Global Variables.
#
#*******************
my ($rootpartition, $count, @message, @squidlogs, @softwares);
my ($LOG, $SQUID, $QUEUE, $QUARANTINE, $ROOT, $BACKUP, $REPORT, $IPTABLES, $URLDB);
my ($LOG_PERCENTAGE, $QUEUE_PERCENTAGE, $SQUID_PERCENTAGE, $QUARANTINE_PERCENTAGE, $ROOT_PERCENTAGE);

#***********************************
#
# Initialization of Variables.
#
#***********************************
$count = 0;
$LOG = "/var/log";
$SQUID = "/var/chroot-squid";
$QUEUE = "/var/qmail/queue";
$QUARANTINE = "/var/spool/qmailscan";
$ROOT = "/";
$BACKUP = "/var/log/backup";
$REPORT = "/var/log/qmail/qmaillog";
$IPTABLES = "/var/log/backup/iptables";
$URLDB = "/var/log/URL/Category.tar.gz";

$squidlogs[0] = "/var/chroot-squid/usr/local/squid/surfcontrol/surfing.log";
$squidlogs[1] = "/var/chroot-squid/usr/local/squid/logs/access.log";
$squidlogs[2] = "/var/chroot-squid/usr/local/squid/logs/store.log";
$squidlogs[3] = "/var/chroot-squid/usr/local/SurfControl/profile/block.log";

$softwares[0] = "/*.tar*";
$softwares[1] = "/*.zip";
$softwares[2] = "/home/loginuser/*.*";
$softwares[3] = "/home/admin/*.*";
$softwares[4] = "/*.iso";
$softwares[5] = "/root/*.*";

$LOG_PERCENTAGE = 0.15;
$QUEUE_PERCENTAGE = 0.15;
$SQUID_PERCENTAGE = 0.22;
$QUARANTINE_PERCENTAGE = 0.095;
$ROOT_PERCENTAGE = 1;

#**********************************************************************************************
                                                                                                   
# Function to find location of Hard Disk (here Compact Flash).
# viz., /dev/hda, /dev/hdc etc., and then root partition.
# /etc/lilo.conf contains the location of Hard Disk (here Compact Flash) as "boot=/dev/hdX"
# it may be "boot=/dev/hda", "boot=/dev/hdc" etc.,
# And root partition is on /dev/hdX3.

#**********************************************************************************************
sub find_harddisk
{
	my $hdisk;
        open (LILOCONF, "/etc/lilo.conf");
        while (<LILOCONF>)
        {
                if (/^boot=/)
                {
                        my @splitvals = split (/=/, $_);
                        $hdisk = $splitvals [1];
                        chomp ($hdisk);
                        last;
                }
        }
        close (LILOCONF);
        $rootpartition = $hdisk . "3";
}

#***********************************************************************
#
# Function to calculate maximum size allowed for different directories.
# and calculation of 90%, 80% & 70% of those directories.
# This function will be called for calculating - i. /var/log/
#						ii. /var/chroot-squid/
#					       iii. /var/qmail/queue/
#						iv. /var/spool/qmailscan/
#						 v. /.
#
#***********************************************************************
sub calculate_size
{
	my $percentage = $_[0];
	my $totalsize_in_KB = `df | grep $rootpartition | tr -s " " | cut -d " " -f2`;
        chomp ($totalsize_in_KB);
        my $totalsize_in_MB = $totalsize_in_KB / 1024;
        my $allowedsize_in_MB = $percentage * $totalsize_in_MB;
        my $allowed_90_percent = $allowedsize_in_MB * 0.9;
        my $allowed_80_percent = $allowedsize_in_MB * 0.8;
        my $allowed_70_percent = $allowedsize_in_MB * 0.7;
	return ($allowed_90_percent, $allowed_80_percent, $allowed_70_percent);
}

#***********************************************************************
#
# Function to check whether URL Category Updation is in progress or not. 
# If not, remove Category.tar.gz file from /var/log/URL/ directory.
# This file is present only during URL Category Updation
# If URL Category Updation is not in progress and this file is present
# Remove this file.
#  
#***********************************************************************
sub is_url_update_running
{
	my $urlcatupdate = `pidof updater`;
	chomp ($urlcatupdate);
	my $procstat = `ps ax --cols 250 | grep -v grep | grep "/usr/bin/perl -w /etc/multiconf/scripts/http updatefiles_up" | tr -s " " | cut -d" " -f1`; 
	chomp ($procstat);
	my $procstatus = `ps ax --cols 250 | grep -v grep | grep "/usr/bin/perl -w /etc/multiconf/scripts/http catupdate" | tr -s " " | cut -d" " -f1`; 
	if (($urlcatupdate ne "") || ($procstat ne "") || ($procstatus ne "") || (-e "/etc/cron.fivemins/urlupdatefiles"))
	{
        	#print "URL Category Updation is in Progress\n";
		return 1;
	}
	else
	{
		#print "URL Category Updation is not in Progress\n";
		if ( -e $URLDB)
        	{
			#print "Running http updatefiles_up\n";
			system ("/etc/multiconf/scripts/http updatefiles_up");
	        }
		return 0;
	}
}

#************************************************************************
#
# Function to calculate current disk usage of different directories.
# This function will be called for calculating - i. /var/log/
#                                               ii. /var/chroot-squid/
#                                              iii. /var/qmail/queue/
#						iv. /var/spool/qmailscan/
#                                                v. /.
#
#************************************************************************
sub calculate_current_usage
{
	chomp ($_[0]);
	my $directoryname = $_[0];
	my $Bytes_plus_directoryname = `du -sb $directoryname 2>/dev/null`;
        chomp ($Bytes_plus_directoryname);
        my @splitvals = split (' ', $Bytes_plus_directoryname);
        chomp ($splitvals[0]);
        my $current_usage_in_Bytes = $splitvals[0];
        my $current_usage_in_MB = $current_usage_in_Bytes / (1024 * 1024);
	return ($current_usage_in_MB);
}

#********************************************************************************
#
# Function to send notification mail to admin(s) - Disk Clean Up - Low Diskspace.
# /etc/multiconf/mailids/email.conf contains Admin mail ids which are configured
# from Administration page from UI.
# Send the notification mail to all the admin mail ids present in this file.
#
#********************************************************************************
sub send_notification_mail
{
	my $NotifyUser = `/etc/multiconf/scripts/settings emailnotify check 'Disk Clean Up - Low Diskspace'`;
                                                                                                                             
        if (-e "/etc/multiconf/mailids/email.conf" && ($NotifyUser eq 'yes'))
        {
                open (MAILIDS, "/etc/multiconf/mailids/email.conf") || die "Cannot open mail id list file\n";
                my $mail_ID = "";
		my $mail_list = "";
                my $Admin_ID_Present = 0;
                while (<MAILIDS>)
                {
                        $Admin_ID_Present = 1;
                        $mail_ID = $_;
                        chomp ($mail_ID);
                        if ($mail_list eq "")
                        {
                                $mail_list = $mail_ID;
                        }
                        else
                        {
                                $mail_list = $mail_list . " " . $mail_ID;
                        }
                }
                close (MAILIDS);
                if ($Admin_ID_Present == 1)
                {
                        # Write the message to be sent into a string
                        my $datetoprint = `date`;
                        chomp ($datetoprint);
                        my $hostname = `hostname`;
                        chomp ($hostname);
                        my $subject = $hostname . " - Disk Usage";
                                                                                                                             
                        my $message_string = "";
			my ($i, $j);
			for ($i = 0; $i < $count; $i++)
                        {
                                if ($count > 1)
                                {
                                        $j = $i + 1;
                                        $message_string = $message_string . "$j. $message[$i]";
                                }
                                else
                                {
                                        $message_string = $message[$i];
                                }
                        }
                        `echo "$datetoprint This message is generated by the Compact Flash Usage utility.\n\n$message_string" | mutt -s "$subject" $mail_list`;
                }
	}
}

#********************************************************************
#
# Function to remove current qmail logs.
# qmail current log files are located under /var/log/qmail/ directory.
# Remove these log files.
#
#********************************************************************
sub remove_current_qmail_logs
{
	system ("rm -f /var/log/qmail/\@*");
        system ("rm -f /var/log/qmail/smtpd/\@*");
}

sub remove_snort_logs
{
	system ("echo > /var/log/snort/alert");
}

#*************************************************
#
# Function to remove backup logs.
# Remove the existing oldest i. Backup Logs
#                           ii. Qmail Report Logs
#			   iii. Iptables Logs.
#
#*************************************************
sub remove_backup_logs
{
	chomp ($_[0]);	
	chdir ($_[0]);
        my $oldest_file = `ls -clt | grep -v ^d | tr -s " " | cut -d " " -f9 | tail -1`;
        chomp ($oldest_file);
        if ($oldest_file eq "")
        {
        	return 0;
        }
        system ("rm -f $oldest_file");
	return 1;
}

#*******************************************************************************************
#Function to Calculate the disk usage of the /var/log when URL Category Updation is running
#
#*******************************************************************************************
sub calculate_log_disk_usage
{
	my $totalsize_in_KB = `df | grep $rootpartition | tr -s " " | cut -d " " -f2`;
        chomp ($totalsize_in_KB);
        my $totalsize_in_MB = $totalsize_in_KB / 1024;
        my $maxlogsize = $totalsize_in_MB * 0.15;
        my $logsize_20_percent = $maxlogsize * 0.2;
        my $max_category_backup_size = $maxlogsize * 0.75;

        my $du_of_log = `du -sb /var/log`;
        chomp ($du_of_log);
        my @values = split (' ', $du_of_log);
        chomp ($values[0]);
        $du_of_log = $values[0];
        my $logusage = $du_of_log / (1024 * 1024);
	my $max_log_usage = $logusage - $max_category_backup_size;
        return ($logsize_20_percent, $max_log_usage);
	
}
#********************************************************************************
#
# Function to check disk usage of log directory. 
# Skip the check disk usage of log directory if URL Category Updation is in 
# Progress, since URL Category Backup is stored in /var/log/URL directory.
# If current disk usage of log directory lies between 80% & 90%, send notification
# mail to Admin(s).
# If current disk usage is more than or equal to 90%, 
# Delete - 1. Current Qmail Logs
#	   2. Backup Logs
#	   3. Iptables Logs 
# till disk usage of log directory comes below 70% or all the logs are removed.
#	 
#********************************************************************************
sub check_log_directory
{
	my $url_update = 0;
	my ($backup_logfiles_found, $iptables_logfiles_found, $report_logfiles_found);
	$url_update = is_url_update_running ();
	chomp ($url_update);
	if ($url_update)
	{
		my ($log_20_percent, $max_log_usage);
		$backup_logfiles_found = 1;
		$iptables_logfiles_found = 1;
		$report_logfiles_found = 1;
		($log_20_percent, $max_log_usage) = calculate_log_disk_usage;
		chomp ($log_20_percent, $max_log_usage);
		while ($max_log_usage > $log_20_percent)
		{
			if ($backup_logfiles_found == 1)
			{
				$backup_logfiles_found = remove_backup_logs ($BACKUP);
				($log_20_percent, $max_log_usage) = calculate_log_disk_usage;
				chomp ($log_20_percent, $max_log_usage);
			}
			if (($max_log_usage > $log_20_percent) && ($iptables_logfiles_found == 1))
			{
				$iptables_logfiles_found = remove_backup_logs ($IPTABLES);
				($log_20_percent, $max_log_usage) = calculate_log_disk_usage;
				chomp ($log_20_percent, $max_log_usage);
			}
			if (($max_log_usage > $log_20_percent) && ($report_logfiles_found == 1))
			{
				$report_logfiles_found = remove_backup_logs ($REPORT);
				($log_20_percent, $max_log_usage) = calculate_log_disk_usage;
				chomp ($log_20_percent, $max_log_usage);
			}
		}
		#print "URL Category Updation is in Progress... Skipping further checks on log directory\n";
		return 0;
	}
	my @log_90_80_70_percent = calculate_size ($LOG_PERCENTAGE);
	chomp (@log_90_80_70_percent);
	my ($log_90_percent, $log_80_percent, $log_70_percent) = @log_90_80_70_percent;
	#print "$LOG directory\n 90% - $log_90_percent\n 80% - $log_80_percent\n 70% - $log_70_percent\n";

	my $current_log_usage = calculate_current_usage ($LOG);
	
	if (($current_log_usage > $log_80_percent) && ($current_log_usage < $log_90_percent))
        {
                if (! (-e "/etc/multiconf/logfull"))
                {
                        $message[$count] = "Compact Flash usage by the log files has exceeded 80% of allowed size. The older log files and the older backup log files including logs of iptables will be automatically deleted when it reaches 90%\n";
                        $count++;
                        system ("touch /etc/multiconf/logfull");
                }
        }
	elsif ($current_log_usage >= $log_90_percent)
        {
		remove_current_qmail_logs ();
		$current_log_usage = calculate_current_usage ($LOG);
		if ($current_log_usage > $log_70_percent)
		{
			remove_snort_logs ();
			$current_log_usage = calculate_current_usage ($LOG);
		}
		$backup_logfiles_found = 1;
		$iptables_logfiles_found = 1;
		while (($current_log_usage > $log_70_percent) && (($backup_logfiles_found == 1) || ($iptables_logfiles_found == 1)))
		{
			if ($backup_logfiles_found == 1)
			{
				$backup_logfiles_found = remove_backup_logs ($BACKUP);
				$current_log_usage = calculate_current_usage ($LOG);
			}
			if (($current_log_usage > $log_70_percent) && ($iptables_logfiles_found == 1))
			{
				$iptables_logfiles_found = remove_backup_logs ($IPTABLES);
				$current_log_usage = calculate_current_usage ($LOG);
			}
		}
		$report_logfiles_found = 1;
		while (($current_log_usage > $log_70_percent) && ($report_logfiles_found == 1))
		{
			$report_logfiles_found = remove_backup_logs ($REPORT);
			$current_log_usage = calculate_current_usage ($LOG);
		}
		$message[$count] = "The older log files and/or the older backup log files including/excluding logs of iptables have been deleted from the log directory\n";
                $count++;
		system ("rm -f /etc/multiconf/logfull");
	}
	elsif ($current_log_usage >= $log_70_percent)
	{
		if (-e "/etc/multiconf/logfull")
		{
			system ("rm -f /etc/multiconf/logfull");
		}
	}
	return 1;
}

#********************************************************
#
# Function to remove unwanted logs from squid directory.
# Remove unwanted squid logs whose path is as specified
# in @squidlogs array [Initialization of Variables].
#
#********************************************************
sub remove_unwanted_squid_logs
{
	my $log_name = $_[0];
	chomp ($log_name);
	if ($log_name ne "")
	{
		if (-e $log_name)
		{
			system ("echo > $log_name");
		}	
	}
}

#****************************************************
#
# Function to check disk usage of squid directory.
# Remove unwanted squid logs whose path specfied in 
# @squidlogs array. 
#
#****************************************************
sub check_squid_directory
{
	my $i = @squidlogs;
	$i--;
	my @squid_90_80_70_percent = calculate_size ($SQUID_PERCENTAGE);
	chomp (@squid_90_80_70_percent);
	my ($squid_90_percent, $squid_80_percent, $squid_70_percent) = @squid_90_80_70_percent;
	#print "$SQUID directory\n 90% - $squid_90_percent\n 80% - $squid_80_percent\n 70% - $squid_70_percent\n";

	my $current_squid_usage = calculate_current_usage ($SQUID);
	if (($current_squid_usage > $squid_80_percent) && ($current_squid_usage < $squid_90_percent))
        {
		# Don't send notification mail to admin(s)
		return 0;
        }
        elsif ($current_squid_usage >= $squid_90_percent)
        {
		while (($current_squid_usage > $squid_80_percent) && ($i >= 0))
		{
			remove_unwanted_squid_logs ($squidlogs[$i]);
			$current_squid_usage = calculate_current_usage ($SQUID);
			$i--;
		}
        }
	return 1;
}

#************************************************
#
# Function to remove qmail bounce mails.
# Call script to remove all admin bounce mails by 
# removing /home/admin/Maildir directory 
# and recreating it.
#
#************************************************
sub remove_qmail_bounce_mails
{
	system ("/etc/multiconf/scripts/flashbouncemails");
	return 1;
}

#*******************************************************
#
# Function to remove i. POP3 Virus Quarantine Mails
#		    ii. SMTP Virus Quarantine Mails
#		   iii. SMTP Spam Quarantine Mails.
# Call script to delete quarantine mails on the basis of
# i. Day ii. Mail Method iii. Mail type.
#
#*******************************************************
sub remove_quarantine_mails
{
	system ("/etc/multiconf/scripts/delquarantine $_[0] $_[1] $_[2]");
	return 1;
}

#****************************************************************
#
# Function to check disk usage of queue directory.
# If current disk usage of queue directory is more than 90%,
# remove all queued bounce mails. 
#
#****************************************************************
sub check_queue_directory
{
	my @queue_90_80_70_percent = calculate_size ($QUEUE_PERCENTAGE);
	chomp (@queue_90_80_70_percent);
	my ($queue_90_percent, $queue_80_percent, $queue_70_percent) = @queue_90_80_70_percent;
	#print "$QUEUE directory\n 90% - $queue_90_percent\n 80% - $queue_80_percent\n 70% - $queue_70_percent\n";
	
	my $current_queue_usage = calculate_current_usage ($QUEUE);
        if (($current_queue_usage > $queue_80_percent) && ($current_queue_usage < $queue_90_percent))
        {
		# Don't send notification mail to Admin(s)
		return 0;
        }
        elsif ($current_queue_usage >= $queue_90_percent)
        {
		remove_qmail_bounce_mails ();
        }
	return 1;
}

#**********************************************************************
#
# Function to check disk usage of quarantine directory.
# If current disk usage of quarantine directory goes above 90%, 
# Old quarantine mails of i. POP3 Virus ii. SMTP Virus iii. SMTP Spam
# will be deleted till disk usage comes below 70%.
#
#**********************************************************************
sub check_quarantine_directory
{
	my $days = 10;
	my @quarantine_90_80_70_percent = calculate_size ($QUARANTINE_PERCENTAGE);
        chomp (@quarantine_90_80_70_percent);
        my ($quarantine_90_percent, $quarantine_80_percent, $quarantine_70_percent) = @quarantine_90_80_70_percent;
        #print "$QUARANTINE directory\n 90% - $quarantine_90_percent\n 80% - $quarantine_80_percent\n 70% - $quarantine_70_percent\n";
                                                                                                                             
        my $current_quarantine_usage = calculate_current_usage ($QUARANTINE);
        if (($current_quarantine_usage > $quarantine_80_percent) && ($current_quarantine_usage < $quarantine_90_percent))
        {
                # Don't send notification mail to Admin(s)
		return 0;
        }
        elsif ($current_quarantine_usage >= $quarantine_90_percent)
        {
		while (($current_quarantine_usage > $quarantine_70_percent) && ($days >= 0))
		{
                	remove_quarantine_mails ($days, "virus", "pop");
        	        remove_quarantine_mails ($days, "virus", "smtp");
	                remove_quarantine_mails ($days, "spam", "smtp");
			$current_quarantine_usage = calculate_current_usage ($QUARANTINE);
			$days--;
		}
        }
        return 1;
}

#*********************************************************************
#
# Function to check disk usage of rpm directory.
#
#*********************************************************************
=senthil
sub check_rpm_directory
{
	if (-e "/etc/multiconf/autostatusindex")
	{
		#print "System Update is supposed to be in Progress\n";
		return;
	}
	
	my $pidof_autoscript = `pidof -x autoscript`;
	chomp ($pidof_autoscript);

	my $pidof_autoupdate = `pidof -x autoupdate`;
	chomp ($pidof_autoupdate);
	
	my $pidof_autoup = `pidof -x autoup`;
	chomp ($pidof_autoup);
	
	my $pidof_updatecheck = `pidof -x updatecheck`;
	chomp ($pidof_updatecheck);

	if (($pidof_autoscript eq "") && ($pidof_autoupdate eq "") && ($pidof_autoup eq "") && ($pidof_updatecheck eq ""))
	{
		#print "System Update is not in Progress\n";

		my $rpmcount = `ls /var/spool/flash/autoupdate | wc -l`;
		chomp ($rpmcount);
		if ($rpmcount != 0)
		{
			system ("rm -f /var/spool/flash/autoupdate/*");
		}
	}
	else
	{
		#print "System Update is in Progress\n";
	}
}
=cut

#****************************************************
#
# Function to remove user downloaded softwares.
# Remove extra files located at the path specified in 
# @softwares array.
#
#****************************************************
sub remove_user_downloaded_softwares
{
	chomp ($_[0]);
	system ("rm -f $_[0]");
	return 1;
}

#*************************************************
#
# Function to remove admin bounce mails.
# Call script to remove all bounce mails of admin.
#
#*************************************************
sub remove_admin_bounce_mails
{
	system ("/etc/multiconf/scripts/flashbouncemails");
	return 1;
}

#***************************************
#
# Function to remove temporary files.
# Call script to remove temporary files.
#
#***************************************
sub remove_temp_files
{
	system ("/etc/cron.daily-1/tmpwatch");
	return 1;
}

#**************************************************
#
# Function to remove PPTP History of Calls.
# Remove older PPTP Call History from the database.
#
#**************************************************
sub remove_pptp_call_history
{
	my $days = $_[0];
	chomp ($days);
	my $db_handler;
	$db_handler = db_open or db_log($db_handler->errstr);
        $db_handler->do("delete from callhistory where ddate < LOCALTIMESTAMP(0) - interval '$days day'") or db_log ($db_handler->errstr);
        $db_handler->disconnect;
	return 1;
}

#****************************************************************
#
# Function to check disk usage of root directory.
# If current disk usage of root directory lies between 80% & 90%,
# send notification mail to admin.
# If disk usage of root directory goes above 90%, delete
# i.   Admin Bounce Mails
# ii.  User Downloaded softwares
# iii. Temporary files
# iv.  PPTP Call History till disk usage comes less than 70% or all the logs are removed.
#
#*****************************************************************
sub check_root_directory
{
	my $days = 10;
	my $number_of_softwares = @softwares;
	$number_of_softwares--;
	my @root_90_80_70_percent = calculate_size ($ROOT_PERCENTAGE);
	chomp (@root_90_80_70_percent);
	my ($root_90_percent, $root_80_percent, $root_70_percent) = @root_90_80_70_percent;
	#print "$ROOT directory\n 90% - $root_90_percent\n 80% - $root_80_percent\n 70% - $root_70_percent\n";
	my $current_root_usage = calculate_current_usage ($ROOT);
        if (($current_root_usage > $root_80_percent) && ($current_root_usage < $root_90_percent))
        {
		if (! (-e "/etc/multiconf/rootfull"))
                {
                	$message[$count] = "Compact Flash usage by the files in root partition has exceeded 80%. The older log files of the web server, bounced mails and all quarantined mails will be automatically deleted when it reaches 90%\n";
                        $count++;
                        system ("touch /etc/multiconf/rootfull");
        	}
	}
        elsif ($current_root_usage >= $root_90_percent)
        {
		remove_admin_bounce_mails ();
		$current_root_usage = calculate_current_usage ($ROOT);
		while (($current_root_usage >= $root_70_percent) && ($number_of_softwares >= 0))
		{
			remove_user_downloaded_softwares ($softwares[$number_of_softwares]);
			$current_root_usage = calculate_current_usage ($ROOT);
			$number_of_softwares--;
		}
		if ($current_root_usage >= $root_70_percent)
		{
			remove_temp_files ();
			$current_root_usage = calculate_current_usage ($ROOT);
		}
		while (($current_root_usage >= $root_70_percent) && ($days >= 0))
		{
			remove_pptp_call_history ($days);
			$current_root_usage = calculate_current_usage ($ROOT);
			$days--;
		}
		$message[$count] = "The user downloaded softwares and/or the old call history entries and/or the mail postmaster's bounced mails have been deleted from the root partition\n";
                $count++;
		system ("rm -f /etc/multiconf/rootfull");
        }
	elsif ($current_root_usage >= $root_70_percent)
        {
                if (-e "/etc/multiconf/rootfull")
                {
                        system ("rm -f /etc/multiconf/rootfull");
                }
        }
	return 1;
}

#********************************
#
# Main Function.
#
#********************************

# Find Hard Disk.
find_harddisk ();
#print "Hard Disk - / partition - $rootpartition\n";

# Check Log Directory.
check_log_directory ();

# Check Squid Directory
check_squid_directory ();

# Check Queue Directory.
check_queue_directory ();

# Check Quarantine Directory.
check_quarantine_directory ();

# Check RPM Directory.
#check_rpm_directory ();

# Check Root Directory.
check_root_directory ();

if ($count > 1)
{
	# Send Notification Mail to Admin(s).
	send_notification_mail ();
}
