Skip to content

Commit

Permalink
Merge branch 'develop' into CTOR-1235-plugin-network-aruba-aoscx-snmp…
Browse files Browse the repository at this point in the history
…-new-mode-stack
  • Loading branch information
omercier authored Jan 10, 2025
2 parents f2d2deb + 046a383 commit b39bde8
Show file tree
Hide file tree
Showing 74 changed files with 86,132 additions and 298 deletions.
12 changes: 9 additions & 3 deletions .github/actions/promote-to-stable/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,21 @@ runs:
shell: bash

- name: Promote DEB package to stable
if: ${{ contains(fromJSON('["bullseye", "bookworm"]'), inputs.distrib) }}
if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy"]'), inputs.distrib) }}
run: |
set -eux
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
echo "[DEBUG] - Distrib: ${{ inputs.module }}"
if [[ "${{ inputs.distrib }}" == "jammy" ]]; then
repo="ubuntu-plugins"
else
repo="apt-plugins"
fi
echo "[DEBUG] - Get path of testing DEB packages to promote to stable."
SRC_PATHS=$(jf rt search --include-dirs apt-plugins-testing/pool/${{ inputs.module }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb | jq -r '.[].path')
SRC_PATHS=$(jf rt search --include-dirs $repo-testing/pool/${{ inputs.module }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb | jq -r '.[].path')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
Expand All @@ -86,7 +92,7 @@ runs:
fi
echo "[DEBUG] - Build target path."
TARGET_PATH="apt-plugins-${{ inputs.stability }}/pool/${{ inputs.module }}/"
TARGET_PATH="$repo-${{ inputs.stability }}/pool/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting DEB testing artifacts to stable."
Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-bookworm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io

FROM ${REGISTRY_URL}/debian:bookworm

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# fix locale
RUN bash -e <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-bullseye
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io

FROM ${REGISTRY_URL}/debian:bullseye

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# fix locale
RUN bash -e <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/docker/testing/Dockerfile.testing-plugins-jammy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG REGISTRY_URL=docker.io

FROM ${REGISTRY_URL}/ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# fix locale
RUN bash -e <<EOF
Expand All @@ -15,7 +15,7 @@ apt-get clean

EOF

ENV LANG en_US.utf8
ENV LANG=en_US.utf8

RUN bash -e <<EOF

Expand Down
57 changes: 48 additions & 9 deletions .github/scripts/pod_spell_check.t
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
use strict;
use warnings;

use Test::More;
use Test::Spelling;
use List::MoreUtils qw(uniq);

# the command must have at least one argument
if (!@ARGV) {
die "Usage: perl pod_spell_check.t module.pm stopwords.t";
}
# the first argument is the module to check
my $module_to_check = $ARGV[0];

# the second (optional) argument is the additional dictionary
my $stopword_filename='tests/resources/spellcheck/stopwords.txt';
if(defined($ARGV[1])){
$stopword_filename=$ARGV[1];
}
open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("Using dictionary: ".$stopword_filename." \n");

add_stopwords(<FILE>);
close(FILE);
set_spell_cmd('hunspell -l');
all_pod_files_spelling_ok($ARGV[0]);
# get_stopwords(): reads the text file and returns its content as an array or strings
sub get_stopwords {
my ($file) = @_;

open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("Using dictionary: ".$stopword_filename." \n");
my @stop_words;
for my $line (<FILE>) {
chomp $line;
push @stop_words, $line;
}
close(FILE);

return @stop_words;
}

# get_module_options(): reads the Perl module file's POD and returns all the encountered --options
sub get_module_options {
my ($module) = @_;

my @cmd_result = `perldoc -T $module_to_check`;
my @new_words;

for my $pod_line (@cmd_result) {
chomp $pod_line;
my @parsed_options = $pod_line =~ /(--[\w-]+){1,}\s?/mg or next;
push @new_words, @parsed_options;
}

return uniq(sort(@new_words));
}

my @known_words = get_stopwords($stopword_filename);
my @module_options = get_module_options($module_to_check);

# take all words from the text file and the module's options as valid words
add_stopwords(@known_words, @module_options);

# prepare the spelling check command
set_spell_cmd('hunspell -d en_US -l');

# check that all is correct in the Perl module file given as an argument
all_pod_files_spelling_ok($module_to_check);
32 changes: 32 additions & 0 deletions .github/workflows/set-pull-request-external-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: set-pull-request-external-label

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request_target:

jobs:
set-pull-request-external-label:
if: |
github.event.pull_request.head.repo.fork &&
! contains(github.event.pull_request.labels.*.name, 'external')
runs-on: ubuntu-24.04

steps:
- name: Set PR external label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const label = 'external';
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
} catch (e) {
core.warning(`failed to add label ${label}: ${e}`);
}
4 changes: 2 additions & 2 deletions .github/workflows/spellchecker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
jobs:
pod-spell-check:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'do-not-spellcheck') }}
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -34,7 +34,7 @@ jobs:
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: Test::More Test::Spelling
install-modules: Test::More Test::Spelling List::MoreUtils

