conflict of memory mode

This commit is contained in:
Sims24 2017-04-11 17:49:24 +02:00
commit 4cf5137482
147 changed files with 11783 additions and 2075 deletions

View File

@ -54,9 +54,9 @@ sub netdom {
my $netdom_cmd = 'netdom verify ';
$netdom_cmd .= ' /Domain:' . $self->{option_results}->{domain} if (defined($self->{option_results}->{domain}) && $self->{option_results}->{domain} ne '');
if (defined($self->{option_results}->{workstation})) {
$netdom_cmd .= ' ' . . $self->{option_results}->{workstation};
$netdom_cmd .= ' ' . $self->{option_results}->{workstation};
} else {
$netdom_cmd .= ' ' . . Win32::NodeName();
$netdom_cmd .= ' ' . Win32::NodeName();
}
my ($stdout, $exit_code) = centreon::plugins::misc::windows_execute(output => $self->{output},

View File

@ -0,0 +1,391 @@
#
# Copyright 2017 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::antivirus::clamav::local::mode::updatestatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use Net::DNS;
use DateTime;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_engine_status_output {
my ($self, %options) = @_;
my $msg = "clamav engine version '" . $self->{result_values}->{current_engine_version} . "/" . $self->{result_values}->{last_engine_version} . "'";
return $msg;
}
sub custom_maindb_status_output {
my ($self, %options) = @_;
my $msg = "main.cvd version '" . $self->{result_values}->{current_maindb_version} . "/" . $self->{result_values}->{last_maindb_version} .
"', last update " . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{current_maindb_timediff});
return $msg;
}
sub custom_dailydb_status_output {
my ($self, %options) = @_;
my $msg = "daily.cvd version '" . $self->{result_values}->{current_dailydb_version} . "/" . $self->{result_values}->{last_dailydb_version} .
"', last update " . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{current_dailydb_timediff});
return $msg;
}
sub custom_engine_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{current_engine_version} = $options{new_datas}->{$self->{instance} . '_current_engine_version'};
$self->{result_values}->{last_engine_version} = $options{new_datas}->{$self->{instance} . '_last_engine_version'};
return 0;
}
sub custom_maindb_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{current_maindb_version} = $options{new_datas}->{$self->{instance} . '_current_maindb_version'};
$self->{result_values}->{last_maindb_version} = $options{new_datas}->{$self->{instance} . '_last_maindb_version'};
$self->{result_values}->{current_maindb_timediff} = $options{new_datas}->{$self->{instance} . '_current_maindb_timediff'};
return 0;
}
sub custom_dailydb_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{current_dailydb_version} = $options{new_datas}->{$self->{instance} . '_current_dailydb_version'};
$self->{result_values}->{last_dailydb_version} = $options{new_datas}->{$self->{instance} . '_last_dailydb_version'};
$self->{result_values}->{current_dailydb_timediff} = $options{new_datas}->{$self->{instance} . '_current_dailydb_timediff'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'update', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{update} = [
{ label => 'engine-status', threshold => 0, set => {
key_values => [ { name => 'last_engine_version' }, { name => 'current_engine_version' } ],
closure_custom_calc => $self->can('custom_engine_status_calc'),
closure_custom_output => $self->can('custom_engine_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
{ label => 'maindb-status', threshold => 0, set => {
key_values => [ { name => 'last_maindb_version' }, { name => 'current_maindb_version' }, { name => 'current_maindb_timediff' } ],
closure_custom_calc => $self->can('custom_maindb_status_calc'),
closure_custom_output => $self->can('custom_maindb_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
{ label => 'dailydb-status', threshold => 0, set => {
key_values => [ { name => 'last_dailydb_version' }, { name => 'current_dailydb_version' }, { name => 'current_dailydb_timediff' } ],
closure_custom_calc => $self->can('custom_dailydb_status_calc'),
closure_custom_output => $self->can('custom_dailydb_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options' },
"warning-engine-status:s" => { name => 'warning_engine_status', default => '' },
"critical-engine-status:s" => { name => 'critical_engine_status', default => '%{last_engine_version} ne %{current_engine_version}' },
"warning-maindb-status:s" => { name => 'warning_maindb_status', default => '' },
"critical-maindb-status:s" => { name => 'critical_maindb_status', default => '%{last_maindb_version} ne %{current_maindb_version}' },
"warning-dailydb-status:s" => { name => 'warning_dailydb_status', default => '' },
"critical-dailydb-status:s" => { name => 'critical_dailydb_status', default => '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000' },
"nameservers:s@" => { name => 'nameservers' },
"maindb-file:s" => { name => 'maindb_file', default => '/var/lib/clamav/main.cvd' },
"dailydb-file:s" => { name => 'dailydb_file', default => '/var/lib/clamav/daily.cvd' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_engine_status', 'critical_engine_status', 'warning_maindb_status', 'critical_maindb_status', 'warning_dailydb_status', 'critical_dailydb_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
$self->{clamav_command} = 'echo "==== CLAMD ===" ; clamd -V ; echo "==== DAILY ===="; sigtool --info ' . $self->{option_results}->{dailydb_file} . '; echo "==== MAIN ====" ; sigtool --info ' . $self->{option_results}->{maindb_file};
}
sub get_clamav_last_update {
my ($self, %options) = @_;
#0.99.2:57:23114:1487851834:1:63:45614:290
# field 2 = main.cvd version number
# field 3 = daily.cvd version number
my $nameservers = [];
if (defined($self->{option_results}->{nameservers})) {
$nameservers = [@{$self->{option_results}->{nameservers}}];
}
my $handle = Net::DNS::Resolver->new(
nameservers => $nameservers
);
my $txt_query = $handle->query("current.cvd.clamav.net", "TXT");
if (!$txt_query) {
$self->{output}->add_option_msg(short_msg => "Unable to get TXT Record : " . $handle->errorstring . ".");
$self->{output}->option_exit();
}
my @fields = split /:/, ($txt_query->answer)[0]->txtdata;
($self->{last_engine_version}, $self->{last_maindb_version}, $self->{last_dailydb_version}) =
($fields[0], $fields[1], $fields[2]);
}
sub get_clamav_current_signature_info {
my ($self, %options) = @_;
if ($options{content} !~ /====\s+$options{label}.*?Build\s+time:\s+(.*?)\n.*?Version:\s+(\d+)/msi) {
return ;
}
$self->{'current_' . $options{label} . 'db_version'} = $2;
#13 Jun 2016 09:53 -0400
my $time = $1;
if ($time =~ /^\s*(\d+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+)\s+(\S+)/) {
my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
my $dt = DateTime->new(
year => $3,
month => $months{$2},
day => $1,
hour => $4,
minute => $5,
second => 0,
time_zone => $6,
);
$self->{'current_' . $options{label} . 'db_timediff'} = time() - $dt->epoch;
}
}
sub manage_selection {
my ($self, %options) = @_;
$self->get_clamav_last_update();
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{clamav_command},
command_path => $self->{option_results}->{command_path},
command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef);
#==== CLAMD ===
#ClamAV 0.99.2/21723/Mon Jun 13 14:53:00 2016
#==== DAILY ====
#File: /var/lib/clamav/daily.cvd
#Build time: 13 Jun 2016 09:53 -0400
#Version: 21723
#Signatures: 276682
#Functionality level: 63
#Builder: neo
#MD5: 280928f25d175359e6e6a0270d9d4fb2
#Digital signature: yLfcgb9dbgKO2rWpXGa238252jqH7VDsAjnqQsHc+9cbIwiM9wnz3fqyl33G15S4YsMbRR6CYbSTxccKXBJvvxRhgZQJmpCYiThslUKBPo5QhIFcI1QBMfoHKCpf8riB2/xAgI401UkZVJip+6eWFpUJ9aeaFai+Mvinif5BRzi
#LibClamAV Warning: **************************************************
#LibClamAV Warning: *** The virus database is older than 7 days! ***
#LibClamAV Warning: *** Please update it as soon as possible. ***
#LibClamAV Warning: **************************************************
#Verification OK.
#==== MAIN ====
#File: /var/lib/clamav/main.cvd
#Build time: 16 Mar 2016 23:17 +0000
#Version: 57
#Signatures: 4218790
#Functionality level: 60
#Builder: amishhammer
#MD5: 06386f34a16ebeea2733ab037f0536be
#Digital signature: AIzk/LYbX8K9OEbR5GMyJ6LWTqSu9ffa5bONcA0FN3+onMlZ2BMRzuyvVURBvAZvOaGPdtMBcgDJSl7fGxDfcxRWhIrQ98f8FPdAQaFPgWu3EX46ufw+IRZnM4irKKYuh1GdCIbsGs6jejWo9iNErsbDqkFSobVBkUJYxBgvqfd
#Verification OK.
$self->get_clamav_current_signature_info(label => 'daily', content => $stdout);
$self->get_clamav_current_signature_info(label => 'main', content => $stdout);
if ($stdout =~ /==== CLAMD.*?ClamAV (.*?)\//msi) {
$self->{current_engine_version} = $1;
}
$self->{update} = {
last_engine_version => $self->{last_engine_version}, last_maindb_version => $self->{last_maindb_version}, last_dailydb_version => $self->{last_dailydb_version},
current_engine_version => $self->{current_engine_version},
current_maindb_version => $self->{current_maindb_version}, current_maindb_timediff => $self->{current_maindb_timediff},
current_dailydb_version => $self->{current_dailydb_version}, current_dailydb_timediff => $self->{current_dailydb_timediff},
};
}
1;
__END__
=head1 MODE
Check antivirus update status.
=over 8
=item B<--nameservers>
Set nameserver to query (can be multiple).
The system configuration is used by default.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information. Used it you have output in a file.
=item B<--command-path>
Command path.
=item B<--command-options>
Command options (Default: '-report -most_columns').
=item B<--maindb-file>
Antivirus main.cvd file (Default: '/var/lib/clamav/main.cvd').
=item B<--dailydb-file>
Antivirus daily.cvd file (Default: '/var/lib/clamav/daily.cvd').
=item B<--warning-engine-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_engine_version}, %{current_engine_version}
=item B<--critical-engine-status>
Set critical threshold for status (Default: '%{last_engine_version} ne %{current_engine_version}').
Can used special variables like: %{last_engine_version}, %{current_engine_version}
=item B<--warning-maindb-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_maindb_version}, %{current_maindb_version}, %{current_maindb_timediff}
=item B<--critical-maindb-status>
Set critical threshold for status (Default: '%{last_maindb_version} ne %{current_maindb_version}').
Can used special variables like: %{last_maindb_version}, %{current_maindb_version}, %{current_maindb_timediff}
=item B<--warning-dailydb-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_dailydb_version}, %{current_dailydb_version}, %{current_dailydb_timediff}
=item B<--critical-dailydb-status>
Set critical threshold for status (Default: '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000').
Can used special variables like: %{last_dailydb_version}, %{current_dailydb_version}, %{current_dailydb_timediff}
=back
=cut

View File

@ -0,0 +1,48 @@
#
# Copyright 2017 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::antivirus::clamav::local::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'update-status' => 'apps::antivirus::clamav::local::mode::updatestatus',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check ClamAV Antivirus through local commands (the plugin can use SSH).
=cut

View File

@ -110,7 +110,7 @@ sub manage_selection {
my @lines = split /\n/, $stdout;
foreach my $policy_name (@lines) {
my $command2 = $self->{option_results}->{command2};
$command2 =~ s/%{policy_name}/$policy_name/g;
$command2 =~ s/%\{policy_name\}/$policy_name/g;
my ($stdout2) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},

View File

@ -76,7 +76,7 @@ sub run {
my ($self, %options) = @_;
$self->{output}->output_add(severity => 'OK',
short_msg => 'centreon-broker failover files and tempory are ok');
short_msg => 'centreon-broker failover/temporary files are ok');
my $total_size = 0;
foreach my $config (@{$self->{option_results}->{broker_config}}) {

View File

@ -0,0 +1,165 @@
#
# Copyright 2017 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::centreon::sql::mode::dsmqueue;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'host', type => 1, cb_prefix_output => 'prefix_host_output', message_multiple => 'All host queues are ok' },
];
$self->{maps_counters}->{global} = [
{ label => 'total-queue-cache', set => {
key_values => [ { name => 'total_queue_cache' } ],
output_template => 'Total current cache queue : %s',
perfdatas => [
{ label => 'total_queue_cache', value => 'total_queue_cache_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'total-queue-lock', set => {
key_values => [ { name => 'total_queue_lock' } ],
output_template => 'Total current lock queue : %s',
perfdatas => [
{ label => 'total_queue_lock', value => 'total_queue_lock_absolute', template => '%s', min => 0 },
],
}
},
];
$self->{maps_counters}->{host} = [
{ label => 'host-queue-cache', set => {
key_values => [ { name => 'num' }, { name => 'display' } ],
output_template => 'current cache queue : %s',
perfdatas => [
{ label => 'host_queue_cache', value => 'num_absolute', template => '%s',
min => 0, label_extra_instance => 1 },
],
}
},
];
}
sub prefix_host_output {
my ($self, %options) = @_;
return "Host '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-host-queue:s" => { name => 'filter_host_queue' },
"centreon-storage-database:s" => { name => 'centreon_storage_database', default => 'centreon_storage' },
"centreon-database:s" => { name => 'centreon_database', default => 'centreon' },
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
$options{sql}->connect();
$self->{global} = { total_queue_cache => 0, total_queue_lock => 0 };
my $query = "SELECT COUNT(*) as nb FROM " . $self->{option_results}->{centreon_storage_database} . ".mod_dsm_cache";
$options{sql}->query(query => $query);
if ((my $row = $options{sql}->fetchrow_hashref())) {
$self->{global}->{total_queue_cache} = $row->{nb};
}
$query = "SELECT COUNT(*) as nb FROM " . $self->{option_results}->{centreon_storage_database} . ".mod_dsm_locks";
$options{sql}->query(query => $query);
if ((my $row = $options{sql}->fetchrow_hashref())) {
$self->{global}->{total_queue_lock} = $row->{nb};
}
# check by poller
$self->{host} = {};
$query = "SELECT mod_dsm_pool.pool_host_id, mod_dsm_pool.pool_prefix, COUNT(*) as nb FROM " . $self->{option_results}->{centreon_database} . ".mod_dsm_pool" .
" LEFT JOIN " . $self->{option_results}->{centreon_storage_database} . ".mod_dsm_cache ON mod_dsm_pool.pool_host_id = mod_dsm_cache.host_id AND mod_dsm_pool.pool_prefix = mod_dsm_cache.pool_prefix" .
" GROUP BY mod_dsm_pool.pool_host_id, mod_dsm_pool.pool_prefix";
$options{sql}->query(query => $query);
while ((my $row = $options{sql}->fetchrow_hashref())) {
my $name = $row->{pool_host_id} . '/' . $row->{pool_prefix};
if (defined($self->{option_results}->{filter_host_queue}) && $self->{option_results}->{filter_host_queue} ne '' &&
$name !~ /$self->{option_results}->{filter_host_queue}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $row->{name} . "': no matching filter.", debug => 1);
next;
}
$self->{host}->{$name} = { display => $name, num => $row->{nb} };
}
}
1;
__END__
=head1 MODE
Check Centreon DSM queue usage.
=over 8
=item B<--centreon-storage-database>
Centreon storage database name (default: 'centreon_storage').
=item B<--centreon-database>
Centreon storage database name (default: 'centreon').
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^total-queue-cache$'
=item B<--warning-*>
Threshold warning.
Can be: Can be: 'total-queue-cache', 'total-queue-lock', 'host-queue-cache'.
=item B<--critical-*>
Threshold critical.
Can be: Can be: 'total-queue-cache', 'total-queue-lock', 'host-queue-cache'.
=item B<--filter-host-queue>
Filter by host and pool prefix name (regexp can be used).
Example: host1.queue1
=back
=cut

View File

@ -92,12 +92,18 @@ sub custom_metric_calc {
$self->{result_values}->{min} = $options{new_datas}->{$self->{instance} . '_min'};
$self->{result_values}->{max} = $options{new_datas}->{$self->{instance} . '_max'};
my $change_bytes_global = ($config_data->{formatting}->{change_bytes} eq 'true');
my $change_bytes_metric_filter = (defined($config_data->{filters}->{formatting}->{change_bytes}) && $config_data->{filters}->{formatting}->{change_bytes} eq 'true');
my $change_bytes_metric_selection = (defined($config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{change_bytes})
&& $config_data->{selection}->{$self->{result_values}->{instance}}->{formatting}->{change_bytes} eq 'true');
my $elem = $self->{result_values}->{type} eq 'unique' ? 'selection' : 'virtualcurve';
my ($change_bytes_metric_selection, $change_bytes_metric_filter);
if (defined($config_data->{filters}->{formatting}->{change_bytes})) {
$change_bytes_metric_filter = $config_data->{filters}->{formatting}->{change_bytes};
}
if (defined($config_data->{$elem}->{$self->{result_values}->{instance}}->{formatting}->{change_bytes})) {
$change_bytes_metric_selection = $config_data->{$elem}->{$self->{result_values}->{instance}}->{formatting}->{change_bytes};
}
if ($change_bytes_global && ($change_bytes_metric_filter || $change_bytes_metric_selection)) {
if ((defined($change_bytes_metric_selection) && $change_bytes_metric_selection) ||
(defined($change_bytes_metric_filter) && $change_bytes_metric_filter) ||
($config_data->{formatting}->{change_bytes} && !defined($change_bytes_metric_selection) && !defined($change_bytes_metric_filter))) {
($self->{result_values}->{value}, $self->{result_values}->{unit}) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{value});
}
return 0;
@ -138,10 +144,10 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'global', set => {
key_values => [ { name => 'value' }, { name => 'display' }, { name => 'type' }, { name => 'unit' }, { name => 'min' }, { name => 'max' } ],
closure_custom_calc => \&custom_metric_calc,
closure_custom_output => \&custom_metric_output,
closure_custom_perfdata => \&custom_metric_perfdata,
closure_custom_threshold_check => \&custom_metric_threshold,
closure_custom_calc => $self->can('custom_metric_calc'),
closure_custom_output => $self->can('custom_metric_output'),
closure_custom_perfdata => $self->can('custom_metric_perfdata'),
closure_custom_threshold_check => $self->can('custom_metric_threshold'),
}
}
];
@ -149,10 +155,10 @@ sub set_counters {
$self->{maps_counters}->{metric} = [
{ label => 'metric', set => {
key_values => [ { name => 'value' }, { name => 'display' }, { name => 'type' }, { name => 'unit' }, { name => 'min' }, { name => 'max' } ],
closure_custom_calc => \&custom_metric_calc,
closure_custom_output => \&custom_metric_output,
closure_custom_perfdata => \&custom_metric_perfdata,
closure_custom_threshold_check => \&custom_metric_threshold,
closure_custom_calc => $self->can('custom_metric_calc'),
closure_custom_output => $self->can('custom_metric_output'),
closure_custom_perfdata => $self->can('custom_metric_perfdata'),
closure_custom_threshold_check => $self->can('custom_metric_threshold'),
}
}
];
@ -199,8 +205,7 @@ sub check_options {
$config_data->{formatting}->{custom_message_global} = "Global metrics are OK" if (!exists($config_data->{formatting}->{custom_message_global}));
$config_data->{formatting}->{custom_message_metric} = "All metrics are OK" if (!exists($config_data->{formatting}->{custom_message_metric}));
$config_data->{formatting}->{cannonical_separator} = "#" if (!exists($config_data->{formatting}->{cannonical_separator}));
$config_data->{formatting}->{change_bytes} = 'false' if (!exists($config_data->{formatting}->{change_bytes}));
$config_data->{formatting}->{change_bytes} = 0 if (!exists($config_data->{formatting}->{change_bytes}));
}
sub parse_json_config {
@ -250,19 +255,19 @@ sub manage_selection {
foreach my $id (keys %{$config_data->{selection}}) {
my $query = "SELECT index_data.host_name, index_data.service_description, metrics.metric_name, metrics.current_value, metrics.unit_name, metrics.min, metrics.max ";
$query .= "FROM centreon_storage.index_data, centreon_storage.metrics WHERE index_data.id = metrics.index_id ";
$query .= "AND index_data.service_description = '" . $config_data->{selection}{$id}->{service_name} . "'";
$query .= "AND index_data.host_name = '" . $config_data->{selection}{$id}->{host_name} . "'" ;
$query .= "AND metrics.metric_name = '" . $config_data->{selection}{$id}->{metric_name} . "'";
$query .= "AND index_data.service_description = '" . $config_data->{selection}->{$id}->{service_name} . "'";
$query .= "AND index_data.host_name = '" . $config_data->{selection}->{$id}->{host_name} . "'" ;
$query .= "AND metrics.metric_name = '" . $config_data->{selection}->{$id}->{metric_name} . "'";
$self->{sql}->query(query => $query);
while ((my $row = $self->{sql}->fetchrow_hashref())) {
my $metric_key = $id;
$self->{metrics}->{$metric_key}{name} = $row->{metric_name};
$self->{metrics}->{$metric_key}{display_name} = $id;
$self->{metrics}->{$metric_key}{current} = $row->{current_value};
$self->{metrics}->{$metric_key}{unit} = defined($row->{unit_name}) ? $row->{unit_name} : '';
$self->{metrics}->{$metric_key}{min} = defined($row->{min}) ? $row->{min} : '';
$self->{metrics}->{$metric_key}{max} = defined($row->{max}) ? $row->{max} : '';
$self->{metrics}->{$metric_key}{display} = (defined($config_data->{selection}{$id}->{display}) && $config_data->{selection}{$id}->{display} eq 'true') ? 1 : 0;
$self->{metrics}->{$metric_key} = { name => $row->{metric_name} };
$self->{metrics}->{$metric_key}->{display_name} = $id;
$self->{metrics}->{$metric_key}->{current} = $row->{current_value};
$self->{metrics}->{$metric_key}->{unit} = defined($row->{unit_name}) ? $row->{unit_name} : '';
$self->{metrics}->{$metric_key}->{min} = defined($row->{min}) ? $row->{min} : '';
$self->{metrics}->{$metric_key}->{max} = defined($row->{max}) ? $row->{max} : '';
$self->{metrics}->{$metric_key}->{display} = (defined($config_data->{selection}->{$id}->{display}) && $config_data->{selection}->{$id}->{display}) ? 1 : 0;
}
}
} elsif (exists($config_data->{filters})) {
@ -277,70 +282,70 @@ sub manage_selection {
$self->{sql}->query(query => $query);
while ((my $row = $self->{sql}->fetchrow_hashref())) {
my $metric_key = $row->{host_name}.$config_data->{formatting}->{cannonical_separator}.$row->{service_description}.$config_data->{formatting}->{cannonical_separator}.$row->{metric_name};
$self->{metrics}->{$metric_key}{display_name} = $metric_key;
$self->{metrics}->{$metric_key}{name} = $row->{metric_name};
$self->{metrics}->{$metric_key}{current} = $row->{current_value};
$self->{metrics}->{$metric_key}{unit} = defined($row->{unit_name}) ? $row->{unit_name} : '';
$self->{metrics}->{$metric_key}{min} = defined($row->{min}) ? $row->{min} : '';
$self->{metrics}->{$metric_key}{max} = defined($row->{max}) ? $row->{max} : '';
$self->{metrics}->{$metric_key}{display} = (defined($config_data->{filters}->{display})) ? 1 : 0;
$self->{metrics}->{$metric_key} = { display_name => $metric_key};
$self->{metrics}->{$metric_key}->{name} = $row->{metric_name};
$self->{metrics}->{$metric_key}->{current} = $row->{current_value};
$self->{metrics}->{$metric_key}->{unit} = defined($row->{unit_name}) ? $row->{unit_name} : '';
$self->{metrics}->{$metric_key}->{min} = defined($row->{min}) ? $row->{min} : '';
$self->{metrics}->{$metric_key}->{max} = defined($row->{max}) ? $row->{max} : '';
$self->{metrics}->{$metric_key}->{display} = (defined($config_data->{filters}->{display}) && $config_data->{filters}->{display}) ? 1 : 0;
}
}
foreach my $metric (keys %{$self->{metrics}}) {
foreach my $vcurve (keys %{$config_data->{virtualcurve}}) {
if (defined($config_data->{virtualcurve}{$vcurve}->{pattern}) && $config_data->{virtualcurve}{$vcurve}->{pattern} ne '') {
push (@{$self->{vmetrics}->{$vcurve}->{values}}, $self->{metrics}->{$metric}->{current}) if $self->{metrics}->{$metric}->{name} =~ /$config_data->{virtualcurve}{$vcurve}->{pattern}/;
} else {
push (@{$self->{vmetrics}->{$vcurve}->{values}}, $self->{metrics}->{$metric}->{current});
}
foreach my $vcurve (keys %{$config_data->{virtualcurve}}) {
$self->{vmetrics}->{$vcurve}->{values} = [] if (!defined($self->{vmetrics}->{$vcurve}->{values}));
if (defined($config_data->{virtualcurve}->{$vcurve}->{pattern}) && $config_data->{virtualcurve}->{$vcurve}->{pattern} ne '') {
push (@{$self->{vmetrics}->{$vcurve}->{values}}, $self->{metrics}->{$metric}->{current}) if $self->{metrics}->{$metric}->{name} =~ /$config_data->{virtualcurve}{$vcurve}->{pattern}/;
} else {
push (@{$self->{vmetrics}->{$vcurve}->{values}}, $self->{metrics}->{$metric}->{current});
}
next if (!defined(@{$self->{vmetrics}->{$vcurve}{values}}));
next if (scalar(@{$self->{vmetrics}->{$vcurve}->{values}}) == 0);
$self->{vmetrics}->{$vcurve}{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}{values}})/scalar(@{$self->{vmetrics}->{$vcurve}{values}})) if ($config_data->{virtualcurve}{$vcurve}->{aggregation} eq 'avg');
$self->{vmetrics}->{$vcurve}{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}{values}})) if ($config_data->{virtualcurve}{$vcurve}->{aggregation} eq 'sum');
$self->{vmetrics}->{$vcurve}{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
min(@{$self->{vmetrics}->{$vcurve}{values}})) if ($config_data->{virtualcurve}{$vcurve}->{aggregation} eq 'min');
$self->{vmetrics}->{$vcurve}{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
max(@{$self->{vmetrics}->{$vcurve}{values}})) if ($config_data->{virtualcurve}{$vcurve}->{aggregation} eq 'max');
$self->{vmetrics}->{$vcurve}{aggregated_value} = eval "$self->{vmetrics}->{$vcurve}{aggregated_value} $config_data->{virtualcurve}->{$vcurve}{custom}" if (defined($config_data->{virtualcurve}->{$vcurve}{custom}));
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}})/scalar(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'avg');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'sum');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
min(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'min');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
max(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'max');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}" if (defined($config_data->{virtualcurve}->{$vcurve}->{custom}));
$self->{vmetrics}->{$vcurve}{unit} = (defined($config_data->{virtualcurve}{$vcurve}->{unit})) ? $config_data->{virtualcurve}{$vcurve}->{unit} : '';
$self->{vmetrics}->{$vcurve}{min} = (defined($config_data->{virtualcurve}{$vcurve}->{min})) ? $config_data->{virtualcurve}{$vcurve}->{min} : '';
$self->{vmetrics}->{$vcurve}{max} = (defined($config_data->{virtualcurve}{$vcurve}->{max})) ? $config_data->{virtualcurve}{$vcurve}->{max} : '';
$self->{vmetrics}->{$vcurve}->{unit} = (defined($config_data->{virtualcurve}->{$vcurve}->{unit})) ? $config_data->{virtualcurve}->{$vcurve}->{unit} : '';
$self->{vmetrics}->{$vcurve}->{min} = (defined($config_data->{virtualcurve}->{$vcurve}->{min})) ? $config_data->{virtualcurve}->{$vcurve}->{min} : '';
$self->{vmetrics}->{$vcurve}->{max} = (defined($config_data->{virtualcurve}->{$vcurve}->{max})) ? $config_data->{virtualcurve}->{$vcurve}->{max} : '';
if (defined($self->{option_results}->{'warning-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{warning})) {
if (defined($self->{option_results}->{'warning-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{warning})) {
$self->{perfdata}->threshold_validate(label => 'warning-global-'.$vcurve,
value => (defined($self->{option_results}->{'warning-global'})) ? $self->{option_results}->{'warning-global'} : $config_data->{virtualcurve}->{$vcurve}->{warning});
}
if (defined($self->{option_results}->{'critical-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{critical})) {
}
if (defined($self->{option_results}->{'critical-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{critical})) {
$self->{perfdata}->threshold_validate(label => 'critical-global-'.$vcurve,
value => (defined($self->{option_results}->{'critical-global'})) ? $self->{option_results}->{'critical-global'} : $config_data->{virtualcurve}->{$vcurve}->{critical});
}
}
$self->{global}->{$vcurve} = {display => $vcurve,
type => 'global',
unit => $self->{vmetrics}->{$vcurve}->{unit},
value => $self->{vmetrics}->{$vcurve}->{aggregated_value},
min => $self->{vmetrics}->{$vcurve}->{min},
max => $self->{vmetrics}->{$vcurve}->{max} };
$self->{global}->{$vcurve} = {display => $vcurve,
type => 'global',
unit => $self->{vmetrics}->{$vcurve}->{unit},
value => $self->{vmetrics}->{$vcurve}->{aggregated_value},
min => $self->{vmetrics}->{$vcurve}->{min},
max => $self->{vmetrics}->{$vcurve}->{max} };
}
$self->{metric}->{$metric} = {display => $self->{metrics}->{$metric}->{display_name},
type => 'unique',
unit => $self->{metrics}->{$metric}->{unit},
value => $self->{metrics}->{$metric}->{current},
min => $self->{metrics}->{$metric}->{min},
max => $self->{metrics}->{$metric}->{max} } if ($self->{metrics}->{$metric}->{display} == 1);
$self->{metric}->{$metric} = {display => $self->{metrics}->{$metric}->{display_name},
type => 'unique',
unit => $self->{metrics}->{$metric}->{unit},
value => $self->{metrics}->{$metric}->{current},
min => $self->{metrics}->{$metric}->{min},
max => $self->{metrics}->{$metric}->{max} } if ($self->{metrics}->{$metric}->{display} == 1);
}
if (scalar(keys %{$self->{metric}}) <= 0 && scalar(keys %{$self->{vmetrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No metrics returned - are your selection/filters correct ?");
$self->{output}->option_exit();
}
}
1

View File

@ -38,11 +38,13 @@ sub custom_status_threshold {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
};
@ -53,14 +55,14 @@ sub custom_status_threshold {
return $status;
}
sub custom_status_output {
sub custom_service_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{primary_status} . '/' . $self->{result_values}->{secondary_status};
return $msg;
}
sub custom_status_calc {
sub custom_service_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{primary_status} = $options{new_datas}->{$self->{instance} . '_primary_status'};
@ -70,20 +72,48 @@ sub custom_status_calc {
return 0;
}
sub custom_global_status_output {
my ($self, %options) = @_;
my $msg = 'state/version : ' . $self->{result_values}->{integration_service_state} . '/' . $self->{result_values}->{integration_service_version};
return $msg;
}
sub custom_global_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{integration_service_state} = $options{new_datas}->{$self->{instance} . '_integration_service_state'};
$self->{result_values}->{integration_service_version} = $options{new_datas}->{$self->{instance} . '_integration_service_version'};
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vm', type => 2, cb_prefix_output => 'prefix_vm_output', cb_long_output => 'vm_long_output', message_multiple => 'All integration services are ok',
group => [ { name => 'service', cb_prefix_output => 'prefix_service_output' } ]
group => [ { name => 'global', cb_prefix_output => 'prefix_global_output' }, { name => 'service', cb_prefix_output => 'prefix_service_output' } ]
}
];
$self->{maps_counters}->{global} = [
{ label => 'global-status', threshold => 0, set => {
key_values => [ { name => 'integration_service_state' }, { name => 'integration_service_version' }, { name => 'state' }, { name => 'vm' } ],
closure_custom_calc => $self->can('custom_global_status_calc'),
closure_custom_output => $self->can('custom_global_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
$self->{maps_counters}->{service} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'primary_status' }, { name => 'secondary_status' }, { name => 'vm' }, { name => 'service' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
{ label => 'service-status', threshold => 0, set => {
key_values => [ { name => 'primary_status' }, { name => 'secondary_status' }, { name => 'enabled' }, { name => 'vm' }, { name => 'service' } ],
closure_custom_calc => $self->can('custom_service_status_calc'),
closure_custom_output => $self->can('custom_service_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
@ -94,7 +124,7 @@ sub set_counters {
sub vm_long_output {
my ($self, %options) = @_;
return "checking policy '" . $options{instance_value}->{display} . "'";
return "checking virtual machine '" . $options{instance_value}->{display} . "'";
}
sub prefix_vm_output {
@ -109,6 +139,12 @@ sub prefix_service_output {
return "integration service '" . $options{instance_value}->{service} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "global virtual machine '" . $options{instance_value}->{vm} . "' integration service ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -125,8 +161,10 @@ sub new {
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-status:s" => { name => 'filter_status', default => 'running' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{primary_status} !~ /Ok/i' },
"warning-global-status:s" => { name => 'warning_global_status', default => '%{integration_service_state} =~ /Update required/i' },
"critical-global-status:s" => { name => 'critical_global_status', default => '' },
"warning-service-status:s" => { name => 'warning_service_status', default => '' },
"critical-service-status:s" => { name => 'critical_service_status', default => '%{primary_status} !~ /Ok/i' },
});
return $self;
}
@ -142,7 +180,7 @@ sub check_options {
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
foreach (('warning_service_status', 'critical_service_status', 'warning_global_status', 'critical_global_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
@ -167,29 +205,23 @@ sub manage_selection {
$self->{output}->exit();
}
#[name= test1 ][state= Running ]
#[service= Time Synchronization ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Heartbeat ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Key-Value Pair Exchange ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Shutdown ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= VSS ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Guest Service Interface ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[service= Time Synchronization ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[service= Heartbeat ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= Ok ]
#[service= Key-Value Pair Exchange ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[service= Shutdown ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[service= VSS ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[service= Guest Service Interface ][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[name= test2 ][state= Running ]
#[service= Time Synchronization ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Heartbeat ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Key-Value Pair Exchange ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Shutdown ][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[name= test1 ][state= Running ][IntegrationServicesState= Update required ][IntegrationServicesVersion= 3.1 ]
#[service= Time Synchronization ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Heartbeat ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Key-Value Pair Exchange ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Shutdown ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= VSS ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Guest Service Interface ][enabled= False][primaryOperationalStatus= Ok ][secondaryOperationalStatus= ]
#[name= test2 ][state= Running ][IntegrationServicesState= ][IntegrationServicesVersion= ]
#[service= Time Synchronization ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Heartbeat ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Key-Value Pair Exchange ][enabled= True][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
#[service= Shutdown ][enabled= False][primaryOperationalStatus= NoContact ][secondaryOperationalStatus= ]
$self->{vm} = {};
my $id = 1;
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) {
my ($name, $status, $content) = ($1, $2, $3);
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[IntegrationServicesState=\s*(.*?)\s*\]\[IntegrationServicesVersion=\s*(.*?)\s*\](.*?)(?=\[name=|\z)/msig) {
my ($name, $status, $integration_service_state, $integration_service_version, $content) = ($1, $2, $3, $4, $5);
if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' &&
$name !~ /$self->{option_results}->{filter_vm}/i) {
@ -202,10 +234,13 @@ sub manage_selection {
next;
}
$self->{vm}->{$id} = { display => $name, service => {} };
$self->{vm}->{$id} = { display => $name, vm => $name, service => {} };
$self->{vm}->{$id}->{global} = {
$name => { vm => $name, integration_service_state => $integration_service_state, integration_service_version => $integration_service_version, state => $status }
};
my $id2 = 1;
while ($content =~ /^\[service=\s*(.*?)\s*\]\[primaryOperationalStatus=\s*(.*?)\s*\]\[secondaryOperationalStatus=\s*(.*?)\s*\]/msig) {
$self->{vm}->{$id}->{service}->{$id2} = { vm => $name, service => $1, primary_status => $2, secondary_status => $3 };
while ($content =~ /^\[service=\s*(.*?)\s*\]\[enabled=\s*(.*?)\s*\]\[primaryOperationalStatus=\s*(.*?)\s*\]\[secondaryOperationalStatus=\s*(.*?)\s*\]/msig) {
$self->{vm}->{$id}->{service}->{$id2} = { vm => $name, service => $1, enabled => $2, primary_status => $3, secondary_status => $4 };
$id2++;
}
@ -256,15 +291,27 @@ Filter virtual machine status (can be a regexp) (Default: 'running').
Filter virtual machines (can be a regexp).
=item B<--warning-status>
=item B<--warning-global-status>
Set warning threshold for status (Default: '%{integration_service_state} =~ /Update required/i').
Can used special variables like: %{vm}, %{integration_service_state},
%{integration_service_version}, %{state}
=item B<--critical-global-status>
Set critical threshold for status (Default: '').
Can used special variables like: %{vm}, %{integration_service_state},
%{integration_service_version}, %{state}
=item B<--warning-service-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{vm}, %{service}, %{primary_status}, %{secondary_status}
Can used special variables like: %{vm}, %{service}, %{primary_status}, %{secondary_status}, %{enabled}
=item B<--critical-status>
=item B<--critical-service-status>
Set critical threshold for status (Default: '%{primary_status} !~ /Ok/i').
Can used special variables like: %{vm}, %{service}, %{primary_status}, %{secondary_status}
Can used special variables like: %{vm}, %{service}, %{primary_status}, %{secondary_status}, %{enabled}
=back

View File

@ -0,0 +1,224 @@
#
# Copyright 2017 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::hyperv::2012::local::mode::nodereplication;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use centreon::common::powershell::hyperv::2012::nodereplication;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'replication health : ' . $self->{result_values}->{health};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
$self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All virtual machines are ok' },
];
$self->{maps_counters}->{vm} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'vm' }, { name => 'state' }, { name => 'health' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /Warning/i' },
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /Critical/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodereplication::get_powershell(no_ps => $self->{option_results}->{no_ps});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
#[name= XXXX1 ][state= Running ][health= Critical ]
#[name= XXXX2 ][state= Running ][health= Normal ]
#[name= XXXX3 ][state= Running ][health= Warning ]
$self->{vm} = {};
my $id = 1;
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[health=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) {
my ($name, $status, $health) = ($1, $2, $3);
if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' &&
$name !~ /$self->{option_results}->{filter_vm}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{vm}->{$id} = { display => $name, vm => $name, state => $status, health => $health };
$id++;
}
}
1;
__END__
=head1 MODE
Check virtual machine replication on hyper-v node.
=over 8
=item B<--timeout>
Set timeout time for command execution (Default: 50 sec)
=item B<--no-ps>
Don't encode powershell. To be used with --command and 'type' command.
=item B<--command>
Command to get information (Default: 'powershell.exe').
Can be changed if you have output in a file. To be used with --no-ps option!!!
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-exec-only>
Print powershell output.
=item B<--filter-vm>
Filter virtual machines (can be a regexp).
=item B<--warning-status>
Set warning threshold for status (Default: '%{health} =~ /Warning/i').
Can used special variables like: %{vm}, %{state}, %{health}
=item B<--critical-status>
Set critical threshold for status (Default: '%{health} =~ /Critical/i').
Can used special variables like: %{vm}, %{state}, %{health}
=back
=cut

View File

@ -0,0 +1,225 @@
#
# Copyright 2017 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::hyperv::2012::local::mode::nodevmstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use centreon::common::powershell::hyperv::2012::nodevmstatus;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status} . " (state: " . $self->{result_values}->{state} . ", is clustered: " . $self->{result_values}->{is_clustered} . ")";
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{is_clustered} = $options{new_datas}->{$self->{instance} . '_is_clustered'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All virtual machines are ok' },
];
$self->{maps_counters}->{vm} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'vm' }, { name => 'state' }, { name => 'status' }, { name => 'is_clustered' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Operating normally/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodevmstatus::get_powershell(no_ps => $self->{option_results}->{no_ps});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
#[name= XXXX1 ][state= Running ][status= Operating normally ][IsClustered= True ]
#[name= XXXX2 ][state= Running ][status= Operating normally ][IsClustered= False ]
#[name= XXXX3 ][state= Running ][status= Operating normally ][IsClustered= False ]
$self->{vm} = {};
my $id = 1;
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[state=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[IsClustered=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) {
my ($name, $state, $status, $is_clustered) = ($1, $2, $3, $4);
if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' &&
$name !~ /$self->{option_results}->{filter_vm}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{vm}->{$id} = { display => $name, vm => $name, status => $status, state => $state, is_clustered => $is_clustered };
$id++;
}
}
1;
__END__
=head1 MODE
Check virtual machine status on hyper-v node.
=over 8
=item B<--timeout>
Set timeout time for command execution (Default: 50 sec)
=item B<--no-ps>
Don't encode powershell. To be used with --command and 'type' command.
=item B<--command>
Command to get information (Default: 'powershell.exe').
Can be changed if you have output in a file. To be used with --no-ps option!!!
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-exec-only>
Print powershell output.
=item B<--filter-vm>
Filter virtual machines (can be a regexp).
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{vm}, %{state}, %{status}, %{is_clustered}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /Operating normally/i').
Can used special variables like: %{vm}, %{state}, %{status}, %{is_clustered}
=back
=cut

View File

@ -181,15 +181,18 @@ sub manage_selection {
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[description=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\]\[VMAddition=\s*(.*?)\s*\]/msig) {
my %values = (vm => $1, description => $2, status => $3, cloud => $4, hostgroup => $5, vmaddition => $6);
$values{hostgroup} =~ s/\\/\//g;
my $filtered = 0;
foreach (('name', 'description', 'status', 'hostgroup')) {
if (defined($self->{option_results}->{'filter_' . $_}) && $self->{option_results}->{'filter_' . $_} ne '' &&
$values{$_} !~ /$self->{option_results}->{'filter_' . $_}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $values{$_} . "': no matching filter.", debug => 1);
next;
$filtered = 1;
last;
}
}
$self->{vm}->{$id} = { %values };
$self->{vm}->{$id} = { %values } if ($filtered == 0);
$id++;
}
}

View File

@ -92,7 +92,7 @@ sub check_options {
$self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option.");
$self->{output}->option_exit();
}
}
}
}
sub manage_selection {
@ -131,6 +131,7 @@ sub manage_selection {
}
next if ($chkpt == -1);
$hg =~ s/\\/\//g;
if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' &&
$name !~ /$self->{option_results}->{filter_vm}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);

View File

@ -0,0 +1,267 @@
#
# Copyright 2017 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::hyperv::2012::local::mode::scvmmvmstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use centreon::common::powershell::hyperv::2012::scvmmvmstatus;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{vm} = $options{new_datas}->{$self->{instance} . '_vm'};
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{hostgroup} = $options{new_datas}->{$self->{instance} . '_hostgroup'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All virtual machines are ok' },
];
$self->{maps_counters}->{vm} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'vm' }, { name => 'hostgroup' }, { name => 'status' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"scvmm-hostname:s" => { name => 'scvmm_hostname' },
"scvmm-username:s" => { name => 'scvmm_username' },
"scvmm-password:s" => { name => 'scvmm_password' },
"scvmm-port:s" => { name => 'scvmm_port', default => 8100 },
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-hostgroup:s" => { name => 'filter_hostgroup' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Running|Stopped/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
foreach my $label (('scvmm_hostname', 'scvmm_username', 'scvmm_password', 'scvmm_port')) {
if (!defined($self->{option_results}->{$label}) || $self->{option_results}->{$label} eq '') {
my ($label_opt) = $label;
$label_opt =~ tr/_/-/;
$self->{output}->add_option_msg(short_msg => "Need to specify --" . $label_opt . " option.");
$self->{output}->option_exit();
}
}
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::scvmmvmstatus::get_powershell(
scvmm_hostname => $self->{option_results}->{scvmm_hostname},
scvmm_username => $self->{option_results}->{scvmm_username},
scvmm_password => $self->{option_results}->{scvmm_password},
scvmm_port => $self->{option_results}->{scvmm_port},
no_ps => $self->{option_results}->{no_ps});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
#[name= test-server ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server ]
#[name= test-server2 ][status= Running ][cloud= ][hostgrouppath= All Hosts\CORP\Test\test-server2 ]
$self->{vm} = {};
my $id = 1;
while ($stdout =~ /^\[name=\s*(.*?)\s*\]\[status=\s*(.*?)\s*\]\[cloud=\s*(.*?)\s*\]\[hostgrouppath=\s*(.*?)\s*\].*?(?=\[name=|\z)/msig) {
my ($name, $status, $cloud, $hg) = ($1, $2, $3, $4);
$hg =~ s/\\/\//g;
if (defined($self->{option_results}->{filter_vm}) && $self->{option_results}->{filter_vm} ne '' &&
$name !~ /$self->{option_results}->{filter_vm}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_hostgroup}) && $self->{option_results}->{filter_hostgroup} ne '' &&
$hg !~ /$self->{option_results}->{filter_hostgroup}/i) {
$self->{output}->output_add(long_msg => "skipping '" . $hg . "': no matching filter.", debug => 1);
next;
}
$self->{vm}->{$id} = { display => $name, vm => $name, status => $status, hostgroup => $hg };
$id++;
}
}
1;
__END__
=head1 MODE
Check virtual machine status on SCVMM.
=over 8
=item B<--scvmm-hostname>
SCVMM hostname (Required).
=item B<--scvmm-username>
SCVMM username (Required).
=item B<--scvmm-password>
SCVMM password (Required).
=item B<--scvmm-port>
SCVMM port (Default: 8100).
=item B<--timeout>
Set timeout time for command execution (Default: 50 sec)
=item B<--no-ps>
Don't encode powershell. To be used with --command and 'type' command.
=item B<--command>
Command to get information (Default: 'powershell.exe').
Can be changed if you have output in a file. To be used with --no-ps option!!!
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-exec-only>
Print powershell output.
=item B<--filter-vm>
Filter virtual machines (can be a regexp).
=item B<--filter-hostgroup>
Filter hostgroup (can be a regexp).
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{vm}, %{status}, %{hostgroup}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /Running|Stopped/i').
Can used special variables like: %{vm}, %{status}, %{hostgroup}
=back
=cut

View File

@ -33,8 +33,11 @@ sub new {
%{$self->{modes}} = (
'scvmm-integration-service' => 'apps::hyperv::2012::local::mode::scvmmintegrationservice',
'scvmm-snapshot' => 'apps::hyperv::2012::local::mode::scvmmsnapshot',
'scvmm-vm-status' => 'apps::hyperv::2012::local::mode::scvmmvmstatus',
'node-integration-service' => 'apps::hyperv::2012::local::mode::nodeintegrationservice',
'node-replication' => 'apps::hyperv::2012::local::mode::nodereplication',
'node-snapshot' => 'apps::hyperv::2012::local::mode::nodesnapshot',
'node-vm-status' => 'apps::hyperv::2012::local::mode::nodevmstatus',
);
return $self;

View File

@ -0,0 +1,146 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::mode::audioengineusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'engine', type => 1, cb_prefix_output => 'prefix_engine_output', message_multiple => 'All audio engines are ok' }
];
$self->{maps_counters}->{engine} = [
{ label => 'avg-load', set => {
key_values => [ { name => 'i3MsAudioEngineAverageLoad' }, { name => 'display' } ],
output_template => 'Average Load : %s',
perfdatas => [
{ label => 'load_avg', value => 'i3MsAudioEngineAverageLoad_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'elem-count', set => {
key_values => [ { name => 'i3MsAudioEngineElementCount' }, { name => 'display' } ],
output_template => 'Total active graph elements : %s',
perfdatas => [
{ label => 'elem_count', value => 'i3MsAudioEngineElementCount_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-location:s" => { name => 'filter_location' },
});
return $self;
}
sub prefix_engine_output {
my ($self, %options) = @_;
return "Audio Engine '" . $options{instance_value}->{display} . "' ";
}
my $mapping = {
i3MsAudioEngineLocation => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.4' },
i3MsAudioEngineAverageLoad => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.6' },
i3MsAudioEngineElementCount => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.8' },
};
my $oid_i3MsAudioEngineInfoTableEntry = '.1.3.6.1.4.1.2793.8227.2.1.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{engine} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3MsAudioEngineInfoTableEntry,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{i3MsAudioEngineLocation}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' &&
$result->{i3MsAudioEngineLocation} !~ /$self->{option_results}->{filter_location}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3MsAudioEngineLocation} . "': no matching filter.", debug => 1);
next;
}
$self->{engine}->{$instance} = { display => $result->{i3MsAudioEngineLocation},
%$result
};
}
if (scalar(keys %{$self->{engine}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No audio engine found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check audio engine usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^elem-count$'
=item B<--filter-location>
Filter location name (can be a regexp).
=item B<--warning-*>
Threshold warning.
Can be: 'elem-count', 'avg-load'.
=item B<--critical-*>
Threshold critical.
Can be: 'elem-count', 'avg-load'.
=back
=cut

View File

@ -0,0 +1,307 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::mode::cmdsrvusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_i3MsCmdSrvStatus'};
$self->{result_values}->{accept_sessions} = $options{new_datas}->{$self->{instance} . '_i3MsCmdSrvAcceptSessions'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_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});
my $msg = sprintf("Disk 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});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'cmd', type => 1, cb_prefix_output => 'prefix_cmd_output', message_multiple => 'All command servers are ok' }
];
$self->{maps_counters}->{cmd} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'i3MsCmdSrvStatus' }, { name => 'i3MsCmdSrvAcceptSessions' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
{ label => 'usage', set => {
key_values => [ { name => 'display' }, { name => 'free' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
{ label => 'resource-count', set => {
key_values => [ { name => 'i3MsCmdSrvResourceCount' }, { name => 'display' } ],
output_template => 'Resource Count : %s',
perfdatas => [
{ label => 'resource_count', value => 'i3MsCmdSrvResourceCount_absolute', template => '%d',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-client:s" => { name => 'filter_client' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^ready/i' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub prefix_cmd_output {
my ($self, %options) = @_;
return "Command Server '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_status = (1 => 'unknown', 1 => 'ready', 2 => 'notready', 3 => 'error');
my %map_truth = (1 => 'true', 2 => 'false');
my $mapping = {
i3MsCmdSrvAcceptSessions => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.8', map => \%map_truth },
i3MsCmdSrvStatus => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.2', map => \%map_status },
i3MsCmdSrvClient => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.6' },
i3MsCmdSrvResourceCount => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.9' },
i3MsCmdSrvRecFreeDiskSpace => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.12' },
i3MsCmdSrvRecTotalDiskSpace => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.13' },
};
my $oid_i3MsCommandServerInfoTableEntry = '.1.3.6.1.4.1.2793.8227.2.2.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{cmd} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3MsCommandServerInfoTableEntry,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{i3MsCmdSrvStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_client}) && $self->{option_results}->{filter_client} ne '' &&
$result->{i3MsCmdSrvClient} !~ /$self->{option_results}->{filter_client}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3MsCmdSrvClient} . "': no matching filter.", debug => 1);
next;
}
$self->{cmd}->{$instance} = {
display => $result->{i3MsCmdSrvClient},
total => $result->{i3MsCmdSrvRecTotalDiskSpace} * 1024 * 1024,
free => $result->{i3MsCmdSrvRecFreeDiskSpace} * 1024 * 1024,
%$result
};
}
if (scalar(keys %{$self->{cmd}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No command server found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check command servers usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^status$'
=item B<--filter-client>
Filter client name (can be a regexp).
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{accept_sessions}, %{status}, %{display}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /^ready/i').
Can used special variables like: %{accept_sessions}, %{status}, %{display}
=item B<--warning-*>
Threshold warning.
Can be: 'usage', 'resource-count'.
=item B<--critical-*>
Threshold critical.
Can be: 'usage', 'resource-count'.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=back
=cut

View File

@ -0,0 +1,138 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::mode::component;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(device)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
device => [
['unknown', 'UNKNOWN'],
['up', 'OK'],
['down', 'CRITICAL'],
['congested', 'WARNING'],
['restarting', 'OK'],
['quiescing', 'OK'],
['testing', 'OK'],
],
};
$self->{components_path} = 'apps::inin::mediaserver::snmp::mode::components';
$self->{components_module} = ['device'];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, no_load_components => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
1;
=head1 MODE
Check hardware devices.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'device'.
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='device,WARNING,restarting'
=back
=cut
package apps::inin::mediaserver::snmp::mode::components::device;
use strict;
use warnings;
my %map_status = (1 => 'unknown', 2 => 'up', 3 => 'down', 4 => 'congested',
5 => 'restarting', 6 => 'quiescing', 7 => 'testing'
);
my $mapping = {
i3MsGeneralInfoOperStatus => { oid => '.1.3.6.1.4.1.2793.8227.1.2', map => \%map_status },
};
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{i3MsGeneralInfoOperStatus}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking devices");
$self->{components}->{device} = {name => 'devices', total => 0, skip => 0};
return if ($self->check_filter(section => 'device'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{i3MsGeneralInfoOperStatus}->{oid}}, instance => '0');
return if (!defined($result->{i3MsGeneralInfoOperStatus}));
$self->{components}->{device}->{total}++;
$self->{output}->output_add(long_msg => sprintf("device status is '%s' [instance = %s]",
$result->{i3MsGeneralInfoOperStatus}, '0'));
my $exit = $self->get_severity(section => 'device', value => $result->{i3MsGeneralInfoOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Device status is '%s'", $result->{i3MsGeneralInfoOperStatus}));
}
}
1;

View File

@ -0,0 +1,200 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::mode::diskusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'disktracelog', type => 0 },
{ name => 'diskhttpcache', type => 0 },
];
$self->{maps_counters}->{disktracelog} = [
{ label => 'tracelog-usage', set => {
key_values => [ { name => 'free' }, { name => 'total' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
];
$self->{maps_counters}->{diskhttpcache} = [
{ label => 'httpcache-usage', set => {
key_values => [ { name => 'free' }, { name => 'total' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
];
}
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used_' . $self->{result_values}->{display};
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
$label = 'free_' . $self->{result_values}->{display};
$value_perf = $self->{result_values}->{free};
}
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(label => $label, unit => 'B',
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_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});
my $msg = sprintf("Disk '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$self->{result_values}->{display},
$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});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_i3MsGeneralInfoTracelogFreeDiskSpace = '.1.3.6.1.4.1.2793.8227.1.12.0'; # MiB
my $oid_i3MsGeneralInfoTracelogTotalDiskSpace = '.1.3.6.1.4.1.2793.8227.1.13.0'; # MiB
my $oid_i3MsGeneralInfoHttpCacheFreeDiskSpace = '.1.3.6.1.4.1.2793.8227.1.15.0'; # MiB
my $oid_i3MsGeneralInfoHttpCacheTotalDiskSpace = '.1.3.6.1.4.1.2793.8227.1.16.0'; # MiB
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_i3MsGeneralInfoTracelogFreeDiskSpace, $oid_i3MsGeneralInfoTracelogTotalDiskSpace,
$oid_i3MsGeneralInfoHttpCacheFreeDiskSpace, $oid_i3MsGeneralInfoHttpCacheTotalDiskSpace
], nothing_quit => 1);
$self->{disktracelog} = {
free => $snmp_result->{$oid_i3MsGeneralInfoTracelogFreeDiskSpace} * 1024 * 1024,
total => $snmp_result->{$oid_i3MsGeneralInfoTracelogTotalDiskSpace} * 1024 * 1024,
display => 'tracelog'
};
$self->{diskhttpcache} = {
free => $snmp_result->{$oid_i3MsGeneralInfoHttpCacheFreeDiskSpace} * 1024 * 1024,
total => $snmp_result->{$oid_i3MsGeneralInfoHttpCacheTotalDiskSpace} * 1024 * 1024,
display => 'httpcache'
};
}
1;
__END__
=head1 MODE
Check disk usages.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'httpcache-usage', 'tracelog-usage'.
=item B<--critical-*>
Threshold critical.
Can be: 'httpcache-usage', 'tracelog-usage'.
=item B<--units>
Default is '%', can be 'B'
=item B<--free>
Thresholds are on free space left.
=back
=cut

View File

@ -0,0 +1,95 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::mode::memoryusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }
];
$self->{maps_counters}->{global} = [
{ label => 'usage', set => {
key_values => [ { name => 'used' } ],
output_template => 'Memory Used : %s %s',
output_change_bytes => 1,
perfdatas => [
{ label => 'used', value => 'used_absolute', template => '%s',
unit => 'B', min => 0 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_i3MsGeneralInfoMemoryUsage = '.1.3.6.1.4.1.2793.8227.1.10.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_i3MsGeneralInfoMemoryUsage
], nothing_quit => 1);
$self->{global} = { used => $snmp_result->{$oid_i3MsGeneralInfoMemoryUsage} };
}
1;
__END__
=head1 MODE
Check memory.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'usage' (B).
=item B<--critical-*>
Threshold critical.
Can be: 'usage' (B).
=back
=cut

View File

@ -0,0 +1,52 @@
#
# Copyright 2017 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::inin::mediaserver::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
'component' => 'apps::inin::mediaserver::snmp::mode::component',
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Interactive Intelligence Media Server in SNMP.
=cut

View File

@ -206,8 +206,7 @@ sub result {
$self->check_results();
$self->{output}->perfdata_add(label => "time", unit => 'ms',
value => sprintf('%.3f', $self->{timeelapsed}));
value => sprintf('%.3f', $self->{timeelapsed})) if (defined($self->{timeelapsed}));
}
sub run {

View File

@ -273,7 +273,7 @@ __END__
Check JSON webservice. Can send the json request with option '--data'. Example:
centreon_plugins.pl --plugin=apps::protocols::http::plugin --mode=json-content --data='/home/user/request.json' --hostname='myws.site.com' --urlpath='/get/payment'
--lookup='$..expiration'
--lookup='$..expiration' --header='Content-Type: application/json'
JSON OPTIONS:

View File

@ -90,15 +90,15 @@ sub run {
if (!defined($connection)) {
if (!defined($!) || ($! eq '')) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => "Connection failed : SSL error");
short_msg => sprintf("Connection failed on port %s : SSL error", $self->{option_results}->{port}));
} else {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Connection failed : %s", $!));
short_msg => sprintf("Connection failed on port %s : %s", $self->{option_results}->{port}, $!));
}
} else {
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time %.3fs", $timeelapsed));
short_msg => sprintf("Response time on port %s is %.3fs", $self->{option_results}->{port}, $timeelapsed));
$self->{output}->perfdata_add(label => 'time',
value => sprintf('%.3f', $timeelapsed),
unit => 's',

View File

@ -0,0 +1,48 @@
#
# Copyright 2017 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::sendmail::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'mta-usage' => 'snmp_standard::mode::mtausage',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Sendmail MTA server in SNMP.
=cut

View File

@ -31,12 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'memory' => 'centreon::common::jvm::mode::memory',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'class-count' => 'centreon::common::jvm::mode::classcount',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'gc-usage' => 'centreon::common::jvm::mode::gcusage',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
);

View File

@ -0,0 +1,94 @@
#
# Copyright 2017 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::vmware::connector::mode::listclusters;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"cluster:s" => { name => 'cluster' },
"filter" => { name => 'filter' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub run {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
$self->{connector}->set_discovery();
$self->{connector}->add_params(params => $self->{option_results},
command => 'listclusters');
$self->{connector}->run();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name']);
}
sub disco_show {
my ($self, %options) = @_;
$self->{connector} = $options{custom};
# We ask to use XML output from the connector
$self->{connector}->add_params(params => { disco_show => 1 });
$self->run(custom => $self->{connector});
}
1;
__END__
=head1 MODE
List clusters.
=over 8
=item B<--cluster>
Cluster to check.
If not set, we check all clusters.
=item B<--filter>
Cluster is a regexp.
=back
=cut

View File

@ -47,6 +47,7 @@ sub new {
'getmap' => 'apps::vmware::connector::mode::getmap',
'health-host' => 'apps::vmware::connector::mode::healthhost',
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
'list-clusters' => 'apps::vmware::connector::mode::listclusters',
'list-datacenters' => 'apps::vmware::connector::mode::listdatacenters',
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
'list-nichost' => 'apps::vmware::connector::mode::listnichost',

View File

@ -199,7 +199,8 @@ sub manage_selection {
{ oid => $mapping3->{bsnAPAdminStatus}->{oid} },
],
nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'});
$self->{output}->output_add(long_msg => "Model: " .
(defined($self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}) ? $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'} : 'unknown'));
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnAPName}->{oid} }}) {
$oid =~ /^$mapping->{bsnAPName}->{oid}\.(.*)$/;
my $instance = $1;

View File

@ -219,7 +219,8 @@ sub manage_selection {
{ oid => $oid_bsnAPIfLoadNumOfClients },
],
nothing_quit => 1);
$self->{output}->output_add(long_msg => "Model: " . $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'});
$self->{output}->output_add(long_msg => "Model: " .
(defined($self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'}) ? $self->{results}->{$oid_agentInventoryMachineModel}->{$oid_agentInventoryMachineModel . '.0'} : 'unknown'));
foreach my $oid (keys %{$self->{results}->{ $mapping->{bsnMobileStationStatus}->{oid} }}) {
$oid =~ /^$mapping->{bsnMobileStationStatus}->{oid}\.(.*)$/;
my $instance = $1;

View File

@ -188,7 +188,7 @@ my $oid_wlsxUserEntry = '.1.3.6.1.4.1.14823.2.2.1.4.1.2.1';
my $oid_wlsxSwitchRole = '.1.3.6.1.4.1.14823.2.2.1.1.1.4';
my $oid_apESSID = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.2';
my $oid_apIpAddress = '.1.3.6.1.4.1.14823.2.2.1.1.3.3.1.5';
my $oid_wlanAPName = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3';
#my $oid_wlanAPName = '.1.3.6.1.4.1.14823.2.2.1.5.2.1.4.1.3';
sub manage_selection {
my ($self, %options) = @_;
@ -205,7 +205,7 @@ sub manage_selection {
{ oid => $mapping2->{nUserApBSSID}->{oid} },
{ oid => $oid_apESSID },
{ oid => $oid_apIpAddress },
{ oid => $oid_wlanAPName },
#{ oid => $oid_wlanAPName },
],
nothing_quit => 1);
@ -241,8 +241,8 @@ sub manage_selection {
$bssid !~ /$self->{option_results}->{filter_bssid}/);
my $ap_id = $bssid;
$ap_id = $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}
if (defined($self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}) && $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid} ne '');
#$ap_id = $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}
# if (defined($self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid}) && $self->{results}->{$oid_wlanAPName}->{$oid_wlanAPName . '.' . $bssid} ne '');
$self->{ap}->{$bssid} = { users => 0, ap_id => $ap_id } if (!defined($self->{ap}->{$bssid}));
$self->{ap}->{$bssid}->{users}++;

View File

@ -0,0 +1,119 @@
#
# Copyright 2017 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 centreon::common::ingrian::snmp::mode::connections;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
key_values => [ { name => 'naeTotalTotalConnections', diff => 1 } ],
output_template => 'Total Connections : %s',
perfdatas => [
{ label => 'total', value => 'naeTotalTotalConnections_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'ssl', set => {
key_values => [ { name => 'naeTotalSSLConnections', diff => 1 } ],
output_template => 'Total SSL Connections : %s',
perfdatas => [
{ label => 'total_ssl', value => 'naeTotalSSLConnections_absolute', template => '%s', min => 0 },
],
}
},
{ label => 'non-ssl', set => {
key_values => [ { name => 'naeTotalNonSSLConnections', diff => 1 } ],
output_template => 'Total non-SSL Connections : %s',
perfdatas => [
{ label => 'total_non_ssl', value => 'naeTotalNonSSLConnections_absolute', template => '%s', min => 0 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
my $mapping = {
naeTotalTotalConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.4' },
naeTotalNonSSLConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.5.4' },
naeTotalSSLConnections => { oid => '.1.3.6.1.4.1.5595.3.5.1.6.4' },
};
my $oid_naeConnectionStats = '.1.3.6.1.4.1.5595.3.5';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_naeConnectionStats,
nothing_quit => 1);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
$self->{global} = { %$result };
$self->{cache_name} = "ingrian_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check connections.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'total', 'ssl', 'non-ssl'.
=item B<--critical-*>
Threshold critical.
Can be: 'total', 'ssl', 'non-ssl'.
=back
=cut

View File

@ -0,0 +1,138 @@
#
# Copyright 2017 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 centreon::common::ingrian::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_init => 'skip_global', },
{ name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPU usages are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total CPU Usage : %.2f %%',
perfdatas => [
{ label => 'total_cpu_avg', value => 'total_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
],
}
},
];
$self->{maps_counters}->{cpu} = [
{ label => 'usage', set => {
key_values => [ { name => 'usage' }, { name => 'display' }, ],
output_template => 'Usage : %.2f %%',
perfdatas => [
{ label => 'cpu', value => 'usage_absolute', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub skip_global {
my ($self, %options) = @_;
scalar(keys %{$self->{cpu}}) > 1 ? return(0) : return(1);
}
sub prefix_cpu_output {
my ($self, %options) = @_;
return "CPU '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
my $mapping = {
naeSystemCPUDescr => { oid => '.1.3.6.1.4.1.5595.3.2.4.1.2' },
naeSystemCPUUtilization => { oid => '.1.3.6.1.4.1.5595.3.2.4.1.3' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_naeSystemStatCPUEntry = '.1.3.6.1.4.1.5595.3.2.4.1';
my $oid_naeSystemStatCPU = '.1.3.6.1.4.1.5595.3.2.2'; # without .0
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_naeSystemStatCPU },
{ oid => $oid_naeSystemStatCPUEntry },
], nothing_quit => 1);
$self->{cpu} = {};
foreach my $oid (keys %{$snmp_result->{$oid_naeSystemStatCPUEntry}}) {
next if ($oid !~ /^$mapping->{naeSystemCPUUtilization}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_naeSystemStatCPUEntry}, instance => $instance);
$self->{cpu}->{$instance} = { display => $instance - 1, usage => $result->{naeSystemCPUUtilization} };
}
$self->{global} = { total => $snmp_result->{$oid_naeSystemStatCPU}->{$oid_naeSystemStatCPU . '.0'} };
}
1;
__END__
=head1 MODE
Check CPU usages.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^total$'
=item B<--warning-*>
Threshold warning.
Can be: 'total', 'usage'.
=item B<--critical-*>
Threshold critical.
Can be: 'total', 'usage'.
=back
=cut

View File

@ -0,0 +1,109 @@
#
# Copyright 2017 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 centreon::common::ingrian::snmp::mode::disk;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All disk usages are ok' }
];
$self->{maps_counters}->{disk} = [
{ label => 'usage', set => {
key_values => [ { name => 'used' }, { name => 'display' } ],
output_template => 'Used : %.2f %%',
perfdatas => [
{ label => 'used', value => 'used_absolute', template => '%.2f', min => 0, max => 100, unit => '%',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_disk_output {
my ($self, %options) = @_;
return "Disk '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
my $mapping = {
naeSystemDiskDescr => { oid => '.1.3.6.1.4.1.5595.3.2.7.1.2' },
naeSystemDiskUtilization => { oid => '.1.3.6.1.4.1.5595.3.2.7.1.3' },
};
my $oid_naeSystemStatDiskEntry = '.1.3.6.1.4.1.5595.3.2.7.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{disk} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_naeSystemStatDiskEntry,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{naeSystemDiskUtilization}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{disk}->{$instance} = { display => $result->{naeSystemDiskDescr},
used => $result->{naeSystemDiskUtilization}};
}
}
1;
__END__
=head1 MODE
Check disk usages.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -0,0 +1,135 @@
#
# Copyright 2017 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 centreon::common::ingrian::snmp::mode::memory;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub custom_usage_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'used', unit => 'B',
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_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});
my $msg = sprintf("Memory 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});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{prct_used} = $options{new_datas}->{$self->{instance} . '_prct_used'};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
$self->{result_values}->{used} = $self->{result_values}->{total} * $self->{result_values}->{prct_used} / 100;
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'memory', type => 0 }
];
$self->{maps_counters}->{memory} = [
{ label => 'usage', set => {
key_values => [ { name => 'prct_used' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_naeSystemStatUsedMem = '.1.3.6.1.4.1.5595.3.2.5.0';
my $oid_naeSystemStatTotalMem = '.1.3.6.1.4.1.5595.3.2.6.0'; # in Bytes
my $snmp_result = $options{snmp}->get_leef(oids => [$oid_naeSystemStatUsedMem, $oid_naeSystemStatTotalMem],
nothing_quit => 1);
$self->{memory} = { prct_used => $snmp_result->{$oid_naeSystemStatUsedMem}, total => $snmp_result->{$oid_naeSystemStatTotalMem} };
}
1;
__END__
=head1 MODE
Check memory usages.
=over 8
=item B<--warning-usage>
Threshold warning (in percent).
=item B<--critical-usage>
Threshold critical (in percent).
=back
=cut

View File

@ -0,0 +1,152 @@
#
# Copyright 2017 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 centreon::common::ingrian::snmp::mode::requeststats;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'rq', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All request statistics are ok' }
];
$self->{maps_counters}->{rq} = [
{ label => 'success', set => {
key_values => [ { name => 'success', diff => 1 }, { name => 'display' } ],
output_template => 'Success : %s',
perfdatas => [
{ label => 'success', value => 'success_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'fail', set => {
key_values => [ { name => 'fail', diff => 1 }, { name => 'display' } ],
output_template => 'Fail : %s',
perfdatas => [
{ label => 'fail', value => 'fail_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_disk_output {
my ($self, %options) = @_;
return "'" . $options{instance_value}->{display} . "' requests ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
my @map = (
{ label => 'Total', suffix => 1 },
{ label => 'KeyGen', suffix => 2 },
{ label => 'KeyInfo', suffix => 3 },
{ label => 'KeyDel', suffix => 4 },
{ label => 'KeyQuery', suffix => 5 },
{ label => 'KeyImport', suffix => 6 },
{ label => 'KeyExport', suffix => 7 },
{ label => 'RandomGen', suffix => 8 },
{ label => 'Cryptographic', suffix => 9 },
{ label => 'Authenticate', suffix => 10 },
{ label => 'KeyModify', suffix => 11 },
{ label => 'KeyClone', suffix => 12 },
{ label => 'CertificateExport', suffix => 13 },
{ label => 'KeyVersionGenerate', suffix => 14 },
{ label => 'KeyVersionModify', suffix => 15 },
{ label => 'KeyCertificateExport', suffix => 16 },
{ label => 'RecordEvent', suffix => 17 },
{ label => 'PublicKeyExport', suffix => 18 },
{ label => 'CAExport', suffix => 19 },
);
my $oid_naeServerStats = '.1.3.6.1.4.1.5595.3.3';
sub manage_selection {
my ($self, %options) = @_;
$self->{rq} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_naeServerStats,
nothing_quit => 1);
foreach (@map) {
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$_->{label} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $_->{label} . "': no matching filter.", debug => 1);
next;
}
$self->{rq}->{$_->{suffix}} = {
display => $_->{label},
success => $snmp_result->{$oid_naeServerStats . '.' . $_->{suffix} . '.3.0'},
fail => $snmp_result->{$oid_naeServerStats . '.' . $_->{suffix} . '.4.0'}
};
}
$self->{cache_name} = "ingrian_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check request statistics.
=over 8
=item B<--filter-name>
Filter by name (can be a regexp).
=item B<--warning-*>
Threshold warning.
Can be: 'success', 'fail'.
=item B<--critical-*>
Threshold critical.
Can be: 'success', 'fail'.
=back
=cut

View File

@ -0,0 +1,139 @@
#
# Copyright 2017 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 centreon::common::jvm::mode::gcusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'gc', type => 1, cb_prefix_output => 'prefix_gc_output', message_multiple => 'All garbage collectors are ok' }
];
$self->{maps_counters}->{gc} = [
{ label => 'time', set => {
key_values => [ { name => 'time', diff => 1 }, { name => 'display' } ],
output_template => 'Collection Time : %s ms',
perfdatas => [
{ label => 'time', value => 'time_absolute', template => '%s',
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'count', set => {
key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ],
output_template => 'Collection Count : %s',
perfdatas => [
{ label => 'count', value => 'count_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_gc_output {
my ($self, %options) = @_;
return "Garbage collector '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
$self->{request} = [
{ mbean => "java.lang:type=GarbageCollector,name=*", attributes => [ { name => 'CollectionCount' }, { name => 'CollectionTime' } ] }
];
$self->{gc} = {};
my $result = $options{custom}->get_attributes(request => $self->{request}, nothing_quit => 1);
foreach my $key (keys %$result) {
$key =~ /name=(.*?)(?:,|$)/;
my $name = $1;
$self->{gc}->{$name} = {
display => $name,
time => $result->{$key}->{CollectionTime},
count => $result->{$key}->{CollectionCount}
}
}
if (scalar(keys %{$self->{gc}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No garbage collector found.");
$self->{output}->option_exit();
}
$self->{cache_name} = "jvm_standard_" . $self->{mode} . '_' . md5_hex($options{custom}->{url}) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check garbage collectors.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^count$'
=item B<--filter-name>
Filter garbage collector name (can be a regexp).
=item B<--warning-*>
Threshold warning.
Can be: 'count', 'time' (ms).
=item B<--critical-*>
Threshold critical.
Can be: 'count', 'time' (ms).
=back
=cut

View File

@ -35,13 +35,13 @@ my %mapping_memory = (
'CMS Perm Gen' => 'permanent',
'PS Perm Gen' => 'permanent',
'Perm Gen' => 'permanent',
'Metaspace' => 'permanent',
'Code Cache' => 'code',
'CMS Old Gen' => 'tenured',
'PS Old Gen' => 'tenured',
'Tenured Gen' => 'tenured',
);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -94,6 +94,12 @@ sub run {
foreach my $key (keys %$result) {
$key =~ /name=(.*?),type/;
my $memtype = $1;
if (!defined($mapping_memory{$memtype})) {
$self->{output}->output_add(long_msg => "unknown memory type: " . $memtype, debug => 1);
next;
}
my $prct = $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{used} / $result->{"java.lang:name=".$memtype.",type=MemoryPool"}->{Usage}->{max} * 100;
$self->{output}->perfdata_add(label => $mapping_memory{$memtype}, unit => 'B',

View File

@ -33,23 +33,16 @@ sub get_powershell {
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"
$vms = Get-VM
$services = Get-VMIntegrationService -VMName *
Foreach ($vm in $vms) {
$i = 0
Foreach ($service in $services) {
if ($services.VMName -eq $vm.VMName) {
if ($i -eq 0) {
Write-Host "[name=" $vm.VMName "][state=" $vm.State "]"
}
Write-Host "[service=" $service.Name "][primaryOperationalStatus=" $service.PrimaryOperationalStatus "][secondaryOperationalStatus=" $service.SecondaryOperationalStatus "]"
$i=1
}
Write-Host "[name=" $vm.VMName "][state=" $vm.State "][IntegrationServicesState=" $vm.IntegrationServicesState "][IntegrationServicesVersion=" $vm.IntegrationServicesVersion "]"
Foreach ($service in $VM.VMIntegrationService) {
Write-Host "[service=" $service.Name "][enabled=" $service.Enabled "][primaryOperationalStatus=" $service.PrimaryOperationalStatus "][secondaryOperationalStatus=" $service.SecondaryOperationalStatus "]"
}
}
} Catch {

View File

@ -0,0 +1,64 @@
#
# Copyright 2017 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 centreon::common::powershell::hyperv::2012::nodereplication;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"
$vms = Get-VMReplication
Foreach ($vm in $vms) {
Write-Host "[name=" $vm.Name "][state=" $vm.State "][health=" $vm.Health "]"
}
} Catch {
Write-Host $Error[0].Exception
exit 1
}
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
}
1;
__END__
=head1 DESCRIPTION
Method to get hyper-v informations.
=cut

View File

@ -33,12 +33,15 @@ sub get_powershell {
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"
$vms = Get-VM
$snapshots = Get-VMSnapshot -VMName *
if ($vms.Length -gt 0) {
$snapshots = Get-VMSnapshot -VMName *
}
Foreach ($vm in $vms) {
$i=0
Foreach ($snap in $snapshots) {

View File

@ -0,0 +1,64 @@
#
# Copyright 2017 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 centreon::common::powershell::hyperv::2012::nodevmstatus;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"
$vms = Get-VM
Foreach ($vm in $vms) {
Write-Host "[name=" $vm.VMName "][state=" $vm.State "][status=" $vm.Status "][IsClustered=" $vm.IsClustered "]"
}
} Catch {
Write-Host $Error[0].Exception
exit 1
}
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
}
1;
__END__
=head1 DESCRIPTION
Method to get hyper-v informations.
=cut

View File

@ -33,6 +33,7 @@ sub get_powershell {
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"

View File

@ -33,6 +33,7 @@ sub get_powershell {
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 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 centreon::common::powershell::hyperv::2012::scvmmvmstatus;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
$ProgressPreference = "SilentlyContinue"
Try {
$ErrorActionPreference = "Stop"
Import-Module -Name "virtualmachinemanager"
$username = "' . $options{scvmm_username} . '"
$password = ConvertTo-SecureString "' . $options{scvmm_password} . '" -AsPlainText -Force
$UserCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password
$connection = Get-VMMServer -ComputerName "' . $options{scvmm_hostname} . '" -TCPPort ' . $options{scvmm_port} . ' -Credential $UserCredential
$vms = Get-SCVirtualMachine -VMMServer $connection
Foreach ($vm in $vms) {
Write-Host "[name=" $vm.Name "][status=" $vm.Status "][cloud=" $vm.Cloud "][hostgrouppath=" $vm.HostGroupPath "]"
}
} Catch {
Write-Host $Error[0].Exception
exit 1
}
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
}
1;
__END__
=head1 DESCRIPTION
Method to get hyper-v informations.
=cut

View File

@ -125,20 +125,17 @@ sub check_options {
$self->{connect_params}->{password} = $self->{password};
}
if (defined($self->{proxy_url}) && $self->{proxy_url} ne '') {
$self->{connect_params}->{username}->{proxy} = { http => undef, https => undef };
if ($self->{proxy_url} =~ /^(.*?):/) {
$self->{connect_params}->{username}->{proxy}->{$1} = $self->{proxy_url};
if (defined($self->{proxy_username}) && $self->{proxy_username} ne '') {
$self->{connect_params}->{proxy_user} = $self->{proxy_username};
$self->{connect_params}->{proxy_password} = $self->{proxy_password};
}
$self->{connect_params}->{proxy} = { url => $self->{proxy_url} };
if (defined($self->{proxy_username}) && $self->{proxy_username} ne '') {
$self->{connect_params}->{proxy}->{'proxy-user'} = $self->{proxy_username};
$self->{connect_params}->{proxy}->{'proxy-password'} = $self->{proxy_password};
}
}
if (defined($self->{target_url}) && $self->{target_url} ne '') {
$self->{connect_params}->{username}->{target} = { url => $self->{target_url}, user => undef, password => undef };
$self->{connect_params}->{target} = { url => $self->{target_url}, user => undef, password => undef };
if (defined($self->{target_username}) && $self->{target_username} ne '') {
$self->{connect_params}->{username}->{target}->{user} = $self->{target_username};
$self->{connect_params}->{username}->{target}->{password} = $self->{target_password};
$self->{connect_params}->{target}->{user} = $self->{target_username};
$self->{connect_params}->{target}->{password} = $self->{target_password};
}
}
@ -168,6 +165,16 @@ sub _add_request {
return $request;
}
sub check_error {
my ($self, %options) = @_;
# 500-599 an error. 400 is an attribute not present
if ($options{response}->status() >= 500 || $options{response}->status() == 401 || $options{response}->status() == 408) {
$self->{output}->add_option_msg(short_msg => "protocol issue: " . $options{response}->error_text());
$self->{output}->option_exit();
}
}
sub get_attributes {
my ($self, %options) = @_;
my $nothing_quit = defined($options{nothing_quit}) && $options{nothing_quit} == 1 ? 1 : 0;
@ -200,13 +207,9 @@ sub get_attributes {
my @responses = $self->{jmx4perl}->request(@requests);
for (my $i = 0, my $pos = 0; defined($options{request}) && $i < scalar(@{$options{request}}); $i++) {
for (my $j = 0; defined($options{request}->[$i]->{attributes}) &&
$j < scalar(@{$options{request}->[$i]->{attributes}}); $j++, $pos++) {
defined($responses[$pos]) && $j < scalar(@{$options{request}->[$i]->{attributes}}); $j++, $pos++) {
if ($responses[$pos]->is_error()) {
# 500-599 an error. 400 is an attribute not present
if ($responses[$pos]->status() >= 500 || $responses[$pos]->status() == 401) {
$self->{output}->add_option_msg(short_msg => "protocol issue: " . $responses[$pos]->error_text());
$self->{output}->option_exit();
}
$self->check_error(response => $responses[$pos]);
next;
}
@ -225,10 +228,14 @@ sub get_attributes {
}
if (!defined($options{request}->[$i]->{attributes}) || scalar(@{$options{request}->[$i]->{attributes}}) == 0) {
my $mbean = $responses[$pos]->{request}->{mbean};
$response->{$mbean} = {} if (!defined($response->{$mbean}));
foreach (keys %{$responses[$pos]->{value}}) {
$response->{$mbean}->{$_} = $responses[$pos]->{value}->{$_};
if ($responses[$pos]->is_error()) {
$self->check_error(response => $responses[$pos]);
} else {
my $mbean = $responses[$pos]->{request}->{mbean};
$response->{$mbean} = {} if (!defined($response->{$mbean}));
foreach (keys %{$responses[$pos]->{value}}) {
$response->{$mbean}->{$_} = $responses[$pos]->{value}->{$_};
}
}
$pos++;
}
@ -332,7 +339,7 @@ Credentials to use for the HTTP request
=item B<--proxy-url>
Optional proxy to use.
Optional HTTP proxy to use.
=item B<--proxy-username>
@ -344,7 +351,7 @@ Credentials to use for the proxy
=item B<--target-url>
Target to use (if you use jolokia agent as a proxy)
Target to use (if you use jolokia agent as a proxy in --url option).
=item B<--target-username>

View File

@ -0,0 +1,141 @@
#
# Copyright 2017 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 centreon::common::sun::snmp::mode::components::entity;
use strict;
use warnings;
my %map_class = (
1 => 'other', 2 => 'unknown', 3 => 'chassis',
4 => 'backplane', 5 => 'container', 6 => 'powerSupply',
7 => 'fan', 8 => 'sensor', 9 => 'module',
10 => 'port', 11 => 'stack',
);
my %map_oper_state = (1 => 'disabled', 2 => 'enabled');
my %map_alarm = (
1 => 'critical', 2 => 'major', 3 => 'minor', 4 => 'indeterminate',
5 => 'warning', 6 => 'pending', 7 => 'cleared'
);
my %map_sensor_type = (1 => 'other',
2 => 'unknown', 3 => 'temperature', 4 => 'voltage', 5 => 'current', 6 => 'tachometer',
7 => 'counter', 8 => 'switch', 9 => 'lock', 10 => 'humidity',
11 => 'smokeDetection', 12 => 'presence', 13 => 'airFlow');
my %mapping_units = (
1 => '', 2 => '',
3 => 'C', # Degrees C
4 => 'F', # Degrees F
5 => 'K', # Degrees K
6 => 'V', # Volts
7 => 'A', # Amps,
8 => 'W', # Watts
9 => 'Joules', 10 => 'Coulombs', 11 => 'VA', 12 => 'Nits',
13 => 'Lumens', 14 => 'Lux', 15 => 'Candelas',
16 => 'kPa', 17 => 'PSI', 18 => 'Newtons',
19 => 'CFM', 20 => 'rpm',
21 => 'Hz', # Hertz
22 => 'Seconds', 23 => 'Minutes', 24 => 'Hours',
25 => 'Days', 26 => 'Weeks', 27 => 'Mils',
28 => 'Inches', 29 => 'Feet', 30 => 'Cubic_Inches',
31 => 'Cubic_Feet', 32 => 'Meters', 33 => 'Cubic_Centimeters',
34 => 'Cubic_Meters', 35 => 'Liters', 36 => 'Fluid_Ounces',
37 => 'Radians', 38 => 'Steradians', 39 => 'Revolutions',
40 => 'Cycles', 41 => 'Gravities', 42 => 'Ounces',
43 => 'Pounds', 44 => 'Foot_Pounds', 45 => 'Ounce_Inches',
46 => 'Gauss', 47 => 'Gilberts', 48 => 'Henries',
49 => 'Farads', 50 => 'Ohms', 51 => 'Siemens',
52 => 'Moles', 53 => 'Becquerels', 54 => 'PPM',
55 => 'Decibels', 56 => 'DbA', 57 => 'DbC',
58 => 'Grays', 59 => 'Sieverts', 60 => 'Color_Temperature_Degrees_K',
61 => 'b', # bits
62 => 'B', # Bytes
63 => 'Words', 64 => 'DoubleWords', 65 => 'QuadWords',
66 => '%', # Percentage,
67 => 'Pascals',
);
my $mapping = {
entPhysicalClass => { oid => '.1.3.6.1.2.1.47.1.1.1.1.5', map => \%map_class },
entPhysicalName => { oid => '.1.3.6.1.2.1.47.1.1.1.1.7' },
sunPlatEquipmentOperationalState => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.2.1.2', map => \%map_oper_state },
sunPlatEquipmentAlarmStatus => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.2.1.3', map => \%map_alarm },
sunPlatSensorType => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.6.1.2', map => \%map_sensor_type },
sunPlatNumericSensorBaseUnits => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.8.1.1', map => \%mapping_units },
sunPlatNumericSensorExponent => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.8.1.2' },
sunPlatNumericSensorCurrent => { oid => '.1.3.6.1.4.1.42.2.70.101.1.1.8.1.4' },
};
my $oid_sunPlatEquipmentEntry = '.1.3.6.1.4.1.42.2.70.101.1.1.2.1';
my $oid_sunPlatNumericSensorEntry = '.1.3.6.1.4.1.42.2.70.101.1.1.8.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{entPhysicalName}->{oid} }, { oid => $mapping->{entPhysicalClass}->{oid} },
{ oid => $oid_sunPlatEquipmentEntry }, { oid => $oid_sunPlatNumericSensorEntry },
{ oid => $mapping->{sunPlatSensorType}->{oid} };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking entities");
$self->{components}->{entity} = {name => 'entity', total => 0, skip => 0};
return if ($self->check_filter(section => 'entity'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}})) {
next if ($oid !~ /^$mapping->{entPhysicalName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
next if ($self->check_filter(section => 'entity', instance => $result->{entPhysicalClass} . '.' . $instance));
next if ($result->{sunPlatEquipmentOperationalState} eq 'disabled');
if (defined($result->{sunPlatNumericSensorCurrent})) {
$result->{sunPlatNumericSensorCurrent} *= 10 ** $result->{sunPlatNumericSensorExponent}
}
$self->{components}->{entity}->{total}++;
$self->{output}->output_add(long_msg => sprintf("%s '%s' status is '%s' [instance = %s, value = %s]",
$result->{entPhysicalClass}, $result->{entPhysicalName},
$result->{sunPlatEquipmentAlarmStatus}, $result->{entPhysicalClass} . '.' . $instance,
defined($result->{sunPlatNumericSensorCurrent}) ? $result->{sunPlatNumericSensorCurrent} : '-'));
$exit = $self->get_severity(label => 'default', section => 'entity', instance => $result->{entPhysicalClass} . '.' . $instance, value => $result->{sunPlatEquipmentAlarmStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s '%s' status is '%s'", $result->{entPhysicalClass}, $result->{entPhysicalName}, $result->{sunPlatEquipmentAlarmStatus}));
}
next if (!defined($result->{sunPlatNumericSensorCurrent}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => $result->{sunPlatSensorType}, instance => $result->{entPhysicalClass} . '.' . $instance,, value => $result->{sunPlatNumericSensorCurrent});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("%s '%s' is '%s' %s", $result->{sunPlatSensorType},
$result->{entPhysicalName}, $result->{sunPlatNumericSensorCurrent}, $result->{sunPlatNumericSensorBaseUnits}));
}
$self->{output}->perfdata_add(label => $result->{sunPlatSensorType} . '_' . $result->{entPhysicalName},, unit => $result->{sunPlatNumericSensorBaseUnits},
value => $result->{sunPlatNumericSensorCurrent},
warning => $warn,
critical => $crit
);
}
}
1;

View File

@ -0,0 +1,117 @@
#
# Copyright 2017 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 centreon::common::sun::snmp::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(entity)$';
$self->{regexp_threshold_numeric_check_section_option} =
'^(other|unknown|temperature|voltage|current|tachometer|counter|switch|lock|humidity|smokeDetection|presence|airFlow)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['critical', 'CRITICAL'],
['major', 'CRITICAL'],
['minor', 'WARNING'],
['indeterminate', 'OK'],
['warning', 'WARNING'],
['pending', 'OK'],
['cleared', 'OK'],
],
};
$self->{components_path} = 'centreon::common::sun::snmp::mode::components';
$self->{components_module} = ['entity'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}, return_type => 1);
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check Hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'entity'.
=item B<--filter>
Exclude some parts (comma seperated list)
Can also exclude specific instance: --filter=entity,sensor.18
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='entity,sensor..*,CRITICAL,minor'
=item B<--warning>
Set warning threshold (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,20'
=item B<--critical>
Set critical threshold (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,30'
=back
=cut

View File

@ -40,7 +40,8 @@ sub get_assigned_value {
my (%options) = @_;
if (!defined($options{val}) || $options{val} eq '') {
if ($options{pos} + 1 < $options{num_args} && $ARGV[$options{pos} + 1] !~ /^--/) {
# Add defined also. Hardened code: already see: $ARGV[6] = undef for example
if ($options{pos} + 1 < $options{num_args} && defined($ARGV[$options{pos} + 1]) && $ARGV[$options{pos} + 1] !~ /^--/) {
my $val = $ARGV[$options{pos} + 1];
splice @ARGV, $options{pos} + 1, 1;
return ($options{num_args} - 1, $val);

View File

@ -30,7 +30,7 @@ use Pod::Find qw(pod_where);
my %handlers = (DIE => {});
my $global_version = 20170120;
my $global_version = 20170329;
my $alternative_fatpacker = 0;
sub new {
@ -102,6 +102,7 @@ sub get_plugin {
'version' => { name => 'version' },
'runas:s' => { name => 'runas' },
'environment:s%' => { name => 'environment' },
'convert-args:s' => { name => 'convert_args' },
} );
$self->{options}->parse_options();
@ -113,6 +114,7 @@ sub get_plugin {
$self->{runas} = $self->{options}->get_option(argument => 'runas' );
$self->{environment} = $self->{options}->get_option(argument => 'environment' );
$self->{ignore_warn_msg} = $self->{options}->get_option(argument => 'ignore_warn_msg' );
$self->{convert_args} = $self->{options}->get_option(argument => 'convert_args' );
$self->{output}->mode(name => $self->{mode});
$self->{output}->plugin(name => $self->{plugin});
@ -121,6 +123,17 @@ sub get_plugin {
$self->{options}->clean();
}
sub convert_args {
my ($self) = @_;
if ($self->{convert_args} =~ /^(.+?),(.*)/) {
my ($search, $replace) = ($1, $2);
for (my $i = 0; $i < $#ARGV; $i++) {
$ARGV[$i] =~ s/$search/$replace/g;
}
}
}
sub display_local_help {
my ($self) = @_;
@ -325,12 +338,11 @@ sub run {
$self->display_list_plugin();
$self->{output}->option_exit();
}
if (!defined($self->{plugin}) || $self->{plugin} eq '') {
$self->check_plugin_option();
}
$self->check_plugin_option() if (!defined($self->{plugin}) || $self->{plugin} eq '');
if (defined($self->{ignore_warn_msg})) {
$SIG{__WARN__} = sub {};
}
$self->convert_args() if (defined($self->{convert_args}));
$self->check_relaunch();
@ -387,6 +399,11 @@ Run the script as a different user (prefer to use directly the good user).
Set environment variables for the script (prefer to set it before running it for better performance).
=item B<--convert-args>
Change strings of arguments. Useful to use '!' in nrpe protocol.
Example: --convert-args='##,!'
=back
=head1 DESCRIPTION

View File

@ -140,7 +140,7 @@ sub is_mode {
# $options->{mode} = mode
if (!defined($self->{modes}{$options{mode}})) {
$self->{output}->add_option_msg(short_msg => "mode '" . $options{mode} . "' doesn't exist (use --list option to show available modes).");
$self->{output}->add_option_msg(short_msg => "mode '" . $options{mode} . "' doesn't exist (use --list-mode option to show available modes).");
$self->{output}->option_exit();
}
}

View File

@ -52,6 +52,7 @@ sub new {
"snmp-retries:s" => { name => 'snmp_retries', default => 5 },
"maxrepetitions:s" => { name => 'maxrepetitions', default => 50 },
"subsetleef:s" => { name => 'subsetleef', default => 50 },
"subsettable:s" => { name => 'subsettable', default => 100 },
"snmp-force-getnext" => { name => 'snmp_force_getnext' },
"snmp-username:s" => { name => 'snmp_security_name' },
"authpassphrase:s" => { name => 'snmp_auth_passphrase' },
@ -68,7 +69,6 @@ sub new {
#####
$self->{session} = undef;
$self->{output} = $options{output};
$self->{maxrepetitions} = undef;
$self->{snmp_params} = {};
# Dont load MIB
@ -348,6 +348,7 @@ sub get_multiple_table {
push @bases, $key;
$current_oids++;
last if ($current_oids > $self->{subsettable});
}
# Nothing more to check. We quit
@ -358,7 +359,7 @@ sub get_multiple_table {
if ($self->is_snmpv1() || defined($self->{snmp_force_getnext})) {
$self->{session}->getnext($vb);
} else {
my $current_repeat_count = floor($repeat_count / (scalar(keys %{$working_oids})));
my $current_repeat_count = floor($repeat_count / $current_oids);
$current_repeat_count = 1 if ($current_repeat_count == 0);
$self->{session}->getbulk(0, $current_repeat_count, $vb);
}
@ -433,7 +434,6 @@ sub get_multiple_table {
if ($nothing_quit == 1) {
if ($return_type == 1) {
$total = scalar(keys %{$results});
} else {
foreach (keys %{$results}) {
$total += scalar(keys %{$results->{$_}});
@ -646,6 +646,7 @@ sub check_options {
$self->{snmp_force_getnext} = $options{option_results}->{snmp_force_getnext};
$self->{maxrepetitions} = $options{option_results}->{maxrepetitions};
$self->{subsetleef} = (defined($options{option_results}->{subsetleef}) && $options{option_results}->{subsetleef} =~ /^[0-9]+$/) ? $options{option_results}->{subsetleef} : 50;
$self->{subsettable} = (defined($options{option_results}->{subsettable}) && $options{option_results}->{subsettable} =~ /^[0-9]+$/) ? $options{option_results}->{subsettable} : 100;
$self->{snmp_errors_exit} = $options{option_results}->{snmp_errors_exit};
%{$self->{snmp_params}} = (DestHost => $options{option_results}->{host},

View File

@ -110,6 +110,8 @@ sub new {
});
}
$self->{load_components} = (defined($options{no_load_components}) && $options{no_load_components} == 1) ?
0 : 1;
$self->{components} = {};
$self->{no_components} = undef;
@ -223,7 +225,7 @@ sub load_components {
if (/$self->{option_results}->{component}/) {
my $mod_name = $self->{components_path} . "::$_";
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
error_msg => "Cannot load module '$mod_name'.");
error_msg => "Cannot load module '$mod_name'.") if ($self->{load_components} == 1);
$self->{loaded} = 1;
if ($self->{components_exec_load} == 1) {
my $func = $mod_name->can('load');

View File

@ -1,3 +1,34 @@
2017-03-29 Quentin Garnier <qgarnier@centreon.com>
* Plugin added: Watchguard SNMP
* Plugin added: Intelligence Interactive SNMP
* Plugin added: Oracle Infiniband SNMP
* Plugin added: Beeware SNMP
* Plugin added: Oracle ZFS Storage ZS SNMP
* Plugin added: Safenet Keysecure SNMP
* Plugin added: Oracle OTD SNMP
* Break: path change for Alteon SNMP
2017-03-10 Quentin Garnier <qgarnier@centreon.com>
* Plugin added: Dell FluidFS SNMP
* Plugin added: Clamav
* Plugin added: Sendmail SNMP
* Plugin added: Centreon DSM
* Plugin added: Audiocodes SNMP
* Mode added: [snmp_standard] 'vrrp-status'
* Mode added: [centreon] 'virtualservice'
* Break: path change for Netscaler SNMP
* Fix: perl connector issue
2017-02-16 Quentin Garnier <qgarnier@centreon.com>
* Plugin added: Hyper-v 2012
* Plugin added: Avocent ACS 6000 SNMP
* Plugin added: Alcatel PSS 1830
* Mode added:: [hp lefthand] 'volume-usage'
* Mode added:: [checkpoint] 'vpn-status'
* Mode added:: [f-5 bigip] 'tmm-usage'
* Break: path change for F-5 BigIp
* Break: path change for Checkpoint
2017-01-20 Quentin Garnier <qgarnier@centreon.com>
* Plugin added: SAP Hana DB
* Plugin added: Efficient IP

View File

@ -85,12 +85,12 @@ sub run {
$self->{sql}->connect();
my $query;
if (defined($self->{option_results}->{incremental_level})) {
$query = q{SELECT v$rman_status.object_type,
$query = q{SELECT v$rman_status.object_type,
((max(v$rman_status.start_time) - date '1970-01-01')*24*60*60) as last_time,
NVL(v$backup_set_details.incremental_level, 0)
SUM(v$backup_set_details.incremental_level)
FROM v$rman_status LEFT JOIN v$backup_set_details ON v$rman_status.session_recid = v$backup_set_details.session_recid
WHERE operation='BACKUP'
GROUP BY object_type, incremental_level ORDER BY last_time DESC
GROUP BY object_type, v$backup_set_details.session_recid ORDER BY last_time DESC
};
} else {
$query = q{SELECT object_type,
@ -114,13 +114,12 @@ sub run {
foreach my $row (@$result) {
if (defined($self->{option_results}->{incremental_level})) {
# db incr with incremental level 0 = DB FULL
if (/db full/ && $$row[0] =~ /db incr/i && defined($$row[2]) && $$row[2] == 0) { # it's a full. we get
if (/db full/ && $$row[0] =~ /db incr/i && (!defined($$row[2]) || $$row[2] == 0)) { # it's a full. we get
$$row[0] = 'DB FULL';
} else {
next if (/db incr/ && $$row[0] =~ /db incr/i && defined($$row[2]) && $$row[2] == 0); # it's a full. we skip.
next if (/db incr/ && $$row[0] =~ /db incr/i && (!defined($$row[2]) || $$row[2] == 0)); # it's a full. we skip.
next if ($$row[0] !~ /$_/i);
}
} else {
next if ($$row[0] !~ /$_/i);
}

View File

@ -157,8 +157,8 @@ sub manage_selection {
select db_name(d.dbid) as db_name,
ceiling(sum(case when u.segmap != 4 then u.size/1.*@@maxpagesize end )) as data_size,
ceiling(sum(case when u.segmap != 4 then size - curunreservedpgs(u.dbid, u.lstart, u.unreservedpgs) end)/1.*@@maxpagesize) as data_used,
ceiling(sum(case when u.segmap = 4 then u.size/1.*@@maxpagesize end)) as log_size,
ceiling(sum(case when u.segmap = 4 then u.size/1.*@@maxpagesize end) - lct_admin("logsegment_freepages",d.dbid)/1.*@@maxpagesize) as log_used
ceiling(sum(case when u.segmap in (4, 7) then u.size/1.*@@maxpagesize end)) as log_size,
ceiling(sum(case when u.segmap in (4, 7) then u.size/1.*@@maxpagesize end) - lct_admin("logsegment_freepages",d.dbid)/1.*@@maxpagesize) as log_used
from master..sysdatabases d, master..sysusages u
where u.dbid = d.dbid and d.status not in (256,4096)
group by d.dbid

View File

@ -0,0 +1,54 @@
#
# Copyright 2017 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 hardware::devices::safenet::keysecure::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'connections' => 'centreon::common::ingrian::snmp::mode::connections',
'cpu' => 'centreon::common::ingrian::snmp::mode::cpu',
'disk' => 'centreon::common::ingrian::snmp::mode::disk',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'centreon::common::ingrian::snmp::mode::memory',
'request-stats' => 'centreon::common::ingrian::snmp::mode::requeststats',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Safenet Keysecure in SNMP.
=cut

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 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 hardware::kvm::avocent::acs::6000::snmp::mode::components::psu;
use strict;
use warnings;
my %map_states = (1 => 'statePowerOn', 2 => 'statePowerOff', 9999 => 'powerNotInstalled');
my $mapping = {
acsPowerSupplyStatePw1 => { oid => '.1.3.6.1.4.1.10418.16.2.1.8.2', map => \%map_states },
acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.16.2.1.8.3', map => \%map_states },
};
my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.16.2.1.8';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acsPowerSupply };
}
sub check_psu {
my ($self, %options) = @_;
return if ($self->check_filter(section => 'psu', instance => $options{instance}));
return if ($options{state} eq 'powerNotInstalled' &&
$self->absent_problem(section => 'psu', instance => $options{instance}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.",
$options{instance}, $options{state}
));
my $exit = $self->get_severity(section => 'psu', value => $options{state});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
$options{instance}, $options{state}));
}
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_acsPowerSupply}, instance => '0');
check_psu($self, state => $result->{acsPowerSupplyStatePw1}, instance => '1');
check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2');
}
1;

View File

@ -0,0 +1,105 @@
#
# Copyright 2017 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 hardware::kvm::avocent::acs::6000::snmp::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(psu)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
psu => [
['statePowerOn', 'OK'],
['statePowerOff', 'CRITICAL'],
['powerNotInstalled', 'OK'],
],
};
$self->{components_path} = 'hardware::kvm::avocent::acs::6000::snmp::mode::components';
$self->{components_module} = ['psu'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=psu)
Can also exclude specific instance: --filter=psu,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=psu
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)'
=back
=cut

View File

@ -0,0 +1,51 @@
#
# Copyright 2017 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 hardware::kvm::avocent::acs::6000::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu-detailed' => 'snmp_standard::mode::cpudetailed',
'hardware' => 'hardware::kvm::avocent::acs::6000::snmp::mode::hardware',
'load' => 'snmp_standard::mode::loadaverage',
'memory' => 'snmp_standard::mode::memory',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Avocent ACS 6000 series in SNMP.
=cut

View File

@ -44,6 +44,6 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Dell Chassis Management Controller (CMC) in SNMP (Dell m1000e).
Check Dell Chassis Management Controller (CMC) in SNMP (Dell m1000e, VRTX, FX2).
=cut

View File

@ -33,6 +33,8 @@ sub check {
return if ($self->check_filter(section => 'cpu'));
return if (!defined($self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR}));
# STATUS can be missing
#
#<PROCESSORS>
# <PROCESSOR>
# <LABEL VALUE = "Proc 1"/>
@ -46,6 +48,7 @@ sub check {
# <INTERNAL_L3_CACHE VALUE = "25600 KB"/>
# </PROCESSOR>
foreach my $result (@{$self->{xml_result}->{GET_EMBEDDED_HEALTH_DATA}->{PROCESSORS}->{PROCESSOR}}) {
next if (!defined($result->{STATUS}));
my $instance = $result->{LABEL}->{VALUE};
next if ($self->check_filter(section => 'cpu', instance => $instance));

View File

@ -0,0 +1,232 @@
#
# Copyright 2017 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 hardware::ups::apc::snmp::mode::outputlines;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_threshold_output {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
} elsif (defined($instance_mode->{option_results}->{unknown_status}) && $instance_mode->{option_results}->{unknown_status} ne '' &&
eval "$instance_mode->{option_results}->{unknown_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("Output status is '%s'", $self->{result_values}->{status});
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_upsBasicOutputStatus'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
];
$self->{maps_counters}->{global} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'upsBasicOutputStatus' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_threshold_output'),
}
},
{ label => 'load', set => {
key_values => [ { name => 'upsAdvOutputLoad' } ],
output_template => 'Load : %s %%',
perfdatas => [
{ label => 'load', value => 'upsAdvOutputLoad_absolute', template => '%s',
min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'current', set => {
key_values => [ { name => 'upsAdvOutputCurrent' } ],
output_template => 'Current : %s A',
perfdatas => [
{ label => 'current', value => 'upsAdvOutputCurrent_absolute', template => '%s',
min => 0, unit => 'A' },
],
}
},
{ label => 'voltage', set => {
key_values => [ { name => 'upsAdvOutputVoltage' } ],
output_template => 'Voltage : %s V',
perfdatas => [
{ label => 'voltage', value => 'upsAdvOutputVoltage_absolute', template => '%s',
unit => 'V' },
],
}
},
{ label => 'frequence', set => {
key_values => [ { name => 'upsAdvOutputFrequency' } ],
output_template => 'Frequence : %s Hz',
perfdatas => [
{ label => 'frequence', value => 'upsAdvOutputFrequency_absolute', template => '%s',
unit => 'Hz' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"unknown-status:s" => { name => 'unknown_status', default => '%{status} =~ /unknown/i' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /onLine|rebooting/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status', 'unknown_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_status = (
1 => 'unknown', 2 => 'onLine', 3 => 'onBattery', 4 => 'onSmartBoost',
5 => 'timedSleeping', 6 => 'softwareBypass', 7 => 'off',
8 => 'rebooting', 9 => 'switchedBypass', 10 => 'hardwareFailureBypass',
11 => 'sleepingUntilPowerReturn', 12 => 'onSmartTrim',
);
my $mapping = {
upsBasicOutputStatus => { oid => '.1.3.6.1.4.1.318.1.1.1.4.1.1', map => \%map_status },
upsAdvOutputVoltage => { oid => '.1.3.6.1.4.1.318.1.1.1.4.2.1' },
upsAdvOutputFrequency => { oid => '.1.3.6.1.4.1.318.1.1.1.4.2.2' },
upsAdvOutputLoad => { oid => '.1.3.6.1.4.1.318.1.1.1.4.2.3' },
upsAdvOutputCurrent => { oid => '.1.3.6.1.4.1.318.1.1.1.4.2.4' },
};
my $oid_upsOutput = '.1.3.6.1.4.1.318.1.1.1.4';
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_upsOutput,
nothing_quit => 1);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
foreach my $name (keys %{$mapping}) {
$self->{global}->{$name} = $result->{$name};
}
}
1;
__END__
=head1 MODE
Check output lines.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^status|load$'
=item B<--unknown-status>
Set warning threshold for status (Default: '%{status} =~ /unknown/i').
Can used special variables like: %{status}
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /onLine|rebooting/i').
Can used special variables like: %{status}
=item B<--warning-*>
Threshold warning.
Can be: 'load', 'voltage', 'current', 'frequence'.
=item B<--critical-*>
Threshold critical.
Can be: 'load', 'voltage', 'current', 'frequence'.
=back
=cut

View File

@ -0,0 +1,180 @@
#
# Copyright 2017 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 hardware::ups::apc::snmp::mode::sensors;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(sensor)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
sensor => [
['uioNormal', 'OK'],
['uioWarning', 'WARNING'],
['uioCritical', 'OK'],
['sensorStatusNotApplicable', 'OK'],
],
};
$self->{components_path} = 'hardware::ups::apc::snmp::mode::components';
$self->{components_module} = ['sensor'];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_load_components => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
1;
=head1 MODE
Check sensors.
=over 8
=item B<--filter>
Exclude some parts (comma seperated list)
Can also exclude specific instance: --filter=sensor,1.1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='sensor,CRITICAL,sensorStatusNotApplicable'
=item B<--warning>
Set warning threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
Example: --warning='temperature,.*,40'
=item B<--critical>
Set critical threshold for 'temperature', 'humidity' (syntax: type,regexp,threshold)
Example: --critical='temperature,.*,50'
=back
=cut
package hardware::ups::apc::snmp::mode::components::sensor;
use strict;
use warnings;
my %map_status = (1 => 'uioNormal', 2 => 'uioWarning', 3 => 'uioCritical', 4 => 'sensorStatusNotApplicable');
my $mapping = {
uioSensorStatusSensorName => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.3' },
uioSensorStatusTemperatureDegC => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.6' },
uioSensorStatusHumidity => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.7' },
uioSensorStatusAlarmStatus => { oid => '.1.3.6.1.4.1.318.1.1.25.1.2.1.9', map => \%map_status },
};
my $oid_uioSensorStatusEntry = '.1.3.6.1.4.1.318.1.1.25.1.2.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_uioSensorStatusEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking sensors");
$self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0};
return if ($self->check_filter(section => 'sensor'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_uioSensorStatusEntry}})) {
next if ($oid !~ /^$mapping->{uioSensorStatusAlarmStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_uioSensorStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'sensor', instance => $instance));
$self->{components}->{sensor}->{total}++;
$self->{output}->output_add(long_msg => sprintf("sensor '%s' status is '%s' [instance = %s]",
$result->{uioSensorStatusSensorName}, $result->{uioSensorStatusAlarmStatus}, $instance));
$exit = $self->get_severity(section => 'sensor', value => $result->{uioSensorStatusAlarmStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sensor '%s' status is '%s'", $result->{uioSensorStatusSensorName}, $result->{uioSensorStatusAlarmStatus}));
}
if ($result->{uioSensorStatusTemperatureDegC} != -1) {
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{uioSensorStatusTemperatureDegC});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sensor temperature '%s' is %s C", $result->{uioSensorStatusSensorName}, $result->{uioSensorStatusTemperatureDegC}));
}
$self->{output}->perfdata_add(label => 'temp_' . $result->{uioSensorStatusSensorName}, unit => 'C',
value => $result->{uioSensorStatusTemperatureDegC},
warning => $warn,
critical => $crit
);
}
if ($result->{uioSensorStatusHumidity} != -1) {
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{uioSensorStatusHumidity});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Sensor humidity '%s' is %s %%", $result->{uioSensorStatusSensorName}, $result->{uioSensorStatusHumidity}));
}
$self->{output}->perfdata_add(label => 'humidity_' . $result->{uioSensorStatusSensorName}, unit => '%',
value => $result->{uioSensorStatusHumidity},
warning => $warn,
critical => $crit, min => 0, max => 100
);
}
}
}
1;

View File

@ -30,6 +30,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'battery-status' => 'hardware::ups::apc::snmp::mode::batterystatus',
'output-lines' => 'hardware::ups::apc::snmp::mode::outputlines',
'sensors' => 'hardware::ups::apc::snmp::mode::sensors',
);
return $self;

View File

@ -0,0 +1,123 @@
#
# Copyright 2017 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 network::alcatel::pss::1830::snmp::mode::listsap;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
my $oid_tnSapDescription = '.1.3.6.1.4.1.7483.6.1.2.4.3.2.1.5';
my $oid_tnSvcName = '.1.3.6.1.4.1.7483.6.1.2.4.2.2.1.28';
sub manage_selection {
my ($self, %options) = @_;
$self->{sap} = {};
my $snmp_result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_tnSapDescription }, { oid => $oid_tnSvcName } ],
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result->{$oid_tnSapDescription}}) {
next if ($oid !~ /^$oid_tnSapDescription\.(.*?)\.(.*?)\.(.*?)\.(.*?)$/);
my ($SysSwitchId, $SvcId, $SapPortId, $SapEncapValue) = ($1, $2, $3, $4);
$self->{sap}->{$SysSwitchId . '.' . $SvcId . '.' . $SapPortId . '.' . $SapEncapValue} = {
SysSwitchId => $SysSwitchId,
SvcId => $SvcId,
SapPortId => $SapPortId,
SapEncapValue => $SapEncapValue,
SapDescription => $snmp_result->{$oid_tnSapDescription}->{$oid},
SvcName => defined($snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId}) ?
$snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId} : ''
};
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection();
foreach my $instance (sort keys %{$self->{sap}}) {
my $msg = '';
$self->{output}->output_add(long_msg =>
"[SysSwitchId = " . $self->{sap}->{$instance}->{SysSwitchId} . "]" .
"[SvcId = " . $self->{sap}->{$instance}->{SvcId} . "]" .
"[SapPortId = " . $self->{sap}->{$instance}->{SapPortId} . "]" .
"[SapEncapValue = " . $self->{sap}->{$instance}->{SapEncapValue} . "]" .
"[SapDescription = " . $self->{sap}->{$instance}->{SapDescription} . "]" .
"[SvcName = " . $self->{sap}->{$instance}->{SvcName} . "]"
);
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List SAP:');
$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 => ['SysSwitchId', 'SvcId', 'SapPortId', 'SapEncapValue', 'SapDescription', 'SvcName']);
}
sub disco_show {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection(disco => 1);
foreach my $instance (sort keys %{$self->{sap}}) {
$self->{output}->add_disco_entry(%{$self->{sap}->{$instance}});
}
}
1;
__END__
=head1 MODE
List SAP.
=over 8
=back
=cut

View File

@ -0,0 +1,381 @@
#
# Copyright 2017 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 network::alcatel::pss::1830::snmp::mode::sapqosstats;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
my $instance_mode;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'sap', type => 1, cb_prefix_output => 'prefix_sap_output', message_multiple => 'All SAP QoS are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{sap} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'admin' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
{ label => 'in-traffic', set => {
key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ],
per_second => 1,
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
closure_custom_output => $self->can('custom_qos_output'),
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
closure_custom_threshold_check => $self->can('custom_qos_threshold'),
}
},
{ label => 'out-traffic', set => {
key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ],
per_second => 1,
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
closure_custom_output => $self->can('custom_qos_output'),
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
closure_custom_threshold_check => $self->can('custom_qos_threshold'),
}
},
{ label => 'in-drop-packets', set => {
key_values => [ { name => 'in_dropped_packets', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_qos_drop_calc'),
output_template => 'In Dropped Packets : %s',
perfdatas => [
{ label => 'in_drop_packets', value => 'in_dropped_packets_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display' },
],
}
},
];
}
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
my $label = $self->{label};
$label =~ s/-/_/g;
if (defined($instance_mode->{option_results}->{'critical_' . $label}) && $instance_mode->{option_results}->{'critical_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'critical_' . $label}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{'warning_' . $label}) && $instance_mode->{option_results}->{'warning_' . $label} ne '' &&
eval "$instance_mode->{option_results}->{'warning_' . $label}") {
$status = 'warning';
}
$instance_mode->{last_status} = 0;
if ($self->{result_values}->{admin} eq 'up') {
$instance_mode->{last_status} = 1;
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'Status : ' . $self->{result_values}->{status} . ' (admin: ' . $self->{result_values}->{admin} . ')';
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{admin} = $options{new_datas}->{$self->{instance} . '_admin'};
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub custom_qos_perfdata {
my ($self, %options) = @_;
my $extra_label = '';
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
$extra_label .= '_' . $self->{result_values}->{display};
}
my ($warning, $critical);
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label});
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label});
}
$self->{output}->perfdata_add(label => 'traffic_' . $self->{result_values}->{label} . $extra_label, unit => 'b/s',
value => sprintf("%.2f", $self->{result_values}->{traffic}),
warning => $warning,
critical => $critical,
min => 0, max => $self->{result_values}->{speed});
}
sub custom_qos_threshold {
my ($self, %options) = @_;
my $exit = 'ok';
if ($instance_mode->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
} elsif ($instance_mode->{option_results}->{units_traffic} eq 'b/s') {
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
}
return $exit;
}
sub custom_qos_output {
my ($self, %options) = @_;
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic}, network => 1);
my ($total_value, $total_unit);
if (defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} =~ /[0-9]/) {
($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{speed}, network => 1);
}
my $msg = sprintf("Traffic %s : %s/s (%s on %s)",
ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit,
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-',
defined($total_value) ? $total_value . $total_unit : '-');
return $msg;
}
sub custom_qos_calc {
my ($self, %options) = @_;
return -10 if (defined($instance_mode->{last_status}) && $instance_mode->{last_status} == 0);
$self->{result_values}->{label} = $options{extra_options}->{label_ref};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{traffic} = ($options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}} - $options{old_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}}) / $options{delta_time};
if (defined($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) {
$self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000);
$self->{result_values}->{speed} = $instance_mode->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000;
}
return 0;
}
sub custom_qos_drop_calc {
my ($self, %options) = @_;
return -10 if (defined($instance_mode->{last_status}) && $instance_mode->{last_status} == 0);
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{in_dropped_packets_absolute} = $options{new_datas}->{$self->{instance} . '_in_dropped_packets'} - $options{old_datas}->{$self->{instance} . '_in_dropped_packets'};
return 0;
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"display-name:s" => { name => 'display_name', default => '%{SysSwitchId}.%{SvcId}.%{SapPortId}.%{SapEncapValue}' },
"filter-name:s" => { name => 'filter_name' },
"speed-in:s" => { name => 'speed_in' },
"speed-out:s" => { name => 'speed_out' },
"units-traffic:s" => { name => 'units_traffic', default => '%' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{admin} =~ /up/i and %{status} !~ /up/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub prefix_sap_output {
my ($self, %options) = @_;
return "SAP '" . $options{instance_value}->{display} . "' ";
}
sub get_display_name {
my ($self, %options) = @_;
my $display_name = $self->{option_results}->{display_name};
$display_name =~ s/%\{(.*?)\}/$options{$1}/ge;
return $display_name;
}
my %map_admin = (1 => 'up', 2 => 'down');
my %map_oper = (1 => 'up', 2 => 'down', 3 => 'ingressQosMismatch',
4 => 'egressQosMismatch', 5 => 'portMtuTooSmall', 6 => 'svcAdminDown',
7 => 'iesIfAdminDown'
);
my $mapping = {
tnSapAdminStatus => { oid => '.1.3.6.1.4.1.7483.6.1.2.4.3.2.1.6', map => \%map_admin },
tnSapOperStatus => { oid => '.1.3.6.1.4.1.7483.6.1.2.4.3.2.1.7', map => \%map_oper },
tnSapBaseStatsIngressForwardedOctets => { oid => '.1.3.6.1.4.1.7483.7.2.2.2.8.1.1.1.4' },
tnSapBaseStatsEgressForwardedOctets => { oid => '.1.3.6.1.4.1.7483.7.2.2.2.8.1.1.1.6' },
tnSapBaseStatsIngressDroppedPackets => { oid => '.1.3.6.1.4.1.7483.7.2.2.2.8.1.1.1.9' },
};
my $oid_tnSapDescription = '.1.3.6.1.4.1.7483.6.1.2.4.3.2.1.5';
my $oid_tnSvcName = '.1.3.6.1.4.1.7483.6.1.2.4.2.2.1.28';
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
# SNMP Get is slow for Dropped, Ingress, Egress. So we are doing in 2 times.
$self->{sap} = {};
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_tnSapDescription },
{ oid => $oid_tnSvcName },
],
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result->{$oid_tnSapDescription}}) {
next if ($oid !~ /^$oid_tnSapDescription\.(.*?)\.(.*?)\.(.*?)\.(.*?)$/);
my ($SysSwitchId, $SvcId, $SapPortId, $SapEncapValue) = ($1, $2, $3, $4);
my $instance = $SysSwitchId . '.' . $SvcId . '.' . $SapPortId . '.' . $SapEncapValue;
my $SapDescription = $snmp_result->{$oid_tnSapDescription}->{$oid};
my $SvcName = defined($snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId}) ?
$snmp_result->{$oid_tnSvcName}->{$oid_tnSvcName . '.' . $SysSwitchId . '.' . $SvcId} : '';
my $name = $self->get_display_name(SapDescription => $SapDescription, SvcName => $SvcName, SysSwitchId => $SysSwitchId, SvcId => $SvcId, SapPortId => $SapPortId, SapEncapValue => $SapEncapValue);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{sap}->{$instance} = { display => $name };
}
$options{snmp}->load(oids => [$mapping->{tnSapBaseStatsIngressForwardedOctets}->{oid},
$mapping->{tnSapBaseStatsEgressForwardedOctets}->{oid}, $mapping->{tnSapBaseStatsIngressDroppedPackets}->{oid},
$mapping->{tnSapAdminStatus}->{oid}, $mapping->{tnSapOperStatus}->{oid}],
instances => [keys %{$self->{sap}}], instance_regexp => '(\d+\.\d+\.\d+\.\d+)$');
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{sap}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
$self->{sap}->{$_}->{in} = $result->{tnSapBaseStatsIngressForwardedOctets} * 8;
$self->{sap}->{$_}->{out} = $result->{tnSapBaseStatsEgressForwardedOctets} * 8;
$self->{sap}->{$_}->{in_dropped_packets} = $result->{tnSapBaseStatsIngressDroppedPackets};
$self->{sap}->{$_}->{status} = $result->{tnSapAdminStatus};
$self->{sap}->{$_}->{admin} = $result->{tnSapOperStatus};
}
if (scalar(keys %{$self->{sap}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No SAP found.");
$self->{output}->option_exit();
}
$self->{cache_name} = "alcatel_pss_1830_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check SAP QoS usage.
=over 8
=item B<--display-name>
Display name (Default: '%{SysSwitchId}.%{SvcId}.%{SapPortId}.%{SapEncapValue}').
Can also be: %{SapDescription}, %{SvcName}
=item B<--filter-name>
Filter by SAP name (can be a regexp).
=item B<--speed-in>
Set interface speed for incoming traffic (in Mb).
=item B<--speed-out>
Set interface speed for outgoing traffic (in Mb).
=item B<--units-traffic>
Units of thresholds for the traffic (Default: '%') ('%', 'b/s').
=item B<--warning-status>
Set warning threshold for ib status.
Can used special variables like: %{admin}, %{status}, %{display}
=item B<--critical-status>
Set critical threshold for ib status (Default: '%{admin} =~ /up/i and %{status} !~ /up/i').
Can used special variables like: %{admin}, %{status}, %{display}
=item B<--warning-*>
Threshold warning.
Can be: 'in-traffic', 'out-traffic', 'in-drop-packets'.
=item B<--critical-*>
Threshold critical.
Can be: 'in-traffic', 'out-traffic', 'in-drop-packets'.
=back
=cut

View File

@ -0,0 +1,49 @@
#
# Copyright 2017 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 network::alcatel::pss::1830::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'sap-qos-stats' => 'network::alcatel::pss::1830::snmp::mode::sapqosstats',
'list-sap' => 'network::alcatel::pss::1830::snmp::mode::listsap',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Alcatel 1830 Photonic Service Switch (PSS) in SNMP.
=cut

View File

@ -0,0 +1,78 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::components::fantray;
use strict;
use warnings;
my %map_status = (
0 => 'cleared',
1 => 'indeterminate',
2 => 'warning',
3 => 'minor',
4 => 'major',
5 => 'critical',
);
my %map_existence = (
1 => 'present',
2 => 'missing',
);
my $mapping = {
acSysFanTrayExistence => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.22.1.3', map => \%map_existence },
acSysFanTraySeverity => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.22.1.6', map => \%map_status },
};
my $oid_acSysFanTrayEntry = '.1.3.6.1.4.1.5003.9.10.10.4.22.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acSysFanTrayEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fantray");
$self->{components}->{fantray} = {name => 'fantray', total => 0, skip => 0};
return if ($self->check_filter(section => 'fantray'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_acSysFanTrayEntry}})) {
next if ($oid !~ /^$mapping->{acSysFanTraySeverity}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_acSysFanTrayEntry}, instance => $instance);
next if ($result->{acSysFanTrayExistence} eq 'missing' &&
$self->absent_problem(section => 'fantray', instance => $instance));
next if ($self->check_filter(section => 'fantray', instance => $instance));
$self->{components}->{fantray}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan tray '%s' status is '%s' [instance = %s]",
$instance, $result->{acSysFanTraySeverity}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'fantray', value => $result->{acSysFanTraySeverity});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan tray '%s' status is '%s'", $instance, $result->{acSysFanTraySeverity}));
}
}
}
1;

View File

@ -0,0 +1,79 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::components::module;
use strict;
use warnings;
my %map_status = (
1 => 'moduleNotExist',
2 => 'moduleExistOk',
3 => 'moduleOutOfService',
4 => 'moduleBackToServiceStart',
5 => 'moduleMismatch',
6 => 'moduleFaulty',
7 => 'notApplicable',
);
my %map_existence = (
1 => 'present',
2 => 'missing',
);
my $mapping = {
acSysModulePresence => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.21.1.4', map => \%map_existence },
acSysModuleFRUstatus => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.21.1.14', map => \%map_status },
};
my $oid_acSysModuleEntry = '.1.3.6.1.4.1.5003.9.10.10.4.21.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acSysModuleEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking modules");
$self->{components}->{module} = {name => 'modules', total => 0, skip => 0};
return if ($self->check_filter(section => 'module'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_acSysModuleEntry}})) {
next if ($oid !~ /^$mapping->{acSysModuleFRUstatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_acSysModuleEntry}, instance => $instance);
next if ($result->{acSysModulePresence} eq 'missing' &&
$self->absent_problem(section => 'module', instance => $instance));
next if ($self->check_filter(section => 'module', instance => $instance));
$self->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("module '%s' status is '%s' [instance = %s]",
$instance, $result->{acSysModuleFRUstatus}, $instance));
my $exit = $self->get_severity(section => 'module', value => $result->{acSysModuleFRUstatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s' status is '%s'", $instance, $result->{acSysModuleFRUstatus}));
}
}
}
1;

View File

@ -0,0 +1,78 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::components::psu;
use strict;
use warnings;
my %map_status = (
1 => 'cleared',
2 => 'indeterminate',
3 => 'warning',
4 => 'minor',
5 => 'major',
6 => 'critical',
);
my %map_existence = (
1 => 'present',
2 => 'missing',
);
my $mapping = {
acSysPowerSupplyExistence => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.23.1.3', map => \%map_existence },
acSysPowerSupplySeverity => { oid => '.1.3.6.1.4.1.5003.9.10.10.4.23.1.6', map => \%map_status },
};
my $oid_acSysPowerSupplyEntry = '.1.3.6.1.4.1.5003.9.10.10.4.23.1';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_acSysPowerSupplyEntry };
}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_acSysPowerSupplyEntry}})) {
next if ($oid !~ /^$mapping->{acSysPowerSupplySeverity}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_acSysPowerSupplyEntry}, instance => $instance);
next if ($result->{acSysPowerSupplyExistence} eq 'missing' &&
$self->absent_problem(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
$instance, $result->{acSysPowerSupplySeverity}, $instance));
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{acSysPowerSupplySeverity});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{acSysPowerSupplySeverity}));
}
}
}
1;

View File

@ -0,0 +1,106 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::cpu;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{ label => 'voip', set => {
key_values => [ { name => 'voip' } ],
output_template => 'CPU VoIp Usage : %.2f %%',
perfdatas => [
{ label => 'cpu_voip', value => 'voip_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'data', set => {
key_values => [ { name => 'data' } ],
output_template => 'CPU Data Usage : %.2f %%',
perfdatas => [
{ label => 'cpu_data', value => 'data_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_acSysStateVoIpCpuUtilization = '.1.3.6.1.4.1.5003.9.10.10.2.5.10.0';
my $oid_acSysStateDataCpuUtilization = '.1.3.6.1.4.1.5003.9.10.10.2.5.8.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_acSysStateVoIpCpuUtilization, $oid_acSysStateDataCpuUtilization
], nothing_quit => 1);
$self->{global} = { data => $snmp_result->{$oid_acSysStateDataCpuUtilization}, voip => $snmp_result->{$oid_acSysStateVoIpCpuUtilization} };
}
1;
__END__
=head1 MODE
Check CPU usages.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^voip$'
=item B<--warning-*>
Threshold warning.
Can be: 'voip', 'data'.
=item B<--critical-*>
Threshold critical.
Can be: 'voip', 'data'.
=back
=cut

View File

@ -0,0 +1,117 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::hardware;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(module|fantray|psu)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
default => [
['cleared', 'OK'],
['indeterminate', 'UNKNOWN'],
['warning', 'WARNING'],
['minor', 'WARNING'],
['major', 'CRITICAL'],
['critical', 'CRITICAL'],
],
module => [
['moduleNotExist', 'OK'],
['moduleExistOk', 'OK'],
['moduleOutOfService', 'CRITICAL'],
['moduleBackToServiceStart', 'WARNING'],
['moduleMismatch', 'WARNING'],
['moduleFaulty', 'CRITICAL'],
['notApplicable', 'OK'],
],
};
$self->{components_path} = 'network::audiocodes::snmp::mode::components';
$self->{components_module} = ['module', 'fantray', 'psu'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check Hardware.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'fantray', 'module', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu)
Can also exclude specific instance: --filter=fantray,1
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=psu,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(cleared)$)'
=back
=cut

View File

@ -0,0 +1,106 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::memory;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{ label => 'voip', set => {
key_values => [ { name => 'voip' } ],
output_template => 'Memory VoIp Usage : %.2f %%',
perfdatas => [
{ label => 'used_voip', value => 'voip_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
],
}
},
{ label => 'data', set => {
key_values => [ { name => 'data' } ],
output_template => 'Memory Data Usage : %.2f %%',
perfdatas => [
{ label => 'used_data', value => 'data_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_acSysStateVoIpMemoryUtilization = '.1.3.6.1.4.1.5003.9.10.10.2.5.11.0';
my $oid_acSysStateDataMemoryUtilization = '.1.3.6.1.4.1.5003.9.10.10.2.5.9.0';
my $snmp_result = $options{snmp}->get_leef(oids => [
$oid_acSysStateVoIpMemoryUtilization, $oid_acSysStateDataMemoryUtilization
], nothing_quit => 1);
$self->{global} = { data => $snmp_result->{$oid_acSysStateDataMemoryUtilization}, voip => $snmp_result->{$oid_acSysStateVoIpMemoryUtilization} };
}
1;
__END__
=head1 MODE
Check memory usages.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^voip$'
=item B<--warning-*>
Threshold warning.
Can be: 'voip', 'data'.
=item B<--critical-*>
Threshold critical.
Can be: 'voip', 'data'.
=back
=cut

View File

@ -0,0 +1,192 @@
#
# Copyright 2017 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 network::audiocodes::snmp::mode::trunkstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'alarm status : ' . $self->{result_values}->{alarm} . ' [state: ' . $self->{result_values}->{state} . ']';
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{alarm} = $options{new_datas}->{$self->{instance} . '_alarm'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{dchannel} = $options{new_datas}->{$self->{instance} . '_dchannel'};
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'trunk', type => 1, cb_prefix_output => 'prefix_vpn_output', message_multiple => 'All trunks are ok' }
];
$self->{maps_counters}->{trunk} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'display' }, { name => 'dchannel' }, { name => 'alarm' }, { name => 'state' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{state} =~ /activated/ and %{alarm} !~ /greenActive/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub prefix_vpn_output {
my ($self, %options) = @_;
return "Trunk '" . $options{instance_value}->{display} . "' ";
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
my %map_alarm = (0 => 'greyDisabled', 1 => 'greenActive', 2 => 'redLosLof',
3 => 'blueAis', 4 => 'yellowRai', 5 => 'orangeDChannel', 6 => 'purpleLowerLayerDown', 7 => 'darkOrangeNFASAlarm');
my %map_dchannel = (0 => 'dChannelEstablished', 1 => 'dChannelNotEstablished', 10 => 'dChannelNotApplicable');
my %map_deactivate = (0 => 'notAvailable', 1 => 'deActivated', 2 => 'activated');
my $mapping = {
acTrunkStatusDChannel => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.6', map => \%map_dchannel },
acTrunkStatusAlarm => { oid => '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1.7', map => \%map_alarm },
acTrunkDeactivate => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.11', map => \%map_deactivate },
acTrunkName => { oid => '.1.3.6.1.4.1.5003.9.10.9.1.1.1.1.1.13' },
};
my $oid_acTrunkStatusEntry = '.1.3.6.1.4.1.5003.9.10.9.2.1.1.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{trunk} = {};
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $mapping->{acTrunkName}->{oid} },
{ oid => $mapping->{acTrunkDeactivate}->{oid} },
{ oid => $oid_acTrunkStatusEntry },
], nothing_quit => 1, return_type => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{acTrunkStatusAlarm}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{trunk}->{$instance} = {
display => defined($result->{acTrunkName}) && $result->{acTrunkName} ne '' ? $result->{acTrunkName} : $instance,
alarm => $result->{acTrunkStatusAlarm},
state => $result->{acTrunkDeactivate},
dchannel => $result->{acTrunkStatusDChannel} };
}
if (scalar(keys %{$self->{trunk}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No trunk found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check vpn status.
=over 8
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{display}, %{alarm}, %{dchannel}, %{state}
=item B<--critical-status>
Set critical threshold for status (Default: '%{state} =~ /activated/ and %{alarm} !~ /greenActive/i').
Can used special variables like: %{display}, %{alarm}, %{dchannel}, %{state}
=back
=cut

View File

@ -0,0 +1,53 @@
#
# Copyright 2017 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 network::audiocodes::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::audiocodes::snmp::mode::cpu',
'hardware' => 'network::audiocodes::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::audiocodes::snmp::mode::memory',
'trunk-status' => 'network::audiocodes::snmp::mode::trunkstatus',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Audiocodes equipments (Mediant) in SNMP.
=cut

View File

@ -0,0 +1,124 @@
#
# Copyright 2017 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 network::beeware::snmp::mode::listreverseproxy;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my %mapping_running = (
0 => 'down',
1 => 'running',
);
my $oid_rp = '.1.3.6.1.4.1.30800.132';
my $oid_running_suffix = '133.57'; # 1 seems running
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-status:s" => { name => 'filter_status' },
});
$self->{rp} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_rp,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$oid_rp\.(.*?)\.$oid_running_suffix$/ || defined($self->{rp}->{$1}));
my $instance = $1;
my $status = defined($mapping_running{$snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_running_suffix}}) ?
$mapping_running{$snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_running_suffix}} : 'unknown';
if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status} ne '' &&
$status !~ /$self->{option_results}->{filter_status}/) {
$self->{output}->output_add(long_msg => "skipping '" . $instance . "': no matching filter.", debug => 1);
next;
}
$self->{rp}->{$instance} = { status => $status };
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{rp}}) {
$self->{output}->output_add(long_msg => '[instance = ' . $instance . "] [status = '" . $self->{rp}->{$instance}->{status} . "']");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List reverse proxies:');
$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 => ['instance', 'status']);
}
sub disco_show {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{rp}}) {
$self->{output}->add_disco_entry(instance => $instance, status => $self->{rp}->{$instance}->{status});
}
}
1;
__END__
=head1 MODE
List reverse proxies.
=over 8
=item B<--filter-status>
Filter which status (can be a regexp).
=back
=cut

View File

@ -0,0 +1,241 @@
#
# Copyright 2017 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 network::beeware::snmp::mode::reverseproxyusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub custom_status_threshold {
my ($self, %options) = @_;
my $status = 'ok';
my $message;
eval {
local $SIG{__WARN__} = sub { $message = $_[0]; };
local $SIG{__DIE__} = sub { $message = $_[0]; };
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
eval "$instance_mode->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
eval "$instance_mode->{option_results}->{warning_status}") {
$status = 'warning';
}
};
if (defined($message)) {
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
}
return $status;
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'rp', type => 1, cb_prefix_output => 'prefix_rp_output', message_multiple => 'All reverse proxy are ok' }
];
$self->{maps_counters}->{rp} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'display' }, { name => 'status' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_status_threshold'),
}
},
{ label => 'cpu', set => {
key_values => [ { name => 'cpu' }, { name => 'display' } ],
output_template => 'CPU Usage : %.2f %%',
perfdatas => [
{ label => 'cpu', value => 'cpu_absolute', template => '%.2f',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'memory', set => {
key_values => [ { name => 'memory' }, { name => 'display' } ],
output_template => 'Memory Usage : %s %s',
output_change_bytes => 1,
perfdatas => [
{ label => 'memory', value => 'memory_absolute', template => '%s',
min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'nbchilds', set => {
key_values => [ { name => 'nbchilds' }, { name => 'display' } ],
output_template => 'Num childs : %s',
perfdatas => [
{ label => 'nbchilds', value => 'nbchilds_absolute', template => '%s',
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /running/i' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
$self->change_macros();
}
sub change_macros {
my ($self, %options) = @_;
foreach (('warning_status', 'critical_status')) {
if (defined($self->{option_results}->{$_})) {
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
}
}
}
sub prefix_rp_output {
my ($self, %options) = @_;
return "Reverse proxy '" . $options{instance_value}->{display} . "' ";
}
my %mapping_running = (
0 => 'down',
1 => 'running',
);
my $oid_rp = '.1.3.6.1.4.1.30800.132';
my $oid_cpu_suffix = '31.57';
my $oid_memory_suffix = '117.57'; # MB
my $oid_nbchils_suffix = '119.57';
my $oid_running_suffix = '133.57'; # 1 seems running
sub manage_selection {
my ($self, %options) = @_;
$self->{rp} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_rp,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$oid_rp\.(.*?)\.$oid_running_suffix$/ || defined($self->{rp}->{$1}));
my $instance = $1;
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$instance !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $instance . "': no matching filter.", debug => 1);
next;
}
$self->{rp}->{$instance} = { display => $instance,
cpu => $snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_cpu_suffix},
memory => $snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_memory_suffix} * 1024 * 1024,
nbchilds => $snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_nbchils_suffix},
status => defined($mapping_running{$snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_running_suffix}}) ?
$mapping_running{$snmp_result->{$oid_rp . '.' . $instance . '.' . $oid_running_suffix}} : 'unknown',
};
}
if (scalar(keys %{$self->{rp}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No reverse proxy found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check reverse proxy usage.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
Example: --filter-counters='^cpu|memory$'
=item B<--filter-name>
Filter reverse proxy (can be a regexp).
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{display}, %{status}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /running/i').
Can used special variables like: %{display}, %{status}
=item B<--warning-*>
Threshold warning.
Can be: 'cpu', 'memory' (B), 'nbchilds'.
=item B<--critical-*>
Threshold critical.
Can be: 'cpu', 'memory' (B), 'nbchilds'.
=back
=cut

View File

@ -0,0 +1,50 @@
#
# Copyright 2017 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 network::beeware::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'list-reverse-proxy' => 'network::beeware::snmp::mode::listreverseproxy',
'reverse-proxy-usage' => 'network::beeware::snmp::mode::reverseproxyusage',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Beeware equipments in SNMP.
Please use plugin SNMP Linux for system checks ('cpu', 'memory', 'traffic',...).
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::brocade::mode::cpu;
package network::brocade::snmp::mode::cpu;
use base qw(centreon::plugins::mode);
@ -62,13 +62,17 @@ sub run {
my $oid_swCpuUsage = '.1.3.6.1.4.1.1588.2.1.1.1.26.1.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_swFwFabricWatchLicense, $oid_swCpuUsage], nothing_quit => 1);
if ($result->{$oid_swFwFabricWatchLicense} == 2) {
$self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information.");
if (!defined($result->{$oid_swCpuUsage})) {
if ($result->{$oid_swFwFabricWatchLicense} == 2) {
$self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information.");
$self->{output}->option_exit();
}
$self->{output}->add_option_msg(short_msg => "Cannot get information.");
$self->{output}->option_exit();
}
my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_swCpuUsage},
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,
short_msg => sprintf("CPU Usage: %.2f%%", $result->{$oid_swCpuUsage}));
$self->{output}->perfdata_add(label => "cpu", unit => '%',

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::brocade::mode::hardware;
package network::brocade::snmp::mode::hardware;
use base qw(centreon::plugins::mode);

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::brocade::mode::memory;
package network::brocade::snmp::mode::memory;
use base qw(centreon::plugins::mode);
@ -62,13 +62,17 @@ sub run {
my $oid_swMemUsage = '.1.3.6.1.4.1.1588.2.1.1.1.26.6.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_swFwFabricWatchLicense, $oid_swMemUsage], nothing_quit => 1);
if ($result->{$oid_swFwFabricWatchLicense} == 2) {
$self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information.");
if (!defined($result->{$oid_swMemUsage})) {
if ($result->{$oid_swFwFabricWatchLicense} == 2) {
$self->{output}->add_option_msg(short_msg => "Need Fabric Watch License to get information.");
$self->{output}->option_exit();
}
$self->{output}->add_option_msg(short_msg => "Cannot get information.");
$self->{output}->option_exit();
}
my $exit = $self->{perfdata}->threshold_check(value => $result->{$oid_swMemUsage},
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,
short_msg => sprintf("Memory Usage: %.2f%% used", $result->{$oid_swMemUsage}));
$self->{output}->perfdata_add(label => "used", unit => '%',

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::brocade::plugin;
package network::brocade::snmp::plugin;
use strict;
use warnings;
@ -31,11 +31,11 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::brocade::mode::cpu',
'hardware' => 'network::brocade::mode::hardware',
'cpu' => 'network::brocade::snmp::mode::cpu',
'hardware' => 'network::brocade::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::brocade::mode::memory',
'memory' => 'network::brocade::snmp::mode::memory',
);
return $self;

View File

@ -31,12 +31,15 @@ sub new {
$self->{version} = '0.5';
%{$self->{modes}} = (
'connections' => 'network::checkpoint::snmp::mode::connections',
'cpu' => 'network::checkpoint::snmp::mode::cpu',
'hardware' => 'network::checkpoint::snmp::mode::hardware',
'hastate' => 'network::checkpoint::snmp::mode::hastate',
'memory' => 'network::checkpoint::snmp::mode::memory',
'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus',
'connections' => 'network::checkpoint::snmp::mode::connections',
'cpu' => 'network::checkpoint::snmp::mode::cpu',
'hardware' => 'network::checkpoint::snmp::mode::hardware',
'hastate' => 'network::checkpoint::snmp::mode::hastate',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::checkpoint::snmp::mode::memory',
'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus',
'vrrp-status' => 'snmp_standard::mode::vrrp',
);
return $self;

View File

@ -1,109 +0,0 @@
#
# Copyright 2017 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 network::citrix::netscaler::common::mode::certificatesexpire;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_sslCertKeyName = '.1.3.6.1.4.1.5951.4.1.1.56.1.1.1';
my $oid_sslDaysToExpire = '.1.3.6.1.4.1.5951.4.1.1.56.1.1.5';
my $result = $self->{snmp}->get_multiple_table(oids => [ { oid => $oid_sslCertKeyName }, { oid => $oid_sslDaysToExpire } ], nothing_quit => 1);
$self->{output}->output_add(severity => 'OK',
short_msg => 'All certificates are ok.');
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result->{$oid_sslCertKeyName}})) {
$oid =~ /^$oid_sslCertKeyName\.(.*)$/;
my $name = $result->{$oid_sslCertKeyName}->{$oid};
my $days = $result->{$oid_sslDaysToExpire}->{$oid_sslDaysToExpire . '.' . $1};
my $exit = $self->{perfdata}->threshold_check(value => $days,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(long_msg => sprintf("Certificate '%s': %d days remaining before expiration",
$name, $days));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Certificate '%s': %d days remaining before expiration",
$name, $days));
}
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check number of days remaining before the expiration of certificates (NS-MIB-smiv2).
=over 8
=item B<--warning>
Threshold warning in days.
=item B<--critical>
Threshold critical in days.
=back
=cut

View File

@ -1,189 +0,0 @@
#
# Copyright 2017 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 network::citrix::netscaler::common::mode::connections;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $maps_counters = {
global => {
'000_active' => { set => {
key_values => [ { name => 'active' } ],
output_template => 'Active Server TCP connections : %s',
perfdatas => [
{ label => 'active_server', value => 'active_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
'001_server' => { set => {
key_values => [ { name => 'server' } ],
output_template => 'Server TCP connections : %s',
perfdatas => [
{ label => 'server', value => 'server_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
'002_client' => { set => {
key_values => [ { name => 'client' } ],
output_template => 'Client TCP connections : %s',
perfdatas => [
{ label => 'client', value => 'client_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
},
};
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
foreach my $key (('global')) {
foreach (keys %{$maps_counters->{$key}}) {
my ($id, $name) = split /_/;
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
$options{options}->add_options(arguments => {
'warning-' . $name . ':s' => { name => 'warning-' . $name },
'critical-' . $name . ':s' => { name => 'critical-' . $name },
});
}
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output},
perfdata => $self->{perfdata},
label => $name);
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
}
}
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach my $key (('global')) {
foreach (keys %{$maps_counters->{$key}}) {
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
}
}
}
sub run_global {
my ($self, %options) = @_;
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters->{global}}) {
my $obj = $maps_counters->{global}->{$_}->{obj};
$obj->set(instance => 'global');
my ($value_check) = $obj->execute(values => $self->{global});
if ($value_check != 0) {
$long_msg .= $long_msg_append . $obj->output_error();
$long_msg_append = ', ';
next;
}
my $exit2 = $obj->threshold_check();
push @exits, $exit2;
my $output = $obj->output();
$long_msg .= $long_msg_append . $output;
$long_msg_append = ', ';
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= $short_msg_append . $output;
$short_msg_append = ', ';
}
$obj->perfdata();
}
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => "$short_msg"
);
} else {
$self->{output}->output_add(short_msg => "$long_msg");
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection();
$self->run_global();
$self->{output}->display();
$self->{output}->exit();
}
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = { client => 0, server => 0, active => 0 };
my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0';
my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0';
my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1);
$self->{global}->{client} = $result->{$oid_tcpCurClientConn};
$self->{global}->{server} = $result->{$oid_tcpCurServerConn};
$self->{global}->{active} = $result->{$oid_tcpActiveServerConn};
}
1;
__END__
=head1 MODE
Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2).
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'server', 'active', 'client'.
=item B<--critical-*>
Threshold critical.
Can be: 'server', 'active', 'client'.
=back
=cut

View File

@ -1,358 +0,0 @@
#
# Copyright 2017 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 network::citrix::netscaler::common::mode::health;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
my $oid_sysHealthCounterName = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1';
my $oid_sysHealthCounterValue = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2';
my $thresholds = {
psu => [
['normal', 'OK'],
['not present', 'OK'],
['failed', 'CRITICAL'],
['not supported', 'UNKNOWN'],
],
};
my %map_psu_status = (
0 => 'normal',
1 => 'not present',
2 => 'failed',
3 => 'not supported',
);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
"no-component:s" => { name => 'no_component' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{components} = {};
$self->{no_components} = undef;
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (defined($self->{option_results}->{no_component})) {
if ($self->{option_results}->{no_component} ne '') {
$self->{no_components} = $self->{option_results}->{no_component};
} else {
$self->{no_components} = 'critical';
}
}
$self->{overload_th} = {};
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ('psu', $1, $2);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section}));
push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status};
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{result} = $self->{snmp}->get_table(oid => $oid_nsSysHealthEntry);
if ($self->{option_results}->{component} eq 'all') {
$self->check_psu();
$self->check_fanspeed();
$self->check_temperature();
$self->check_voltage();
} elsif ($self->{option_results}->{component} eq 'psu') {
$self->check_psu();
} elsif ($self->{option_results}->{component} eq 'fanspeed') {
$self->check_fanspeed();
} elsif ($self->{option_results}->{component} eq 'temperature') {
$self->check_temperature();
} elsif ($self->{option_results}->{component} eq 'voltage') {
$self->check_voltage();
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
my $count_by_components = $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $count_by_components . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components are ok [%s].",
$total_components,
$display_by_component,
)
);
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
$self->{output}->output_add(severity => $self->{no_components},
short_msg => 'No components are checked.');
}
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, %options) = @_;
if (defined($options{instance})) {
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
$self->{components}->{$options{section}}->{skip}++;
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
return 1;
}
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
return 1;
}
return 0;
}
sub get_severity {
my ($self, %options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($self->{overload_th}->{$options{section}})) {
foreach (@{$self->{overload_th}->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) {
$status = $_->{status};
return $status;
}
}
}
foreach (@{$thresholds->{$options{section}}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
sub absent_problem {
my ($self, %options) = @_;
if (defined($self->{option_results}->{absent}) &&
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Component '%s' instance '%s' is not present",
$options{section}, $options{instance}));
return 1;
}
return 0;
}
sub check_fanspeed {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fanspeed");
$self->{components}->{fanspeed} = {name => 'fanspeed', total => 0, skip => 0};
return if ($self->check_exclude(section => 'fanspeed'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /Speed|Fan/i);
my $name = $self->{result}->{$oid};
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1};
if ($value == 0) {
$self->{output}->output_add(long_msg => sprintf("Skipping Fanspeed '%s' (counter is 0)",
$name));
next;
}
next if ($self->check_exclude(section => 'fanspeed', instance => $name));
$self->{components}->{fanspeed}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' speed is %s (rpm)",
$name, $value));
$self->{output}->perfdata_add(label => "speed_" . $name, unit => 'rpm',
value => $value,
min => 0);
}
}
sub check_psu {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_exclude(section => 'psu'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /PowerSupply(.)FailureStatus/i);
my $instance = $1;
my $name = $self->{result}->{$oid};
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1};
next if ($map_psu_status{$value} eq 'not present' &&
$self->absent_problem(section => 'psu', instance => $instance));
next if ($self->check_exclude(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s",
$instance, $map_psu_status{$value}));
my $exit = $self->get_severity(section => 'psu', value => $map_psu_status{$value});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power Supply '%s' status is %s",
$instance, $map_psu_status{$value}));
}
}
}
sub check_voltage {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltages");
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
return if ($self->check_exclude(section => 'voltage'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /Voltage|IntelCPUVttPower/i);
my $name = $self->{result}->{$oid};
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1} / 1000; # in mv
if ($value == 0) {
$self->{output}->output_add(long_msg => sprintf("Skipping voltage '%s' (counter is 0)",
$name));
next;
}
next if ($self->check_exclude(section => 'voltage', instance => $name));
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Voltage '%s' is %.2f V",
$name, $value));
$self->{output}->perfdata_add(label => "volt_" . $name, unit => 'V',
value => sprintf("%.2f", $value),
min => 0);
}
}
sub check_temperature {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_exclude(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) {
next if ($oid !~ /^$oid_sysHealthCounterName\.(.*)$/ || $self->{result}->{$oid} !~ /temperature/i);
my $name = $self->{result}->{$oid};
$oid =~ /^$oid_sysHealthCounterName\.(.*)$/;
my $value = $self->{result}->{$oid_sysHealthCounterValue . '.' . $1}; # in C
if ($value == 0) {
$self->{output}->output_add(long_msg => sprintf("Skipping temperature '%s' (counter is 0)",
$name));
next;
}
next if ($self->check_exclude(section => 'temperature', instance => $name));
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s C",
$name, $value));
$self->{output}->perfdata_add(label => "temp_" . $name, unit => 'C',
value => $value,
min => 0);
}
}
1;
__END__
=head1 MODE
Check System Health Status (temperatures, voltages, power supplies, fanspeed).
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'temperature', 'voltage', 'fanspeed', 'psu'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=psu)
Can also exclude specific instance: --exclude='psu#1#'
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is 'ok') (only for psu)
Can be specific or global: --exclude=psu#1#
=item B<--threshold-overload>
Set to overload default threshold values (syntax: status,regexp).
It used before default thresholds (order stays) (only for psu).
Example: --threshold-overload='CRITICAL,^(?!(normal)$)'
=back
=cut

