From 8da25e681b03d8a8e8c95ef46130ee2cc4c5123c Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 21 May 2012 11:33:16 +0200 Subject: [PATCH 1/3] Update copyright year and add license --- plugins/disk/du-2 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/disk/du-2 b/plugins/disk/du-2 index 16bd1873..bdea7bb9 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; From b6f9a54af7ee8d87811034ff77fbafc2a3b4c964 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 21 May 2012 11:35:22 +0200 Subject: [PATCH 2/3] Remove trailing spaces and make some esthetic cleaning --- plugins/disk/du-2 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/disk/du-2 b/plugins/disk/du-2 index bdea7bb9..4ea0f68a 100755 --- a/plugins/disk/du-2 +++ b/plugins/disk/du-2 @@ -113,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); @@ -121,7 +121,7 @@ daemonize(); # ## -### PUBLiC FONCTiONS +### PUBLIC FONCTIONS ############################################################################### ## Used to create the fork sub daemonize { @@ -149,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`; @@ -162,18 +162,18 @@ sub du_not_running { return 0 if (-e $LOCKFILE); 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; From a2b3e009afc271c7f774bd280182abd3f6a7194f Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 21 May 2012 11:35:33 +0200 Subject: [PATCH 3/3] Bugfix : force lockfile removal if the cache is really too old --- plugins/disk/du-2 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/disk/du-2 b/plugins/disk/du-2 index 4ea0f68a..39787e50 100755 --- a/plugins/disk/du-2 +++ b/plugins/disk/du-2 @@ -159,8 +159,20 @@ 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 {