#!/usr/bin/perl #Einbinden nötiger Module use strict; use warnings; use English; use Getopt::Long; use File::stat; use vars qw($PROGNAME); use lib "/usr/lib64/nagios/plugins"; my $pfad = shift ; local *DIR; my @dateien = (); my $pfadtotal = ''; my $groesse = 0; my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); my ($result, $message, $age, $size, $st); # Verzeichnis lesen opendir(DIR, $pfad); @dateien = readdir(DIR); closedir(DIR); # Addition oder Rekursion fuer alle gelesenen foreach my $datei (@dateien) { next if ($datei eq '.' || $datei eq '..'); print "DATEI: $pfad\n"; $pfadtotal = "$pfad/$datei"; $opt_w = 240000000; $opt_c = 6000000000; $opt_W = 0; $opt_C = 0; $opt_f = ""; if(-d $pfadtotal) { $st = File::stat::stat($pfadtotal); $age = time - $st->mtime; $size = $st->size; $result = 'OK'; #if (($opt_c and $age > $opt_c)) { $result = 'CRITICAL'; #} #elsif (($opt_w and $age > $opt_w)) { $result = 'WARNING'; #} print "FILE_AGE $result: $pfadtotal is $age seconds old \n"; print "VERZEICHNIS: $pfadtotal\n"; } else { print "NNNEEEEIIINNN" } }