View File

@ -1,127 +0,0 @@
#
# Copyright 2017 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 network::citrix::netscaler::common::mode::storage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_nsSysHealthDiskEntry = '.1.3.6.1.4.1.5951.4.1.1.41.8.1';
my $oid_sysHealthDiskName = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.1';
my $oid_sysHealthDiskSize = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.2'; # in MB
my $oid_sysHealthDiskUsed = '.1.3.6.1.4.1.5951.4.1.1.41.8.1.4'; # in MB
my $result = $self->{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry, nothing_quit => 1);
$self->{output}->output_add(severity => 'OK',
short_msg => 'All storages are ok.');
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($oid !~ /^$oid_sysHealthDiskName\.(.*)$/);
my $name = $result->{$oid};
my $total_used = $result->{$oid_sysHealthDiskUsed . '.' . $1} * 1024 * 1024;
my $total_size = $result->{$oid_sysHealthDiskSize . '.' . $1} * 1024 * 1024;
my $total_free = $total_size - $total_used;
my $prct_used = $total_used * 100 / $total_size;
my $prct_free = 100 - $prct_used;
my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $total_size);
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $total_used);
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $total_free);
$self->{output}->output_add(long_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name,
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $prct_used,
$total_free_value . " " . $total_free_unit, $prct_free));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Storage '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $name,
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $prct_used,
$total_free_value . " " . $total_free_unit, $prct_free));
}
$self->{output}->perfdata_add(label => 'used_' . $name, unit => 'B',
value => $total_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1),
min => 0, max => $total_size);
}
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check disk usages (NS-MIB-smiv2).
=over 8
=item B<--warning>
Threshold warning in percent.
=item B<--critical>
Threshold critical in percent.
=back
=cut

