SF.net SVN: logwatch:[137]

[email protected]
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Revision: 137
          http://logwatch.svn.sourceforge.net/logwatch/?rev=137&view=rev
Author:   stefjakobs
Date:     2013-02-21 12:34:19 +0000 (Thu, 21 Feb 2013)
Log Message:
-----------
zz-disk_space: implement $local_disks_only, change formating

Modified Paths:
--------------
    conf/services/zz-disk_space.conf
    scripts/services/zz-disk_space

Modified: conf/services/zz-disk_space.conf
===================================================================
--- conf/services/zz-disk_space.conf	2013-02-21 12:18:59 UTC (rev 136)
+++ conf/services/zz-disk_space.conf	2013-02-21 12:34:19 UTC (rev 137)
@@ -1,9 +1,5 @@
-###########################################################################
-# $Id: zz-disk_space.conf,v 1.9 2006/12/15 05:10:59 bjorn Exp $
-###########################################################################
+# This just displays the file system disk usage at the end of the report...
 
-# This just displays a fortune at the end of the report...
-
 # You can put comments anywhere you want to.  They are effective for the
 # rest of the line.
 
@@ -19,16 +15,16 @@
 # Which logfile group...
 LogFile = NONE
 
-#New disk report options
-#Uncomment this to show the home directory sizes
+# disk report options
+# Uncomment this to show the home directory sizes
 #$show_home_dir_sizes = 1
 #$home_dir = "/home"
 
-#Uncomment this to show the mail spool size
+# Uncomment this to show the mail spool size
 #$show_mail_dir_sizes = 1
 #$mail_dir = "/var/spool/mail"
 
-#Uncomment this to show the system directory sizes /opt /usr/ /var/log
+# Uncomment this to show the system directory sizes /opt /usr/ /var/log
 #$show_disk_usage = 1
 
 # The variables df_options and disk_cmd are used to customize the reporting
@@ -37,7 +33,7 @@
 # $df_options = "-h -l -x tmpfs"
 # $disk_cmd = "df $df_options"
 
-#Uncomment this to add -l to df command.. Only see local disks
+# Uncomment this to add -l to df command. Only see local disks.
 #$local_disks_only = 1
 
 # The variable diskfull_threshold, when set to a positive number, will
@@ -45,6 +41,7 @@
 # is 90.  Set to 0 if no warning desired.
 #$diskfull_threshold = 0
 
+
 ########################################################
 # This was written and is maintained by:
 #    Kirk Bauer <[email protected]>

Modified: scripts/services/zz-disk_space
===================================================================
--- scripts/services/zz-disk_space	2013-02-21 12:18:59 UTC (rev 136)
+++ scripts/services/zz-disk_space	2013-02-21 12:34:19 UTC (rev 137)
@@ -1,7 +1,3 @@
-##########################################################################
-# $Id: zz-disk_space,v 1.24 2008/12/08 15:16:06 mike Exp $
-##########################################################################
-
 #######################################################
 ## Copyright (c) 2008 Kirk Bauer
 ## Covered under the included MIT/X-Consortium License:
@@ -34,6 +30,7 @@
 my $mail_dir = $ENV{'mail_dir'} || 0;
 my $show_disk_usage = $ENV{'show_disk_usage'} || 0;
 my $diskfull_threshhold = $ENV{'diskfull_threshold'} || 90;
+my $local_disks_only = $ENV{'local_disks_only'} || 0;
 
 my $df_options;
 my $disk_cmd;
@@ -43,86 +40,79 @@
 exit (0) if ($ENV{'LOGWATCH_ONLY_HOSTNAME'} and ($logwatch_hostname ne $hostname));
 
 if ( $Debug >= 5 ) {
-    print STDERR "\n\nDEBUG: Inside zz-disk-space Filter \n\n";
-    $DebugCounter = 1;
+	print STDERR "\n\nDEBUG: Inside zz-disk-space Filter \n\n";
+	$DebugCounter = 1;
 }
 
 sub DirUsage {
-    my $Dir = $_[0];
+	my $Dir = $_[0];
 	if ($OSname eq "Linux") {
 		system("du -s --block-size=1048576 -h $Dir | sort -n -r -k 1");
 	} elsif ($OSname eq "Darwin") {
 		system("du -s --block-size=1048576 -h $Dir | sort -n -r -k 1");
 	} elsif ($OSname eq "SunOS") {
 		if ( ($release eq "5.10") || ($release eq "5.9") || ($release eq "5.11") ) {
-			system("/usr/xpg4/bin/du -s -h $Dir | sort -n -r -k 1");
-		} else {
-			system("du -s $Dir | sort -n -r -k 1");
-  		}
+		   system("/usr/xpg4/bin/du -s -h $Dir | sort -n -r -k 1");
+      } else {
+         system("du -s $Dir | sort -n -r -k 1");
+      }
 	} elsif ($OSname eq "HP-UX") {
-    	system("du -s -k $Dir | sort -n -r -k 1");
+		system("du -s -k $Dir | sort -n -r -k 1");
 	} elsif ($OSname eq "AIX") {
-    	system("du -s -k $Dir | sort -n -r -k 1");
+	 	system("du -s -k $Dir | sort -n -r -k 1");
 	} else {
-    	system("du -s -h $Dir | sort -n -r -k 1");
+	  	system("du -s -h $Dir | sort -n -r -k 1");
 	}
