����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.170 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/1630575/root/proc/1630575/root/proc/self/root/usr/lib64/nagios/plugins/extra/ |
Upload File : |
#!/usr/bin/env perl
use extreme;
use File::Slurp;
use Carp;
use Getopt::Long;
use Digest::MD5::File qw(file_md5_hex);
sub help {
say "$0 --directory /path/to/dir --files data\n\n"
. "--directory - path to directory with files\n"
. "--files='file1;size;hash; file2;size;hash'\n"
. "--build - options to build files parameter. \n"
. "--skipundef - do not critical for undefined files, just skip\n";
exit 3;
}
my $exit = 0;
my ( $build, $dir, $files, $help, $skip_undef );
GetOptions(
"directory=s" => \$dir,
"files=s" => \$files,
"help" => \$help,
"build" => \$build,
"skipundef" => \$skip_undef
) or croak "Error in command line arguments";
help if $help;
if ( !$files && !$build ) {
say "--files - required parameter";
help;
}
if ( !$dir ) {
say "--directory - required parameter";
help;
}
croak "directory not exists" unless -d $dir;
my %tt;
my @files = split /\s/, $files unless $build;
for my $in_file (@files) {
my ( $f, $s, $h ) = split /;/, $in_file;
$tt{$f}{size} = $s;
$tt{$f}{md5} = $h;
}
for my $file ( read_dir $dir) {
if ( !$tt{$file} && !$build && !$skip_undef ) {
say "found undefined file $file";
$exit = 2;
next;
}
next if -d "$dir/$file";
my $size = -s "$dir/$file";
my $md5 = file_md5_hex "$dir/$file";
if ($build) {
print "$file;$size;$md5; ";
next;
}
next if $skip_undef;
if ( $tt{$file}{'size'} != $size ) {
$exit = "2";
say "file $file has incorrect size: $size";
}
if ( $tt{$file}{'md5'} ne $md5 ) {
$exit = "2";
say "file $file has incorrect md5summ: $md5";
}
}
say 'OK' if $exit == 0 and !$build;
exit $exit;