View File

@ -1,335 +0,0 @@
#
# Copyright 2017 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 network::citrix::netscaler::common::mode::vserverstatus;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::values;
my $maps_counters = {
status => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'state' },
],
closure_custom_calc => \&custom_status_calc,
closure_custom_output => \&custom_status_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&custom_threshold_output,
}
},
health => { class => 'centreon::plugins::values', obj => undef,
set => {
key_values => [
{ name => 'health' }, { name => 'display' },
],
output_template => 'Health: %.2f %%', output_error_template => 'Health: %s',
output_use => 'health_absolute', threshold_use => 'health_absolute',
perfdatas => [
{ value => 'health_absolute', label => 'health', template => '%.2f',
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
};
my $overload_th = {};
my $oid_vsvrName = '.1.3.6.1.4.1.5951.4.1.3.1.1.1';
my $oid_vsvrState = '.1.3.6.1.4.1.5951.4.1.3.1.1.5';
my $oid_vsvrHealth = '.1.3.6.1.4.1.5951.4.1.3.1.1.62';
my $oid_vsvrEntityType = '.1.3.6.1.4.1.5951.4.1.3.1.1.64';
my $thresholds = {
vs => [
['unknown', 'UNKNOWN'],
['down|outOfService|transitionToOutOfService|transitionToOutOfServiceDown', 'CRITICAL'],
['up', 'OK'],
],
};
my %map_vs_type = (
0 => 'unknown',
1 => 'loadbalancing',
2 => 'loadbalancinggroup',
3 => 'sslvpn',
4 => 'contentswitching',
5 => 'cacheredirection',
);
my %map_vs_status = (
1 => 'down',
2 => 'unknown',
3 => 'busy',
4 => 'outOfService',
5 => 'transitionToOutOfService',
7 => 'up',
8 => 'transitionToOutOfServiceDown',
);
sub get_severity {
my (%options) = @_;
my $status = 'UNKNOWN'; # default
if (defined($overload_th->{$options{section}})) {
foreach (@{$overload_th->{$options{section}}}) {
if ($options{value} =~ /$_->{filter}/i) {
$status = $_->{status};
return $status;
}
}
}
foreach (@{$thresholds->{$options{section}}}) {
if ($options{value} =~ /$$_[0]/i) {
$status = $$_[1];
return $status;
}
}
return $status;
}
sub custom_threshold_output {
my ($self, %options) = @_;
return get_severity(section => 'vs', value => $map_vs_status{$self->{result_values}->{state}});
}
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'State : ' . $map_vs_status{$self->{result_values}->{state}};
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
return 0;
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"name:s" => { name => 'name' },
"regexp" => { name => 'use_regexp' },
"filter-type:s" => { name => 'filter_type' },
"threshold-overload:s@" => { name => 'threshold_overload' },
});
$self->{vs_id_selected} = {};
foreach (keys %{$maps_counters}) {
$options{options}->add_options(arguments => {
'warning-' . $_ . ':s' => { name => 'warning-' . $_ },
'critical-' . $_ . ':s' => { name => 'critical-' . $_ },
});
my $class = $maps_counters->{$_}->{class};
$maps_counters->{$_}->{obj} = $class->new(output => $self->{output}, perfdata => $self->{perfdata},
label => $_);
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
}
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
foreach (keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
}
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
if ($val !~ /^(.*?),(.*)$/) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'.");
$self->{output}->option_exit();
}
my ($section, $status, $filter) = ('vs', $1, $2);
if ($self->{output}->is_litteral_status(status => $status) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'.");
$self->{output}->option_exit();
}
$overload_th->{$section} = [] if (!defined($overload_th->{$section}));
push @{$overload_th->{$section}}, {filter => $filter, status => $status};
}
}
sub run {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->manage_selection();
my $multiple = 1;
if (scalar(keys %{$self->{vs_id_selected}}) == 1) {
$multiple = 0;
}
if ($multiple == 1) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All Virtual Servers are ok.');
}
foreach my $id (sort keys %{$self->{vs_id_selected}}) {
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
my @exits;
foreach (sort keys %{$maps_counters}) {
$maps_counters->{$_}->{obj}->set(instance => $id);
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{vs_id_selected}->{$id});
if ($value_check != 0) {
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
$long_msg_append = ', ';
next;
}
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
push @exits, $exit2;
my $output = $maps_counters->{$_}->{obj}->output();
$long_msg .= $long_msg_append . $output;
$long_msg_append = ', ';
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
$short_msg .= $short_msg_append . $output;
$short_msg_append = ', ';
}
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
}
$self->{output}->output_add(long_msg => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $long_msg");
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
$self->{output}->output_add(severity => $exit,
short_msg => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $short_msg"
);
}
if ($multiple == 0) {
$self->{output}->output_add(short_msg => "Virtual Server '" . $self->{vs_id_selected}->{$id}->{display} . "' $long_msg");
}
}
$self->{output}->display();
$self->{output}->exit();
}
sub add_result {
my ($self, %options) = @_;
$self->{vs_id_selected}->{$options{instance}} = {};
$self->{vs_id_selected}->{$options{instance}}->{display} = $self->{results}->{$oid_vsvrName}->{$oid_vsvrName . '.' . $options{instance}};
$self->{vs_id_selected}->{$options{instance}}->{health} = $self->{results}->{$oid_vsvrHealth}->{$oid_vsvrHealth . '.' . $options{instance}};
$self->{vs_id_selected}->{$options{instance}}->{state} = $self->{results}->{$oid_vsvrState}->{$oid_vsvrState . '.' . $options{instance}};
}
sub manage_selection {
my ($self, %options) = @_;
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
{ oid => $oid_vsvrName },
{ oid => $oid_vsvrState },
{ oid => $oid_vsvrHealth },
{ oid => $oid_vsvrEntityType },
],
, nothing_quit => 1);
foreach my $oid (keys %{$self->{results}->{$oid_vsvrName}}) {
$oid =~ /^$oid_vsvrName\.(.*)$/;
my $instance = $1;
my $filter_name = $self->{results}->{$oid_vsvrName}->{$oid};
my $filter_type = $self->{results}->{$oid_vsvrEntityType}->{$oid_vsvrEntityType . '.' . $instance};
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
$map_vs_type{$filter_type} !~ /$self->{option_results}->{filter_type}/) {
$self->{output}->output_add(long_msg => "Skipping Virtual Server '" . $filter_name . "'.");
next;
}
if (!defined($self->{option_results}->{name})) {
$self->add_result(instance => $instance);
next;
}
if (!defined($self->{option_results}->{use_regexp}) && $filter_name eq $self->{option_results}->{name}) {
$self->add_result(instance => $instance);
}
if (defined($self->{option_results}->{use_regexp}) && $filter_name =~ /$self->{option_results}->{name}/) {
$self->add_result(instance => $instance);
}
}
if (scalar(keys %{$self->{vs_id_selected}}) <= 0) {
if (defined($self->{option_results}->{name})) {
$self->{output}->add_option_msg(short_msg => "No Virtual Server found '" . $self->{option_results}->{name} . "'.");
} else {
$self->{output}->add_option_msg(short_msg => "No Virtual Server found.");
}
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check vservers status and health.
=over 8
=item B<--warning-health>
Threshold warning in percent.
=item B<--critical-health>
Threshold critical in percent.
=item B<--name>
Set the virtual server name.
=item B<--regexp>
Allows to use regexp to filter virtual server name (with option --name).
=item B<--filter-type>
Filter which type of vserver (can be a regexp).
=item B<--threshold-overload>
Set to overload default threshold values (syntax: status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='CRITICAL,^(?!(green)$)'
=back
=cut

View File

@ -0,0 +1,125 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::certificatesexpire;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'certificates', type => 1, cb_prefix_output => 'prefix_certificates_output', message_multiple => 'All certificates are ok' }
];
$self->{maps_counters}->{certificates} = [
{ label => 'days', set => {
key_values => [ { name => 'days' }, { name => 'display' } ],
output_template => '%d days remaining before expiration',
closure_custom_perfdata => sub { return 0; },
}
},
];
}
sub prefix_certificates_output {
my ($self, %options) = @_;
return "Certificate '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
my $mapping = {
sslCertKeyName => { oid => '.1.3.6.1.4.1.5951.4.1.1.56.1.1.1' },
sslDaysToExpire => { oid => '.1.3.6.1.4.1.5951.4.1.1.56.1.1.5' },
};
sub manage_selection {
my ($self, %options) = @_;
$self->{certificates} = {};
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{sslCertKeyName}->{oid} }, { oid => $mapping->{sslDaysToExpire}->{oid} } ],
return_type => 1, nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{sslCertKeyName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{sslCertKeyName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{sslCertKeyName} . "': no matching filter.", debug => 1);
next;
}
$self->{certificates}->{$instance} = {
display => $result->{sslCertKeyName},
days => $result->{sslDaysToExpire},
};
}
if (scalar(keys %{$self->{certificates}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No certificate found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check number of days remaining before the expiration of certificates (NS-MIB-smiv2).
=over 8
=item B<--filter-name>
Filter by name (can be a regexp).
=item B<--warning-days>
Threshold warning in days.
=item B<--critical-days>
Threshold critical in days.
=back
=cut

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::fanspeed;
use strict;
use warnings;
my $mapping = {
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
};
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking fans");
$self->{components}->{fanspeed} = {name => 'fans', total => 0, skip => 0};
return if ($self->check_filter(section => 'fanspeed'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /Speed|Fan/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
next if ($self->check_filter(section => 'fanspeed', instance => $instance));
if ($result->{sysHealthCounterValue} == 0) {
$self->{output}->output_add(long_msg => sprintf("skipping fan '%s' (counter is 0)",
$result->{sysHealthCounterName}));
next;
}
$self->{components}->{fanspeed}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' speed is %s C [instance = %s]",
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanspeed', instance => $instance, value => $result->{sysHealthCounterValue});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' speed is %s rpm", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
}
$self->{output}->perfdata_add(label => 'speed_' . $result->{sysHealthCounterName}, unit => 'rpm',
value => $result->{sysHealthCounterValue},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::psu;
use strict;
use warnings;
my %map_psu_status = (
0 => 'normal',
1 => 'not present',
2 => 'failed',
3 => 'not supported',
);
my $mapping = {
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2', map => \%map_psu_status },
};
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking power supplies");
$self->{components}->{psu} = {name => 'psus', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu'));
my ($exit, $warn, $crit, $checked);
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /PowerSupply(.)(?:Status|FailureStatus)/i);
my $power_num = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
next if ($result->{sysHealthCounterValue} eq 'not present' &&
$self->absent_problem(section => 'psu', instance => $power_num));
next if ($self->check_filter(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
$power_num, $result->{sysHealthCounterValue}, $power_num));
$exit = $self->get_severity(section => 'psu', value => $result->{sysHealthCounterValue});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $power_num, $result->{sysHealthCounterValue}));
}
}
}
1;

