diff --git a/plugins/disk/du-2 b/plugins/disk/du-2 index 16bd1873..39787e50 100755 --- a/plugins/disk/du-2 +++ b/plugins/disk/du-2 @@ -5,10 +5,9 @@ du - Plugin to monitor multiple directories size -=head1 AUTHOR +=head1 AUTHOR AND COPYRIGHT - Luc Didry - April 2011 + Copyright 2011-2012 Luc Didry =head1 HOWTO CONFIGURE AND USE : @@ -44,6 +43,21 @@ #%# family=auto #%# capabilities=autoconf +=head1 LICENSE + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + =cut use warnings; @@ -99,7 +113,7 @@ while(defined (my $foo = )) { if ($foo =~ m/(\d+)\s+(.+)/) { my ($field, $value) = ($2, $1); clean_path(\$field); - print $field, ".value ", $value, "\n"; + print $field, ".value ", $value, "\n"; } } close(FILE); @@ -107,7 +121,7 @@ daemonize(); # ## -### PUBLiC FONCTiONS +### PUBLIC FONCTIONS ############################################################################### ## Used to create the fork sub daemonize { @@ -135,7 +149,7 @@ sub clean_path { } } ## clean_path -## Do you really need I told you what this function is going to check ? +## Do you really need I told you what this functions are going to check ? sub cache_is_too_old { return 1 if (! -e $TIMEFILE); my ($time) = `cat $TIMEFILE`; @@ -145,21 +159,33 @@ sub cache_is_too_old { } ## cache_is_too_old sub du_not_running { - return 0 if (-e $LOCKFILE); - return 1; + if (-e $LOCKFILE) { + my ($time) = `cat $TIMEFILE`; + chomp $time; + if ( (time - $time) > ($ENV{interval}*60*60) ) { + # The cache is really old (60xinterval) => Maybe the lockfile wasn't properly deleted. + # Let's delete it. + system("rm $LOCKFILE;"); + return 1; + } else { + return 0; + } + } else { + return 1; + } } + sub munin_exit_done { __munin_exit(0); } ## sub munin_exit_done - sub munin_exit_fail { __munin_exit(1); } ## sub munin_exit_fail # ## -### iNTERNALS FONCTiONS +### INTERNALS FONCTIONS ############################################################################### sub __munin_exit { my $exitcode = shift;