Skip to content

Commit

Permalink
Merge branch 'develop' into CTOR-666-plugin-hardware-server-lenovo-xc…
Browse files Browse the repository at this point in the history
…c-snmp-mode-hardware-system-health-memory-and-cpu-table-not-checked
  • Loading branch information
Evan-Adam authored Dec 24, 2024
2 parents 3297cd8 + f1ab4d9 commit 12b490c
Show file tree
Hide file tree
Showing 52 changed files with 85,170 additions and 229 deletions.
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);
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 @@ -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
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::hardware;
package centreon::common::huawei::standard::snmp::mode::hardware;

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

Expand All @@ -41,7 +41,7 @@ sub set_system {
]
};

$self->{components_path} = 'network::huawei::snmp::mode::components';
$self->{components_path} = 'centreon::common::huawei::standard::snmp::mode::components';
$self->{components_module} = ['fan', 'temperature'];
}

Expand Down
Loading

0 comments on commit 12b490c

Please sign in to comment.