- name: Install librairies
continue-on-error: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"files": [
"centreon/plugins/script_snmp.pm",
"centreon/plugins/snmp.pm",
"snmp_standard/mode/uptime.pm",
"storage/netapp/ontap/snmp/"
]
}
5 changes: 3 additions & 2 deletions packaging/centreon-plugin-Network-Huawei-Snmp/pkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"pkg_summary": "Centreon Plugin",
"plugin_name": "centreon_huawei_snmp.pl",
"files": [
"centreon/common/huawei/standard/snmp",
"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/resources/",
"snmp_standard/mode/uptime.pm",
"network/huawei/snmp/"
"network/huawei/standard/snmp/"
]
}
5 changes: 5 additions & 0 deletions packaging/centreon-plugin-Network-Huawei-Wlc-Snmp/deb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"libsnmp-perl"
]
}
15 changes: 15 additions & 0 deletions packaging/centreon-plugin-Network-Huawei-Wlc-Snmp/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pkg_name": "centreon-plugin-Network-Huawei-Wlc-Snmp",
"pkg_summary": "Centreon Plugin for Huawei WLC using SNMP protocol",
"plugin_name": "centreon_huawei_wlc_snmp.pl",
"files": [
"centreon/common/huawei/standard/snmp/",
"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/huawei/wlc/snmp/"
]
}
5 changes: 5 additions & 0 deletions packaging/centreon-plugin-Network-Huawei-Wlc-Snmp/rpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": [
"perl(SNMP)"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"centreon/plugins/snmp.pm",
"snmp_standard/mode/interfaces.pm",
"snmp_standard/mode/listinterfaces.pm",
"snmp_standard/mode/resources/",
"snmp_standard/mode/listspanningtrees.pm",
"snmp_standard/mode/resources/",
"snmp_standard/mode/spanningtree.pm",
"snmp_standard/mode/uptime.pm",
"network/hp/procurve/"
]
}
2 changes: 1 addition & 1 deletion src/apps/protocols/smtp/lib/smtp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ sub connect {
$self->{output}->exit();
}
if ($smtp_handle == -1) {
chomp $stdout;
chomp $stdout if (defined($stdout));
$self->{output}->output_add(
severity => $connection_exit,
short_msg => 'Unable to connect to SMTP: ' . (defined($stdout) ? $stdout : $error_msg)
Expand Down
12 changes: 6 additions & 6 deletions src/apps/salesforce/restapi/custom/api.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ sub request_api {
$self->{output}->option_exit();
}
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{message});
$self->{output}->add_option_msg(short_msg => "Connection issue: " . defined($decoded->{message}) ? $decoded->{message} : '');
$self->{output}->option_exit();
}

Expand All @@ -125,27 +125,27 @@ __END__
=head1 NAME
SFDC API boilerplate
Monitor SFDC API boilerplate
=head1 SYNOPSIS
Get informations from SFDC API
Get information from SFDC API
=head1 REST API OPTIONS
=over 8
=item B<--hostname>
Set hostname to query (default: 'api.status.salesforce.com')
Define the hostname to query (default: C<api.status.salesforce.com>)
=item B<--timeout>
Set HTTP timeout in seconds (default: '10').
Define the HTTP timeout in seconds (default: '10').
=item B<--api-version>
API version (default: 'v1').
Define the API version (default: 'v1').
=back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

package network::huawei::snmp::mode::components::fan;
package centreon::common::huawei::standard::snmp::mode::components::fan;

use strict;
use warnings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

package network::huawei::snmp::mode::components::temperature;
package centreon::common::huawei::standard::snmp::mode::components::temperature;

use strict;
use warnings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

package network::huawei::snmp::mode::cpu;
package centreon::common::huawei::standard::snmp::mode::cpu;

use base qw(centreon::plugins::templates::counter);

Expand Down Expand Up @@ -56,9 +56,7 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;

$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {});

return $self;
}
Expand All @@ -80,17 +78,17 @@ sub manage_selection {
$self->{cpu} = {};
my $num = 1;
if (defined($results->{$oid_hwAvgDuty5min}) && scalar(keys %{$results->{$oid_hwAvgDuty5min}}) > 0) {
foreach (keys %{$results->{$oid_hwAvgDuty5min}}) {
foreach (sort keys %{$results->{$oid_hwAvgDuty5min}}) {
$self->{cpu}->{$num} = { num => $num, cpu => $results->{$oid_hwAvgDuty5min}->{$_} };
$num++;
}
} elsif (defined($results->{$oid_hwEntityCpuUsage}) && scalar(keys %{$results->{$oid_hwEntityCpuUsage}}) > 0) {
foreach (keys %{$results->{$oid_hwEntityCpuUsage}}) {
foreach (sort keys %{$results->{$oid_hwEntityCpuUsage}}) {
$self->{cpu}->{$num} = { num => $num, cpu => $results->{$oid_hwEntityCpuUsage}->{$_} };
$num++;
}
} else {
foreach (keys %{$results->{$oid_hwResOccupancy}}) {
foreach (sort keys %{$results->{$oid_hwResOccupancy}}) {
/\.([0-9]*?)$/;
next if (!defined($map_type->{$1}) || $map_type->{$1} ne 'cpu');
$self->{cpu}->{$num} = { num => $num, cpu => $results->{$oid_hwResOccupancy}->{$_} };
Expand Down
Loading

0 comments on commit b39bde8

Please sign in to comment.