View File

@ -0,0 +1,71 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::temperature;
use strict;
use warnings;
my $mapping = {
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
};
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperatures");
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
return if ($self->check_filter(section => 'temperature'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /temperature/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
next if ($self->check_filter(section => 'temperature', instance => $instance));
if ($result->{sysHealthCounterValue} == 0) {
$self->{output}->output_add(long_msg => sprintf("skipping temperature '%s' (counter is 0)",
$result->{sysHealthCounterName}));
next;
}
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' is %s C [instance = %s]",
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{sysHealthCounterValue});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Temperature '%s' is %s C", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
}
$self->{output}->perfdata_add(label => 'temp_' . $result->{sysHealthCounterName}, unit => 'C',
value => $result->{sysHealthCounterValue},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,72 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::components::voltage;
use strict;
use warnings;
my $mapping = {
sysHealthCounterName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1' },
sysHealthCounterValue => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2' },
};
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
sub load {}
sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking voltages");
$self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0};
return if ($self->check_filter(section => 'voltage'));
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_nsSysHealthEntry}})) {
next if ($oid !~ /^$mapping->{sysHealthCounterName}->{oid}\.(.*)$/);
my $instance = $1;
next if ($self->{results}->{$oid_nsSysHealthEntry}->{$oid} !~ /Voltage|IntelCPUVttPower/i);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_nsSysHealthEntry}, instance => $instance);
next if ($self->check_filter(section => 'voltage', instance => $instance));
if ($result->{sysHealthCounterValue} == 0) {
$self->{output}->output_add(long_msg => sprintf("skipping voltage '%s' (counter is 0)",
$result->{sysHealthCounterName}));
next;
}
$result->{sysHealthCounterValue} = $result->{sysHealthCounterValue} / 1000; # in mv
$self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("voltage '%s' is %s V [instance = %s]",
$result->{sysHealthCounterName}, $result->{sysHealthCounterValue}, $instance));
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{sysHealthCounterValue});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage '%s' is %s V", $result->{sysHealthCounterName}, $result->{sysHealthCounterValue}));
}
$self->{output}->perfdata_add(label => 'volt_' . $result->{sysHealthCounterName}, unit => 'V',
value => $result->{sysHealthCounterValue},
warning => $warn,
critical => $crit, min => 0
);
}
}
1;

