#!/usr/bin/perl
###############################################################################
#
# checkWebdavDirectory.pl

# check webdav as checkmk local check
#
# need to be executed in directory: /usr/lib/check_mk_agent/local
#
###############################################################################
use strict;

my $critical=95;
my $warning=90;


#get data using df-k: df -k |grep directory
#https://myurl/webdav1 3 100000 55000 45000 45% /mnt/webdav1directoryname

my $usage=-1;

open(IN,"df -k \|grep webdav1directoryname | ");
while(<IN>){
my $line=$_;
chomp($line);
# print "$line\n";
if ($line =~ /\s(\d*)%\s/){
$usage=$1;
}
}
close(IN);
if ($usage > $critical ){
print "2 webdav-directory1 usage=$usage Critical! The usage is $usage\n";
exit 0;
}

if ($usage > $warning ){
print "1 webdav-directory1 usage=$usage Warning! The usage is $usage\n";
exit 0;
}

print "0 webdav-directory1 usage=$usage Ok. The usage is $usage\n";

computer2know :: thank you for your visit :: have a nice day :: © 2022