-
 }
 
-
 sub DirectorySizes
 {
-      my $Dir = $_[0];
-      DirUsage($Dir.'/*');
+	my $Dir = $_[0];
+	DirUsage($Dir.'/*');
 }
 
 sub HomeDirectorySizes
 {
-      my $HomeDir = $_[0];
-      print "\n\n------------- Home Directory Sizes ---------------\n\n";
-      print "Size    Location\n";
-      print "(MB)\n";
-      DirectorySizes($HomeDir);
-      print "\n\n------------- Home Directory Sizes ---------------\n\n";
+	my $HomeDir = $_[0];
+	print "\n\n------------- Home Directory Sizes ---------------\n\n";
+	print "Size    Location\n";
+	DirectorySizes($HomeDir);
+	print "\n\n------------- Home Directory Sizes ---------------\n\n";
 }
 
-
 sub MailDirectorySizes
 {
-      my $MailDir = $_[0];
-      print "\n\n------------- Mail Directory Sizes ---------------\n\n";
-      print "Size    Location\n";
-      print "(MB)\n";
-      DirectorySizes($MailDir);
-      print "\n\n------------- Mail Directory Sizes ---------------\n\n";
+	my $MailDir = $_[0];
+	print "\n\n------------- Mail Directory Sizes ---------------\n\n";
+	print "Size    Location\n";
+	DirectorySizes($MailDir);
+	print "\n\n------------- Mail Directory Sizes ---------------\n\n";
 }
 
