summaryrefslogtreecommitdiffstats
path: root/contrib/check_backup.pl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 11:16:24 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 11:16:24 (GMT)
commitb15adb7762b6caaecaa83637abfcf5fdb4802092 (patch)
tree64eddbe2aa1a7f98a140be0f7973f05d7a781ae0 /contrib/check_backup.pl
parentc4d5882b9e1d07c7b61091062b7d085fa5f00284 (diff)
downloadmonitoring-plugins-b15adb7762b6caaecaa83637abfcf5fdb4802092.tar.gz
Remove "contrib" plugins
These days, sites such as "Nagios Exchange" are a much better place for publishing plugins not maintained by the Plugins Development Team.
Diffstat (limited to 'contrib/check_backup.pl')
-rw-r--r--contrib/check_backup.pl114
1 files changed, 0 insertions, 114 deletions
diff --git a/contrib/check_backup.pl b/contrib/check_backup.pl
deleted file mode 100644
index 703d242..0000000
--- a/contrib/check_backup.pl
+++ /dev/null
@@ -1,114 +0,0 @@
1#! /usr/bin/perl -wT
2
3# (c)2001 Patrick Greenwell, Stealthgeeks, LLC. (patrick@stealthgeeks.net)
4# Licensed under the GNU GPL
5# http://www.gnu.org/licenses/gpl.html
6
7# check_backup: Checks a directory to see if at least one file was
8# created within a specified period of time that is of equal to or greater
9# than a given size.
10
11# Version 1.0
12# Last Updated: 9/12/01
13
14
15BEGIN {
16 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
17 $runtimedir = $1;
18 $PROGNAME = $2;
19 }
20}
21
22require 5.004;
23use strict;
24use Getopt::Long;
25use vars qw($opt_H $opt_d $opt_s $opt_t $verbose $PROGNAME);
26use lib $main::runtimedir;
27use utils qw($TIMEOUT %ERRORS &print_revision &usage &support &is_error);
28
29sub help ();
30sub print_help ();
31sub print_usage ();
32sub version ();
33sub display_res($$);
34my ($filesize, $answer) = ();
35my $state = $ERRORS{'UNKNOWN'};
36
37# Directory to check.
38my $dir = "/backup/";
39
40# Time period(in seconds)
41my $within = "3600";
42
43# Minimum size of file (in bytes)
44my $minsize = "40000000";
45
46delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
47
48Getopt::Long::Configure('bundling', 'no_ignore_case');
49GetOptions
50 ("V|version" => \&version,
51 "h|help" => \&help,
52 "v|verbose" => \$verbose,
53 "d|directory=s" => \$opt_d,
54 "s|minsize=s" => \$opt_s,
55 "t|timeout=s" => \$opt_t,
56 );
57
58($opt_s) || ($opt_s = shift) || usage("Minimum File size not specified\n");
59usage("File size must be numeric value") unless ($opt_s =~ m/^[0-9]+$/);
60
61(($opt_t) && ($TIMEOUT = $opt_t)) || ($TIMEOUT = 120);
62usage("TIMEOUT must be numeric value") unless ($TIMEOUT =~ m/^[0-9]+$/);
63
64# Don't hang if there are timeout issues
65$SIG{'ALRM'} = sub {
66 print ("ERROR: No response from ftp server (alarm)\n");
67 exit $ERRORS{'UNKNOWN'};
68};
69alarm($TIMEOUT);
70
71# Do stuff
72
73my $time = time;
74
75opendir(THISDIR, "$dir") or die "Can't open directory! $!";
76my @allfiles = grep !/^\./, readdir THISDIR;
77closedir THISDIR;
78while (my $file = $dir . pop @allfiles){
79 my ($size, $mtime) = (stat($file))[7,9];
80 if (((my $a = ($time - $mtime)) <= $within) and ($size >= $opt_s)){
81 display_res("OK: File $file is <= $within and >=$opt_s bytes.\n","OK");
82 }
83}
84
85# If we got here nothing matched....
86display_res("CRITICAL: No files in $dir are <= $within and >= $minsize.", "CRITICAL");
87
88exit;
89
90sub print_usage () {
91 print "Usage: $PROGNAME -s <minimum file size in bytes> -t <timeout> \n";
92}
93
94sub print_help () {
95 print_revision($PROGNAME,'$ Revision: 1.0 $ ');
96 print_usage();
97 support();
98}
99
100sub version () {
101 print_revision($PROGNAME,'$ Revision: 1.0 $ ');
102 exit $ERRORS{'OK'};
103}
104
105sub help () {
106 print_help();
107 exit $ERRORS{'OK'};
108}
109
110sub display_res ($$) {
111 my ($answer, $state) = @_;
112 print $answer;
113 exit $ERRORS{$state};
114}