View File

@ -0,0 +1,114 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::connections;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }
];
$self->{maps_counters}->{global} = [
{ label => 'active', set => {
key_values => [ { name => 'active' } ],
output_template => 'Active Server TCP connections : %s',
perfdatas => [
{ label => 'active_server', value => 'active_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
{ label => 'server', set => {
key_values => [ { name => 'server' } ],
output_template => 'Server TCP connections : %s',
perfdatas => [
{ label => 'server', value => 'server_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
{ label => 'client', set => {
key_values => [ { name => 'client' } ],
output_template => 'Client TCP connections : %s',
perfdatas => [
{ label => 'client', value => 'client_absolute', template => '%s',
unit => 'con', min => 0 },
],
}
},
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = { client => 0, server => 0, active => 0 };
my $oid_tcpCurServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.1.0';
my $oid_tcpCurClientConn = '.1.3.6.1.4.1.5951.4.1.1.46.2.0';
my $oid_tcpActiveServerConn = '.1.3.6.1.4.1.5951.4.1.1.46.8.0';
my $result = $options{snmp}->get_leef(oids => [$oid_tcpCurServerConn, $oid_tcpCurClientConn, $oid_tcpActiveServerConn ], nothing_quit => 1);
$self->{global}->{client} = $result->{$oid_tcpCurClientConn};
$self->{global}->{server} = $result->{$oid_tcpCurServerConn};
$self->{global}->{active} = $result->{$oid_tcpActiveServerConn};
}
1;
__END__
=head1 MODE
Check connections usage (Client, Server, ActiveServer) (NS-ROOT-MIBv2).
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'server', 'active', 'client'.
=item B<--critical-*>
Threshold critical.
Can be: 'server', 'active', 'client'.
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::citrix::netscaler::common::mode::cpu;
package network::citrix::netscaler::snmp::mode::cpu;
use base qw(centreon::plugins::mode);

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::citrix::netscaler::common::mode::hastate;
package network::citrix::netscaler::snmp::mode::hastate;
use base qw(centreon::plugins::mode);

View File

@ -0,0 +1,129 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::health;
use base qw(centreon::plugins::templates::hardware);
use strict;
use warnings;
sub set_system {
my ($self, %options) = @_;
$self->{regexp_threshold_overload_check_section_option} = '^(psu)$';
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fanspeed|voltage)$';
$self->{cb_hook2} = 'snmp_execute';
$self->{thresholds} = {
psu => [
['normal', 'OK'],
['not present', 'OK'],
['failed', 'CRITICAL'],
['not supported', 'UNKNOWN'],
],
};
$self->{components_path} = 'network::citrix::netscaler::snmp::mode::components';
$self->{components_module} = ['psu', 'fanspeed', 'temperature', 'voltage'];
}
sub snmp_execute {
my ($self, %options) = @_;
my $oid_nsSysHealthEntry = '.1.3.6.1.4.1.5951.4.1.1.41.7.1';
push @{$self->{request}}, { oid => $oid_nsSysHealthEntry };
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
my $oid_sysHealthCounterName = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.1';
my $oid_sysHealthCounterValue = '.1.3.6.1.4.1.5951.4.1.1.41.7.1.2';
my %map_psu_status = (
0 => 'normal',
1 => 'not present',
2 => 'failed',
3 => 'not supported',
);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
});
return $self;
}
1;
__END__
=head1 MODE
Check System Health Status.
=over 8
=item B<--component>
Which component to check (Default: '.*').
Can be: 'temperature', 'voltage', 'fanspeed', 'psu'.
=item B<--filter>
Exclude some parts (comma seperated list) (Example: --filter=psu)
Can also exclude specific instance: --filter=fan,1
=item B<--no-component>
Return an error if no compenents are checked.
If total (with skipped) is 0. (Default: 'critical' returns).
=item B<--absent-problem>
Return an error if an entity is not 'present' (default is skipping) (comma seperated list)
Can be specific or global: --absent-problem=psu,1
=item B<--threshold-overload>
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
It used before default thresholds (order stays).
Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)'
=item B<--warning>
Set warning threshold for 'temperature', 'fanspeed', 'voltage' (syntax: type,regexp,threshold)
Example: --warning='temperature,.,30'
=item B<--critical>
Set critical threshold for 'temperature', 'fanspeed', 'voltage'(syntax: type,regexp,threshold)
Example: --critical='temperature,.*,40'
=back
=cut

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::citrix::netscaler::common::mode::listvservers;
package network::citrix::netscaler::snmp::mode::listvservers;
use base qw(centreon::plugins::mode);

View File

@ -18,7 +18,7 @@
# limitations under the License.
#
package network::citrix::netscaler::common::mode::memory;
package network::citrix::netscaler::snmp::mode::memory;
use base qw(centreon::plugins::mode);

View File

@ -0,0 +1,216 @@
#
# Copyright 2017 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 network::citrix::netscaler::snmp::mode::storage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
my $instance_mode;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All storages are ok' }
];
$self->{maps_counters}->{storage} = [
{ label => 'usage', set => {
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
}
},
];
}
sub custom_usage_perfdata {
my ($self, %options) = @_;
my $label = 'used';
my $value_perf = $self->{result_values}->{used};
if (defined($instance_mode->{option_results}->{free})) {
$label = 'free';
$value_perf = $self->{result_values}->{free};
}
my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
my %total_options = ();
if ($instance_mode->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
if ($instance_mode->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_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});
my $msg = sprintf("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});
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'};
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub prefix_volume_output {
my ($self, %options) = @_;
return "Storage '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$instance_mode = $self;
}
my $mapping = {
sysHealthDiskName => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.1' },
sysHealthDiskSize => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.2' }, # in MB
sysHealthDiskUsed => { oid => '.1.3.6.1.4.1.5951.4.1.1.41.8.1.4' }, # in MB
};
my $oid_nsSysHealthDiskEntry = '.1.3.6.1.4.1.5951.4.1.1.41.8.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{storage} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_nsSysHealthDiskEntry,
nothing_quit => 1);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{sysHealthDiskName}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{sysHealthDiskName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{sysHealthDiskName} . "': no matching filter.", debug => 1);
next;
}
$result->{sysHealthDiskSize} *= 1024 * 1024;
$result->{sysHealthDiskUsed} *= 1024 * 1024;
$self->{storage}->{$instance} = {
display => $result->{sysHealthDiskName},
total => $result->{sysHealthDiskSize},
used => $result->{sysHealthDiskUsed}
};
}
if (scalar(keys %{$self->{storage}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No storage found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check disk usages (NS-MIB-smiv2).
=over 8
=item B<--filter-name>
Filter storage name (can be a regexp).
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=back
=cut

Some files were not shown because too many files have changed in this diff Show More