From 932e4259319f92ee77c8825c9e2018ce845d6da4 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:29:02 +0200 Subject: [PATCH 01/18] fix(protocols/http): mode json-content missing expression (#5064) Co-authored-by: garnier-quentin Fixes CTOR-679 --- src/apps/protocols/http/mode/jsoncontent.pm | 20 ++++---- tests/resources/spellcheck/stopwords.t | 53 +++++++++++++-------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/apps/protocols/http/mode/jsoncontent.pm b/src/apps/protocols/http/mode/jsoncontent.pm index f9f2c6e327..d57d8b3183 100644 --- a/src/apps/protocols/http/mode/jsoncontent.pm +++ b/src/apps/protocols/http/mode/jsoncontent.pm @@ -193,6 +193,8 @@ sub lookup { $self->decode_json_response(); foreach my $xpath_find (@{$self->{option_results}->{lookup}}) { + next if ($xpath_find eq ''); + eval { my $jpath = JSON::Path->new($xpath_find); @values = $jpath->values($self->{json_response_decoded}); @@ -379,7 +381,7 @@ __END__ =head1 MODE -Check JSON webservice. Can send the json request with option '--data'. Example: +Check JSON web service. 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' --header='Content-Type: application/json' @@ -389,7 +391,7 @@ JSON OPTIONS: =item B<--data> -Set the JSON request or specify a file with the request inside. +Set the JSON request or specify a file with the request inside. =item B<--lookup> @@ -398,8 +400,8 @@ See: http://goessner.net/articles/JsonPath/ =item B<--lookup-perfdatas-nagios> -Take perfdatas from the JSON response (JSON XPath string) -Chain must be formated in Nagios format. +Take perfdata from the JSON response (JSON XPath string) +Chain must be formatted in Nagios format. Ex : "rta=10.752ms;50.000;100.000;0; pl=0%;20;40;; rtmax=10.802ms;;;;" =back @@ -473,11 +475,11 @@ Returns a UNKNOWN status if the value matches the string. =item B<--warning-time> -Warning threshold in seconds of webservice response time +Warning threshold in seconds of web service response time. =item B<--critical-time> -Critical threshold in seconds of webservice response time +Critical threshold in seconds of web service response time. =back @@ -523,7 +525,7 @@ Specify this option if you are accessing a web page using hidden basic authentic =item B<--ntlmv2> -Specify this option if you are accessing a web page using ntlmv2 authentication (use with --credentials and --port options). +Specify this option if you are accessing a web page using NTLMv2 authentication (use with --credentials and --port options). =item B<--timeout> @@ -551,11 +553,11 @@ Specify that the type of certificate is PKCS1. =item B<--get-param> -Set GET params (multiple option. Example: --get-param='key=value'). +Set a parameter for GET requests (multiple option. Example: --get-param='key=value'). =item B<--header> -Set HTTP headers(multiple option). Example: --header='Content-Type: xxxxx'. +Set HTTP headers(multiple option). Example: --header='Content-Type: application/json'. =item B<--unknown-status> diff --git a/tests/resources/spellcheck/stopwords.t b/tests/resources/spellcheck/stopwords.t index fcdc4a2936..6dd7131a0c 100644 --- a/tests/resources/spellcheck/stopwords.t +++ b/tests/resources/spellcheck/stopwords.t @@ -1,6 +1,9 @@ --add-sysdesc --api-password --api-version +--cacert-file +--cert-pkcs12 +--cert-pwd --critical-bytesallocatedpercentage --display-transform-dst --display-transform-src @@ -11,6 +14,8 @@ --force-counters32 --force-counters64 --force-oid +--get-param +--lookup-perfdatas-nagios --map-speed-dsl --mqtt --mqtt-allow-insecure @@ -23,22 +28,46 @@ --mqtt-timeout --mqtt-username --nagvis-perfdata +--ntlmv2 --oid-display --oid-extra-display --oid-filter +--urlpath --warning-bytesallocatedpercentage 2c ADSL Avigilon Centreon Datacore +Fortigate +Fortinet +HashiCorp +IpAddr +Iwsva +Loggly +MBean +MQTT +Mosquitto +NTLMv2 +NagVis +Nagios +Netscaler +OID +PKCS1 +RRDCached +SNMP +SSH +Sansymphony +SureBackup +TendMicro +VDSL2 +Veeam +WSMAN +XPath deltaps df eth fanspeed -Fortigate -Fortinet -HashiCorp hashicorpvault ifAlias ifDesc @@ -47,18 +76,9 @@ in-bcast in-mcast in-ucast interface-dsl-name -IpAddr -Iwsva keepass ldap license-instances-usage-prct -Loggly -MBean -Mosquitto -MQTT -NagVis -Netscaler -OID okta oneaccess-sys-mib out-bcast @@ -69,22 +89,13 @@ powershell proto psu queue-messages-inflighted -RRDCached -Sansymphony -SNMP space-usage-prct -SSH -SureBackup teampass timeframe topic-messages-inflighted total-oper-down total-oper-up -TendMicro uptime userpass -VDSL2 -Veeam v1 v2 -WSMAN From 04fac2d7923230ee4f5cbc9fb97335524c821e80 Mon Sep 17 00:00:00 2001 From: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:44:00 +0200 Subject: [PATCH 02/18] CTOR-174 Change Pull request template (#5055) Co-authored-by: Lucie Dubrunfaut Co-authored-by: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com> Co-authored-by: omercier <32134301+omercier@users.noreply.github.com> --- .github/PULL_REQUEST_TEMPLATE.md | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..7045372502 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,80 @@ +# Community contributors + +## Description + +Please include a short resume of the changes and what is the purpose of this pull request. +Any relevant information should be added to help **reviewers** to understand what are the stakes +of the pull request. + +**Fixes** # (issue) +If you are fixing a github Issue already existing, mention it here. + +## Type of change + +- [ ] Patch fixing an issue (non-breaking change) +- [ ] New functionality (non-breaking change) +- [ ] Functionality enhancement or optimization (non-breaking change) +- [ ] Breaking change (patch or feature) that might cause side effects breaking part of the Software + +## How this pull request can be tested ? + +Please describe the **procedure** to verify that the goal of the PR is matched. +Provide clear instructions so that it can be **correctly tested**. + +Any **relevant details** of the configuration to perform the test should be added. +To integrate this pull request into our core we need to add some **automated tests** to check the proper +functioning of this PR. Ideally we need the following informations: +* **SNMP**: MIB files and full snmpwalk of enterprise branch (`snmpwalk -ObentU -v 2c -c public address .1.3.6.1.4.1 > equipment.snmpwalk`) or [SNMP collections](https://thewatch.centreon.com/product-how-to-21/snmp-collection-tutorial-132). +* **HTTP API (SOAP, Rest/Json, XML-RPC)**: the documentation and some curl examples (command with -v + output) or HTTP [collections](https://thewatch.centreon.com/data-collection-6/centreon-plugins-discover-collection-modes-131). +* **CLI**: command line examples (command + result). +* **SQL**: queries + results + column types or [SQL collections](https://thewatch.centreon.com/product-how-to-21/sql-collection-tutorial-134). +* **JMX**: mbean names and attributes. + +If some information is confidential, such as logins or IP addresses, obfuscate them in what is sent +publicly and we'll get in touch with you by private message if this information is needed. + +## Checklist + +- [ ] I have followed the **[coding style guidelines](https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/plugins_global.md#5-code-style-guidelines)** provided by Centreon +- [ ] I have commented my code, especially **hard-to-understand areas** of the PR. +- [ ] I have **rebased** my development branch on the base branch (develop). +- [ ] I have provide data or shown output displaying the result of this code in the plugin area concerned. + +------------------------------------------------------------------------------------------------------ +# Centreon team + +## Description + +**PLEASE MAKE SURE THAT THE BRANCH PR INCLUDES JIRA TICKET ID** + +Please include a short resume of the changes and what is the purpose of this pull request. +Any relevant information should be added to help **reviewers** to understand what are the stakes +of the pull request. + +**Fixes** # (issue) +If you are fixing a github Issue already existing, mention it here. +If you are fixing one or more JIRA ticket, mention it here too. + +## Type of change + +- [ ] Patch fixing an issue (non-breaking change) +- [ ] New functionality (non-breaking change) +- [ ] Functionality enhancement or optimization (non-breaking change) +- [ ] Breaking change (patch or feature) that might cause side effects breaking part of the Software + +## How this pull request can be tested ? + +Please describe the **procedure** to verify that the goal of the PR is matched. +Provide clear instructions so that it can be **correctly tested**. +Mention the automated tests included in this FOR (what they test like mode/option combinations). + +## Checklist + +- [ ] I have followed the **[coding style guidelines](https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/plugins_global.md#5-code-style-guidelines)** provided by Centreon +- [ ] I have commented my code, especially **hard-to-understand areas** of the PR. +- [ ] I have **rebased** my development branch on the base branch (develop). +- [ ] I have implemented automated tests related to my commits. +- [ ] I have reviewed all the help messages in all the .pm files I have modified. + - [ ] All sentences begin with a capital letter. + - [ ] All sentences are terminated by a period. + - [ ] I am able to understand all the help messages, if not, exchange with the PO or TW to rewrite them. \ No newline at end of file From f4052dde1948ce01bca64f7cdc8b3e4cabad6196 Mon Sep 17 00:00:00 2001 From: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:36:04 +0200 Subject: [PATCH 03/18] ench(vmware-connector) Change error message to help user debug (#5066) --- connectors/vmware/src/centreon/vmware/common.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectors/vmware/src/centreon/vmware/common.pm b/connectors/vmware/src/centreon/vmware/common.pm index 0d58f776fd..2704a63f45 100644 --- a/connectors/vmware/src/centreon/vmware/common.pm +++ b/connectors/vmware/src/centreon/vmware/common.pm @@ -406,7 +406,7 @@ sub generic_performance_values_historic { return undef if (!defined($perfdata)); if (!$$perfdata[0] || !defined($$perfdata[0]->value)) { - set_response(code => -1, short_message => 'Cannot get value for counters (Maybe, object(s) cannot be reached: disconnected, not running, time not synced (see time-host mode),...)'); + set_response(code => -1, short_message => 'Cannot get value for counters (Maybe, object(s) cannot be reached: disconnected, not running, time not synced (see time-host mode) check option --time-shift and ensure this specific metric is retrieved and not late in the vcenter)'); return undef; } foreach my $val (@$perfdata) { From 1333b452fb46553faca7fb43fffae0eb5efb9e45 Mon Sep 17 00:00:00 2001 From: Jochen Platzgummer Date: Tue, 25 Jun 2024 14:29:23 +0200 Subject: [PATCH 04/18] Update listinterfaces.pm - special char in status (#4901) --- src/os/windows/wsman/mode/listinterfaces.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/windows/wsman/mode/listinterfaces.pm b/src/os/windows/wsman/mode/listinterfaces.pm index 66c9fdc235..e821121b1e 100644 --- a/src/os/windows/wsman/mode/listinterfaces.pm +++ b/src/os/windows/wsman/mode/listinterfaces.pm @@ -52,7 +52,7 @@ my $map_status = { 7 => 'mediaDisconnect', 8 => 'auth', 9 => 'authSucceeded', - 10 => 'ÁuthFailed', + 10 => 'AuthFailed', 11 => 'invalidAddress', 12 => 'credentialsRequired' }; From 294fa2b394a8914b06d84b1a01a8ab2bfd18f915 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:20:19 +0200 Subject: [PATCH 05/18] add(mode): new vpn tunnels mode to meraki api plugin + tests (#5084) Co-authored-by: garnier-quentin REFS: CTOR-98 --- .../cloudcontroller/restapi/custom/api.pm | 58 ++- .../cloudcontroller/restapi/mode/devices.pm | 14 +- .../restapi/mode/listvpntunnels.pm | 149 ++++++ .../cloudcontroller/restapi/mode/networks.pm | 2 +- .../restapi/mode/vpntunnels.pm | 188 +++++++ .../meraki/cloudcontroller/restapi/plugin.pm | 16 +- tests/resources/spellcheck/stopwords.t | 11 + .../restapi/meraki.mockoon.json | 480 ++++++++++++++++++ .../cloudcontroller/restapi/vpntunnels.robot | 46 ++ 9 files changed, 939 insertions(+), 25 deletions(-) create mode 100644 src/network/cisco/meraki/cloudcontroller/restapi/mode/listvpntunnels.pm create mode 100644 src/network/cisco/meraki/cloudcontroller/restapi/mode/vpntunnels.pm create mode 100644 tests/robot/network/cisco/meraki/cloudcontroller/restapi/meraki.mockoon.json create mode 100644 tests/robot/network/cisco/meraki/cloudcontroller/restapi/vpntunnels.robot diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index a743fa565e..2d1cf92f56 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -241,16 +241,17 @@ sub write_cache_file { sub get_cache_file_response { my ($self, %options) = @_; + my $cache_filename = 'cache_meraki_' + . md5_hex($self->{api_token} . '_' .(defined($self->{option_results}->{api_filter_orgs}) ? + $self->{option_results}->{api_filter_orgs} : '') + ); $self->{cache}->read( - statefile => 'cache_meraki_' . md5_hex( - $self->{api_token} . '_' . - (defined($self->{option_results}->{api_filter_orgs}) ? $self->{option_results}->{api_filter_orgs} : '') - ) + statefile => $cache_filename ); $self->{datas} = $self->{cache}->get(name => 'response'); if (!defined($self->{datas})) { - $self->{output}->add_option_msg(short_msg => 'Cache file missing'); + $self->{output}->add_option_msg(short_msg => 'Cache file missing or could not load ' . $cache_filename); $self->{output}->option_exit(); } @@ -261,7 +262,9 @@ sub call_datas { my ($self, %options) = @_; $self->get_organizations(); - $self->get_networks(orgs => [keys %{$self->{datas}->{orgs}}]); + if (!defined($options{skipNetworks})) { + $self->get_networks(orgs => [keys %{$self->{datas}->{orgs}}]); + } if (!defined($options{skipDevices})) { $self->get_devices(orgs => [keys %{$self->{datas}->{orgs}}]); @@ -269,6 +272,9 @@ sub call_datas { if (!defined($options{skipDevicesStatus})) { $self->get_organization_device_statuses(orgs => [keys %{$self->{datas}->{orgs}}]); } + if (!defined($options{skipVpnTunnelsStatus})) { + $self->get_organization_vpn_tunnels_statuses(orgs => [keys %{$self->{datas}->{orgs}}]); + } if (defined($options{cache})) { foreach my $orgId (keys %{$self->{datas}->{orgs}}) { @@ -408,6 +414,26 @@ sub get_organization_device_statuses { return $self->{datas}->{devices_status}; } +sub get_organization_vpn_tunnels_statuses { + my ($self, %options) = @_; + + $self->{datas}->{vpn_tunnels_status} = {}; + foreach my $id (@{$options{orgs}}) { + my $datas = $self->request_api( + endpoint => '/organizations/' . $id . '/appliance/vpn/statuses', + paginate => 300, + hostname => $self->get_shard_hostname(organization_id => $id), + ignore_codes => { 400 => 1 } # it can be disabled + ); + foreach (@$datas) { + $self->{datas}->{vpn_tunnels_status}->{ $_->{deviceSerial} } = $_; + $self->{datas}->{vpn_tunnels_status}->{ $_->{deviceSerial} }->{organizationId} = $id; + } + } + + return $self->{datas}->{vpn_tunnels_status}; +} + sub get_network_device_uplink { my ($self, %options) = @_; @@ -444,7 +470,7 @@ sub get_organization_uplink_loss_and_latency { if (defined($datas)) { foreach (@$datas) { # sometimes uplink is undef. so we skip - next if (!defined($_->{uplink})); + next if (!defined($_->{uplink}) || !defined($_->{serial})); $self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} } = {} if (!defined($self->{datas}->{uplinks_loss_latency}->{ $options{orgId} }->{ $_->{serial} })); @@ -554,7 +580,7 @@ Meraki REST API =head1 SYNOPSIS -api_token Rest API custom mode +Rest API custom mode =head1 REST API OPTIONS @@ -562,23 +588,23 @@ api_token Rest API custom mode =item B<--hostname> -Meraki api hostname (default: 'api.meraki.com') +Meraki API hostname (default: 'api.meraki.com') =item B<--port> -Port used (default: 443) +Define the TCP port to use to reach the API (default: 443). =item B<--proto> -Specify https if needed (default: 'https') +Define the protocol to reach the API (default: 'https'). =item B<--api-token> -Meraki api token. +Meraki API token. =item B<--timeout> -Set HTTP timeout +Define the timeout for HTTP requests. =item B<--ignore-permission-errors> @@ -586,15 +612,15 @@ Ignore permission errors (403 status code). =item B<--ignore-orgs-api-disabled> -Ignore organizations with api disabled. +Ignore organizations where the API is disabled. =item B<--api-filter-orgs> -Filter organizations (regexp). +Define the organizations to monitor (regular expression). =item B<--cache-use> -Use the cache file (created with cache mode). +Use the cache file instead of requesting the API (the cache file can be created with the cache mode). =back diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index a0f6bf1b1f..c699545fd3 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -312,6 +312,7 @@ sub new { 'filter-tags:s' => { name => 'filter_tags' }, 'add-switch-ports' => { name => 'add_switch_ports' }, 'filter-switch-port:s' => { name => 'filter_switch_port' }, + 'filter-link-name:s' => { name => 'filter_link_name' }, 'skip-traffic-disconnect-port' => { name => 'skip_traffic_disconnect_port' }, 'skip-clients' => { name => 'skip_clients' }, 'skip-performance' => { name => 'skip_performance' }, @@ -373,6 +374,10 @@ sub add_uplink { foreach (@$links) { my $interface = lc($_->{interface}); $interface =~ s/\s+//g; + + next if (defined($self->{option_results}->{filter_link_name}) && $self->{option_results}->{filter_link_name} ne '' && + $interface !~ /$self->{option_results}->{filter_link_name}/); + $self->{devices}->{ $options{serial} }->{device_links}->{$interface} = { display => $interface, link_status => lc($_->{status}) @@ -396,7 +401,10 @@ sub add_uplink_loss_latency { foreach (values %$links) { my $interface = lc($_->{uplink}); $interface =~ s/\s+//g; + next if (!defined($self->{devices}->{ $options{serial} }->{device_links}->{$interface})); + next if (defined($self->{option_results}->{filter_link_name}) && $self->{option_results}->{filter_link_name} ne '' && + $interface !~ /$self->{option_results}->{filter_link_name}/); my ($latency, $loss, $count) = (0, 0, 0); foreach my $ts (@{$_->{timeSeries}}) { @@ -581,6 +589,10 @@ Check devices. Filter devices by name (can be a regexp). +=item B<--filter-link-name> + +Filter VPN links by name (can be a regexp). + =item B<--filter-network-id> Filter devices by network ID (can be a regexp). @@ -611,7 +623,7 @@ Don't monitor clients traffic on device. =item B<--skip-performance> -Don't monitor appliance perfscore. +Don't monitor appliance performance score. =item B<--skip-connections> diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/listvpntunnels.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/listvpntunnels.pm new file mode 100644 index 0000000000..bdcfdf8239 --- /dev/null +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/listvpntunnels.pm @@ -0,0 +1,149 @@ +# +# 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 network::cisco::meraki::cloudcontroller::restapi::mode::listvpntunnels; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my @labels = ( + 'organization_id', + 'organization_name', + 'network_id', + 'network_name', + 'device_serial', + 'mode', + 'status' +); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-network-id:s' => { name => 'filter_network_id' }, + 'filter-organization-name:s' => { name => 'filter_organization_name' }, + 'filter-organization-id:s' => { name => 'filter_organization_id' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $organizations = $options{custom}->get_organizations(); + my $devices = $options{custom}->get_organization_vpn_tunnels_statuses( + orgs => [keys %$organizations] + ); + + my $results = {}; + foreach (keys %$devices) { + next if (defined($self->{option_results}->{filter_network_id}) && $self->{option_results}->{filter_network_id} ne '' && + $devices->{$_}->{networkId} !~ /$self->{option_results}->{filter_network_id}/); + next if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' && + $devices->{$_}->{organizationId} !~ /$self->{option_results}->{filter_organization_id}/); + + my $organization_name = $organizations->{ $devices->{$_}->{organizationId} }->{name}; + next if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' && + $organization_name !~ /$self->{option_results}->{filter_organization_name}/); + + $results->{$_} = { + network_id => $devices->{$_}->{networkId}, + network_name => $devices->{$_}->{networkName}, + device_serial => $devices->{$_}->{deviceSerial}, + organization_id => $devices->{$_}->{organizationId}, + organization_name => $organization_name, + mode => $devices->{$_}->{vpnMode}, + status => $devices->{$_}->{deviceStatus} + }; + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(custom => $options{custom}); + foreach my $instance (sort keys %$results) { + $self->{output}->output_add(long_msg => + join('', map("[$_: " . $results->{$instance}->{$_} . ']', @labels)) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List VPN tunnels:' + ); + $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 => [@labels]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(custom => $options{custom}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + %{$results->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List VPN tunnels. + +=over 8 + +=item B<--filter-network-id> + +Filter VPN tunnels by network ID (can be a regexp). + +=item B<--filter-organization-id> + +Filter VPN tunnels by organization ID (can be a regexp). + +=item B<--filter-organization-name> + +Filter VPN tunnels by organization name (can be a regexp). + +=back + +=cut diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm index 6813fad097..1543892353 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -126,7 +126,7 @@ sub manage_selection { (defined($self->{option_results}->{filter_organization_name}) ? $self->{option_results}->{filter_organization_name} : 'all') ); - my $datas = $options{custom}->get_datas(skipDevices => 1, skipDevicesStatus => 1); + my $datas = $options{custom}->get_datas(skipDevices => 1, skipDevicesStatus => 1, skipVpnTunnelsStatus => 1); $self->{networks} = {}; foreach my $id (keys %{$datas->{networks}}) { diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/mode/vpntunnels.pm b/src/network/cisco/meraki/cloudcontroller/restapi/mode/vpntunnels.pm new file mode 100644 index 0000000000..61505a9dfc --- /dev/null +++ b/src/network/cisco/meraki/cloudcontroller/restapi/mode/vpntunnels.pm @@ -0,0 +1,188 @@ +# +# 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 network::cisco::meraki::cloudcontroller::restapi::mode::vpntunnels; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); +use Digest::MD5 qw(md5_hex); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status} . ' [mode: ' . $self->{result_values}->{mode} . ']'; +} + +sub prefix_tunnel_output { + my ($self, %options) = @_; + + return "vpn tunnel '" . $options{instance_value}->{deviceSerial} . "' "; +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return 'Vpn tunnels '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, + { name => 'tunnels', type => 1, cb_prefix_output => 'prefix_tunnel_output', message_multiple => 'All vpn tunnels are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total-online', nlabel => 'vpn.tunnels.online.count', display_ok => 0, set => { + key_values => [ { name => 'online' }, { name => 'total' } ], + output_template => 'online: %s', + perfdatas => [ + { template => '%s', min => 0, max => 'total' } + ] + } + }, + { label => 'total-offline', nlabel => 'vpn.tunnels.offline.count', display_ok => 0, set => { + key_values => [ { name => 'offline' }, { name => 'total' } ], + output_template => 'offline: %s', + perfdatas => [ + { template => '%s', min => 0, max => 'total' } + ] + } + }, + { label => 'total-dormant', nlabel => 'vpn.tunnels.dormant.count', display_ok => 0, set => { + key_values => [ { name => 'dormant' }, { name => 'total' } ], + output_template => 'dormant: %s', + perfdatas => [ + { template => '%s', min => 0, max => 'total' } + ] + } + } + ]; + + $self->{maps_counters}->{tunnels} = [ + { + label => 'status', type => 2, + critical_default => '%{status} =~ /offline/i', + set => { + key_values => [ { name => 'status' }, { name => 'mode' }, { name => 'deviceSerial' } ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold_ng + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-network-name:s' => { name => 'filter_network_name' }, + 'filter-organization-name:s' => { name => 'filter_organization_name' }, + 'filter-organization-id:s' => { name => 'filter_organization_id' }, + 'filter-device-serial:s' => { name => 'filter_device_serial' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $datas = $options{custom}->get_datas(skipDevices => 1, skipDevicesStatus => 1, skipNetworks => 1); + + $self->{global} = { total => 0, online => 0, offline => 0, dormant => 0 }; + $self->{tunnels} = {}; + foreach my $id (keys %{$datas->{vpn_tunnels_status}}) { + next if (defined($self->{option_results}->{filter_network_name}) && $self->{option_results}->{filter_network_name} ne '' && + $datas->{vpn_tunnels_status}->{$id}->{networkName} !~ /$self->{option_results}->{filter_network_name}/); + + next if (defined($self->{option_results}->{filter_organization_id}) && $self->{option_results}->{filter_organization_id} ne '' && + $datas->{vpn_tunnels_status}->{$id}->{organizationId} !~ /$self->{option_results}->{filter_organization_id}/); + next if (defined($self->{option_results}->{filter_organization_name}) && $self->{option_results}->{filter_organization_name} ne '' && + $datas->{orgs}->{ $datas->{vpn_tunnels_status}->{$id}->{organizationId} }->{name} !~ /$self->{option_results}->{filter_organization_name}/); + + $self->{tunnels}->{$id} = { + deviceSerial => $id, + status => $datas->{vpn_tunnels_status}->{$id}->{deviceStatus}, + mode => $datas->{vpn_tunnels_status}->{$id}->{vpnMode} + }; + + $self->{global}->{total}++; + $self->{global}->{ lc($datas->{vpn_tunnels_status}->{$id}->{deviceStatus}) }++ + if (defined($self->{global}->{ lc($datas->{vpn_tunnels_status}->{$id}->{deviceStatus}) })); + } +} + +1; + +__END__ + +=head1 MODE + +Check VPN tunnels. + +=over 8 + +=item B<--filter-network-name> + +Filter VPN tunnels by network name (can be a regexp). + +=item B<--filter-organization-id> + +Filter VPN tunnels by organization ID (can be a regexp). + +=item B<--filter-organization-name> + +Filter VPN tunnels by organization name (can be a regexp). + +=item B<--filter-device-serial> + +Filter VPN tunnels by device serial (can be a regexp). + +=item B<--unknown-status> + +Define the conditions to match for the status to be UNKNOWN. +You can use the following variables: %{status}, %{deviceSerial}, %{mode} + +=item B<--warning-status> + +Define the conditions to match for the status to be WARNING. +You can use the following variables: %{status}, %{deviceSerial}, %{mode} + +=item B<--critical-status> + +Define the conditions to match for the status to be CRITICAL (default: '%{status} =~ /offline/i'). +You can use the following variables: %{status}, %{deviceSerial}, %{mode} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total-online', 'total-offline', 'total-dormant'. + +=back + +=cut diff --git a/src/network/cisco/meraki/cloudcontroller/restapi/plugin.pm b/src/network/cisco/meraki/cloudcontroller/restapi/plugin.pm index 2a8fd6a7a1..8c6f001470 100644 --- a/src/network/cisco/meraki/cloudcontroller/restapi/plugin.pm +++ b/src/network/cisco/meraki/cloudcontroller/restapi/plugin.pm @@ -30,13 +30,15 @@ sub new { bless $self, $class; $self->{modes} = { - 'api-requests' => 'network::cisco::meraki::cloudcontroller::restapi::mode::apirequests', - 'cache' => 'network::cisco::meraki::cloudcontroller::restapi::mode::cache', - 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', - 'discovery' => 'network::cisco::meraki::cloudcontroller::restapi::mode::discovery', - 'list-devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::listdevices', - 'list-tags' => 'network::cisco::meraki::cloudcontroller::restapi::mode::listtags', - 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks' + 'api-requests' => 'network::cisco::meraki::cloudcontroller::restapi::mode::apirequests', + 'cache' => 'network::cisco::meraki::cloudcontroller::restapi::mode::cache', + 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', + 'discovery' => 'network::cisco::meraki::cloudcontroller::restapi::mode::discovery', + 'list-devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::listdevices', + 'list-tags' => 'network::cisco::meraki::cloudcontroller::restapi::mode::listtags', + 'list-vpn-tunnels' => 'network::cisco::meraki::cloudcontroller::restapi::mode::listvpntunnels', + 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks', + 'vpn-tunnels' => 'network::cisco::meraki::cloudcontroller::restapi::mode::vpntunnels' }; $self->{custom_modes}->{api} = 'network::cisco::meraki::cloudcontroller::restapi::custom::api'; diff --git a/tests/resources/spellcheck/stopwords.t b/tests/resources/spellcheck/stopwords.t index 6dd7131a0c..b7ffac982d 100644 --- a/tests/resources/spellcheck/stopwords.t +++ b/tests/resources/spellcheck/stopwords.t @@ -1,5 +1,7 @@ --add-sysdesc +--api-filter-orgs --api-password +--api-token --api-version --cacert-file --cert-pkcs12 @@ -15,6 +17,7 @@ --force-counters64 --force-oid --get-param +--ignore-orgs-api-disabled --lookup-perfdatas-nagios --map-speed-dsl --mqtt @@ -47,6 +50,7 @@ Iwsva Loggly MBean MQTT +Meraki Mosquitto NTLMv2 NagVis @@ -59,11 +63,16 @@ SNMP SSH Sansymphony SureBackup +TCP TendMicro VDSL2 +VPN Veeam WSMAN XPath +api.meraki.com +connections-dhcp +connections-dns deltaps df eth @@ -93,6 +102,8 @@ space-usage-prct teampass timeframe topic-messages-inflighted +total-offline-prct +total-online-prct total-oper-down total-oper-up uptime diff --git a/tests/robot/network/cisco/meraki/cloudcontroller/restapi/meraki.mockoon.json b/tests/robot/network/cisco/meraki/cloudcontroller/restapi/meraki.mockoon.json new file mode 100644 index 0000000000..3a0834fd75 --- /dev/null +++ b/tests/robot/network/cisco/meraki/cloudcontroller/restapi/meraki.mockoon.json @@ -0,0 +1,480 @@ +{ + "uuid": "a1da12c3-97f5-4ab7-bec7-a30e1c36309a", + "lastMigration": 32, + "name": "Meraki.mockoon", + "endpointPrefix": "", + "latency": 0, + "port": 3000, + "hostname": "", + "folders": [], + "routes": [ + { + "uuid": "77da22e2-4161-4be7-a598-62e372cf0438", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations", + "responses": [ + { + "uuid": "4c2ab123-f20d-4e65-a422-096ecec496ce", + "body": "", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "DATABUCKET", + "filePath": "", + "databucketID": "xl8l", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "3d572355-f7f4-4558-abc6-0e4c2c8b06f9", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/appliance/vpn/statuses", + "responses": [ + { + "uuid": "4baedfc4-2a1d-4dd1-aff6-e07f6c4144e9", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "DATABUCKET", + "filePath": "", + "databucketID": "zqoq", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [], + "body": "{}" + } + ], + "responseMode": null + }, + { + "uuid": "c8872c69-c290-4c5e-aa4b-18f8ffaf084b", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/networks", + "responses": [ + { + "uuid": "0723def4-07b5-4549-962a-e041423a9733", + "body": "[]", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "e7b443c0-4b6e-41b0-bfad-6b23fd14a9cd", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/devices", + "responses": [ + { + "uuid": "c1d9369d-ee0e-4b4c-b6df-5f64f4112382", + "body": "[]", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "83ae251f-e2ac-4eb0-bed3-9d024d2d4055", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/devices/statuses", + "responses": [ + { + "uuid": "e459d826-8630-498d-983f-5259052584b7", + "body": "[]", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "05351271-5695-4ccc-bdd2-75fd0ab68def", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/uplinks/statuses", + "responses": [ + { + "uuid": "e6e461fe-86d2-43c1-adb9-73047593e783", + "body": "[]", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + }, + { + "uuid": "1ee10c37-cb78-4594-9fd9-006a3927f6f2", + "type": "http", + "documentation": "", + "method": "get", + "endpoint": "api/v1/organizations/123456789123456789/devices/uplinksLossAndLatency", + "responses": [ + { + "uuid": "18e3e93c-302d-4fda-86d1-9ffd1a8b8abd", + "body": "[]", + "latency": 0, + "statusCode": 200, + "label": "", + "headers": [ + { + "key": "access-control-allow-headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + }, + { + "key": "access-control-allow-methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "access-control-allow-origin", + "value": "*" + }, + { + "key": "content-security-policy", + "value": "default-src 'none'" + }, + { + "key": "content-type", + "value": "text/html; charset=utf-8" + }, + { + "key": "x-content-type-options", + "value": "nosniff" + } + ], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [], + "rulesOperator": "OR", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + } + ], + "responseMode": null + } + ], + "rootChildren": [ + { + "type": "route", + "uuid": "77da22e2-4161-4be7-a598-62e372cf0438" + }, + { + "type": "route", + "uuid": "3d572355-f7f4-4558-abc6-0e4c2c8b06f9" + }, + { + "type": "route", + "uuid": "c8872c69-c290-4c5e-aa4b-18f8ffaf084b" + }, + { + "type": "route", + "uuid": "e7b443c0-4b6e-41b0-bfad-6b23fd14a9cd" + }, + { + "type": "route", + "uuid": "83ae251f-e2ac-4eb0-bed3-9d024d2d4055" + }, + { + "type": "route", + "uuid": "05351271-5695-4ccc-bdd2-75fd0ab68def" + }, + { + "type": "route", + "uuid": "1ee10c37-cb78-4594-9fd9-006a3927f6f2" + } + ], + "proxyMode": false, + "proxyHost": "", + "proxyRemovePrefix": false, + "tlsOptions": { + "enabled": false, + "type": "CERT", + "pfxPath": "", + "certPath": "", + "keyPath": "", + "caPath": "", + "passphrase": "" + }, + "cors": true, + "headers": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], + "proxyReqHeaders": [ + { + "key": "", + "value": "" + } + ], + "proxyResHeaders": [ + { + "key": "", + "value": "" + } + ], + "data": [ + { + "uuid": "80e9ddfd-1272-45d6-a29e-c927f0f8cebd", + "id": "xl8l", + "name": "Organizations", + "documentation": "", + "value": "[\n {\n \"id\": \"123456789123456789\",\n \"name\": \"Endor\",\n \"url\": \"http://127.0.0.1:3000/o/NQkU0cWc/manage/organization/overview\",\n \"samlConsumerUrl\": \"http://127.0.0.1:3000/saml/login/NQkU0cWc/RV3RrcB2UCVa\",\n \"samlConsumerUrls\": [\n \"http://127.0.0.1:3000/saml/login/NQkU0cWc/RV3RrcB2UCVa\"\n ],\n \"api\": {\n \"enabled\": true\n },\n \"licensing\": {\n \"model\": \"per-device\"\n },\n \"cloud\": {\n \"region\": {\n \"name\": \"Europe\",\n \"host\": {\n \"name\": \"Europe\"\n }\n }\n },\n \"management\": {\n \"details\": [\n {\n \"name\": \"customer number\",\n \"value\": \"56417983\"\n }\n ]\n }\n }\n]\n" + }, + { + "uuid": "337987b2-984c-4882-9e6e-83a2c2b714f5", + "id": "zqoq", + "name": "VPN Tunnels", + "documentation": "", + "value": "[\n {\n \"networkId\": \"Z_000000000000000001\",\n \"networkName\": \"ALDERAAN\",\n \"deviceSerial\": \"C3PO-R2P2-BB88\",\n \"deviceStatus\": \"dormant\",\n \"uplinks\": [],\n \"vpnMode\": \"spoke\",\n \"exportedSubnets\": [\n {\n \"name\": \"Single LAN Settings\",\n \"subnet\": \"172.16.254.24/29\"\n }\n ],\n \"merakiVpnPeers\": [\n {\n \"networkId\": \"Z_000000000000000002\",\n \"networkName\": \"KASHYYYK\",\n \"reachability\": \"unreachable\"\n },\n {\n \"networkId\": \"Z_000000000000000003\",\n \"networkName\": \"TATOOINE\",\n \"reachability\": \"unreachable\"\n },\n {\n \"networkId\": \"Z_000000000000000004\",\n \"networkName\": \"HOTH\",\n \"reachability\": \"unreachable\"\n }\n ],\n \"thirdPartyVpnPeers\": []\n }\n]" + } + ], + "callbacks": [] +} \ No newline at end of file diff --git a/tests/robot/network/cisco/meraki/cloudcontroller/restapi/vpntunnels.robot b/tests/robot/network/cisco/meraki/cloudcontroller/restapi/vpntunnels.robot new file mode 100644 index 0000000000..af59e31b9d --- /dev/null +++ b/tests/robot/network/cisco/meraki/cloudcontroller/restapi/vpntunnels.robot @@ -0,0 +1,46 @@ +*** Settings *** +Documentation Meraki VPN Tunnels + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource + +Suite Setup Start Mockoon ${MOCKOON_JSON} +Test Timeout 120s + + +*** Variables *** +${MOCKOON_JSON} ${CURDIR}${/}meraki.mockoon.json + +${CMD} ${CENTREON_PLUGINS} --plugin=network::cisco::meraki::cloudcontroller::restapi::plugin +... --api-token=EEECGFCGFCGF +... --statefile-dir=/dev/shm/ + +*** Test Cases *** +Create cache from API + [Tags] meraki api vpn network cache + ${output} Run + ... ${CMD} --mode=cache --proto http --port 3000 --hostname=127.0.0.1 + + ${output} Strip String ${output} + Should Be Equal As Strings + ... ${output} + ... OK: Cache files created successfully + ... Wrong output result:\n\n ${output}\nInstead of:\n OK: Cache files created successfully\n\n + # Mockoon is not needed any longer since the data are cached + Stop Mockoon + +Check if ${test_desc} works + [Tags] meraki api vpn network + ${output} Run + ... ${CMD} --mode=vpn-tunnels --filter-network-name=${filter_network_name} --cache-use --critical-total-dormant=1: + + ${output} Strip String ${output} + Should Be Equal As Strings + ... ${output} + ... ${expected} + ... Wrong output result:\n\n ${output}\nInstead of:\n ${expected}\n\n + + Examples: test_desc filter_network_name expected -- + ... all links .* OK: vpn tunnel 'C3PO-R2P2-BB88' status: dormant [mode: spoke] | 'vpn.tunnels.online.count'=0;;;0;1 'vpn.tunnels.offline.count'=0;;;0;1 'vpn.tunnels.dormant.count'=1;;1:;0;1 + ... empty filter ${EMPTY} OK: vpn tunnel 'C3PO-R2P2-BB88' status: dormant [mode: spoke] | 'vpn.tunnels.online.count'=0;;;0;1 'vpn.tunnels.offline.count'=0;;;0;1 'vpn.tunnels.dormant.count'=1;;1:;0;1 + ... absurd filter toto CRITICAL: Vpn tunnels dormant: 0 | 'vpn.tunnels.online.count'=0;;;0;0 'vpn.tunnels.offline.count'=0;;;0;0 'vpn.tunnels.dormant.count'=0;;1:;0;0 + From 5ff0fd9e810a57e36bb443878cdea3634df52b05 Mon Sep 17 00:00:00 2001 From: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com> Date: Fri, 28 Jun 2024 17:25:57 +0200 Subject: [PATCH 06/18] fix(gorgone) fix Mojo::IOLoop::Signal dependency on rpm for gorgone (#5079) --- .github/workflows/perl-cpan-libraries.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/perl-cpan-libraries.yml b/.github/workflows/perl-cpan-libraries.yml index 7521bffe23..7538ee10c3 100644 --- a/.github/workflows/perl-cpan-libraries.yml +++ b/.github/workflows/perl-cpan-libraries.yml @@ -139,6 +139,9 @@ jobs: - name: "ZMQ::LibZMQ4" version: "0.01" rpm_dependencies: "zeromq" + - name: "Mojo::IOLoop::Signal" + rpm_dependencies: "perl-Mojolicious" + name: package ${{ matrix.distrib }} ${{ matrix.name }} container: @@ -443,7 +446,6 @@ jobs: path: ./*.${{ matrix.package_extension }} retention-days: 1 - merge-package-deb-artifacts: needs: [package-deb] runs-on: ubuntu-22.04 From eca3644d598e0b0faaff37ddada226112da56be6 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Mon, 1 Jul 2024 10:18:56 +0200 Subject: [PATCH 07/18] Ctor 146 escalation microsoft hyperv 2012 add option for powershell module version in node integration service mode (#5080) --- .github/scripts/pod_spell_check.t | 7 +- .../2012/local/mode/nodeintegrationservice.pm | 23 +- src/apps/trendmicro/iwsva/snmp/plugin.pm | 2 +- .../hyperv/2012/nodeintegrationservice.pm | 16 +- tests/resources/spellcheck/stopwords.t | 10 +- .../local/nodeintegrationservice-2022.json | 407 ++++++++++++++++++ .../2012/local/nodeintegrationservice.robot | 37 ++ 7 files changed, 489 insertions(+), 13 deletions(-) create mode 100644 tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice-2022.json create mode 100644 tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice.robot diff --git a/.github/scripts/pod_spell_check.t b/.github/scripts/pod_spell_check.t index 3aef6bb8a2..8d6790446f 100644 --- a/.github/scripts/pod_spell_check.t +++ b/.github/scripts/pod_spell_check.t @@ -5,7 +5,7 @@ use Test::More; use Test::Spelling; if (!@ARGV) { - die "Missing perl file to check."; + die "Usage: perl pod_spell_check.t module.pm stopwords.t"; } my $stopword_filename='tests/resources/spellcheck/stopwords.t'; @@ -14,9 +14,10 @@ if(defined($ARGV[1])){ } open(FILE, "<", $stopword_filename) or die "Could not open $stopword_filename"; -printf("stopword file use : ".$stopword_filename." \n"); +printf("Using dictionary: ".$stopword_filename." \n"); add_stopwords(); +close(FILE); set_spell_cmd('hunspell -l'); all_pod_files_spelling_ok($ARGV[0]); -close(FILE); + diff --git a/src/apps/microsoft/hyperv/2012/local/mode/nodeintegrationservice.pm b/src/apps/microsoft/hyperv/2012/local/mode/nodeintegrationservice.pm index 1061317e7b..68c154ecd7 100644 --- a/src/apps/microsoft/hyperv/2012/local/mode/nodeintegrationservice.pm +++ b/src/apps/microsoft/hyperv/2012/local/mode/nodeintegrationservice.pm @@ -134,6 +134,20 @@ sub check_options { if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq ''); } +sub determine_operational_status { + my ($operational_status) = @_; + + if ( defined($operational_status) ) { + if ( defined($node_vm_integration_service_operational_status->{ $operational_status}) ) { + return $node_vm_integration_service_operational_status->{ $operational_status }; + } else { + return $operational_status; + } + } else { + return '-'; + } +} + sub manage_selection { my ($self, %options) = @_; @@ -235,16 +249,13 @@ sub manage_selection { my $services = (ref($node->{services}) eq 'ARRAY') ? $node->{services} : [ $node->{services} ]; foreach my $service (@$services) { + $self->{vm}->{$id}->{service}->{$id2} = { vm => $node->{name}, service => $service->{service}, enabled => $service->{enabled} =~ /True|1/i ? 1 : 0, - primary_status => - defined($service->{primary_operational_status}) && defined($node_vm_integration_service_operational_status->{ $service->{primary_operational_status} }) ? - $node_vm_integration_service_operational_status->{ $service->{primary_operational_status} } : '-', - secondary_status => - defined($service->{secondary_operational_status}) && defined($node_vm_integration_service_operational_status->{ $service->{secondary_operational_status} }) ? - $node_vm_integration_service_operational_status->{ $service->{secondary_operational_status} } : '-' + primary_status => determine_operational_status($service->{primary_operational_status}), + secondary_status => determine_operational_status($service->{secondary_operational_status}) }; $id2++; } diff --git a/src/apps/trendmicro/iwsva/snmp/plugin.pm b/src/apps/trendmicro/iwsva/snmp/plugin.pm index 2e46ac9a7e..17075b4581 100644 --- a/src/apps/trendmicro/iwsva/snmp/plugin.pm +++ b/src/apps/trendmicro/iwsva/snmp/plugin.pm @@ -50,6 +50,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check TendMicro Iwsva equipments in SNMP. +Check TrendMicro Iwsva equipments in SNMP. =cut diff --git a/src/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm b/src/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm index a85f509617..245b37c518 100644 --- a/src/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm +++ b/src/centreon/common/powershell/hyperv/2012/nodeintegrationservice.pm @@ -35,6 +35,9 @@ $culture = new-object "System.Globalization.CultureInfo" "en-us" $ps .= centreon::common::powershell::functions::escape_jsonstring(%options); $ps .= centreon::common::powershell::functions::convert_to_json(%options); + # if the version of HyperV Powershell module is higher than 2.0.0 and not compatible with + # the following script, then use this Import-Module instead: + # Import-Module -Name "Hyper-V" -MaximumVersion "2.0.0" $ps .= ' $ProgressPreference = "SilentlyContinue" @@ -68,8 +71,19 @@ Try { $item_service.service = $service.Name $item_service.enabled = $service.Enabled + + # this works for sure on v1.1 of HyperV Powershell module $item_service.primary_operational_status = $service.PrimaryOperationalStatus.value__ $item_service.secondary_operational_status = $service.SecondaryOperationalStatus.value__ + + # this works for sure on v2.0.0 of HyperV Powershell module + if (($service.PrimaryStatusDescription -ne $null) -and ($service.PrimaryStatusDescription -ne "")) { + $item_service.primary_operational_status = $service.PrimaryStatusDescription + } + if (($service.SecondaryStatusDescription -ne $null) -and ($service.SecondaryStatusDescription -ne "")) { + $item_service.secondary_operational_status = $service.SecondaryStatusDescription + } + $services.Add($item_service) } @@ -96,6 +110,6 @@ __END__ =head1 DESCRIPTION -Method to get hyper-v informations. +Method to get Hyper-V information. =cut diff --git a/tests/resources/spellcheck/stopwords.t b/tests/resources/spellcheck/stopwords.t index b7ffac982d..6219228ef4 100644 --- a/tests/resources/spellcheck/stopwords.t +++ b/tests/resources/spellcheck/stopwords.t @@ -13,6 +13,7 @@ --exclude-fs --filter-fs --filter-vdom +--filter-vm --force-counters32 --force-counters64 --force-oid @@ -37,6 +38,9 @@ --oid-filter --urlpath --warning-bytesallocatedpercentage +-EncodedCommand +-InputFormat +-NoLogo 2c ADSL Avigilon @@ -64,10 +68,11 @@ SSH Sansymphony SureBackup TCP -TendMicro +TrendMicro VDSL2 -VPN +VM Veeam +VPN WSMAN XPath api.meraki.com @@ -95,6 +100,7 @@ out-mcast out-ucast perfdata powershell +powershell.exe proto psu queue-messages-inflighted diff --git a/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice-2022.json b/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice-2022.json new file mode 100644 index 0000000000..0434e275ab --- /dev/null +++ b/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice-2022.json @@ -0,0 +1,407 @@ +[ + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER01", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER02", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER03", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER04", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 2, + "name": "VSERVER05", + "services": [ + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": false + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "VSS", + "enabled": false + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER06", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 2, + "name": "VSERVER07", + "services": [ + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": false + }, + { + "primary_operational_status": "Error", + "secondary_operational_status": "OK", + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": "OK", + "secondary_operational_status": null, + "service": "VSS", + "enabled": false + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER07", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + }, + { + "note": "", + "integration_services_state": "", + "state": 3, + "name": "VSERVER08", + "services": [ + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Guest Service Interface", + "enabled": false + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Heartbeat", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Key-Value Pair Exchange", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Shutdown", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "Time Synchronization", + "enabled": true + }, + { + "primary_operational_status": null, + "secondary_operational_status": null, + "service": "VSS", + "enabled": true + } + ], + "integration_services_version": "0.0" + } +] diff --git a/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice.robot b/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice.robot new file mode 100644 index 0000000000..7cd3da3d88 --- /dev/null +++ b/tests/robot/apps/microsoft/hyperv/2012/local/nodeintegrationservice.robot @@ -0,0 +1,37 @@ +*** Settings *** +Documentation Application Microsoft HyperV 2022 + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource + +Test Timeout 120s + + +*** Variables *** +${CMD} ${CENTREON_PLUGINS} +... --plugin=apps::microsoft::hyperv::2012::local::plugin +... --mode=node-integration-service +... --command=cat +... --command-path=/usr/bin +... --no-ps +... --command-options=nodeintegrationservice-2022.json + +*** Test Cases *** +HyperV 2022 ${tc}/3 + [Documentation] Apps Microsoft HyperV 2022 + [Tags] applications microsoft hyperv virtualization + ${command} Catenate + ... ${CMD} + ... --filter-vm='${filter_vm}' + + ${output} Run ${command} + ${output} Strip String ${output} + Should Be Equal As Strings + ... ${output} + ... ${expected_result} + ... \nWrong output result for command:\n${command}\n\nExpected:\n${expected_result}\nCommand output:\n${output}\n\n + + Examples: tc filter_vm expected_result -- + ... 1 ${EMPTY} CRITICAL: 1 problem(s) detected + ... 2 VSERVER05 OK: VM 'VSERVER05' 0 problem(s) detected - VM 'VSERVER05' 0 problem(s) detected + ... 3 VSERVER07 CRITICAL: VM 'VSERVER07' 1 problem(s) detected + From 8065a56f059deb73a36fc18ee0b32321be22bc36 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:20:28 +0200 Subject: [PATCH 08/18] Ctor 264 plugin database mysql mode databasesize change the way we calculate the fragmentation rate (#5088) --- src/database/mysql/mode/databasessize.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/database/mysql/mode/databasessize.pm b/src/database/mysql/mode/databasessize.pm index fdb849a017..a0660fb0e7 100644 --- a/src/database/mysql/mode/databasessize.pm +++ b/src/database/mysql/mode/databasessize.pm @@ -172,7 +172,20 @@ sub manage_selection { $innodb_per_table = 1 if ($value =~ /on/i); $options{sql}->query( - query => q{SELECT table_schema, table_name, engine, data_free, data_length+index_length as data_used, (DATA_FREE / (DATA_LENGTH+INDEX_LENGTH)) as TAUX_FRAG FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND engine IN ('InnoDB', 'MyISAM')} + query => q{ + SELECT + table_schema, + table_name, + engine, + data_free, + data_length + index_length as data_used, + DATA_FREE / (DATA_LENGTH + INDEX_LENGTH + DATA_FREE) as TAUX_FRAG + FROM + information_schema.tables + WHERE + table_type = 'BASE TABLE' + AND engine IN ('InnoDB', 'MyISAM') + } ); my $result = $options{sql}->fetchall_arrayref(); @@ -230,7 +243,7 @@ __END__ =head1 MODE -Check MySQL databases size and tables. +Check MySQL/MariaDB databases and tables sizes. =over 8 @@ -240,7 +253,7 @@ Filter the databases to monitor with a regular expression. =item B<--filter-table> -Filter table name (can be a regexp). +Filter tables by name (can be a regexp). =item B<--warning-*> B<--critical-*> From 831abe58c755fb043c6e382195692a5372727a1b Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:29:34 +0200 Subject: [PATCH 09/18] use alma8 for packaging for plugins packaging (#5095) --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 036bddac9f..3aefec91a5 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -118,7 +118,7 @@ jobs: matrix: include: - package_extension: rpm - image: packaging-plugins-centos7 + image: packaging-plugins-alma8 distrib: el7 - package_extension: rpm image: packaging-plugins-alma8 From 2f9b1fe43ae1f54d30a944b6a9e53e15c96e788f Mon Sep 17 00:00:00 2001 From: Sfarouq-ext Date: Fri, 5 Jul 2024 14:17:42 +0000 Subject: [PATCH 10/18] Refactor Linux SNMP DiskIO robot test to robot-example --- tests/robot/os/linux/snmp/diskio.robot | 36 +++++++++++++++ tests/robot/os/linux/snmp/os-linux-snmp.robot | 45 ------------------- 2 files changed, 36 insertions(+), 45 deletions(-) create mode 100644 tests/robot/os/linux/snmp/diskio.robot delete mode 100644 tests/robot/os/linux/snmp/os-linux-snmp.robot diff --git a/tests/robot/os/linux/snmp/diskio.robot b/tests/robot/os/linux/snmp/diskio.robot new file mode 100644 index 0000000000..eb223be395 --- /dev/null +++ b/tests/robot/os/linux/snmp/diskio.robot @@ -0,0 +1,36 @@ +*** Settings *** +Documentation OS Linux SNMP plugin + +Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource + +Test Timeout 120s + + +*** Variables *** +${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::snmp::plugin + + +*** Test Cases *** +Linux SNMP list diskio devices ${documentation} ${tc}/2 + [Tags] os linux snmp + ${command} Catenate + ... ${CMD} + ... --mode=list-diskio + ... --hostname=127.0.0.1 + ... --snmp-version=2 + ... --snmp-port=2024 + ... --disco-show + ... --snmp-community=${snmpcommunity} + ${output} Run ${command} + Log To Console ${command} + ${nb_results} Get Element Count + ... ${output} + ... label + Should Be Equal As Integers + ... ${expected_result} + ... ${nb_results} + ... Wrong output result for list diskio devices: ${snmpcommunity}.{\n}Command output:{\n}${output} + + Examples: documentation tc snmpcommunity expected_result -- + ... First run 1 os/linux/snmp/list-diskio 10 + ... Second run 2 os/linux/snmp/list-diskio-2 4 \ No newline at end of file diff --git a/tests/robot/os/linux/snmp/os-linux-snmp.robot b/tests/robot/os/linux/snmp/os-linux-snmp.robot deleted file mode 100644 index de69eb79a3..0000000000 --- a/tests/robot/os/linux/snmp/os-linux-snmp.robot +++ /dev/null @@ -1,45 +0,0 @@ -*** Settings *** -Documentation OS Linux SNMP plugin - -Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource - -Test Timeout 120s - - -*** Variables *** -${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::snmp::plugin - -&{list_diskio_test1} -... snmpcommunity=os/linux/snmp/list-diskio -... nbresults=10 -&{list_diskio_test2} -... snmpcommunity=os/linux/snmp/list-diskio-2 -... nbresults=4 -@{list_diskio_tests} -... &{list_diskio_test1} -... &{list_diskio_test2} - - -*** Test Cases *** -Linux SNMP list diskio devices - [Documentation] List Linux diskio devices - [Tags] os linux snmp - FOR ${list_diskio_test} IN @{list_diskio_tests} - ${command} Catenate - ... ${CMD} - ... --mode=list-diskio - ... --hostname=127.0.0.1 - ... --snmp-version=2 - ... --snmp-port=2024 - ... --disco-show - ... --snmp-community=${list_diskio_test.snmpcommunity} - ${output} Run ${command} - Log To Console ${command} - ${nb_results} Get Element Count - ... ${output} - ... label - Should Be Equal As Integers - ... ${list_diskio_test.nbresults} - ... ${nb_results} - ... Wrong output result for list diskio devices: ${list_diskio_test}.{\n}Command output:{\n}${output} - END From 8a2fba3a2560fddee39cdefe0f061757a803b16a Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:28:12 +0200 Subject: [PATCH 11/18] Update diskio.pm --- src/snmp_standard/mode/diskio.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/snmp_standard/mode/diskio.pm b/src/snmp_standard/mode/diskio.pm index 7138101e0b..9df6c1b300 100644 --- a/src/snmp_standard/mode/diskio.pm +++ b/src/snmp_standard/mode/diskio.pm @@ -297,7 +297,6 @@ sub disco_show { } } - 1; __END__ From 085040fe20ec11dca77a06bbc7826b52a6943e98 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:54:37 +0200 Subject: [PATCH 12/18] new(packaging): nokia (formerly alcatel) isam snmp plugin (#5087) Co-authored-by: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com> REFS: CTOR-594 --- .../deb.json | 5 +++ .../pkg.json | 14 +++++++ .../rpm.json | 5 +++ .../snmp/mode/components/cardtemperature.pm | 4 +- .../isam/snmp/mode/components/resources.pm | 4 +- .../isam/snmp/mode/components/sfp.pm | 4 +- .../{alcatel => nokia}/isam/snmp/mode/cpu.pm | 4 +- .../isam/snmp/mode/hardware.pm | 21 +++++++---- .../isam/snmp/mode/hubsapusage.pm | 37 +++++++++---------- .../isam/snmp/mode/listhubsap.pm | 4 +- .../isam/snmp/mode/memory.pm | 19 ++++------ .../{alcatel => nokia}/isam/snmp/plugin.pm | 15 ++++---- tests/resources/spellcheck/stopwords.t | 6 +++ 13 files changed, 87 insertions(+), 55 deletions(-) create mode 100644 packaging/centreon-plugin-Network-Nokia-Isam-Snmp/deb.json create mode 100644 packaging/centreon-plugin-Network-Nokia-Isam-Snmp/pkg.json create mode 100644 packaging/centreon-plugin-Network-Nokia-Isam-Snmp/rpm.json rename src/network/{alcatel => nokia}/isam/snmp/mode/components/cardtemperature.pm (95%) rename src/network/{alcatel => nokia}/isam/snmp/mode/components/resources.pm (93%) rename src/network/{alcatel => nokia}/isam/snmp/mode/components/sfp.pm (98%) rename src/network/{alcatel => nokia}/isam/snmp/mode/cpu.pm (98%) rename src/network/{alcatel => nokia}/isam/snmp/mode/hardware.pm (74%) rename src/network/{alcatel => nokia}/isam/snmp/mode/hubsapusage.pm (93%) rename src/network/{alcatel => nokia}/isam/snmp/mode/listhubsap.pm (98%) rename src/network/{alcatel => nokia}/isam/snmp/mode/memory.pm (95%) rename src/network/{alcatel => nokia}/isam/snmp/plugin.pm (68%) diff --git a/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/deb.json b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/deb.json new file mode 100644 index 0000000000..663aaacebf --- /dev/null +++ b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/deb.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "libsnmp-perl" + ] +} \ No newline at end of file diff --git a/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/pkg.json b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/pkg.json new file mode 100644 index 0000000000..92f79896d5 --- /dev/null +++ b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/pkg.json @@ -0,0 +1,14 @@ +{ + "pkg_name": "centreon-plugin-Network-Nokia-Isam-Snmp", + "pkg_summary": "Centreon Plugin to monitor Nokia (formerly Alcatel) Isam devices", + "plugin_name": "centreon_nokia_isam_snmp.pl", + "files": [ + "centreon/plugins/script_snmp.pm", + "centreon/plugins/snmp.pm", + "snmp_standard/mode/interfaces.pm", + "snmp_standard/mode/listinterfaces.pm", + "snmp_standard/mode/resources/", + "snmp_standard/mode/uptime.pm", + "network/nokia/isam/snmp/" + ] +} diff --git a/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/rpm.json b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/rpm.json new file mode 100644 index 0000000000..418a331fce --- /dev/null +++ b/packaging/centreon-plugin-Network-Nokia-Isam-Snmp/rpm.json @@ -0,0 +1,5 @@ +{ + "dependencies": [ + "perl(SNMP)" + ] +} \ No newline at end of file diff --git a/src/network/alcatel/isam/snmp/mode/components/cardtemperature.pm b/src/network/nokia/isam/snmp/mode/components/cardtemperature.pm similarity index 95% rename from src/network/alcatel/isam/snmp/mode/components/cardtemperature.pm rename to src/network/nokia/isam/snmp/mode/components/cardtemperature.pm index 305b008b51..f6002ec304 100644 --- a/src/network/alcatel/isam/snmp/mode/components/cardtemperature.pm +++ b/src/network/nokia/isam/snmp/mode/components/cardtemperature.pm @@ -18,11 +18,11 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::components::cardtemperature; +package network::nokia::isam::snmp::mode::components::cardtemperature; use strict; use warnings; -use network::alcatel::isam::snmp::mode::components::resources qw($mapping_slot); +use network::nokia::isam::snmp::mode::components::resources qw($mapping_slot); my $oid_eqptBoardThermalSensorActualTemperature = '.1.3.6.1.4.1.637.61.1.23.10.1.2'; diff --git a/src/network/alcatel/isam/snmp/mode/components/resources.pm b/src/network/nokia/isam/snmp/mode/components/resources.pm similarity index 93% rename from src/network/alcatel/isam/snmp/mode/components/resources.pm rename to src/network/nokia/isam/snmp/mode/components/resources.pm index ff71783cfb..8a2ea85cb7 100644 --- a/src/network/alcatel/isam/snmp/mode/components/resources.pm +++ b/src/network/nokia/isam/snmp/mode/components/resources.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::components::resources; +package network::nokia::isam::snmp::mode::components::resources; use strict; use warnings; @@ -34,4 +34,4 @@ $mapping_slot = { eqptBoardInventorySerialNumber => { oid => '.1.3.6.1.4.1.637.61.1.23.3.1.19' }, }; -1; \ No newline at end of file +1; diff --git a/src/network/alcatel/isam/snmp/mode/components/sfp.pm b/src/network/nokia/isam/snmp/mode/components/sfp.pm similarity index 98% rename from src/network/alcatel/isam/snmp/mode/components/sfp.pm rename to src/network/nokia/isam/snmp/mode/components/sfp.pm index f9d9e0b6aa..38f1177754 100644 --- a/src/network/alcatel/isam/snmp/mode/components/sfp.pm +++ b/src/network/nokia/isam/snmp/mode/components/sfp.pm @@ -18,11 +18,11 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::components::sfp; +package network::nokia::isam::snmp::mode::components::sfp; use strict; use warnings; -use network::alcatel::isam::snmp::mode::components::resources qw($mapping_slot); +use network::nokia::isam::snmp::mode::components::resources qw($mapping_slot); my %map_los = (1 => 'los', 2 => 'noLos', 3 => 'notAvailable'); diff --git a/src/network/alcatel/isam/snmp/mode/cpu.pm b/src/network/nokia/isam/snmp/mode/cpu.pm similarity index 98% rename from src/network/alcatel/isam/snmp/mode/cpu.pm rename to src/network/nokia/isam/snmp/mode/cpu.pm index ec4e8f16cf..f4e27e7f98 100644 --- a/src/network/alcatel/isam/snmp/mode/cpu.pm +++ b/src/network/nokia/isam/snmp/mode/cpu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::cpu; +package network::nokia::isam::snmp::mode::cpu; use base qw(centreon::plugins::templates::counter); @@ -95,7 +95,7 @@ __END__ =head1 MODE -Check CPU usages. +Monitor the CPU usage. =over 8 diff --git a/src/network/alcatel/isam/snmp/mode/hardware.pm b/src/network/nokia/isam/snmp/mode/hardware.pm similarity index 74% rename from src/network/alcatel/isam/snmp/mode/hardware.pm rename to src/network/nokia/isam/snmp/mode/hardware.pm index 32e5cb725f..2c96e04e07 100644 --- a/src/network/alcatel/isam/snmp/mode/hardware.pm +++ b/src/network/nokia/isam/snmp/mode/hardware.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::hardware; +package network::nokia::isam::snmp::mode::hardware; use base qw(centreon::plugins::templates::hardware); @@ -40,7 +40,7 @@ sub set_system { ] }; - $self->{components_path} = 'network::alcatel::isam::snmp::mode::components'; + $self->{components_path} = 'network::nokia::isam::snmp::mode::components'; $self->{components_module} = ['cardtemperature', 'sfp']; } @@ -76,7 +76,7 @@ Check Hardware. =item B<--component> -Which component to check (default: '.*'). +Define which component to check (default: '.*'). Can be: 'cardtemperature', 'sfp'. =item B<--filter> @@ -88,7 +88,6 @@ You can also exclude items from specific instances: --filter=cardtemperature,108 Define the expected status if no components are found (default: critical). - =item B<--threshold-overload> Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp). @@ -96,13 +95,19 @@ Example: --threshold-overload='sfp,OK,^los$' =item B<--warning> -Set warning threshold for 'sfp.temperature', 'cardtemperature' (syntax: type,regexp,threshold) -Example: --warning='sfp.temperature,1.1,30' +Define the warning thresholds for an instance of a certain type of sensor. +Syntax: ,,. +Supported types of sensors: 'sfp.temperature', 'cardtemperature'. +Instances are identified by the last two parts of the OID, separated by a period (example: 1.1) and are filtered as a regular expression. +Example: --warning='sfp.temperature,1\.1,30' =item B<--critical> -Set critical threshold for 'sfp.temperature', 'cardtemperature' (syntax: type,regexp,threshold) -Example: --warning='sfp.temperature,1.1,40' +Define the critical thresholds for an instance of a certain type of sensor. +Syntax: ,,. +Supported types of sensors: 'sfp.temperature', 'cardtemperature'. +Instances are identified by the last two parts of the OID, separated by a period (example: 1.1) and are filtered as a regular expression. +Example: --critical='sfp.temperature,1\.1,40' =back diff --git a/src/network/alcatel/isam/snmp/mode/hubsapusage.pm b/src/network/nokia/isam/snmp/mode/hubsapusage.pm similarity index 93% rename from src/network/alcatel/isam/snmp/mode/hubsapusage.pm rename to src/network/nokia/isam/snmp/mode/hubsapusage.pm index 11f5a597b7..336a8551bf 100644 --- a/src/network/alcatel/isam/snmp/mode/hubsapusage.pm +++ b/src/network/nokia/isam/snmp/mode/hubsapusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::hubsapusage; +package network::nokia::isam::snmp::mode::hubsapusage; use base qw(centreon::plugins::templates::counter); @@ -334,7 +334,7 @@ sub manage_selection { $self->{output}->option_exit(); } - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_alcatel_isam_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_nokia_isam_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode}); my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp'); if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) { @@ -404,7 +404,7 @@ sub manage_selection { $self->{output}->option_exit(); } - $self->{cache_name} = 'alcatel_isam_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + $self->{cache_name} = 'nokia_isam_' . $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')); } @@ -415,62 +415,61 @@ __END__ =head1 MODE -Check SAP QoS usage. +Check Service Access Points (SAP) QoS usage. =over 8 =item B<--display-name> -Display name (default: '%{SvcDescription}.%{IfName}.%{SapEncapName}'). -Can also be: %{SapDescription}, %{SapPortId} +Define the name to display (default: '%{SvcDescription}.%{IfName}.%{SapEncapName}'). +Other available macros: %{SapDescription}, %{SapPortId} =item B<--filter-name> -Filter by SAP name (can be a regexp). +Filter by Service Access Point (SAP) name (can be a regexp). =item B<--speed-in> -Set interface speed for incoming traffic (in Mb). +Define the actual maximum incoming traffic speed you can have on the interfaces in megabits per second. =item B<--speed-out> -Set interface speed for outgoing traffic (in Mb). +Define the actual maximum outgoing traffic speed you can have on the interfaces in megabits per second. =item B<--speed-total-in> -Set interface speed for total incoming traffic (in Mb). +Define the actual maximum total incoming traffic speed you can have on the interfaces in megabits per second. =item B<--speed-total-out> -Set interface speed for total outgoing traffic (in Mb). +Define the actual maximum total outgoing traffic speed you can have on the interfaces in megabits per second. =item B<--units-traffic> -Units of thresholds for the traffic (default: '%') ('%', 'b/s'). +Define the unit to use to apply to thresholds (default: '%') ('%', 'b/s'). =item B<--warning-status> -Set warning threshold for ib status. +Define the conditions to match for the status to be WARNING. You can use the following variables: %{admin}, %{status}, %{display} =item B<--critical-status> -Set critical threshold for ib status (default: '%{admin} =~ /up/i and %{status} !~ /up/i'). +Define the conditions to match for the status to be CRITICAL. +Default: '%{admin} =~ /up/i and %{status} !~ /up/i'. You can use the following variables: %{admin}, %{status}, %{display} =item B<--warning-*> -Warning threshold. -Can be: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. +Warning thresholds for: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. =item B<--critical-*> -Critical threshold. -Can be: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. +Critical thresholds for: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. =item B<--reload-cache-time> -Time in seconds before reloading cache file (default: 300). +Time in seconds before reloading the cache file (default: 300). =back diff --git a/src/network/alcatel/isam/snmp/mode/listhubsap.pm b/src/network/nokia/isam/snmp/mode/listhubsap.pm similarity index 98% rename from src/network/alcatel/isam/snmp/mode/listhubsap.pm rename to src/network/nokia/isam/snmp/mode/listhubsap.pm index 75274b527a..3483e3fdb0 100644 --- a/src/network/alcatel/isam/snmp/mode/listhubsap.pm +++ b/src/network/nokia/isam/snmp/mode/listhubsap.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::listhubsap; +package network::nokia::isam::snmp::mode::listhubsap; use base qw(centreon::plugins::mode); @@ -137,7 +137,7 @@ __END__ =head1 MODE -List SAP. +List Service Access Points (SAP) for service discovery. =over 8 diff --git a/src/network/alcatel/isam/snmp/mode/memory.pm b/src/network/nokia/isam/snmp/mode/memory.pm similarity index 95% rename from src/network/alcatel/isam/snmp/mode/memory.pm rename to src/network/nokia/isam/snmp/mode/memory.pm index 005f7b6c29..fb605058ef 100644 --- a/src/network/alcatel/isam/snmp/mode/memory.pm +++ b/src/network/nokia/isam/snmp/mode/memory.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::mode::memory; +package network::nokia::isam::snmp::mode::memory; use base qw(centreon::plugins::templates::counter); @@ -159,7 +159,7 @@ sub manage_selection { my $name = $result->{eqptBoardInventorySerialNumber} . '_' . $result->{eqptSlotActualType}; 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); + $self->{output}->output_add(long_msg => "skipping '" . $name . "': not matching filter.", debug => 1); next; } $self->{memory}->{$name} = { display => $name, total => $result->{totalMemSize} * 1024 * 1024, used => $result->{memAbsoluteUsage} * 1024 * 1024 }; @@ -170,7 +170,7 @@ sub manage_selection { my $name = 'SD Card'; 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); + $self->{output}->output_add(long_msg => "skipping '" . $name . "': not matching filter.", debug => 1); } else { $self->{memory}->{$name} = { display => $name, total => $snmp_result->{$oid_asamSwmTotalSpaceOnFileDisk}, used => $snmp_result->{$oid_asamSwmTotalSpaceOnFileDisk} - $snmp_result->{$oid_asamSwmFreeSpaceOnFileDisk} }; @@ -189,17 +189,14 @@ __END__ =head1 MODE -Check memory usages. +Monitor memory usage. =over 8 =item B<--filter-name> -Filter memory name (can be a regexp). - -=item B<--filter-project> - -Filter project name (can be a regexp). +Define which memory component to monitor based on their name. +This option will be treated as a regular expression. =item B<--warning-usage> @@ -211,11 +208,11 @@ Critical threshold. =item B<--units> -Units of thresholds (default: '%') ('%', 'B'). +Define the unit to use to apply to thresholds (default: '%') ('%', 'B'). =item B<--free> -Thresholds are on free space left. +Apply the thresholds on free space left instead of on used space. =back diff --git a/src/network/alcatel/isam/snmp/plugin.pm b/src/network/nokia/isam/snmp/plugin.pm similarity index 68% rename from src/network/alcatel/isam/snmp/plugin.pm rename to src/network/nokia/isam/snmp/plugin.pm index d8437c6e2a..9c31934236 100644 --- a/src/network/alcatel/isam/snmp/plugin.pm +++ b/src/network/nokia/isam/snmp/plugin.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::alcatel::isam::snmp::plugin; +package network::nokia::isam::snmp::plugin; use strict; use warnings; @@ -31,13 +31,14 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu' => 'network::alcatel::isam::snmp::mode::cpu', - 'hardware' => 'network::alcatel::isam::snmp::mode::hardware', + 'cpu' => 'network::nokia::isam::snmp::mode::cpu', + 'hardware' => 'network::nokia::isam::snmp::mode::hardware', + 'hub-sap-usage' => 'network::nokia::isam::snmp::mode::hubsapusage', 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-hub-sap' => 'network::alcatel::isam::snmp::mode::listhubsap', + 'list-hub-sap' => 'network::nokia::isam::snmp::mode::listhubsap', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::alcatel::isam::snmp::mode::memory', - 'hub-sap-usage' => 'network::alcatel::isam::snmp::mode::hubsapusage', + 'memory' => 'network::nokia::isam::snmp::mode::memory', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self; @@ -49,6 +50,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Alcatel DSL ISAM Family (also ASAM) in SNMP. +Monitor Nokia (formerly Alcatel) DSL ISAM devices (also ASAM) using SNMP. =cut diff --git a/tests/resources/spellcheck/stopwords.t b/tests/resources/spellcheck/stopwords.t index 6219228ef4..e2257eb37a 100644 --- a/tests/resources/spellcheck/stopwords.t +++ b/tests/resources/spellcheck/stopwords.t @@ -43,12 +43,15 @@ -NoLogo 2c ADSL +ASAM +Alcatel Avigilon Centreon Datacore Fortigate Fortinet HashiCorp +ISAM IpAddr Iwsva Loggly @@ -62,6 +65,7 @@ Nagios Netscaler OID PKCS1 +QoS RRDCached SNMP SSH @@ -76,6 +80,7 @@ VPN WSMAN XPath api.meraki.com +cardtemperature connections-dhcp connections-dns deltaps @@ -104,6 +109,7 @@ powershell.exe proto psu queue-messages-inflighted +sfp.temperature space-usage-prct teampass timeframe From eb226c79420e38381241dfa6a43a366c7d41e773 Mon Sep 17 00:00:00 2001 From: sdepassio <114986849+sdepassio@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:45:08 +0200 Subject: [PATCH 13/18] fix(library and packaging): package dependencies for paws cpan library for el8/el9 and package paws without using fpm for debian (#5065) --- .github/workflows/perl-cpan-libraries.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/perl-cpan-libraries.yml b/.github/workflows/perl-cpan-libraries.yml index 7538ee10c3..188e33a65d 100644 --- a/.github/workflows/perl-cpan-libraries.yml +++ b/.github/workflows/perl-cpan-libraries.yml @@ -33,6 +33,7 @@ jobs: distrib: [el8, el9] name: [ + "ARGV::Struct", "Authen::SASL::SASLprep", "Authen::SCRAM::Client", "boolean", @@ -42,9 +43,11 @@ jobs: "Clone", "Clone::Choose", "common::sense", + "Config::AWS", "Convert::Binary::C", "Convert::EBCDIC", "Crypt::Blowfish_PP", + "DataStruct::Flat", "DateTime::Format::Duration::ISO8601", "DBD::Sybase", "Device::Modbus", @@ -70,6 +73,8 @@ jobs: "MIME::Types", "Mojo::IOLoop::Signal", "MongoDB", + "MooseX::ClassAttribute", + "Net::Amazon::Signature::V4", "Net::DHCP", "Net::FTPSSL", "Net::HTTPTunnel", @@ -91,6 +96,7 @@ jobs: "URI::Encode", "URI::Template", "URL::Encode", + "URL::Encode::XS", "UUID", "UUID::URandom", "WWW::Selenium", @@ -130,6 +136,8 @@ jobs: rpm_provides: "perl(Net::DHCP::Constants) perl(Net::DHCP::Packet)" - name: "Statistics::Regression" version: "0.53" + - name: "URL::Encode::XS" + build_distribs: el9 - name: "UUID" version: "0.31" - name: "ZMQ::Constants" @@ -357,8 +365,6 @@ jobs: image: packaging-plugins-bullseye-arm64 arch: arm64 runner_name: ["self-hosted", "collect-arm64"] - - name: "Paws" - use_dh_make_perl: "false" - name: "Statistics::Regression" build_distribs: "bullseye" version: "0.53" From f00a76b915394126a7d45d43daec46ae1d4ee45d Mon Sep 17 00:00:00 2001 From: tuntoja <58987095+tuntoja@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:00:19 +0200 Subject: [PATCH 14/18] fix(ci): remove centos7 from docker-builder matrix (#5097) --- .github/workflows/docker-builder-packaging-plugins.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docker-builder-packaging-plugins.yml b/.github/workflows/docker-builder-packaging-plugins.yml index 948c983602..fa981cdab4 100644 --- a/.github/workflows/docker-builder-packaging-plugins.yml +++ b/.github/workflows/docker-builder-packaging-plugins.yml @@ -22,9 +22,6 @@ jobs: strategy: matrix: include: - - runner: ubuntu-22.04 - dockerfile: packaging-plugins-centos7 - image: packaging-plugins-centos7 - runner: ubuntu-22.04 dockerfile: packaging-plugins-alma8 image: packaging-plugins-alma8 From 01de69b2847ba01b03d5f516c90e1786020e1f78 Mon Sep 17 00:00:00 2001 From: May <110405507+mushroomempires@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:49:16 +0200 Subject: [PATCH 15/18] chore(deps): absorb 24.07 dependabot GitHub Actions updates (#5092) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker-builder-packaging-plugins.yml | 6 +++--- .github/workflows/docker-builder-testing-plugins.yml | 6 +++--- .github/workflows/perl-cpan-libraries.yml | 4 ++-- .github/workflows/perl-crypt-argon2.yml | 2 +- .github/workflows/perl-json-path.yml | 2 +- .github/workflows/perl-libssh-session.yml | 2 +- .github/workflows/perl-net-curl.yml | 2 +- .github/workflows/plink.yml | 2 +- .github/workflows/plugins.yml | 6 +++--- .github/workflows/spellchecker.yml | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docker-builder-packaging-plugins.yml b/.github/workflows/docker-builder-packaging-plugins.yml index fa981cdab4..b78d83a28f 100644 --- a/.github/workflows/docker-builder-packaging-plugins.yml +++ b/.github/workflows/docker-builder-packaging-plugins.yml @@ -48,14 +48,14 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Login to Registry - uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }} username: ${{ secrets.DOCKER_REGISTRY_ID }} password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - name: Login to proxy registry - uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }} username: ${{ secrets.DOCKER_REGISTRY_ID }} @@ -63,7 +63,7 @@ jobs: - uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + - uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1 # v6.2.0 with: file: .github/docker/packaging/Dockerfile.${{ matrix.dockerfile }} context: . diff --git a/.github/workflows/docker-builder-testing-plugins.yml b/.github/workflows/docker-builder-testing-plugins.yml index b3aa9f149a..2a8b549726 100644 --- a/.github/workflows/docker-builder-testing-plugins.yml +++ b/.github/workflows/docker-builder-testing-plugins.yml @@ -48,14 +48,14 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Login to Registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }} username: ${{ secrets.DOCKER_REGISTRY_ID }} password: ${{ secrets.DOCKER_REGISTRY_PASSWD }} - name: Login to proxy registry - uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 with: registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }} username: ${{ secrets.DOCKER_REGISTRY_ID }} @@ -63,7 +63,7 @@ jobs: - uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 - - uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + - uses: docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1 # v6.2.0 with: file: .github/docker/testing/Dockerfile.testing-plugins-${{ matrix.dockerfile }} context: . diff --git a/.github/workflows/perl-cpan-libraries.yml b/.github/workflows/perl-cpan-libraries.yml index 188e33a65d..fc54f84814 100644 --- a/.github/workflows/perl-cpan-libraries.yml +++ b/.github/workflows/perl-cpan-libraries.yml @@ -227,7 +227,7 @@ jobs: shell: bash - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ steps.package-name.outputs.name_with_dash }} path: ./*.${{ matrix.package_extension }} @@ -446,7 +446,7 @@ jobs: shell: bash - if: ${{ contains(matrix.build_distribs, matrix.distrib) }} - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ matrix.arch }}-${{ steps.package-name.outputs.name_with_dash}} path: ./*.${{ matrix.package_extension }} diff --git a/.github/workflows/perl-crypt-argon2.yml b/.github/workflows/perl-crypt-argon2.yml index 808458b4cd..34638474bd 100644 --- a/.github/workflows/perl-crypt-argon2.yml +++ b/.github/workflows/perl-crypt-argon2.yml @@ -135,7 +135,7 @@ jobs: # set condition to true if artifacts are needed - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.distrib }}-${{ matrix.arch }} path: ./*.${{ matrix.package_extension}} diff --git a/.github/workflows/perl-json-path.yml b/.github/workflows/perl-json-path.yml index 2c7c4a888b..77cb2d5a15 100644 --- a/.github/workflows/perl-json-path.yml +++ b/.github/workflows/perl-json-path.yml @@ -120,7 +120,7 @@ jobs: # set condition to true if artifacts are needed - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.distrib }} path: ./*.${{ matrix.package_extension}} diff --git a/.github/workflows/perl-libssh-session.yml b/.github/workflows/perl-libssh-session.yml index 69f068d40d..15209ec0d0 100644 --- a/.github/workflows/perl-libssh-session.yml +++ b/.github/workflows/perl-libssh-session.yml @@ -133,7 +133,7 @@ jobs: # set condition to true if artifacts are needed - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.distrib }}-${{ matrix.arch }} path: ./*.${{ matrix.package_extension}} diff --git a/.github/workflows/perl-net-curl.yml b/.github/workflows/perl-net-curl.yml index 830c2aaef9..f5f44533b6 100644 --- a/.github/workflows/perl-net-curl.yml +++ b/.github/workflows/perl-net-curl.yml @@ -133,7 +133,7 @@ jobs: # set condition to true if artifacts are needed - if: ${{ false }} name: Upload package artifacts - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.distrib }}-${{ matrix.arch }} path: ./*.${{ matrix.package_extension }} diff --git a/.github/workflows/plink.yml b/.github/workflows/plink.yml index 6feea0c67b..8b65217bfc 100644 --- a/.github/workflows/plink.yml +++ b/.github/workflows/plink.yml @@ -102,7 +102,7 @@ jobs: path: ./*.rpm key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }} - - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: packages-${{ matrix.distrib }} path: ./*.rpm diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 3aefec91a5..fdcc7605bd 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -93,7 +93,7 @@ jobs: fetch-depth: 1 - name: Prepare FatPacker - uses: shogo82148/actions-setup-perl@28eae78d12c2bba1163aec45d123f6d9228bc307 # v1.29.0 + uses: shogo82148/actions-setup-perl@f551dafcc94572adc179bbddbb409b3ada8f8ff5 # v1.30.0 with: perl-version: '5.34' install-modules-with: cpm @@ -156,7 +156,7 @@ jobs: - if: ${{ matrix.distrib == 'el7' }} # el7 is not compatible with checkout v4 which uses node20 - uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ./build/ key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }} @@ -284,7 +284,7 @@ jobs: - name: Upload apt/dnf logs as artifacts if tests failed if: failure() - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: plugin-installation-${{ matrix.distrib }} path: /var/log/robot-plugins-installation-tests.log diff --git a/.github/workflows/spellchecker.yml b/.github/workflows/spellchecker.yml index a526a450c7..fa272fbf6e 100644 --- a/.github/workflows/spellchecker.yml +++ b/.github/workflows/spellchecker.yml @@ -30,7 +30,7 @@ jobs: - added|modified: 'src/**/*.pm' - name: Install CPAN Libraries - uses: shogo82148/actions-setup-perl@28eae78d12c2bba1163aec45d123f6d9228bc307 # v1.29.0 + uses: shogo82148/actions-setup-perl@f551dafcc94572adc179bbddbb409b3ada8f8ff5 # v1.30.0 with: perl-version: '5.34' install-modules-with: cpm From 90f3d1427a6fe55dc48d52e3a9d3d43936f23c25 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Jul 2024 13:56:18 +0000 Subject: [PATCH 16/18] refactor and renaming test --- .../snmp/{diskio.robot => list-diskio.robot} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename tests/robot/os/linux/snmp/{diskio.robot => list-diskio.robot} (54%) diff --git a/tests/robot/os/linux/snmp/diskio.robot b/tests/robot/os/linux/snmp/list-diskio.robot similarity index 54% rename from tests/robot/os/linux/snmp/diskio.robot rename to tests/robot/os/linux/snmp/list-diskio.robot index eb223be395..15ba6333f6 100644 --- a/tests/robot/os/linux/snmp/diskio.robot +++ b/tests/robot/os/linux/snmp/list-diskio.robot @@ -1,5 +1,5 @@ *** Settings *** -Documentation OS Linux SNMP plugin +Documentation Check the list-diskio mode Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource @@ -11,8 +11,9 @@ ${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::snmp::plugin *** Test Cases *** -Linux SNMP list diskio devices ${documentation} ${tc}/2 - [Tags] os linux snmp +List diskio ${tc} + [Documentation] Check the number of returned disks + [Tags] os linux snmp service-disco ${command} Catenate ... ${CMD} ... --mode=list-diskio @@ -22,15 +23,14 @@ Linux SNMP list diskio devices ${documentation} ${tc}/2 ... --disco-show ... --snmp-community=${snmpcommunity} ${output} Run ${command} - Log To Console ${command} ${nb_results} Get Element Count ... ${output} ... label Should Be Equal As Integers ... ${expected_result} ... ${nb_results} - ... Wrong output result for list diskio devices: ${snmpcommunity}.{\n}Command output:{\n}${output} + ... Wrong output result for command:{\n}{\n}${command}{\n}{\n}Command output:{\n}{\n}${output} - Examples: documentation tc snmpcommunity expected_result -- - ... First run 1 os/linux/snmp/list-diskio 10 - ... Second run 2 os/linux/snmp/list-diskio-2 4 \ No newline at end of file + Examples: tc snmpcommunity expected_result -- + ... 1 os/linux/snmp/list-diskio 10 + ... 2 os/linux/snmp/list-diskio-2 4 \ No newline at end of file From c3d939ebb847027f5583c1d692c28beec638877f Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:02:05 +0200 Subject: [PATCH 17/18] Update diskio.pm --- src/snmp_standard/mode/diskio.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/snmp_standard/mode/diskio.pm b/src/snmp_standard/mode/diskio.pm index 9df6c1b300..7138101e0b 100644 --- a/src/snmp_standard/mode/diskio.pm +++ b/src/snmp_standard/mode/diskio.pm @@ -297,6 +297,7 @@ sub disco_show { } } + 1; __END__ From 9e08da41f0836959bec36f2d0bb8c958ccc553cb Mon Sep 17 00:00:00 2001 From: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:11:46 +0200 Subject: [PATCH 18/18] MON-34540-gorgone-fix-perl-mojo-ioloop-signal-v3 (#5101) --- .github/workflows/perl-cpan-libraries.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/perl-cpan-libraries.yml b/.github/workflows/perl-cpan-libraries.yml index fc54f84814..6ffbd7add5 100644 --- a/.github/workflows/perl-cpan-libraries.yml +++ b/.github/workflows/perl-cpan-libraries.yml @@ -149,6 +149,8 @@ jobs: rpm_dependencies: "zeromq" - name: "Mojo::IOLoop::Signal" rpm_dependencies: "perl-Mojolicious" + rpm_provides: "perl(Mojo::IOLoop::Signal)" + no-auto-depends: true name: package ${{ matrix.distrib }} ${{ matrix.name }} @@ -190,6 +192,10 @@ jobs: done fi + if [ ! -z "${{ matrix.no-auto-depends }}" ]; then + PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends" + fi + if [ -z "${{ matrix.rpm_provides }}" ]; then PACKAGE_PROVIDES="" else