mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
[CTOR-304] [Plugin] [InternalPR] New Veeam backup plugin (#4886)
Co-authored-by: Tpo76 <fthepaut@centreon.com>
This commit is contained in:
parent
68a17c7d7c
commit
6d95f1484f
6
.github/scripts/stopwords.t
vendored
6
.github/scripts/stopwords.t
vendored
@ -1,9 +1,15 @@
|
|||||||
--filter-vdom
|
--filter-vdom
|
||||||
--force-counters32
|
--force-counters32
|
||||||
|
Centreon
|
||||||
Fortinet
|
Fortinet
|
||||||
Fortigate
|
Fortigate
|
||||||
|
license-instances-usage-prct
|
||||||
OID
|
OID
|
||||||
oneaccess-sys-mib
|
oneaccess-sys-mib
|
||||||
perfdata
|
perfdata
|
||||||
|
powershell
|
||||||
SNMP
|
SNMP
|
||||||
|
space-usage-prct
|
||||||
SSH
|
SSH
|
||||||
|
SureBackup
|
||||||
|
Veeam
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"dependencies": [
|
||||||
|
"libopenwsman-perl",
|
||||||
|
"libjson-perl",
|
||||||
|
"libdatetime-perl"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"pkg_name": "centreon-plugin-Applications-Backup-Veeam-Wsman",
|
||||||
|
"pkg_summary": "Centreon Plugin",
|
||||||
|
"plugin_name": "centreon_veeam_backup_wsman.pl",
|
||||||
|
"files": [
|
||||||
|
"centreon/plugins/script_wsman.pm",
|
||||||
|
"centreon/plugins/wsman.pm",
|
||||||
|
"apps/backup/veeam/wsman/",
|
||||||
|
"centreon/common/powershell/functions.pm",
|
||||||
|
"centreon/common/powershell/veeam/"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"dependencies": [
|
||||||
|
"perl(openwsman)",
|
||||||
|
"perl(JSON::XS)",
|
||||||
|
"perl(POSIX)"
|
||||||
|
]
|
||||||
|
}
|
312
src/apps/backup/veeam/wsman/mode/jobstatus.pm
Normal file
312
src/apps/backup/veeam/wsman/mode/jobstatus.pm
Normal file
@ -0,0 +1,312 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::jobstatus;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::common::powershell::veeam::jobstatus;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($job_type $job_result);
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'status: ' . $self->{result_values}->{status} . ' [type: ' . $self->{result_values}->{type} . ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_long_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'started since: ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_long_calc {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
|
||||||
|
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||||
|
$self->{result_values}->{elapsed} = $options{new_datas}->{$self->{instance} . '_elapsed'};
|
||||||
|
$self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'};
|
||||||
|
$self->{result_values}->{is_running} = $options{new_datas}->{$self->{instance} . '_is_running'};
|
||||||
|
$self->{result_values}->{is_continuous} = $options{new_datas}->{$self->{instance} . '_is_continuous'};
|
||||||
|
|
||||||
|
return -11 if ($self->{result_values}->{is_running} != 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0 },
|
||||||
|
{ name => 'job', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All jobs are ok', skipped_code => { -11 => 1, -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'total', nlabel => 'jobs.detected.count', set => {
|
||||||
|
key_values => [ { name => 'total' } ],
|
||||||
|
output_template => 'Total jobs: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{job} = [
|
||||||
|
{ label => 'status', threshold => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'status' }, { name => 'display' },
|
||||||
|
{ name => 'type' }, { name => 'is_running' },
|
||||||
|
{ name => 'is_continuous' }, { name => 'scheduled' }
|
||||||
|
],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'long', threshold => 0, set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'status' }, { name => 'display' },
|
||||||
|
{ name => 'elapsed' }, { name => 'type' },
|
||||||
|
{ name => 'is_running' }, { name => 'is_continuous' }
|
||||||
|
],
|
||||||
|
closure_custom_calc => $self->can('custom_long_calc'),
|
||||||
|
closure_custom_output => $self->can('custom_long_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'exclude-name:s' => { name => 'exclude_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' },
|
||||||
|
'filter-end-time:s' => { name => 'filter_end_time', default => 86400 },
|
||||||
|
'filter-start-time:s' => { name => 'filter_start_time' },
|
||||||
|
'ok-status:s' => { name => 'ok_status', default => '' },
|
||||||
|
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||||
|
'critical-status:s' => { name => 'critical_status', default => '%{is_running} == 0 and not %{status} =~ /success/i' },
|
||||||
|
'warning-long:s' => { name => 'warning_long' },
|
||||||
|
'critical-long:s' => { name => 'critical_long' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$self->change_macros(macros => ['ok_status', 'warning_status', 'critical_status', 'warning_long', 'critical_long']);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_job_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Job '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::jobstatus::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'jobstatus',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{jobstatus}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{jobstatus}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
# { "name": "backup 1", "type": 0, "isRunning": false, "scheduled": true, "isContinuous": 0, "sessions": { "result": 0, "creationTimeUTC": 1512875246.2, "endTimeUTC": 1512883615.377 } },
|
||||||
|
# { "name": "backup 2", "type": 0, "isRunning": false, "scheduled": true, "isContinuous": 0, "sessions": { "result": -10, "creationTimeUTC": "", "endTimeUTC": "" } },
|
||||||
|
# { "name": "backup 3", "type": 1, "isRunning": true, "scheduled": true, "isContinuous": 0, "sessions": { "result": 0, "creationTimeUTC": 1513060425.027, "endTimeUTC": -2208992400 } }
|
||||||
|
#]
|
||||||
|
|
||||||
|
$self->{global} = { total => 0 };
|
||||||
|
$self->{job} = {};
|
||||||
|
my $current_time = time();
|
||||||
|
foreach my $job (@$decoded) {
|
||||||
|
my $sessions = ref($job->{sessions}) eq 'ARRAY' ? $job->{sessions} : [ $job->{sessions} ];
|
||||||
|
my $session = $sessions->[0];
|
||||||
|
if ($job->{isContinuous} == 1 && defined($sessions->[1])) {
|
||||||
|
$session = $sessions->[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$session->{creationTimeUTC} =~ s/,/\./;
|
||||||
|
$session->{endTimeUTC} =~ s/,/\./;
|
||||||
|
|
||||||
|
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$job->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
next if (defined($self->{option_results}->{exclude_name}) && $self->{option_results}->{exclude_name} ne '' &&
|
||||||
|
$job->{name} =~ /$self->{option_results}->{exclude_name}/);
|
||||||
|
|
||||||
|
my $job_type = defined($job_type->{ $job->{type} }) ? $job_type->{ $job->{type} } : 'unknown';
|
||||||
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$job_type !~ /$self->{option_results}->{filter_type}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': no matching filter type.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_end_time}) && $self->{option_results}->{filter_end_time} =~ /[0-9]+/ &&
|
||||||
|
$session->{endTimeUTC} =~ /[0-9]+/ && $session->{endTimeUTC} > 0 && $session->{endTimeUTC} < $current_time - $self->{option_results}->{filter_end_time}) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': end time too old.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_start_time}) && $self->{option_results}->{filter_start_time} =~ /[0-9]+/ &&
|
||||||
|
$session->{creationTimeUTC} =~ /[0-9]+/ && $session->{creationTimeUTC} < $current_time - $self->{option_results}->{filter_start_time}) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': start time too old.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $elapsed_time;
|
||||||
|
$elapsed_time = $current_time - $session->{creationTimeUTC} if ($session->{creationTimeUTC} =~ /[0-9]/);
|
||||||
|
|
||||||
|
#is_running = 2 (never running)
|
||||||
|
$self->{job}->{ $job->{name} } = {
|
||||||
|
display => $job->{name},
|
||||||
|
elapsed => $elapsed_time,
|
||||||
|
type => $job_type,
|
||||||
|
is_continuous => $job->{isContinuous},
|
||||||
|
is_running => $job->{isRunning} =~ /True|1/ ? 1 : ($session->{creationTimeUTC} !~ /[0-9]/ ? 2 : 0),
|
||||||
|
scheduled => $job->{scheduled} =~ /True|1/i ? 1 : 0,
|
||||||
|
status => defined($job_result->{ $session->{result} }) && $job_result->{ $session->{result} } ne '' ?
|
||||||
|
$job_result->{ $session->{result} } : '-'
|
||||||
|
};
|
||||||
|
$self->{global}->{total}++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check job status.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter job name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--exclude-name>
|
||||||
|
|
||||||
|
Exclude job name (regexp can be used).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter job type (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--filter-start-time>
|
||||||
|
|
||||||
|
Filter job with start time greater than current time less value in seconds.
|
||||||
|
|
||||||
|
=item B<--filter-end-time>
|
||||||
|
|
||||||
|
Filter job with end time greater than current time less value in seconds (Default: 86400).
|
||||||
|
|
||||||
|
=item B<--ok-status>
|
||||||
|
|
||||||
|
Set ok threshold for status.
|
||||||
|
Can used special variables like: %{display}, %{status}, %{type}, %{is_running}, %{scheduled}.
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{display}, %{status}, %{type}, %{is_running}, %{scheduled}.
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: '%{is_running} == 0 and not %{status} =~ /Success/i').
|
||||||
|
Can used special variables like: %{display}, %{status}, %{type}, %{is_running}, %{scheduled}.
|
||||||
|
|
||||||
|
=item B<--warning-long>
|
||||||
|
|
||||||
|
Set warning threshold for long jobs.
|
||||||
|
Can used special variables like: %{display}, %{status}, %{type}, %{elapsed}.
|
||||||
|
|
||||||
|
=item B<--critical-long>
|
||||||
|
|
||||||
|
Set critical threshold for long jobs.
|
||||||
|
Can used special variables like: %{display}, %{status}, %{type}, %{elapsed}.
|
||||||
|
|
||||||
|
=item B<--warning-total>
|
||||||
|
|
||||||
|
Set warning threshold for total jobs.
|
||||||
|
|
||||||
|
=item B<--critical-total>
|
||||||
|
|
||||||
|
Set critical threshold for total jobs.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
318
src/apps/backup/veeam/wsman/mode/licenses.pm
Normal file
318
src/apps/backup/veeam/wsman/mode/licenses.pm
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::licenses;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::common::powershell::veeam::licenses;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($license_type $license_status);
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
use POSIX;
|
||||||
|
|
||||||
|
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
|
||||||
|
my $unitdiv_long = { s => 'seconds', w => 'weeks', d => 'days', h => 'hours', m => 'minutes' };
|
||||||
|
|
||||||
|
sub custom_expires_perfdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{output}->perfdata_add(
|
||||||
|
nlabel => $self->{nlabel} . '.' . $unitdiv_long->{ $self->{instance_mode}->{option_results}->{unit} },
|
||||||
|
unit => $self->{instance_mode}->{option_results}->{unit},
|
||||||
|
instances => $self->{result_values}->{to},
|
||||||
|
value => floor($self->{result_values}->{expires_seconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||||
|
min => 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_expires_threshold {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return $self->{perfdata}->threshold_check(
|
||||||
|
value => floor($self->{result_values}->{expires_seconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
|
||||||
|
threshold => [
|
||||||
|
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||||
|
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' },
|
||||||
|
{ label => 'unknown-'. $self->{thlabel}, exit_litteral => 'unknown' }
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'status: ' . $self->{result_values}->{status};
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_license_instances_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'instances total: %s used: %s (%.2f%%) free: %s (%.2f%%)',
|
||||||
|
$self->{result_values}->{instances_total},
|
||||||
|
$self->{result_values}->{instances_used},
|
||||||
|
$self->{result_values}->{instances_prct_used},
|
||||||
|
$self->{result_values}->{instances_free},
|
||||||
|
$self->{result_values}->{instances_prct_free}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_license_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"License '%s' [type: %s] ",
|
||||||
|
$options{instance_value}->{to},
|
||||||
|
$options{instance_value}->{type}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0 },
|
||||||
|
{ name => 'licenses', type => 1, cb_prefix_output => 'prefix_license_output', message_multiple => 'All licenses are ok', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'total', nlabel => 'licenses.total.count', set => {
|
||||||
|
key_values => [ { name => 'total' } ],
|
||||||
|
output_template => 'Number of licenses: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{licenses} = [
|
||||||
|
{ label => 'status', type => 2, critical_default => '%{status} =~ /expired|invalid/i', set => {
|
||||||
|
key_values => [ { name => 'to' }, { name => 'status' }, { name => 'type' } ],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'expires', nlabel => 'license.expires', set => {
|
||||||
|
key_values => [ { name => 'expires_seconds' }, { name => 'expires_human' }, { name => 'to' } ],
|
||||||
|
output_template => 'expires in %s',
|
||||||
|
output_use => 'expires_human',
|
||||||
|
closure_custom_perfdata => $self->can('custom_expires_perfdata'),
|
||||||
|
closure_custom_threshold_check => $self->can('custom_expires_threshold')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'license-instances-usage', nlabel => 'license.instances.usage.count', set => {
|
||||||
|
key_values => [ { name => 'instances_used' }, { name => 'instances_free' }, { name => 'instances_prct_used' }, { name => 'instances_prct_free' }, { name => 'instances_total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_license_instances_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'instances_total', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'license-instances-free', display_ok => 0, nlabel => 'license.instances.free.count', set => {
|
||||||
|
key_values => [ { name => 'instances_free' }, { name => 'instances_used' }, { name => 'instances_prct_used' }, { name => 'instances_prct_free' }, { name => 'instances_total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_license_instances_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'instances_total', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'license-instances-usage-prct', display_ok => 0, nlabel => 'license.instances.usage.percentage', set => {
|
||||||
|
key_values => [ { name => 'instances_prct_used' }, { name => 'instances_used' }, { name => 'instances_free' }, { name => 'instances_prct_free' }, { name => 'instances_total' } ],
|
||||||
|
closure_custom_output => $self->can('custom_license_instances_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-to:s' => { name => 'filter_to' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' },
|
||||||
|
'filter-status:s' => { name => 'filter_status' },
|
||||||
|
'unit:s' => { name => 'unit', default => 's' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
|
||||||
|
$self->{option_results}->{unit} = 's';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::licenses::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'licenses',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{licenses}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{licenses}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
# {"licensed_instances":7150,"expiration_time":"1632960000","type":0,"licensed_to":"Centreon Services","status":0,"used_instances":165}
|
||||||
|
#]
|
||||||
|
|
||||||
|
$self->{global} = { total => 0 };
|
||||||
|
$self->{licenses} = {};
|
||||||
|
my $current_time = time();
|
||||||
|
foreach my $license (@$decoded) {
|
||||||
|
if (defined($self->{option_results}->{filter_to}) && $self->{option_results}->{filter_to} ne '' &&
|
||||||
|
$license->{licensed_to} !~ /$self->{option_results}->{filter_to}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping license '" . $license->{licensed_to} . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$license_type->{ $license->{type} } !~ /$self->{option_results}->{filter_type}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping license '" . $license->{licensed_to} . "': no matching filter type.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' &&
|
||||||
|
$license_status->{ $license->{status} } !~ /$self->{option_results}->{filter_status}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping license '" . $license->{licensed_to} . "': no matching filter type.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} } = {
|
||||||
|
to => $license->{licensed_to},
|
||||||
|
type => $license_type->{ $license->{type} },
|
||||||
|
status => $license_status->{ $license->{status} }
|
||||||
|
};
|
||||||
|
if (defined($license->{expiration_time})) {
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{expires_seconds} = $license->{expiration_time} - $current_time;
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{expires_human} = centreon::plugins::misc::change_seconds(
|
||||||
|
value => $self->{licenses}->{ $license->{licensed_to} }->{expires_seconds}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (defined($license->{licensed_instances}) && $license->{licensed_instances} > 0) {
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{instances_total} = $license->{licensed_instances};
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{instances_used} = $license->{used_instances};
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{instances_free} = $license->{licensed_instances} - $license->{used_instances};
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{instances_prct_used} = $license->{used_instances} * 100 / $license->{licensed_instances};
|
||||||
|
$self->{licenses}->{ $license->{licensed_to} }->{instances_prct_free} = 100 - $self->{licenses}->{ $license->{licensed_to} }->{instances_prct_used};
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{global}->{total}++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check licenses.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-to>
|
||||||
|
|
||||||
|
Filter licenses by person/organization (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter licenses by type (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--filter-status>
|
||||||
|
|
||||||
|
Filter licenses by status (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{to}, %{status}, %{type}.
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: '%{status} =~ /expired|invalid/i').
|
||||||
|
Can used special variables like: %{to}, %{status}, %{type}.
|
||||||
|
|
||||||
|
=item B<--unit>
|
||||||
|
|
||||||
|
Select the unit for expires threshold. May be 's' for seconds, 'm' for minutes,
|
||||||
|
'h' for hours, 'd' for days, 'w' for weeks. Default is seconds.
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'total', 'expires', 'license-instances-usage', 'license-instances-free', 'license-instances-usage-prct'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
156
src/apps/backup/veeam/wsman/mode/listjobs.pm
Normal file
156
src/apps/backup/veeam/wsman/mode/listjobs.pm
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::listjobs;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($job_type);
|
||||||
|
use centreon::common::powershell::veeam::listjobs;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->manage_selection(%options);
|
||||||
|
foreach (sort keys %{$self->{jobs}}) {
|
||||||
|
$self->{output}->output_add(long_msg => "'" . $_ . "' [type = " . $self->{jobs}->{$_}->{type} . "]");
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => 'List jobs:'
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_format {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{output}->add_disco_format(elements => ['name', 'type']);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_show {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->manage_selection(%options);
|
||||||
|
foreach (sort keys %{$self->{jobs}}) {
|
||||||
|
$self->{output}->add_disco_entry(
|
||||||
|
name => $_,
|
||||||
|
type => $self->{jobs}->{$_}->{type}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::listjobs::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'listjobs',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{listjobs}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{listjobs}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{jobs} = {};
|
||||||
|
foreach my $job (@$decoded) {
|
||||||
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$job->{name} !~ /$self->{option_results}->{filter_name}/i) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': no matching filter name", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{jobs}->{ $job->{name} } = {
|
||||||
|
type => defined($job_type->{ $job->{type} }) ? $job_type->{ $job->{type} } : 'unknown'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
List jobs.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter job name (can be a regexp).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
156
src/apps/backup/veeam/wsman/mode/listrepositories.pm
Normal file
156
src/apps/backup/veeam/wsman/mode/listrepositories.pm
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::listrepositories;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($repository_type $repository_status);
|
||||||
|
use centreon::common::powershell::veeam::repositories;
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $repos = $self->manage_selection(%options);
|
||||||
|
foreach (@$repos) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
'[name: %s][type: %s][status: %s][totalSpace: %s]',
|
||||||
|
$_->{name},
|
||||||
|
$_->{type},
|
||||||
|
$_->{status},
|
||||||
|
$_->{totalSpace}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => 'List repositories:'
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_format {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{output}->add_disco_format(elements => ['name', 'type', 'status', 'totalSpace']);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub disco_show {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $repos = $self->manage_selection(%options);
|
||||||
|
foreach (@$repos) {
|
||||||
|
$self->{output}->add_disco_entry(%$_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::repositories::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'repositories',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{repositories}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{repositories}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $repos = [];
|
||||||
|
foreach (@$decoded) {
|
||||||
|
push @$repos, {
|
||||||
|
name => $_->{name},
|
||||||
|
type => defined($repository_type->{ $_->{type} }) ? $repository_type->{ $_->{type} } : 'unknown',
|
||||||
|
status => defined($repository_status->{ $_->{status} }) ? $repository_status->{ $_->{status} } : 'unknown',
|
||||||
|
totalSpace => $_->{totalSpace}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return $repos;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
List repositories.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
272
src/apps/backup/veeam/wsman/mode/repositories.pm
Normal file
272
src/apps/backup/veeam/wsman/mode/repositories.pm
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::repositories;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::common::powershell::veeam::repositories;
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($repository_type $repository_status);
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"status: %s",
|
||||||
|
$self->{result_values}->{status}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_space_usage_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||||
|
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||||
|
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||||
|
return sprintf(
|
||||||
|
"space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)",
|
||||||
|
$total_size_value . " " . $total_size_unit,
|
||||||
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub repository_long_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"checking repository '%s' [type: %s]",
|
||||||
|
$options{instance_value}->{name},
|
||||||
|
$options{instance_value}->{type}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_repository_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"repository '%s' [type: %s] ",
|
||||||
|
$options{instance_value}->{name},
|
||||||
|
$options{instance_value}->{type}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'repositories', type => 3, cb_prefix_output => 'prefix_repository_output', cb_long_output => 'repository_long_output',
|
||||||
|
indent_long_output => ' ', message_multiple => 'All repositories are ok',
|
||||||
|
group => [
|
||||||
|
{ name => 'status', type => 0, skipped_code => { -10 => 1 } },
|
||||||
|
{ name => 'space', type => 0, skipped_code => { -10 => 1 } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{status} = [
|
||||||
|
{
|
||||||
|
label => 'status',
|
||||||
|
type => 2,
|
||||||
|
critical_default => 'not %{status} =~ /ordinal|maintenance/i',
|
||||||
|
set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'status' }, { name => 'name' }, { name => 'type' }
|
||||||
|
],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{space} = [
|
||||||
|
{ label => 'space-usage', nlabel => 'repository.space.usage.bytes', set => {
|
||||||
|
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ],
|
||||||
|
closure_custom_output => $self->can('custom_space_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'space-usage-free', display_ok => 0, nlabel => 'repository.space.free.bytes', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ],
|
||||||
|
closure_custom_output => $self->can('custom_space_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'space-usage-prct', display_ok => 0, nlabel => 'repository.space.usage.percentage', set => {
|
||||||
|
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' }, { name => 'name' } ],
|
||||||
|
closure_custom_output => $self->can('custom_space_usage_output'),
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'exclude-name:s' => { name => 'exclude_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::repositories::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'repositories',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{repositories}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{repositories}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
# {"name": "repo 1", "type": 10, "status": 0, "totalSpace": 100000000, "freeSpace": 1000000 },
|
||||||
|
# {"name": "repo 2", "type": 11, "status": 0, "totalSpace": 250000000, "freeSpace": 1000000 }
|
||||||
|
#]
|
||||||
|
|
||||||
|
$self->{repositories} = {};
|
||||||
|
foreach my $repo (@$decoded) {
|
||||||
|
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$repo->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
next if (defined($self->{option_results}->{exclude_name}) && $self->{option_results}->{exclude_name} ne '' &&
|
||||||
|
$repo->{name} =~ /$self->{option_results}->{exclude_name}/);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$repo->{type} !~ /$self->{option_results}->{filter_type}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping repository '$repo->{name}'.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $type = defined($repository_type->{ $repo->{type} }) ? $repository_type->{ $repo->{type} } : 'unknown';
|
||||||
|
$self->{repositories}->{ $repo->{name} } = {
|
||||||
|
name => $repo->{name},
|
||||||
|
type => $type,
|
||||||
|
status => {
|
||||||
|
name => $repo->{name},
|
||||||
|
type => $type,
|
||||||
|
status => defined($repository_status->{ $repo->{status} }) ? $repository_status->{ $repo->{status} } : 'unknown'
|
||||||
|
},
|
||||||
|
space => {
|
||||||
|
name => $repo->{name},
|
||||||
|
total => $repo->{totalSpace},
|
||||||
|
free => $repo->{freeSpace},
|
||||||
|
used => $repo->{totalSpace} - $repo->{freeSpace},
|
||||||
|
prct_used => 100 - ($repo->{freeSpace} * 100 / $repo->{totalSpace}),
|
||||||
|
prct_free => $repo->{freeSpace} * 100 / $repo->{totalSpace}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check repositories.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter repositories by name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--exclude-name>
|
||||||
|
|
||||||
|
Exclude repositories by name (regexp can be used).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter repositories by type (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{status}, %{name}, %{type}.
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: 'not %{status} =~ /ordinal|maintenance/i').
|
||||||
|
Can used special variables like: %{status}, %{name}, %{type}.
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'space-usage', 'space-usage-free', 'space-usage-prct'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
167
src/apps/backup/veeam/wsman/mode/resources/types.pm
Normal file
167
src/apps/backup/veeam/wsman/mode/resources/types.pm
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2023 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::resources::types;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Exporter;
|
||||||
|
|
||||||
|
our $job_type;
|
||||||
|
our $job_result;
|
||||||
|
our $job_tape_type;
|
||||||
|
our $job_tape_result;
|
||||||
|
our $job_tape_state;
|
||||||
|
our $license_type;
|
||||||
|
our $license_status;
|
||||||
|
our $repository_type;
|
||||||
|
our $repository_status;
|
||||||
|
|
||||||
|
our @ISA = qw(Exporter);
|
||||||
|
our @EXPORT_OK = qw(
|
||||||
|
$job_type $job_result $job_tape_type $job_tape_result $job_tape_state
|
||||||
|
$license_type $license_status
|
||||||
|
$repository_type $repository_status
|
||||||
|
);
|
||||||
|
|
||||||
|
$job_type = {
|
||||||
|
0 => 'Backup', 1 => 'Replica', 2 => 'Copy',
|
||||||
|
3 => 'DRV', 4 => 'RestoreVm', 5 => 'RestoreVmFiles',
|
||||||
|
6 => 'RestoreFiles', 7 => 'Failover', 8 => 'QuickMigration',
|
||||||
|
9 => 'UndoFailover', 10 => 'FileLevelRestore',
|
||||||
|
11 => 'LinuxFileLevelRestore', 12 => 'InstantRecovery',
|
||||||
|
13 => 'RestoreHdd', 14 => 'Failback', 15 => 'PermanentFailover',
|
||||||
|
16 => 'UndoFailback', 17 => 'CommitFailback', 18 => 'ShellRun',
|
||||||
|
19 => 'VolumesDiscover', 20 => 'HvCtpRescan',
|
||||||
|
21 => 'CatCleanup', 22 => 'SanRescan', 23 => 'CreateSanSnapshot',
|
||||||
|
24 => 'FileTapeBackup', 25 => 'FileTapeRestore',
|
||||||
|
26 => 'TapeValidate', 27 => 'TapeInventory', 28 => 'VmTapeBackup',
|
||||||
|
29 => 'VmTapeRestore', 30 => 'SanMonitor', 31 => 'DeleteSanSnapshot',
|
||||||
|
32 => 'TapeErase', 33 => 'TapeEject', 34 => 'TapeExport',
|
||||||
|
35 => 'TapeImport', 36 => 'TapeCatalog', 37 => 'TapeLibrariesDiscover',
|
||||||
|
38 => 'PowerShellScript', 39 => 'VmReconfig', 40 => 'VmStart',
|
||||||
|
41 => 'VcdVAppRestore', 42 => 'VcdVmRestore', 46 => 'HierarchyScan',
|
||||||
|
47 => 'ViVmConsolidation', 48 => 'ApplicationLevelRestore',
|
||||||
|
50 => 'RemoteReplica', 51 => 'BackupSync', 52 => 'SqlLogBackup',
|
||||||
|
53 => 'LicenseAutoUpdate', 54 => 'OracleLogBackup',
|
||||||
|
55 => 'TapeMarkAsFree', 56 => 'TapeDeleteFromLibrary',
|
||||||
|
57 => 'TapeMoveToMediaPool', 58 => 'TapeCatalogueDecrypted',
|
||||||
|
63 => 'SimpleBackupCopyWorker', 64 => 'QuickMigrationCheck',
|
||||||
|
65 => 'BackupCopy', 100 => 'ConfBackup',
|
||||||
|
101 => 'ConfRestore', 102 => 'ConfResynchronize',
|
||||||
|
103 => 'WaGlobalDedupFill', 104 => 'DatabaseMaintenance',
|
||||||
|
105 => 'RepositoryMaintenance', 106 => 'InfrastructureRescan',
|
||||||
|
200 => 'HvLabDeploy', 201 => 'HvLabDelete', 202 => 'FailoverPlan',
|
||||||
|
203 => 'UndoFailoverPlan', 204 => 'FailoverPlanTask',
|
||||||
|
205 => 'UndoFailoverPlanTask', 206 => 'PlannedFailover',
|
||||||
|
207 => 'ViLabDeploy', 208 => 'ViLabDelete', 209 => 'ViLabStart',
|
||||||
|
300 => 'Cloud', 301 => 'CloudApplDeploy',
|
||||||
|
302 => 'HardwareQuotasProcessing', 303 => 'ReconnectVpn',
|
||||||
|
304 => 'DisconnectVpn', 305 => 'OrchestratedTask',
|
||||||
|
306 => 'ViReplicaRescan', 307 => 'ExternalRepositoryMaintenance',
|
||||||
|
308 => 'DeleteBackup', 309 => 'CloudProviderRescan',
|
||||||
|
401 => 'AzureApplDeploy', 500 => 'TapeTenantRestore',
|
||||||
|
666 => 'Unknown', 4000 => 'EndpointBackup',
|
||||||
|
4005 => 'EndpointRestore', 4010 => 'BackupCacheSync',
|
||||||
|
4020 => 'EndpointSqlLogBackup', 4021 => 'EndpointOracleLogBackup',
|
||||||
|
4030 => 'OracleRMANBackup', 4031 => 'SapBackintBackup',
|
||||||
|
5000 => 'CloudBackup', 6000 => 'RestoreVirtualDisks',
|
||||||
|
6001 => 'RestoreAgentVolumes', 7000 => 'InfraItemSave',
|
||||||
|
7001 => 'InfraItemUpgrade', 7002 => 'InfraItemDelete',
|
||||||
|
7003 => 'AzureWinProxySave', 8000 => 'FileLevelRestoreByEnterprise',
|
||||||
|
9000 => 'RepositoryEvacuate', 10000 => 'LogsExport',
|
||||||
|
10001 => 'InfraStatistic', 11000 => 'AzureVmRestore',
|
||||||
|
12000 => 'EpAgentManagement', 12001 => 'EpAgentDiscoveryObsolete',
|
||||||
|
12002 => 'EpAgentPolicy', 12003 => 'EpAgentBackup',
|
||||||
|
12004 => 'EpAgentTestCreds', 12005 => 'EpAgentDiscovery',
|
||||||
|
12006 => 'EpAgentDeletedRetention', 13000 => 'NasBackup',
|
||||||
|
13001 => 'NasBackupBrowse', 13002 => 'NasRestore',
|
||||||
|
14000 => 'VmbApiPolicyTempJob', 15000 => 'ExternalInfrastructureRescan',
|
||||||
|
16000 => 'AmazonRestore', 17000 => 'StagedRestore',
|
||||||
|
18000 => 'ArchiveBackup', 18001 => 'ArchiveRehydration',
|
||||||
|
18002 => 'ArchiveDownload', 19000 => 'HvStagedRestore',
|
||||||
|
20000 => 'VbkExport', 21000 => 'GuestScriptingConnect'
|
||||||
|
};
|
||||||
|
|
||||||
|
$job_result = {
|
||||||
|
0 => 'success',
|
||||||
|
1 => 'warning',
|
||||||
|
2 => 'failed',
|
||||||
|
-1 => 'none',
|
||||||
|
-10 => 'never'
|
||||||
|
};
|
||||||
|
|
||||||
|
$job_tape_type = {
|
||||||
|
0 => 'BackupToTape', 1 => 'FileToTape',
|
||||||
|
2 => 'TapeCatalog', 3 => 'TapeEject',
|
||||||
|
4 => 'TapeErase', 5 => 'TapeExport',
|
||||||
|
6 => 'TapeImport', 7 => 'TapeInventory',
|
||||||
|
8 => 'TapeRescan', 9 => 'Backup',
|
||||||
|
10 => 'BackupSync', 11 => 'EndpointBackup',
|
||||||
|
12 => 'ConfigurationBackup'
|
||||||
|
};
|
||||||
|
|
||||||
|
$job_tape_result = {
|
||||||
|
0 => 'none', 1 => 'success', 2 => 'warning', 3 => 'failed'
|
||||||
|
};
|
||||||
|
|
||||||
|
$job_tape_state = {
|
||||||
|
0 => 'Stopped', 1 => 'Starting', 2 => 'Stopping',
|
||||||
|
3 => 'Working', 4 => 'Pausing', 5 => 'Resuming',
|
||||||
|
6 => 'WaitingTape', 7 => 'Idle', 8 => 'Postprocessing',
|
||||||
|
9 => 'WaitingRepository', 10 => 'Pending'
|
||||||
|
};
|
||||||
|
|
||||||
|
$license_type = {
|
||||||
|
0 => 'rental', 1 => 'perpetual',
|
||||||
|
2 => 'subscription', 3 => 'evaluation',
|
||||||
|
4 => 'free', 5 => 'NFR', 6 => 'empty'
|
||||||
|
};
|
||||||
|
|
||||||
|
$license_status = {
|
||||||
|
0 => 'valid', 1 => 'expired', 2 => 'invalid'
|
||||||
|
};
|
||||||
|
|
||||||
|
$repository_type = {
|
||||||
|
0 => 'WinLocal', 1 => 'LinuxLocal',
|
||||||
|
2 => 'CifsShare', 3 => 'DDBoost',
|
||||||
|
4 => 'Cloud', 5 => 'HPStoreOnce',
|
||||||
|
6 => 'ExaGrid', 7 => 'Foreign',
|
||||||
|
8 => 'SanSnapshotOnly', 9 => 'HPStoreOnceIntegration',
|
||||||
|
10 => 'ExtendableRepository', 11 => 'AmazonS3',
|
||||||
|
12 => 'AzureStorage', 13 => 'AmazonS3Glacier',
|
||||||
|
14 => 'AmazonS3Compatible', 15 => 'Tape',
|
||||||
|
16 => 'AmazonS3External', 17 => 'AzureStorageExternal',
|
||||||
|
18 => 'Quantum', 19 => 'IbmCosS3',
|
||||||
|
20 => 'Nfs', 21 => 'AzureDataBox',
|
||||||
|
22 => 'PlatformServiceExternal', 23 => 'GoogleCloudStorage',
|
||||||
|
24 => 'AzureArchiveStorage', 25 => 'AmazonSnowball',
|
||||||
|
26 => 'GoogleCloudStorageExternal', 27 => 'SmartObjectS3',
|
||||||
|
31 => 'AmazonS3GlacierExternal', 32 => 'GoogleArchiveStorageExternal',
|
||||||
|
33 => 'AzureArchiveStorageExternal'
|
||||||
|
};
|
||||||
|
|
||||||
|
$repository_status = {
|
||||||
|
0 => 'ordinal', 1 => 'maintenancePending',
|
||||||
|
2 => 'maintenance', 4 => 'evacuating',
|
||||||
|
8 => 'sealed'
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
234
src/apps/backup/veeam/wsman/mode/tapejobs.pm
Normal file
234
src/apps/backup/veeam/wsman/mode/tapejobs.pm
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::tapejobs;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::common::powershell::veeam::tapejobs;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($job_tape_type $job_tape_result $job_tape_state);
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"last result: '%s' [type: '%s'][last state: '%s']",
|
||||||
|
$self->{result_values}->{last_result},
|
||||||
|
$self->{result_values}->{type},
|
||||||
|
$self->{result_values}->{last_state},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_job_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Tape job '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0 },
|
||||||
|
{ name => 'job', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All jobs are ok', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'total', nlabel => 'tapejobs.total.count', set => {
|
||||||
|
key_values => [ { name => 'total' } ],
|
||||||
|
output_template => 'total jobs: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{job} = [
|
||||||
|
{ label => 'status', type => 2, critical => '%{enabled} == 1 and not %{last_result} =~ /Success|None/i', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'display' }, { name => 'enabled' },
|
||||||
|
{ name => 'type' }, { name => 'last_result' },
|
||||||
|
{ name => 'last_state' }
|
||||||
|
],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'exclude-name:s' => { name => 'exclude_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::tapejobs::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'tapejobs',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{tapejobs}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{tapejobs}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
# { name: 'xxxx', type: 0, Enabled: True, lastResult: 0, lastState: 0 },
|
||||||
|
# { name: 'xxxx', type: 1, Enabled: True, lastResult: 1, lastState: 1 }
|
||||||
|
#]
|
||||||
|
|
||||||
|
$self->{global} = { total => 0 };
|
||||||
|
$self->{job} = {};
|
||||||
|
foreach my $job (@$decoded) {
|
||||||
|
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$job->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
next if (defined($self->{option_results}->{exclude_name}) && $self->{option_results}->{exclude_name} ne '' &&
|
||||||
|
$job->{name} =~ /$self->{option_results}->{exclude_name}/);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$job->{type} !~ /$self->{option_results}->{filter_type}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': no matching filter type.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
# Sometimes we may get such JSON: [{"lastResult":null,"name":null,"lastState":null,"type":null,"enabled":null}]
|
||||||
|
if (!defined($job->{name})) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping nulled job (empty json)", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{job}->{ $job->{name} } = {
|
||||||
|
display => $job->{name},
|
||||||
|
type => $job_tape_type->{ $job->{type} },
|
||||||
|
enabled => $job->{enabled} =~ /True|1/ ? 1 : 0,
|
||||||
|
last_result => $job_tape_result->{ $job->{lastResult} },
|
||||||
|
last_state => $job_tape_state->{ $job->{lastState} }
|
||||||
|
};
|
||||||
|
$self->{global}->{total}++;
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{job}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No tape jobs found. Review filters. More infos with --debug option");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check tape jobs status.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter job name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--exclude-name>
|
||||||
|
|
||||||
|
Exclude job name (regexp can be used).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter job type (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--unknown-status>
|
||||||
|
|
||||||
|
Set unknown threshold for status (Default: '')
|
||||||
|
Can used special variables like: %{display}, %{enabled}, %{type}, %{last_result}, %{last_state}.
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status (Default: '')
|
||||||
|
Can used special variables like: %{display}, %{enabled}, %{type}, %{last_result}, %{last_state}.
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: '%{enabled} == 1 and not %{last_result} =~ /Success|None/i').
|
||||||
|
Can used special variables like: %{display}, %{enabled}, %{type}, %{last_result}, %{last_state}.
|
||||||
|
|
||||||
|
=item B<--warning-total>
|
||||||
|
|
||||||
|
Set warning threshold for total jobs.
|
||||||
|
|
||||||
|
=item B<--critical-total>
|
||||||
|
|
||||||
|
Set critical threshold for total jobs.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
265
src/apps/backup/veeam/wsman/mode/vsbjobs.pm
Normal file
265
src/apps/backup/veeam/wsman/mode/vsbjobs.pm
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::mode::vsbjobs;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use centreon::common::powershell::veeam::vsbjobs;
|
||||||
|
use apps::backup::veeam::wsman::mode::resources::types qw($job_type $job_result);
|
||||||
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
use centreon::plugins::misc;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'last status: %s [duration: %s]',
|
||||||
|
$self->{result_values}->{status},
|
||||||
|
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{duration})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_job_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"SureBackup job '%s' [type: %s] ",
|
||||||
|
$options{instance_value}->{name},
|
||||||
|
$options{instance_value}->{type}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_global_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Number of SureBackup jobs ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', },
|
||||||
|
{ name => 'jobs', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All SureBackup jobs are ok', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'jobs-detected', nlabel => 'sure_backup.jobs.detected.count', set => {
|
||||||
|
key_values => [ { name => 'detected' } ],
|
||||||
|
output_template => 'detected jobs: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'jobs-success', nlabel => 'sure_backup.jobs.success.count', set => {
|
||||||
|
key_values => [ { name => 'success' } ],
|
||||||
|
output_template => 'success: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'jobs-failed', nlabel => 'sure_backup.jobs.failed.count', set => {
|
||||||
|
key_values => [ { name => 'failed' } ],
|
||||||
|
output_template => 'failed: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'jobs-warning', nlabel => 'sure_backup.jobs.warning.count', set => {
|
||||||
|
key_values => [ { name => 'warning' } ],
|
||||||
|
output_template => 'warning: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{jobs} = [
|
||||||
|
{ label => 'status', type => 2, critical_default => 'not %{status} =~ /success/i', set => {
|
||||||
|
key_values => [
|
||||||
|
{ name => 'name' }, { name => 'type' },
|
||||||
|
{ name => 'status' }, { name => 'duration' }
|
||||||
|
],
|
||||||
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
|
closure_custom_perfdata => sub { return 0; },
|
||||||
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
|
'ps-display' => { name => 'ps_display' },
|
||||||
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'exclude-name:s' => { name => 'exclude_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $ps = centreon::common::powershell::veeam::vsbjobs::get_powershell();
|
||||||
|
if (defined($self->{option_results}->{ps_display})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $ps
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $options{wsman}->execute_powershell(
|
||||||
|
label => 'vsbjobs',
|
||||||
|
content => centreon::plugins::misc::powershell_encoded($ps)
|
||||||
|
);
|
||||||
|
if (defined($self->{option_results}->{ps_exec_only})) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => 'OK',
|
||||||
|
short_msg => $result->{vsbjobs}->{stdout}
|
||||||
|
);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
my $decoded;
|
||||||
|
eval {
|
||||||
|
$decoded = JSON::XS->new->decode($self->{output}->decode($result->{vsbjobs}->{stdout}));
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[
|
||||||
|
# { name: 'xxxx', type: 0, result: 0, creationTimeUTC: 1512875246.2, endTimeUTC: 1512883615.377 },
|
||||||
|
# { name: 'xxxx', type: 0, result: 1, creationTimeUTC: '', endTimeUTC: '' },
|
||||||
|
# { name: 'xxxx', type: 1, result: 0, creationTimeUTC: 1513060425.027, endTimeUTC: -2208992400 }
|
||||||
|
#]
|
||||||
|
|
||||||
|
$self->{global} = { detected => 0, success => 0, failed => 0, warning => 0 };
|
||||||
|
$self->{jobs} = {};
|
||||||
|
my $current_time = time();
|
||||||
|
foreach my $job (@$decoded) {
|
||||||
|
$job->{creationTimeUTC} =~ s/,/\./;
|
||||||
|
$job->{endTimeUTC} =~ s/,/\./;
|
||||||
|
|
||||||
|
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$job->{name} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
next if (defined($self->{option_results}->{exclude_name}) && $self->{option_results}->{exclude_name} ne '' &&
|
||||||
|
$job->{name} =~ /$self->{option_results}->{exclude_name}/);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||||
|
$job->{type} !~ /$self->{option_results}->{filter_type}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': no matching filter type.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
# Sometimes we may get such JSON: [{"lastResult":null,"name":null,"lastState":null,"type":null,"enabled":null}]
|
||||||
|
if (!defined($job->{name})) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping nulled job (empty json)", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $elapsed_time = 0;
|
||||||
|
$elapsed_time = $current_time - $job->{creationTimeUTC} if ($job->{creationTimeUTC} =~ /[0-9]/);
|
||||||
|
|
||||||
|
my $status = defined($job_result->{ $job->{result} }) && $job_result->{ $job->{result} } ne '' ? $job_result->{ $job->{result} } : '-';
|
||||||
|
$self->{jobs}->{ $job->{name} } = {
|
||||||
|
name => $job->{name},
|
||||||
|
type => defined($job_type->{ $job->{type} }) ? $job_type->{ $job->{type} } : 'unknown',
|
||||||
|
duration => $elapsed_time,
|
||||||
|
status => $status
|
||||||
|
};
|
||||||
|
$self->{global}->{$status}++ if (defined($self->{global}->{$status}));
|
||||||
|
$self->{global}->{detected}++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
EXPERIMENTAL Mode : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check SureBackup jobs.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
|
||||||
|
=item B<--ps-display>
|
||||||
|
|
||||||
|
Display powershell script.
|
||||||
|
|
||||||
|
=item B<--ps-exec-only>
|
||||||
|
|
||||||
|
Print powershell output.
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter job name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--exclude-name>
|
||||||
|
|
||||||
|
Exclude job name (regexp can be used).
|
||||||
|
|
||||||
|
=item B<--filter-type>
|
||||||
|
|
||||||
|
Filter job type (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--unknown-status>
|
||||||
|
|
||||||
|
Set unknown threshold for status.
|
||||||
|
Can used special variables like: %{name}, %{type}, %{status}, %{duration}.
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{name}, %{type}, %{status}, %{duration}.
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: 'not %{status} =~ /success/i').
|
||||||
|
Can used special variables like: %{name}, %{type}, %{status}, %{duration}.
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'jobs-detected', 'jobs-success', 'jobs-warning', 'jobs-failed'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
55
src/apps/backup/veeam/wsman/plugin.pm
Normal file
55
src/apps/backup/veeam/wsman/plugin.pm
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2024 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::backup::veeam::wsman::plugin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use base qw(centreon::plugins::script_wsman);
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{modes} = {
|
||||||
|
'job-status' => 'apps::backup::veeam::wsman::mode::jobstatus',
|
||||||
|
'licenses' => 'apps::backup::veeam::wsman::mode::licenses',
|
||||||
|
'list-jobs' => 'apps::backup::veeam::wsman::mode::listjobs',
|
||||||
|
'list-repositories' => 'apps::backup::veeam::wsman::mode::listrepositories',
|
||||||
|
'repositories' => 'apps::backup::veeam::wsman::mode::repositories',
|
||||||
|
'tape-jobs' => 'apps::backup::veeam::wsman::mode::tapejobs',
|
||||||
|
'vsb-jobs' => 'apps::backup::veeam::wsman::mode::vsbjobs'
|
||||||
|
};
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
EXPERIMENTAL Plugin : Community-supported only (no support from Centreon at this time)
|
||||||
|
|
||||||
|
Check Veeam through powershell.
|
||||||
|
|
||||||
|
=cut
|
Loading…
x
Reference in New Issue
Block a user