-
 sub DiskUsage ()
 {
-    my $Dir = $_[0];
-    print "\n\n------------- Directory Sizes ---------------\n\n";
-    print "Size    Location\n";
-    print "(GB)\n";
+	my $Dir = $_[0];
+	print "\n\n------------- Directory Sizes ---------------\n\n";
+	print "Size    Location\n";
 
 	if ($OSname eq "Linux") {
-   		DirUsage("/var/log");
-   		DirUsage("/usr");
+	 	DirUsage("/var/log");
+	 	DirUsage("/usr");
 	} elsif ($OSname eq "Darwin") {
-   		DirUsage("/var/log");
-   		DirUsage("/usr");
+		DirUsage("/var/log");
+		DirUsage("/usr");
 	} elsif ($OSname eq "SunOS") {
-   		DirUsage("/var/log");
-   		DirUsage("/usr");
-   		DirUsage("/opt");
+		DirUsage("/var/log");
+		DirUsage("/usr");
+		DirUsage("/opt");
 	} elsif ($OSname eq "HP-UX") {
-   		DirUsage("/var/adm");
-   		DirUsage("/usr");
-   		DirUsage("/opt");
+		DirUsage("/var/adm");
+		DirUsage("/usr");
+		DirUsage("/opt");
 	} else {
-   		DirUsage("/var/log");
-   		DirUsage("/usr");
-   		DirUsage("/opt");
+		DirUsage("/var/log");
+		DirUsage("/usr");
+		DirUsage("/opt");
 	}
 
 	print "\n\n------------- Directory Sizes ---------------\n\n";
@@ -131,66 +121,68 @@
 
 sub DiskSpace ()
 {
-   if ($OSname eq "Linux") {
-      $df_options = "-h -l -x tmpfs -x udf -x iso9660";
+	if ($OSname eq "Linux") {
+		$df_options = "-h -x tmpfs -x udf -x iso9660";
+		if ($local_disks_only) { $df_options .= " -l"; }
 	} elsif ($OSname eq "Darwin") {
-      $df_options = "-h -l";
+		$df_options = "-h";
+		if ($local_disks_only) { $df_options .= " -l"; }
 	} elsif ($OSname eq "SunOS") {
 		if ( ($release eq "5.10") || ($release eq "5.9") || ($release eq "5.11") ) {
-         $df_options = "-h -l";
-  		} else {
-         $df_options = "-l";
-  		}
-   } elsif ($OSname eq "HP-UX") {
-      $df_options = "-l";
-   } elsif ($OSname eq "AIX") {
-      $df_options = "-P";
-   } elsif ($OSname eq "GNU/kFreeBSD") {
-      $df_options = "-h -l -x tmpfs -x udf -x iso9660 -x devfs -x linprocfs -x sysfs -x fdescfs";
-   } else {
-      $df_options = "-l";
+			$df_options = "-h";
+		} 
+		if ($local_disks_only) { $df_options .= " -l"; }
+	} elsif ($OSname eq "HP-UX") {
+		$df_options = "";
+		if ($local_disks_only) { $df_options .= " -l"; }
+	} elsif ($OSname eq "AIX") {
+		$df_options = "";
+		if ($local_disks_only) { $df_options .= " -P"; }
+	} elsif ($OSname eq "GNU/kFreeBSD") {
+		$df_options = "-h -x tmpfs -x udf -x iso9660 -x devfs -x linprocfs -x sysfs -x fdescfs";
+		if ($local_disks_only) { $df_options .= " -l"; }
+	} else {
+		$df_options = "";
+		if ($local_disks_only) { $df_options .= " -l"; }
 	}
 
-   if ( $ENV{'df_options'} ) {
-      $df_options = $ENV{'df_options'};
-   };
+	if ( $ENV{'df_options'} ) {
+		$df_options = $ENV{'df_options'};
+	};
 
-   if ($OSname eq "Linux") {
-      $disk_cmd = "df $df_options";
+	if ($OSname eq "Linux") {
+		$disk_cmd = "df $df_options";
 	} elsif ($OSname eq "Darwin") {
-      $disk_cmd = "df $df_options";
+		$disk_cmd = "df $df_options";
 	} elsif ($OSname eq "SunOS") {
-      $disk_cmd = "/usr/xpg4/bin/df $df_options";
+		$disk_cmd = "/usr/xpg4/bin/df $df_options";
 	} elsif ($OSname eq "HP-UX") {
-      $disk_cmd = "bdf $df_options";
+		$disk_cmd = "bdf $df_options";
 	} else {
-      $disk_cmd = "df $df_options";
+		$disk_cmd = "df $df_options";
 	}
 
-   if ( $ENV{'disk_cmd'} ) {
-      $disk_cmd = $ENV{'disk_cmd'};
-   };
+	if ( $ENV{'disk_cmd'} ) {
+		$disk_cmd = $ENV{'disk_cmd'};
+	};
 
-   system($disk_cmd);
+	system($disk_cmd);
 
-   print "\n";
+	print "\n";
 }
 
-sub DiskFull
-{
-   my $o = `$disk_cmd`;
-   my @rows = split('\n', $o);
-   foreach my $row (@rows)
-   {
-     my @fields = split(' ', $row);
-     my $use = $fields[4];
-     $use =~ s/%//;
-     if (($use > $diskfull_threshhold) && ($fields[0] !~ /\/dev\/scd/ ) && ($fields[0] !~ /\/dev\/sr/ )
-         && ($fields[0] !~ /\/dev\/loop./))
-     {
-       print "$fields[0] => $fields[4] Used. Warning. Disk Filling up.\n";
-     }
-   }
+sub DiskFull {
+	my $o = `$disk_cmd`;
+	my @rows = split('\n', $o);
+	foreach my $row (@rows) {
+		my @fields = split(' ', $row);
+		my $use = $fields[4];
+		$use =~ s/%//;
+		if (($use > $diskfull_threshhold) && ($fields[0] !~ /\/dev\/scd/ ) && ($fields[0] !~ /\/dev\/sr/ )
+				&& ($fields[0] !~ /\/dev\/loop./)) {
+			print "$fields[0] => $fields[4] Used. Warning. Disk Filling up.\n";
+		}
+	}
 }
 
 #####################
@@ -201,17 +193,16 @@
 
 if ( $show_disk_usage == 1 ) { DiskUsage(); }; #Turn on in zz-disk_space.conf
 
-if (($Detail > 10) || ($show_home_dir_sizes == 1)) { #set in zz-disk_space.conf -mgt
+if (($Detail >= 10) || ($show_home_dir_sizes == 1)) { #set in zz-disk_space.conf -mgt
 	HomeDirectorySizes($home_dir);
 }
 
-if (($Detail > 10) || ($show_mail_dir_sizes == 1)) { #set in zz-disk_space.conf -mgt
-    MailDirectorySizes($mail_dir);
+if (($Detail >= 10) || ($show_mail_dir_sizes == 1)) { #set in zz-disk_space.conf -mgt
+	MailDirectorySizes($mail_dir);
 }
 
-if ($diskfull_threshhold > 0)
-{
-  DiskFull();
+if ($diskfull_threshhold > 0) {
+	DiskFull();
 }
 
 # vi: shiftwidth=3 tabstop=3 syntax=perl et

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.