Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4909454
fix(ci): add missing image + fix path for tests on noble
omercier Mar 20, 2025
9274e64
fix(ci): add missing image + fix path for tests on noble (#5516)
omercier Mar 21, 2025
e74825a
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 9, 2025
75a686f
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 23, 2025
06d9cca
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 29, 2025
a655ae5
Merge branch 'centreon:develop' into develop
garnier-quentin May 13, 2025
0e2a2c2
Merge branch 'centreon:develop' into develop
garnier-quentin May 14, 2025
868a37b
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 4, 2025
6fd626e
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 12, 2025
cf2d401
Merge branch 'centreon:develop' into develop
garnier-quentin Jul 17, 2025
7930cbe
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 16, 2025
7ef7c1c
Merge branch 'centreon:develop' into develop
garnier-quentin Sep 25, 2025
adbb960
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 11, 2025
4b45367
Merge branch 'centreon:develop' into develop
garnier-quentin Dec 22, 2025
dc85ae4
Merge branch 'centreon:develop' into develop
garnier-quentin Jan 7, 2026
4243e13
Merge branch 'centreon:develop' into develop
garnier-quentin Feb 10, 2026
b6020da
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 16, 2026
339e322
Merge branch 'centreon:develop' into develop
garnier-quentin Mar 26, 2026
15da907
Merge branch 'centreon:develop' into develop
garnier-quentin Apr 8, 2026
ffa1515
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 8, 2026
b1f102a
wip
garnier-quentin Jun 8, 2026
84033c9
wip
garnier-quentin Jun 8, 2026
d10a1f1
Merge branch 'centreon:develop' into CTOR-2380-paloalto-new-modes
garnier-quentin Jun 11, 2026
b2471a7
wip
garnier-quentin Jun 15, 2026
83fa138
wip
garnier-quentin Jun 15, 2026
b23bf91
wip
garnier-quentin Jun 15, 2026
73475f5
wip
garnier-quentin Jun 15, 2026
c98cfa9
Merge branch 'centreon:develop' into CTOR-2394-veritas-nba
garnier-quentin Jun 15, 2026
f77187d
wip
garnier-quentin Jun 15, 2026
22c922b
wip
garnier-quentin Jun 15, 2026
74d6829
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 16, 2026
ba38634
Merge branch 'centreon:develop' into CTOR-2394-veritas-nba
garnier-quentin Jun 18, 2026
de25f45
wip
garnier-quentin Jun 18, 2026
c97c83a
Merge branch 'CTOR-2394-veritas-nba' of https://github.com/garnier-qu…
garnier-quentin Jun 18, 2026
6a2ade7
Merge branch 'centreon:develop' into develop
garnier-quentin Jun 18, 2026
fcd539c
Merge branch 'centreon:develop' into develop
garnier-quentin Jul 9, 2026
b30910a
Merge branch 'centreon:develop' into develop
garnier-quentin Jul 20, 2026
4898841
wip
garnier-quentin Jul 20, 2026
8e14a32
wip
garnier-quentin Jul 20, 2026
dc70a6e
wi
garnier-quentin Jul 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"libssh-session-perl"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"pkg_name": "centreon-plugin-Hardware-Storage-Veritas-Nba-Ssh",
"pkg_summary": "Centreon Plugin",
"plugin_name": "centreon_veritas_nba_ssh.pl",
"files": [
"centreon/plugins/script_custom.pm",
"centreon/plugins/backend/ssh/",
"centreon/plugins/ssh.pm",
"storage/veritas/nba/ssh/"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"perl(Libssh::Session)"
]
}
34 changes: 34 additions & 0 deletions src/centreon/plugins/backend/ssh/libssh.pm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,40 @@ sub execute {
return ($content, $exit_code);
}

