Typo
This commit is contained in:
Quentin Garnier 2014-09-12 14:40:24 +02:00
parent c0b8715030
commit 2479fe890c
2 changed files with 31 additions and 31 deletions

View File

@ -29,7 +29,7 @@
# do not wish to do so, delete this exception statement from your version. # do not wish to do so, delete this exception statement from your version.
# #
# For more information : contact@centreon.com # For more information : contact@centreon.com
# Author : Quentin Garnier <qgarnier@merethis.com> # Author : Simon Bomm <sbomm@merethis.com>
# #
#################################################################################### ####################################################################################
@ -103,11 +103,11 @@ sub run {
@array = @$ref_array; @array = @$ref_array;
if (defined($self->{option_results}->{recursive})) { if (defined($self->{option_results}->{recursive})) {
while ($flag == 1) { while ($flag == 1) {
($ref_array, $cpt, $flag) = $self->countFiles(@array); ($ref_array, $cpt, $flag) = $self->countFiles(@array);
$globalCount = $globalCount + $cpt; $globalCount = $globalCount + $cpt;
@array = @$ref_array; @array = @$ref_array;
} }
} }
apps::protocols::ftp::lib::ftp::quit(); apps::protocols::ftp::lib::ftp::quit();
@ -115,41 +115,41 @@ sub run {
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit_code, $self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Number of files : %s", $globalCount)); short_msg => sprintf("Number of files : %s", $globalCount));
$self->{output}->perfdata_add(label => 'files', $self->{output}->perfdata_add(label => 'files',
value => $globalCount, value => $globalCount,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
); min => 0);
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit(); $self->{output}->exit();
} }
sub countFiles { sub countFiles {
my ($self, @array) = @_; my ($self, @array) = @_;
my @files; my @files;
my @subdirs; my @subdirs;
my $size; my $size;
my $cpt = 0; my $cpt = 0;
my $time_result; my $time_result;
my $flag = 0; my $flag = 0;
foreach my $dir (@array) { foreach my $dir (@array) {
if (!(@files = apps::protocols::ftp::lib::ftp::execute($self, command => $map_commands{ls}->{$self->{ssl_or_not}}->{name}, command_args => [$dir]))) { if (!(@files = apps::protocols::ftp::lib::ftp::execute($self, command => $map_commands{ls}->{$self->{ssl_or_not}}->{name}, command_args => [$dir]))) {
$flag = 0; $flag = 0;
} }
foreach my $file (@files) { foreach my $file (@files) {
if (!($time_result = apps::protocols::ftp::lib::ftp::execute($self, command => $map_commands{mdtm}->{$self->{ssl_or_not}}->{name}, command_args => [$file]))) { if (!($time_result = apps::protocols::ftp::lib::ftp::execute($self, command => $map_commands{mdtm}->{$self->{ssl_or_not}}->{name}, command_args => [$file]))) {
push(@subdirs, $file); push(@subdirs, $file);
$flag = 1; $flag = 1;
} }
$cpt++; $cpt++;
} }
$size = @subdirs; $size = @subdirs;
} }
$cpt = $cpt - $size; $cpt = $cpt - $size;
return \@subdirs, $cpt, $flag; return \@subdirs, $cpt, $flag;
} }
1; 1;
@ -158,7 +158,7 @@ __END__
=head1 MODE =head1 MODE
Count files in an FTP directory, cab be recursive Count files in an FTP directory (can be recursive).
=over 8 =over 8

View File

@ -47,10 +47,10 @@ sub new {
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'login' => 'apps::protocols::ftp::mode::login', 'login' => 'apps::protocols::ftp::mode::login',
'commands' => 'apps::protocols::ftp::mode::commands', 'commands' => 'apps::protocols::ftp::mode::commands',
'date' => 'apps::protocols::ftp::mode::date', 'date' => 'apps::protocols::ftp::mode::date',
'filescount'=> 'apps::protocols::ftp::mode::filescount', 'filescount' => 'apps::protocols::ftp::mode::filescount',
); );
return $self; return $self;
} }