sub execute_scenario {
my ($self, %options) = @_;

if (defined($options{timeout}) && $options{timeout} =~ /(\d+)/) {
$self->{ssh}->options(timeout => $options{timeout});
}

$self->connect(hostname => $options{hostname});

my $ret = $self->{ssh}->execute_scenario(%{$options{request}});

$self->{output}->output_add(long_msg => $ret->{stdout}, debug => 1) if (defined($ret->{stdout}));
$self->{output}->output_add(long_msg => $ret->{stderr}, debug => 1) if (defined($ret->{stderr}));

my ($content, $exit_code);
if ($ret->{exit} == $self->{constant_cb}->(name => 'SSH_OK')) {
$content = $ret->{stdout};
$exit_code = $ret->{exit};
} elsif ($ret->{exit} == $self->{constant_cb}->(name => 'SSH_AGAIN')) { # AGAIN means timeout
$self->{output}->add_option_msg(short_msg => sprintf('command execution timeout'));
$self->{output}->option_exit();
} else {
$self->{output}->add_option_msg(short_msg =>
sprintf(
'command execution error: %s',
$self->{ssh}->error(GetErrorSession => 1)
)
);
$self->{output}->option_exit();
}

return ($content, $exit_code);
}

1;

__END__
Expand Down
7 changes: 7 additions & 0 deletions src/centreon/plugins/backend/ssh/plink.pm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ sub execute {
return ($content, $exit_code);
}

sub execute_scenario {
my ($self, %options) = @_;

$self->{output}->add_option_msg(short_msg => 'Unsupported method for sshcli backend: execute_scenario');
$self->{output}->option_exit();
}

1;

__END__
Expand Down
7 changes: 7 additions & 0 deletions src/centreon/plugins/backend/ssh/sshcli.pm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ sub execute {
return ($content, $exit_code);
}

sub execute_scenario {
my ($self, %options) = @_;

$self->{output}->add_option_msg(short_msg => 'Unsupported method for sshcli backend: execute_scenario');
$self->{output}->option_exit();
}

1;

__END__
Expand Down
14 changes: 12 additions & 2 deletions src/centreon/plugins/ssh.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sub new {

if (!defined($options{noptions}) || $options{noptions} != 1) {
$options{options}->add_options(arguments => {
'ssh-backend:s' => { name => 'ssh_backend', default => 'sshcli' },
'ssh-backend:s' => { name => 'ssh_backend' },
'ssh-port:s' => { name => 'ssh_port' },
'ssh-priv-key:s' => { name => 'ssh_priv_key' },
'ssh-username:s' => { name => 'ssh_username' },
Expand Down Expand Up @@ -60,6 +60,9 @@ sub new {
);
$self->{backend_libssh} = centreon::plugins::backend::ssh::libssh->new(%options);

$self->{default_backend} = defined($options{default_backend}) && $options{default_backend} ne '' ?
$options{default_backend} : 'sshcli';

$self->{output} = $options{output};
return $self;
}
Expand All @@ -68,12 +71,13 @@ sub check_options {
my ($self, %options) = @_;

$self->{ssh_backend} = $options{option_results}->{ssh_backend};

my $default_port = 22;
if (defined($options{default_ssh_port}) && $options{default_ssh_port} =~ /\d+/) {
$default_port = $options{default_ssh_port};
}
$self->{ssh_port} = defined($options{option_results}->{ssh_port}) && $options{option_results}->{ssh_port} =~ /(\d+)/ ? $1 : $default_port;
$self->{ssh_backend} = 'sshcli'
$self->{ssh_backend} = $self->{default_backend}
if (!defined($options{option_results}->{ssh_backend}) || $options{option_results}->{ssh_backend} eq '');
if (!defined($self->{'backend_' . $self->{ssh_backend}})) {
$self->{output}->add_option_msg(short_msg => 'unknown ssh backend: ' . $self->{ssh_backend});
Expand All @@ -100,6 +104,12 @@ sub execute {
return $self->{'backend_' . $self->{ssh_backend}}->execute(%options);
}

sub execute_scenario {
my ($self, %options) = @_;

return $self->{'backend_' . $self->{ssh_backend}}->execute_scenario(%options);
}

1;

__END__
Expand Down
159 changes: 159 additions & 0 deletions src/storage/veritas/nba/ssh/custom/cli.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#
# Copyright 2026-Present 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 storage::veritas::nba::ssh::custom::cli;

use strict;
use warnings;
use centreon::plugins::ssh;
use centreon::plugins::misc;

sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;

if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}

if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'timeout:s' => { name => 'timeout', default => 55 },
'command:s' => { name => 'command' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'SSH OPTIONS', once => 1);

$self->{output} = $options{output};
$self->{ssh} = centreon::plugins::ssh->new(%options, default_backend => 'libssh');

return $self;
}

sub set_options {
my ($self, %options) = @_;

$self->{option_results} = $options{option_results};
}

sub set_defaults {}

sub check_options {
my ($self, %options) = @_;

if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
$self->{ssh}->check_options(option_results => $self->{option_results});
}

centreon::plugins::misc::check_security_command(
output => $self->{output},
command => $self->{option_results}->{command},
command_options => $self->{option_results}->{command_options},
command_path => $self->{option_results}->{command_path}
);

return 0;
}

sub execute_scenario {
my ($self, %options) = @_;

my $content;
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
($content) = $self->{ssh}->execute_scenario(
hostname => $self->{option_results}->{hostname},
request => $options{request},
timeout => $self->{option_results}->{timeout}
);
} else {
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command for local)');
$self->{output}->option_exit();
}

($content) = centreon::plugins::misc::execute(
output => $self->{output},
options => { timeout => $self->{option_results}->{timeout} },
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}
);
}

$content =~ s/\x{0d}//g; # carriage return
$content =~ s/\x{08}//g; # backspace
$content =~ s/\x{1b}\x{5b}\x{30}\x{6d}//g;
$content =~ s/\x{1b}\x{5b}\x{31}\x{6d}//g;

return $content;
}

1;

__END__

=head1 NAME

ssh

=head1 SYNOPSIS

my ssh

=head1 SSH OPTIONS

=over 8

=item B<--hostname>

Hostname to query.

=item B<--timeout>

Timeout in seconds for the command (default: 55).

=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.

=back

=head1 DESCRIPTION

B<custom>.

=cut
72 changes: 72 additions & 0 deletions src/storage/veritas/nba/ssh/mode/components/disk.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

package storage::veritas::nba::ssh::mode::components::disk;

use strict;
use warnings;
use centreon::plugins::misc;

sub load {}

sub check {
my ($self) = @_;

$self->{output}->output_add(long_msg => 'checking disks');
$self->{components}->{disk} = { name => 'disk', total => 0, skip => 0 };
return if ($self->check_filter(section => 'disk'));

while ($self->{result} =~ /Hardware\s+monitor\s+information\s+(.*?)(?=\s+Hardware monitor information|\Z$)/msg) {
my $part = $1;

next if ($part !~ /NetBackup\s+StorageShelf\s+(\d+)/i);
my $shelf = $1;

while ($part =~ /^.*?Controller.*?Disk.*?\|(.*?)\|.*?\|.*?\|.*?\|.*?\|.*?\|.*?\|.*?\|(.*?)\|(.*?)\|/mig) {
my ($enclosure, $disk, $state) = (centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($3));
my $instance = 'shelf' . $shelf . '.' . $enclosure . '.' . $disk;

next if ($self->check_filter(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;

$self->{output}->output_add(
long_msg => sprintf(
"disk '%s' shelf '%s' enclosure '%s' state is %s",
$disk,
$shelf,
$enclosure,
$state
)
);
my $exit = $self->get_severity(label => 'default', section => 'disk', instance => $instance, value => $state);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"disk '%s' shelf '%s' enclosure '%s' state is %s",
$disk, $shelf, $enclosure, $state
)
);
}
}
}
}

1;
Loading