Compare commits

...

90 Commits

Author SHA1 Message Date
pkippes
5822de6cc1
Sync release 20250400 (#5544) 2025-04-07 18:47:06 +02:00
pkippes
d894389296
Release 20250400 (#5542) 2025-04-07 16:55:42 +02:00
pkippes
23526ce247 Empty-Commit 2025-04-07 11:27:59 +02:00
Lucie Dubrunfaut
59d5ef16d2
fix(network/aruba/aoscx/snmp): fixed hardware help section (#5448)
Co-authored-by: sdepassio <114986849+sdepassio@users.noreply.github.com>
2025-04-04 10:12:00 +02:00
Lucie Dubrunfaut
eab7a046d2
fix(apps::backup::veeam::local): update jobstatus help section (#5492) 2025-04-04 10:01:23 +02:00
sdepassio
781dac79b4
fix(apps::eclipse::mosquitto::mqtt): fixed metrics labels in numeric-value mode (#5534, #5462)
Co-authored-by: rmorandell-pgum@users.noreply.github.com

Refs: CTOR-1447
2025-04-03 15:16:20 +02:00
Lucie Dubrunfaut
d117f13521
enh(centreon-plugin-notification-*) : added missing packages on plugin repository (#5528)
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
Co-authored-by: EvanAdam <eadam@centreon.com>
Refs: CTOR-1215
2025-04-02 16:40:34 +02:00
Evan-Adam
5889295b77
enh(mysql) add uptime in plugin output (#5535)
Refs:CTOR-1217

Co-authored-by: SavCent <134679564+SavCent@users.noreply.github.com>
2025-04-02 14:00:09 +02:00
qgarnier
edd04d213c
enh(f5-bigip-snmp): switch to metric v2 + add tests (#4656)
Co-authored-by: sfarouq-ext <116093375+sfarouq-ext@users.noreply.github.com>

Refs: MON-20991
Refs: CTOR-427
2025-04-01 18:06:41 +02:00
sfarouq-ext
5d10adc39b
Ctor 716 plugin network cisco standar (#5455)
Co-authored-by: garnier-quentin <garnier.quentin@gmail.com>
Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>
2025-04-01 17:23:09 +02:00
Lucie Dubrunfaut
f2142d2485
fix options (#5527)
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
2025-04-01 16:38:50 +02:00
Stéphane Chapron
035e018397
enh(secu): add gitleaks configuration (#5520)
Co-authored-by: sc <sc@centreon>
2025-04-01 12:04:25 +02:00
technique-ci
f7b45b2193
chore(deps): absorb 2025-03 dependabot GitHub Actions updates (#5485)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Paul Oureib <poureib@centreon.com>
2025-04-01 11:15:20 +02:00
sdepassio
b5c5fb4b61
enh(ups-apc-snmp): improve last time in battery status + fix dereference in script.pm (#5524 + #5412)
- Update the output for the "replace last time" for the battery status mode : it was displayed in seconds, it is now converted to a human readable format.

Refs: CTOR-1077

- $rebuild_args needs to be dereferenced when used in a join because it is a reference to an array. This is done when the script is executed with a non-root user (line 359) but not when called with root.

Authored by eseyman@users.noreply.github.com #5412
2025-03-31 14:28:23 +02:00
Jochen Platzgummer
75873668bf fix(network::sonus::sbc::snmp): fixed unknown call method map instance in dsp-stats mode (#5483)
Refs: CTOR-1460
2025-03-28 15:47:23 +01:00
sfarouq-ext
82074e5f9e feat(f5-bigip-snmp): add cpuusage mode + tests (#5471)
Refs: CTOR-427
2025-03-28 15:43:29 +01:00
sfarouq-ext
7baab38df6 feat(fortinet-fortigate-restapi): add certificates mode + tests (#5515)
Refs: CTOR-1451
2025-03-28 15:43:02 +01:00
sfarouq-ext
08e0e04099 feat(exense-step-restapi): new plugin to monitor plans executions + tests (#5518)
Refs: CTOR-854
2025-03-28 15:43:02 +01:00
Evan-Adam
92a92c0436 fix(veeam): remove unused sub
Refs:CTOR-1321
2025-03-28 15:43:02 +01:00
sfarouq-ext
63fa39cde5 spellcheck 2025-03-28 15:43:02 +01:00
sfarouq-ext
65569fe9e0 NEW TEST mode (jobs & list-jobs) 2025-03-28 15:43:02 +01:00
sfarouq-ext
6de4e7a770 WIP 2025-03-28 15:43:02 +01:00
Lucie Dubrunfaut
391f77555b Fix after user feedback 2025-03-28 15:43:02 +01:00
Lucie Dubrunfaut
480b0b05f8 First test to add replication jobs 2025-03-28 15:43:02 +01:00
omercier
4a50605c36 enh(vmware8-esx): add swap, diskio and network + tests (#5510) 2025-03-28 15:43:02 +01:00
sfarouq-ext
4e0df4ca4a Ctor 1452 plugin network fortinet fortigate snmp new modes switch usage and switches discovery (#5514)
Co-authored-by: Roman Morandell <46994680+rmorandell-pgum@users.noreply.github.com>
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
2025-03-28 15:43:02 +01:00
omercier
6f94314a60 fix(ci): add missing image + fix path for tests on noble 2025-03-28 15:43:02 +01:00
omercier
6027943d65
enh(counters/iplabe-ekara): allow to sort instances on attribute instead of instance key (#5501)
Refs: CTOR-1388
2025-03-21 08:56:35 +01:00
tuntoja
eeac58c17f
fix(release): fix plugins version detection on stable branch runs (#5439) 2025-03-20 10:21:58 +01:00
tuntoja
9a67330f43
feat: add noble to ci packaging and delivery (#5497) 2025-03-20 09:48:37 +01:00
technique-ci
7bcde8e753
chore(ci): update tj-actions/changed-files to 46.0.1 for branch develop (#5511) 2025-03-18 11:28:50 +01:00
Lucie Dubrunfaut
35ea6cf02f
fix(storage::ibm::fs900::snmp): remove wrong default value all CTOR-544 (#5495)
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>
2025-03-14 09:57:12 +01:00
pkippes
ab9af303e1
Sync release 20250303 (#5507) 2025-03-13 17:30:36 +01:00
pkippes
5726ad44b3
Release 20250303 (#5506) 2025-03-13 17:03:50 +01:00
tuntoja
5da5683f94
fix(packaging): handle specific case of libssh-session packaging name (#5505) 2025-03-13 15:07:22 +01:00
sdepassio
c69ef4f5c5
fix(cpan-libraries): Add revision to update libraries (#5503) 2025-03-13 14:15:07 +01:00
pkippes
33bf4482a5
Release 20250302 (#5499) 2025-03-10 17:24:57 +01:00
sdepassio
800edc6a24
fix(cpan-libraries): Missing provides for some libraries (#5498) 2025-03-10 16:01:25 +01:00
pkippes
a7b7ac2c53
Sync release 20250300 (#5494) 2025-03-07 10:36:51 +01:00
pkippes
0634714531
Release 20250300 (#5491) 2025-03-06 16:20:20 +01:00
pkippes
946af281c8
Merge branch 'master' into release-20250300 2025-03-06 15:04:46 +01:00
omercier
c254a23f77
enh(aruba-aoscx): add spanning tree (mon+disco) and uptime modes (#5454)
Refs: CTOR-1397
2025-03-06 10:07:10 +01:00
sdepassio
baf703598e
enh(as400): add ssl connection option (#5476)
Co-authored-by: garnier-quentin <garnier.quentin@gmail.com>
2025-03-05 17:25:13 +01:00
sfarouq-ext
aaf4bb47d6 removing £ 2025-03-05 12:56:25 +01:00
sdepassio
5a23b681ec
Ctor 1018 perl json path dependencies issue (#5469)
Refs: CTOR-1018
2025-03-05 09:20:04 +01:00
omercier
1571d4ba18
test(cisco-ucs): add tests (#5411)
Refs: CTOR-1323
2025-03-04 17:11:40 +01:00
sfarouq-ext
225180dbe6 spellcheck 2025-03-04 16:55:36 +01:00
sfarouq-ext
1bec397161 WIP 2025-03-04 16:17:00 +01:00
sfarouq-ext
8a41d6eb85 rebased 2025-03-04 16:10:58 +01:00
sfarouq-ext
653e58f7d0 spellcheck 2025-03-04 16:07:49 +01:00
sfarouq-ext
bfc0eb2541 resolving reviews 2025-03-04 16:07:35 +01:00
sfarouq-ext
94d60537a6 Modification 2025-03-04 16:07:34 +01:00
sfarouq-ext
5dab3fe02e spell-check 2025-03-04 16:07:19 +01:00
sfarouq-ext
0d5355cd7d ENH(new mode): test-Plugin(hardware::server::cisco::ucs::snmp)- Mode(equipment) 2025-03-04 16:06:02 +01:00
sfarouq-ext
8e66284819 ENH(new mode): test-Plugin(hardware::server::cisco::ucs::snmp)- Mode(equipment) 2025-03-04 16:06:02 +01:00
Lucie Dubrunfaut
4d055649a3
fix(storage::emc::datadomain::snmp): fixed cleaning mode by adding timezone option CTOR-1415 (#5453)
Co-authored-by: omercier <omercier@centreon.com>
2025-03-04 14:24:30 +01:00
itoussies
129256e737
enh(network::chapsvision::crossing::snmp): Update antivirus OIDs (#5413) 2025-03-04 14:12:23 +01:00
omercier
9b5cc956f0
fix(iplabel-ekara): handle step metrics when scenario failed (#5461)
Refs: CTOR-1394
2025-03-04 12:24:02 +01:00
omercier
a7d4d51198
feat(vmware8-esx): add MVP modes (#5482)
Refs:CTOR-430

Co-authored-by: Evan-Adam <152897682+Evan-Adam@users.noreply.github.com>
2025-03-04 11:56:38 +01:00
Evan-Adam
148030bf66
Update src/apps/monitoring/iplabel/ekara/restapi/mode/scenarios.pm
Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>
2025-03-04 11:52:09 +01:00
omercier
4669ded30a
fix(cisco-ucs): fix wrong count when using threshold overload option (#5467)
Refs: CTOR-1294
2025-03-03 17:37:45 +01:00
sfarouq-ext
ca9e07e13f
enh(fortinet): vpn snmp mode add counter for ip sec tunnels (#5449)
Refs:CTOR-1237

Co-authored-by: Patrick <jummo4@yahoo.de>
Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-PORT-A198>
2025-03-03 16:19:31 +01:00
omercier
635401745c
fix(purestorage-flasharray-v2-restapi): fixed wrong option filter-resolution in arrays and volumes mode (#5472)
Refs: CTOR-1218
2025-03-03 15:23:13 +01:00
sdepassio
9978f5cfcb
fix(as400): fix previous pending request (#5475)
Refs:CTOR-1263

Co-authored-by: garnier-quentin <garnier.quentin@gmail.com>
2025-03-03 11:49:11 +01:00
Kevin Duret
3fa339ca75
enh(ci): migrate runners to arc v2 (#5470) 2025-02-28 13:41:53 +01:00
Lucie Dubrunfaut
81bcdc4a7e fix spellcheck 2025-02-27 15:50:03 +01:00
Lucie Dubrunfaut
12785e80da fix(storage::purestorage::flasharray::v2::restapi): fixed wrong option filter-resolution in arrays and volumes mode 2025-02-27 15:44:28 +01:00
Lucie Dubrunfaut
e2c193f941
Update src/hardware/server/cisco/ucs/snmp/mode/equipment.pm
Co-authored-by: sdepassio <114986849+sdepassio@users.noreply.github.com>
2025-02-27 15:17:19 +01:00
EvanAdam
f4d4ccbca5 fix(cisco): fix spellcheck
Refs:CTOR-1294
2025-02-25 14:48:22 +01:00
Lucie Dubrunfaut
2aecd211bf Fixed wrong count when using threshold-overload option and memories are not equipped 2025-02-25 14:15:44 +01:00
EvanAdam
1b7b8d7468 fix(iplabel): don't show perfdata when the last execution don't have perfdata
Refs:CTOR-1394
2025-02-25 11:37:07 +01:00
May
295cb0d494
enh(deps): increase dependabot allowed pull request openings for github actions (#5460) 2025-02-25 10:12:34 +01:00
itoussies
843694df86
Plugin(hardware::pdu::raritan::snmp): fix sensors state for PDU > 4.x when an outlet sensor is off (#5397)
Co-authored-by: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com>
Co-authored-by: omercier <omercier@centreon.com>
Refs: CTOR-1082
2025-02-20 16:56:57 +01:00
itoussies
48f85e3ba7
Plugin(cloud::azure::network::vpngateway::plugin) - Mode(vpn-gateway-status) : Wrong variable assignment (#5342)
Co-authored-by: sdepassio <114986849+sdepassio@users.noreply.github.com>
Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>
Refs: CTOR-1073
2025-02-20 16:30:34 +01:00
itoussies
0d10876061
fix(netapp-ontap-restapi-plugin): fix hardware API requests for bays and tests (#5395)
Co-authored-by: Lucie Dubrunfaut <123162035+lucie-dubrunfaut@users.noreply.github.com>

Refs: CTOR-783
2025-02-20 16:10:37 +01:00
sfarouq-ext
d40ae9bb6d
enh(purestorage-flasharray): add handling of 'flagged' information + tests to alerts mode (#5403)
Co-authored-by: Fabien-Bernard <78682398+Fabien-Bernard@users.noreply.github.com>
Refs: CTOR-1218
2025-02-20 10:10:29 +01:00
sfarouq-ext
cc89be8b3a Modifications 2025-02-19 09:11:51 +01:00
sfarouq-ext
1e033613f5 ENH add new tests network/aruba/aoscx/snmp 2025-02-17 16:29:58 +01:00
Lucie Dubrunfaut
8486e3592a enh(iplabel::ekara::restapi::scenarios): reworked defaults status 2025-02-13 14:23:17 +01:00
Lucie Dubrunfaut
471a591596
Update pkg.json 2025-02-11 14:45:57 +01:00
Lucie Dubrunfaut
19ec3f4605 nh(network:🇦🇼:aoscx::snmp): added uptime, spanning tree and its discovery modes 2025-02-11 14:44:13 +01:00
pkippes
349d5217d6
Release 20250202 (#5445) 2025-02-11 14:36:45 +01:00
tuntoja
de31640388
fix(packaging): fix dependecy listing for perl-cpan-libraries (#5442) (#5444) 2025-02-11 10:41:51 +01:00
May
2c868ab9dd
chore(deps): absorb 2025-02 dependabot GitHub Actions updates (#5428)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-11 10:34:51 +01:00
tuntoja
4cbb03561f
fix(packaging): fix dependecy listing for perl-cpan-libraries (#5442) 2025-02-11 10:10:23 +01:00
pkippes
85a30e0394
Sync release 20250201 (#5440) 2025-02-07 15:36:45 +01:00
pkippes
44f4bd2e14 Merge branch 'master' into sync-release-20250201 2025-02-07 15:09:00 +01:00
sdepassio
a4383ffd9e
fix(podman): pod-status mode (#5434)
Refs: CTOR-1389
2025-02-07 11:45:17 +01:00
tuntoja
f354080ba9
fix(release): use new version scheme for plugin release tags (#5436) 2025-02-07 11:42:20 +01:00
psame
e82bdef5a5
fix(collections): added missing 'safe' in reval() calls for unknown status check (#5151)
Refs: CTOR-1219
2025-02-07 10:00:55 +01:00
262 changed files with 42514 additions and 2078 deletions

3
.github/CODEOWNERS vendored
View File

@ -21,3 +21,6 @@ tests/** @centreon/owners-robot-e2e
packaging/** @centreon/owners-perl
selinux/** @centreon/owners-pipelines
.github/scripts/pod_spell_check.t @centreon/owners-perl
.gitleaks.toml @centreon/owners-security
.gitleaksignore @centreon/owners-security

View File

@ -18,7 +18,7 @@ runs:
using: 'composite'
steps:
- name: Download Artifacts
uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 # v4.1.0
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
pattern: ${{ inputs.source_name_pattern }}*
path: ${{ inputs.target_name }}

View File

@ -77,7 +77,7 @@ runs:
- if: ${{ inputs.stability != 'stable' }}
name: Restore packages from cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ steps.parse-distrib.outputs.package_extension }}
key: ${{ inputs.cache_key }}
@ -107,7 +107,7 @@ runs:
}
- name: Download packages from testing
if: ${{ inputs.stability == 'stable' && github.event_name == 'push' && inputs.distrib != 'jammy' }}
if: ${{ inputs.stability == 'stable' && github.event_name == 'push' && (inputs.distrib != 'jammy' || inputs.distrib != 'noble') }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
@ -170,7 +170,7 @@ runs:
- name: Publish packages to ${{ inputs.stability }}
if: |
contains(fromJson('["testing", "unstable"]'), inputs.stability) ||
(inputs.stability == 'stable' && github.event_name == 'push' && inputs.distrib != 'jammy')
(inputs.stability == 'stable' && github.event_name == 'push' && (inputs.distrib != 'jammy' || inputs.distrib != 'noble'))
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |

View File

@ -122,7 +122,7 @@ runs:
done
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}

View File

@ -54,6 +54,11 @@ runs:
PACKAGE_DISTRIB_NAME="0ubuntu.22.04"
PACKAGE_EXTENSION="deb"
DISTRIB_FAMILY="ubuntu"
elif [[ "${{ inputs.distrib }}" == "noble" ]]; then
PACKAGE_DISTRIB_SEPARATOR="-"
PACKAGE_DISTRIB_NAME="0ubuntu.24.04"
PACKAGE_EXTENSION="deb"
DISTRIB_FAMILY="ubuntu"
else
echo "::error::Distrib ${{ inputs.distrib }} cannot be parsed"
exit 1

View File

@ -66,14 +66,14 @@ runs:
shell: bash
- name: Promote DEB package to stable
if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy"]'), inputs.distrib) }}
if: ${{ contains(fromJSON('["bullseye", "bookworm", "jammy", "noble"]'), inputs.distrib) }}
run: |
set -eux
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
echo "[DEBUG] - Distrib: ${{ inputs.module }}"
if [[ "${{ inputs.distrib }}" == "jammy" ]]; then
if [[ "${{ inputs.distrib }}" == "jammy" || "${{ inputs.distrib }}" == "noble" ]]; then
repo="ubuntu-plugins"
else
repo="apt-plugins"

View File

@ -0,0 +1,141 @@
name: "test-cpan-libs"
description: "Test packaged CPAN libraries"
inputs:
package_extension:
description: "The package extension (deb or rpm)"
required: true
distrib:
description: "The distribution name"
required: true
arch:
description: "The architecture (amd64 or arm64)"
required: true
runs:
using: "composite"
steps:
- if: ${{ inputs.package_extension == 'rpm' }}
name: Install zstd, perl and Centreon repositories
run: |
dnf install -y zstd perl epel-release 'dnf-command(config-manager)' perl-App-cpanminus
dnf config-manager --set-enabled powertools || true # alma 8
dnf config-manager --set-enabled crb || true # alma 9
# Import Centreon GPG key
GPG_KEY_URL="https://yum-gpg.centreon.com/RPM-GPG-KEY-CES"
curl -sSL $GPG_KEY_URL -o RPM-GPG-KEY-CES
rpm --import RPM-GPG-KEY-CES
shell: bash
- if: ${{ inputs.package_extension == 'deb' }}
name: Install zstd, perl and Centreon repositories
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y zstd perl wget gpg apt-utils procps build-essential cpanminus
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
# Avoid apt to clean packages cache directory
rm -f /etc/apt/apt.conf.d/docker-clean
apt-get update
shell: bash
- name: Restore packages from cache
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ github.sha }}-${{ github.run_id }}-${{ inputs.package_extension }}-${{ inputs.distrib }}
fail-on-cache-miss: true
- if: ${{ inputs.package_extension == 'rpm' }}
name: Check packages installation / uninstallation
run: |
error_log="install_error_${{ inputs.distrib }}_${{ inputs.arch }}.log"
for package in ./*.rpm; do
echo "Installing package: $package"
# List dependencies, and remove version and comparison operators
dependencies=$(rpm -qpR $package | sed 's/ [0-9.-]*\(\s\|$\)/ /g' | sed 's/ [<>!=]*\(\s\|$\)/ /g')
for dependency in $dependencies; do
# Skip non-perl dependencies
if [[ $dependency != perl* ]]; then
continue
else
echo "Check dependency: $dependency"
# Update the dependency name to match the package name
dependency=$(echo $dependency | sed 's/(/-/g' | sed 's/)//g' | sed 's/::/-/g')
fi
# If the dependency has been built in the same workflow, install it
if [[ -n $(find . -maxdepth 1 -regex "\.\/$dependency-[0-9v].*\.rpm") ]]; then
echo "Installing dependency: $dependency"
error_output=$(dnf install -y ./$dependency*.rpm 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
fi
done
# Install package, then uninstall it with all his dependencies
echo "Package installation..."
error_output=$(dnf install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
script_name=$(echo $package | tr '[:upper:]' '[:lower:]' | sed 's/\.\/perl-//' | sed 's/-[0-9\.-]*.el[0-9]..*.rpm//')
if [[ -f ./tests/cpan-libraries/$script_name.pl ]]; then
echo "Testing package..."
error_output=$(perl tests/cpan-libraries/$script_name.pl 2>&1) || { echo "$error_output" >> $error_log; echo "Error during the usage test of the package $package" >> $error_log; true; }
echo "Testing done."
else
echo "No test script found for the package $package"
fi
echo "Package uninstallation..."
error_output=$(dnf autoremove --setopt=keepcache=True -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
done
# If the file error_log exists and is not empty, the workflow is in error
if [[ -s $error_log ]]; then
cat $error_log
exit 1
fi
shell: bash
- if: ${{ inputs.package_extension == 'deb' }}
name: Check packages installation / uninstallation
run: |
error_log="install_error_${{ inputs.distrib }}_${{ inputs.arch }}.log"
for package in ./*.deb; do
# If the debian package name ends with amd64 or arm64, we only install it if the tested architecture is the same, otherwise we skip it
if [[ $package == *amd64.deb && ${{ inputs.arch }} != "amd64" || $package == *arm64.deb && ${{ inputs.arch }} != "arm64" ]]; then
continue
fi
echo "Installing package: $package"
# List dependencies
dependencies=$(dpkg-deb -I $package | grep Depends | sed 's/Depends: //' | sed 's/,//g' | sed 's/(\(.*\)//g') || { echo "$error_output" >> $error_log; echo "Error while listing dependencies of the package $package" >> $error_log; true; }
for dependency in $dependencies; do
# If the dependency exists in the Debian repository, don't check the local dependencies
dependency_info=$(apt-cache policy $dependency)
if [[ -n $dependency_info ]]; then
echo "Dependency $dependency exists in debian repository."
else
# If the dependency has been built in the same workflow, install it
for dependency_package in $(find . -maxdepth 1 -regex "\.\/${dependency}_[0-9].*all\.deb" -o -regex "\.\/${dependency}_[0-9].*${{ inputs.arch }}\.deb"); do
echo "Installing dependency: $dependency_package"
error_output=$(apt-get install -y ./$dependency_package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
done
fi
done
# Install package, then uninstall it with all his dependencies
echo "Package installation..."
error_output=$(apt-get install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
script_name=$(echo $package | sed 's/.\/lib//' | sed 's/-perl_[0-9\.-]*-deb.*\.deb//')
if [[ -f ./tests/cpan-libraries/$script_name.pl ]]; then
echo "Testing package..."
error_output=$(perl tests/cpan-libraries/$script_name.pl 2>&1) || { echo "$error_output" >> $error_log; echo "Error during the usage test of the package $package" >> $error_log; true; }
echo "Testing done."
else
echo "No test script found for the package $package"
fi
echo "Package uninstallation..."
error_output=$(apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
done
# If the file error_log exists and is not empty, the workflow is in error
if [[ -s $error_log ]]; then
cat $error_log
exit 1
fi
shell: bash

View File

@ -16,7 +16,7 @@ runs:
steps:
- name: get the cached plugin
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ inputs.package-extension }}
key: ${{ inputs.cache-key }}
@ -24,4 +24,6 @@ runs:
- name: Install, test and remove plugin
shell: bash
run: python3 .github/scripts/test-all-plugins.py ${{ inputs.package-extension }} ${{ inputs.plugin-list }}
run: |
[[ -f /.venv/bin/activate ]] && source /.venv/bin/activate
python3 .github/scripts/test-all-plugins.py ${{ inputs.package-extension }} ${{ inputs.plugin-list }}

View File

@ -4,7 +4,7 @@ updates:
directory: '/'
schedule:
interval: monthly
open-pull-requests-limit: 10
open-pull-requests-limit: 50
labels:
- 'dependencies'
- 'gha'

View File

@ -6,9 +6,9 @@ RUN bash -e <<EOF
dnf install -y \
git \
java-17-openjdk-devel \
wget \
zstd \
java-17-openjdk-devel
zstd
cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz

View File

@ -6,9 +6,9 @@ RUN bash -e <<EOF
dnf install -y \
git \
java-17-openjdk-devel \
wget \
zstd \
java-17-openjdk-devel
zstd
cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz

View File

@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
zstd \
maven=3.8.7-1 \
openjdk-17-jdk
openjdk-17-jdk \
zstd
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list

View File

@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
zstd \
maven=3.6.3-5 \
openjdk-17-jdk
openjdk-17-jdk \
zstd
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list

View File

@ -8,9 +8,9 @@ apt-get update
apt-get install -y \
ca-certificates \
git \
openjdk-17-jdk \
wget \
zstd \
openjdk-17-jdk
zstd
cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz

View File

@ -0,0 +1,30 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/ubuntu:noble
RUN bash -e <<EOF
apt-get update
apt-get install -y \
ca-certificates \
git \
openjdk-17-jdk \
wget \
zstd
cd /usr/local/src
wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz
tar zxf apache-maven-3.8.8-bin.tar.gz
ln -s /usr/local/src/apache-maven-3.8.8/bin/mvn /usr/bin/mvn
rm -f apache-maven-3.8.8-bin.tar.gz
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
apt-get update
apt-get install -y nfpm=2.41.0
apt-get clean all
EOF
WORKDIR /src

View File

@ -0,0 +1,72 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:noble
ENV DEBIAN_FRONTEND=noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG=en_US.utf8
RUN bash -e <<EOF
apt-get update
echo 'http://deb.debian.org/debian' | apt-get install -y pbuilder
apt-get install -y \
aptitude \
ca-certificates \
cpanminus \
curl \
debmake \
devscripts \
dh-make \
dh-make-perl \
fakeroot \
gcc \
git \
git-buildpackage \
jq \
libapp-fatpacker-perl \
libcurl4-openssl-dev \
libczmq-dev \
libczmq-dev\
libfile-copy-recursive-perl \
libjson-perl \
libmodule-build-tiny-perl \
libmodule-install-perl \
libssh-dev \
lintian \
python3 \
quilt \
ruby \
uuid-dev \
zstd
cpanm Module::Build::Tiny
cpanm Module::Install
cpanm Crypt::OpenSSL::Guess
gem install fpm
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list
apt-get update
apt-get install -y nfpm=2.41.0
apt-get clean
EOF
COPY .github/patch/fpm-deb.rb.diff /tmp/fpm-deb.rb.diff
# Patch to apply fpm fix for debian package generation while waiting for the official fix to be released (https://github.com/jordansissel/fpm/pull/1947).
RUN patch -i /tmp/fpm-deb.rb.diff $(find / -type f -name "deb.rb") && /bin/rm -rf /tmp/fpm-deb.rb.diff

View File

@ -12,7 +12,7 @@ dnf clean all
dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples
# Install snmpsim
pip3.11 install snmpsim-lextudio
pip3.11 install snmpsim
# Install node
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -

View File

@ -12,7 +12,7 @@ dnf clean all
dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples
# Install snmpsim
pip3.11 install snmpsim-lextudio
pip3.11 install snmpsim
# Install node
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -

View File

@ -28,7 +28,7 @@ apt-get install -y python3-dev python3-pip
rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED
pip3 install robotframework robotframework-examples
# Install snmpsim
pip3 install snmpsim-lextudio
pip3 install snmpsim
# Install nodejs
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\

View File

@ -27,7 +27,7 @@ apt-get update
apt-get install -y python3 python3-dev python3-pip
pip3 install robotframework robotframework-examples
# Install snmpsim
pip3 install snmpsim-lextudio
pip3 install snmpsim
# Install nodejs
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\

View File

@ -27,7 +27,7 @@ apt-get update
apt-get install -y python3 python3-dev python3-pip
pip3 install robotframework robotframework-examples
# Install snmpsim
pip3 install snmpsim-lextudio
pip3 install snmpsim
# Install nodejs
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\

View File

@ -0,0 +1,53 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:noble
ENV DEBIAN_FRONTEND=noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG=en_US.utf8
RUN bash -e <<EOF
# Avoid apt to clean packages cache directory
rm -f /etc/apt/apt.conf.d/docker-clean
apt-get update
# Install requirements for python virtual envs
apt-get install -y python3-venv
python3 -m venv .venv
source .venv/bin/activate
# Install Robotframework
apt-get install -y python3 python3-dev python3-pip
pip3 install robotframework robotframework-examples
# Install snmpsim
pip3 install snmpsim
# Install nodejs
curl -fsSL https://deb.nodesource.com/setup_21.x | bash - &&\
apt-get install -y nodejs
# Install mockoon (needs nodejs)
npm install -g -D @mockoon/cli
# Add Centreon plugins repositories
echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ noble main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-unstable/ noble main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
apt-get clean
EOF

View File

@ -0,0 +1,37 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:noble
ENV DEBIAN_FRONTEND=noninteractive
# fix locale
RUN bash -e <<EOF
apt-get update
apt-get install -y locales libcurl4-openssl-dev curl wget zstd jq gpg
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
apt-get clean
EOF
ENV LANG=en_US.utf8
RUN bash -e <<EOF
# Add Centreon plugins repositories
echo "deb https://packages.centreon.com/ubuntu-plugins-stable/ noble main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ noble main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-unstable/ noble main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
apt-get update
apt-get -y install gcc make libtest2-plugin-nowarnings-perl libauthen-radius-perl libconvert-binary-c-perl libcrypt-openssl-rsa-perl libdata-dump-perl libdatetime-format-dateparse-perl libdatetime-format-strptime-perl libdatetime-perl libdbd-mysql-perl libdbd-odbc-perl libdbd-pg-perl libdbd-sybase-perl libdbi-perl libdigest-crc-perl libdigest-md5-perl libdigest-sha-perl libemail-mime-perl libemail-sender-perl libemail-send-smtp-gmail-perl libfilesys-smbclient-perl libhtml-template-perl libio-socket-inet6-perl libio-socket-ip-perl libjmx4perl-perl libjson-maybexs-perl libjson-perl libjson-webtoken-perl libmail-imapclient-perl libmime-base64-perl libmongodb-perl libnet-dhcp-perl libnet-dns-perl libnet-ldap-perl libnet-mqtt-simple-perl libnet-ntp-perl libnet-ssleay-perl libnet-subnet-perl libnet-telnet-perl libnet-tftp-perl libopenwsman-perl libredis-perl librrds-perl libsnmp-perl libsocket-perl libssh-session-perl libtest-www-selenium-perl libtext-csv-perl libtime-hires-perl libtime-parsedate-perl libuuid-perl libxml-libxml-perl libxml-libxml-simple-perl libxml-simple-perl libxml-xpath-perl libzmq-libzmq4-perl perl perl-modules
# this image is used by centreon-perl-libs unit test and centreon-gorgone unit tests.
apt-get -y install libcrypt-openssl-aes-perl libnet-curl-perl libyaml-libyaml-perl libhash-merge-perl libclone-choose-perl libcryptx-perl libjson-xs-perl libjson-pp-perl
apt-get clean
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness UUID
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
EOF

View File

@ -29,8 +29,8 @@ jobs:
- name: Check workflow files
run: |
${{ steps.get_actionlint.outputs.executable }} \
-ignore 'label "common" is unknown' \
-ignore 'label "veracode" is unknown' \
-ignore 'label "centreon-common" is unknown' \
-ignore 'label "centreon-collect-arm64" is unknown' \
-ignore '"github.head_ref" is potentially untrusted' \
-shellcheck= \
-pyflakes= \

View File

@ -20,7 +20,7 @@ jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: as400/packaging/centreon-as400-daemon.yaml
version_file: as400/connector.as400/pom.xml
package:
needs: [get-environment]
@ -47,7 +47,9 @@ jobs:
- package_extension: deb
image: packaging-plugins-java-jammy
distrib: jammy
- package_extension: deb
image: packaging-plugins-java-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
@ -102,7 +104,7 @@ jobs:
stability: ${{ needs.get-environment.outputs.stability }}
- name: Save to cache
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ matrix.package_extension }}
key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
@ -130,6 +132,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -48,6 +48,9 @@ jobs:
- package_extension: deb
image: packaging-plugins-jammy
distrib: jammy
- package_extension: deb
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
@ -106,6 +109,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -45,7 +45,7 @@ jobs:
- runner: ubuntu-22.04
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye
- runner: ["self-hosted", "collect-arm64"]
- runner: centreon-collect-arm64
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye-arm64
- runner: ubuntu-22.04
@ -63,6 +63,12 @@ jobs:
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-jammy
image: packaging-plugins-java-jammy
- runner: ubuntu-22.04
dockerfile: packaging-plugins-noble
image: packaging-plugins-noble
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-noble
image: packaging-plugins-java-noble
runs-on: ${{ matrix.runner }}
@ -84,9 +90,9 @@ jobs:
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/packaging/Dockerfile.${{ matrix.dockerfile }}
context: .

View File

@ -39,7 +39,7 @@ jobs:
- runner: ubuntu-24.04
dockerfile: bullseye
image: bullseye
- runner: ["self-hosted", "collect-arm64"]
- runner: centreon-collect-arm64
dockerfile: bullseye
image: bullseye-arm64
- runner: ubuntu-24.04
@ -48,6 +48,10 @@ jobs:
- runner: ubuntu-24.04
dockerfile: jammy
image: jammy
- runner: ubuntu-24.04
dockerfile: noble
image: noble
runs-on: ${{ matrix.runner }}
@ -69,9 +73,9 @@ jobs:
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/testing/Dockerfile.testing-plugins-${{ matrix.dockerfile }}
context: .

View File

@ -39,7 +39,7 @@ jobs:
- runner: ubuntu-22.04
dockerfile: bullseye
image: bullseye
- runner: ["self-hosted", "collect-arm64"]
- runner: centreon-collect-arm64
dockerfile: bullseye
image: bullseye-arm64
- runner: ubuntu-22.04
@ -48,6 +48,9 @@ jobs:
- runner: ubuntu-22.04
dockerfile: jammy
image: jammy
- runner: ubuntu-22.04
dockerfile: noble
image: noble
runs-on: ${{ matrix.runner }}
@ -69,9 +72,9 @@ jobs:
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/unit-tests/Dockerfile.unit-tests-${{ matrix.dockerfile }}
context: .

View File

@ -134,7 +134,7 @@ jobs:
- if: ${{ steps.has_skip_label.outputs.result == 'true' }}
name: Get push changes
id: get_push_changes
uses: tj-actions/changed-files@bab30c2299617f6615ec02a68b9a40d10bd21366 # v45.0.5
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
with:
since_last_remote_commit: true
json: true
@ -205,7 +205,7 @@ jobs:
script: |
const getStability = (branchName) => {
switch (true) {
case /(^develop$)|(^dev-\d{2}\.\d{2}\.x$)|(^prepare-release-cloud.*)/.test(branchName):
case /(^develop$)|(^dev-\d{2}\.\d{2}\.x$)/.test(branchName):
return 'unstable';
case /(^release.+)|(^hotfix.+)/.test(branchName):
return 'testing';
@ -249,9 +249,46 @@ jobs:
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { execSync } = require('child_process');
const fs = require('fs');
let version = '';
if ('${{ inputs.version_file }}'.match(/pom\.xml$/)) {
version = execSync(`grep -m 1 "<version>.*</version>" ${{ inputs.version_file }} | sed 's/.*<version>\\(.*\\)<\\/version>.*/\\1/'`).toString().trim();
if ('${{ steps.get_stability.outputs.stability }}' === 'testing') {
} else if ('${{ steps.get_stability.outputs.stability }}' === 'stable') {
const { owner, repo } = context.repo;
// Fetch the most recent tag for plugins
const { data: tags } = await github.rest.repos.listTags({
owner,
repo,
per_page: 10
});
let latestTag = null;
let latestDate = 0;
// Filter tags matching format plugins-YYYYMMDD
for (const tag of tags) {
const match = tag.name.match(/^plugins-(\d{8})$/);
const tagDate = parseInt(match[1], 10);
// ensure we get the true latest tag and not the most recent created
if (tagDate > latestDate) {
latestTag = tag.name;
latestDate = tagDate;
}
}
console.log(`Most recent tag found: ${latestTag}`)
// Get current release tag from .version file
version = fs.readFileSync('.version.plugins', 'utf8').trim();
console.log(`Stable version based on .version.plugins file will be: ${version}`)
} else if ('${{ steps.get_stability.outputs.stability }}' === 'testing') {
const branchName = "${{ github.head_ref || github.ref_name }}";
const matches = branchName.match(/^(?:release|hotfix)-(\d{8})$/);
if (matches) {

View File

@ -47,6 +47,9 @@ jobs:
- package_extension: deb
image: packaging-plugins-jammy
distrib: jammy
- package_extension: deb
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
@ -140,6 +143,9 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -43,6 +43,7 @@ jobs:
"Config::AWS",
"Convert::Binary::C",
"Convert::EBCDIC",
"Crypt::Argon2",
"Crypt::Blowfish_PP",
"Crypt::OpenSSL::AES",
"DataStruct::Flat",
@ -52,15 +53,20 @@ jobs:
"Device::Modbus::RTU::Client",
"Device::Modbus::TCP::Client",
"Email::Send::SMTP::Gmail",
"Exporter::Tiny", # Required by JSON::Path: the version available in the official repositories doesn't work with the last version of JSON::Path
"FFI::CheckLib",
"FFI::Platypus",
"File::SearchPath",
"HTTP::ProxyPAC",
"JMX::Jmx4Perl",
"JSON::Path",
"Libssh::Session",
"LV",
"Mojo::IOLoop::Signal",
"MongoDB",
"MooseX::ClassAttribute",
"Net::Amazon::Signature::V4",
"Net::Curl",
"Net::DHCP",
"Net::FTPSSL",
"Net::HTTPTunnel",
@ -92,7 +98,9 @@ jobs:
- rpm_provides: ""
- version: ""
- spec_file: ""
- no-auto-depends: false
- no-auto-depends: "false"
- preinstall_cpanlibs: ""
- revision: "1"
- distrib: el8
package_extension: rpm
image: packaging-plugins-alma8
@ -101,6 +109,10 @@ jobs:
image: packaging-plugins-alma9
- name: "BSON"
rpm_provides: "perl(BSON::Bytes) perl(BSON::Code) perl(BSON::DBRef) perl(BSON::OID) perl(BSON::Raw) perl(BSON::Regex) perl(BSON::Time) perl(BSON::Timestamp) perl(BSON::Types) perl(BSON)"
- name: "Crypt::Argon2"
preinstall_cpanlibs: "Dist::Build"
rpm_provides: "perl-Crypt-Argon2-debuginfo perl(Crypt::Argon2)"
revision: "2"
- name: "DateTime::Format::Duration::ISO8601"
rpm_provides: "perl(DateTime-Format-Duration-ISO8601)"
- name: "Device::Modbus::RTU::Client"
@ -112,11 +124,19 @@ jobs:
- name: "FFI::Platypus"
rpm_provides: "perl(FFI::Platypus::Buffer) perl(FFI::Platypus::Memory)"
rpm_dependencies: "perl(Capture::Tiny) perl(FFI::CheckLib) perl(File::Spec::Functions) perl(IPC::Cmd) perl(JSON::PP) perl(List::Util) perl(autodie) perl(constant) perl(parent)"
no-auto-depends: true
no-auto-depends: "true"
- name: "Libssh::Session"
rpm_dependencies: "libssh"
rpm_provides: "perl-Libssh-Session-debuginfo perl(Libssh::Session) perl(Libssh::Sftp)"
revision: "2"
- name: "Mojo::IOLoop::Signal"
rpm_dependencies: "perl-Mojolicious"
rpm_provides: "perl(Mojo::IOLoop::Signal)"
no-auto-depends: true
no-auto-depends: "true"
- name: "Net::Curl"
rpm_dependencies: "libcurl"
rpm_provides: "perl-Net-Curl-debuginfo perl(Net::Curl) perl(Net::Curl::Compat) perl(Net::Curl::Easy) perl(Net::Curl::Form) perl(Net::Curl::Multi) perl(Net::Curl::Share)"
revision: "2"
- name: "Net::DHCP"
rpm_provides: "perl(Net::DHCP::Constants) perl(Net::DHCP::Packet)"
- name: "Net::SMTPS"
@ -146,7 +166,28 @@ jobs:
steps:
- if: ${{ contains(matrix.build_distribs, matrix.distrib) }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- if: ${{ contains(matrix.build_distribs, matrix.distrib) }}
name: Get package infos
id: package-infos
run: |
cpan_info=$(cpanm --info ${{ matrix.name }})
if [ -z "${{ matrix.version }}" ]; then
CPAN_PACKAGE_VERSION=$(echo $cpan_info | sed 's/\.tar\.gz$//' | sed 's/.*\-//')
if [[ ! $CPAN_PACKAGE_VERSION =~ ^[v0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid version number: ${CPAN_PACKAGE_VERSION}"
exit 1
fi
PACKAGE_VERSION="${CPAN_PACKAGE_VERSION}"
else
PACKAGE_VERSION="${{ matrix.version }}"
fi
echo "package_version=$(echo $PACKAGE_VERSION)" >> $GITHUB_OUTPUT
CPAN_PACKAGE_NAME=$(echo $cpan_info | sed 's/.*\///g' | sed 's/-[0-9\.]*\.tar\.gz//g')
PACKAGE_NAME="perl-$CPAN_PACKAGE_NAME"
echo "package_name=$(echo $PACKAGE_NAME)" >> $GITHUB_OUTPUT
shell: bash
- if: ${{ contains(matrix.build_distribs, matrix.distrib) }}
name: Check if package already exists
@ -155,8 +196,8 @@ jobs:
package_info=$(dnf provides 'perl(${{ matrix.name }})' 2>&1 | tr '[:upper:]' '[:lower:]' || true)
do_not_build="false"
if [[ ! $package_info =~ "no matches found" ]]; then
package_version=$(echo $package_info | grep -oP 'perl\(${{ matrix.name }}\) = \K[0-9]+\.[0-9]+')
if [[ -z "${{ matrix.version }}" || "$package_version" == "${{ matrix.version }}" ]]; then
package_version=$(echo $package_info | grep -oP "perl\($(echo ${{ matrix.name }} | tr '[:upper:]' '[:lower:]')\) = \K[0-9]+\.[0-9]+")
if [[ "$package_version" == "${{ steps.package-infos.outputs.package_version }}" || "v$package_version" == "${{ steps.package-infos.outputs.package_version }}" ]]; then
echo "::warning::Package ${{ matrix.name }} already exists in the official ${{ matrix.distrib }} repository with the same version."
do_not_build="true"
else
@ -169,11 +210,7 @@ jobs:
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_distribs, matrix.distrib) && matrix.spec_file == '' }}
run: |
if [ -z "${{ matrix.version }}" ]; then
PACKAGE_VERSION=""
else
PACKAGE_VERSION=" -v ${{ matrix.version }}"
fi
PACKAGE_VERSION=" -v ${{ steps.package-infos.outputs.package_version }}"
if [ -z "${{ matrix.rpm_dependencies }}" ]; then
PACKAGE_DEPENDENCIES=""
@ -183,7 +220,7 @@ jobs:
done
fi
if [ ! -z "${{ matrix.no-auto-depends }}" ]; then
if [ "${{ matrix.no-auto-depends }}" == "true" ]; then
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends"
fi
@ -195,10 +232,15 @@ jobs:
done
fi
for CPANLIB_PREINSTALL in `echo "${{ matrix.preinstall_cpanlibs }}"`; do
cpanm $CPANLIB_PREINSTALL
done
export SYBASE="/usr"
temp_file=$(mktemp)
created_package=$(fpm -s cpan -t ${{ matrix.package_extension }} --rpm-dist ${{ matrix.distrib }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES$PACKAGE_PROVIDES$PACKAGE_VERSION ${{ matrix.name }} | tee "$temp_file" | grep "Created package" | grep -oP '(?<=:path=>").*?(?=")')
echo "default.local" | tee /etc/mailname
created_package=$(fpm -s cpan -t ${{ matrix.package_extension }} --rpm-dist ${{ matrix.distrib }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES$PACKAGE_PROVIDES$PACKAGE_VERSION --iteration ${{ matrix.revision }} ${{ matrix.name }} | tee "$temp_file" | grep "Created package" | grep -oP '(?<=:path=>").*?(?=")')
# Check package name
if [ -z "$created_package" ]; then
echo "Error: fpm command failed"
@ -281,9 +323,9 @@ jobs:
- run: apt-get install -y zstd
shell: bash
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: packages-rpm-${{ matrix.distrib }}
path: ./
@ -294,7 +336,7 @@ jobs:
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -309,12 +351,13 @@ jobs:
strategy:
fail-fast: false
matrix:
image: [packaging-plugins-bullseye, packaging-plugins-bookworm, packaging-plugins-jammy, packaging-plugins-bullseye-arm64]
image: [packaging-plugins-bullseye, packaging-plugins-bookworm, packaging-plugins-jammy, packaging-plugins-noble, packaging-plugins-bullseye-arm64]
name:
[
"ARGV::Struct",
"Config::AWS",
"Convert::EBCDIC",
"Crypt::Argon2",
"Crypt::Blowfish_PP",
"Crypt::OpenSSL::AES",
"DataStruct::Flat",
@ -327,8 +370,10 @@ jobs:
"Hash::Ordered",
"HTTP::ProxyPAC",
"JMX::Jmx4Perl",
"Libssh::Session",
"Mojo::IOLoop::Signal",
"Net::Amazon::Signature::V4",
"Net::Curl",
"Net::FTPSSL",
"Net::HTTPTunnel",
"Net::MQTT::Simple",
@ -341,11 +386,14 @@ jobs:
include:
- runner_name: ubuntu-24.04
- arch: amd64
- build_names: "bullseye-amd64,bookworm,jammy"
- build_names: "bullseye-amd64,bookworm,jammy,noble"
- deb_dependencies: ""
- rpm_provides: ""
- deb_provides: ""
- version: ""
- use_dh_make_perl: "true"
- no-auto-depends: "false"
- preinstall_cpanlibs: ""
- revision: "1"
- build_name: bullseye-amd64
distrib: bullseye
package_extension: deb
@ -358,31 +406,57 @@ jobs:
distrib: jammy
package_extension: deb
image: packaging-plugins-jammy
- build_name: noble
distrib: noble
package_extension: deb
image: packaging-plugins-noble
- build_name: bullseye-arm64
distrib: bullseye
package_extension: deb
image: packaging-plugins-bullseye-arm64
arch: arm64
runner_name: ["self-hosted", "collect-arm64"]
runner_name: centreon-collect-arm64
- name: "Crypt::Argon2"
build_names: "bullseye-amd64,jammy,noble,bullseye-arm64"
preinstall_cpanlibs: "Dist::Build"
use_dh_make_perl: "false"
no-auto-depends: "true"
deb_dependencies: "libexporter-tiny-perl libtime-hires-perl libxsloader-perl"
deb_provides: "libcrypt-argon2-perl-dbgsym"
revision: "2"
- name: "Crypt::OpenSSL::AES"
use_dh_make_perl: "false"
deb_dependencies: "libexporter-tiny-perl libxs-install-perl"
no-auto-depends: true
build_names: "bullseye-amd64,bookworm,jammy,bullseye-arm64"
no-auto-depends: "true"
build_names: "bullseye-amd64,bookworm,jammy,noble,bullseye-arm64"
- name: "Device::Modbus::RTU::Client"
build_names: "bookworm"
- name: "Device::Modbus::TCP::Client"
build_names: "bookworm"
- name: "Digest::SHA1"
build_names: "jammy"
build_names: "jammy,noble"
- name: "Libssh::Session"
use_dh_make_perl: "false"
build_names: "bullseye-amd64,bookworm,jammy,noble,bullseye-arm64"
no-auto-depends: "true"
deb_dependencies: "libcarp-assert-perl libdynaloader-functions-perl libexporter-tiny-perl libdevel-overloadinfo-perl libssh-4 libc6"
deb_provides: "libssh-session-perl-dbgsym libssh-session-sftp"
revision: "2"
- name: "Net::Amazon::Signature::V4"
build_names: ["bullseye-amd64", "jammy"]
build_names: ["bullseye-amd64", "jammy", "noble"]
- name: "Net::Curl"
use_dh_make_perl: "false"
build_names: "bullseye-amd64,bookworm,jammy,noble,bullseye-arm64"
no-auto-depends: "true"
deb_dependencies: "libcarp-assert-perl libdynaloader-functions-perl libexporter-tiny-perl libdevel-overloadinfo-perl libcurl4"
deb_provides: "libnet-curl-perl-dbgsym libnet-curl-compat-perl libnet-curl-easy-perl libnet-curl-form-perl libnet-curl-share-perl libnet-curl-multi-perl"
revision: "2"
- name: "Net::MQTT::Simple"
version: "1.29"
- name: "Paws"
use_dh_make_perl: "false"
deb_dependencies: "libmoose-perl libmoosex-classattribute-perl libjson-maybexs-perl liburl-encode-perl libargv-struct-perl libmoo-perl libtype-tiny-perl libdatastruct-flat-perl libmodule-find-perl libthrowable-perl liburi-template-perl libnet-amazon-signature-v4-perl"
no-auto-depends: true
no-auto-depends: "true"
- name: "Statistics::Regression"
build_names: "bullseye-amd64"
version: "0.53"
@ -390,7 +464,7 @@ jobs:
use_dh_make_perl: "false"
version: "0.01"
deb_dependencies: "libzmq5"
build_names: "bullseye-amd64,bookworm,jammy,bullseye-arm64"
build_names: "bullseye-amd64,bookworm,jammy,noble,bullseye-arm64"
name: package ${{ matrix.distrib }} ${{ matrix.arch }} ${{ matrix.name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
@ -400,7 +474,7 @@ jobs:
steps:
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
name: Parse distrib name
@ -416,8 +490,8 @@ jobs:
apt-get update
cpan_info=$(cpanm --info ${{ matrix.name }})
if [ -z "${{ matrix.version }}" ]; then
CPAN_PACKAGE_VERSION=$(echo $cpan_info | sed 's/\.tar\.gz$//' | sed 's/.*\-//' | sed 's/v//')
if [[ ! $CPAN_PACKAGE_VERSION =~ ^[0-9]+\.[0-9]+ ]]; then
CPAN_PACKAGE_VERSION=$(echo $cpan_info | sed 's/\.tar\.gz$//' | sed 's/.*\-//')
if [[ ! $CPAN_PACKAGE_VERSION =~ ^[v0-9]+\.[0-9]+ ]]; then
echo "::error::Invalid version number: ${CPAN_PACKAGE_VERSION}"
exit 1
fi
@ -427,7 +501,14 @@ jobs:
fi
echo "package_version=$(echo $PACKAGE_VERSION)" >> $GITHUB_OUTPUT
CPAN_PACKAGE_NAME=$(echo $cpan_info | sed 's/.*\///g' | sed 's/-[0-9\.]*\.tar\.gz//g' | tr '[:upper:]' '[:lower:]')
PACKAGE_NAME="lib$CPAN_PACKAGE_NAME-perl"
# Handle specific cases of libssh-session
if [[ "$CPAN_PACKAGE_NAME" == "lib"* ]];then
PACKAGE_NAME="$CPAN_PACKAGE_NAME-perl"
else
PACKAGE_NAME="lib$CPAN_PACKAGE_NAME-perl"
fi
echo "package_name=$(echo $PACKAGE_NAME)" >> $GITHUB_OUTPUT
shell: bash
@ -442,7 +523,7 @@ jobs:
do_not_build="false"
if [[ -n $package_info ]]; then
candidate_version=$(echo "$package_info" | grep 'Candidate:' | awk '{print $2}')
if [[ "$candidate_version" == "${{ steps.package-infos.outputs.package_version }}"* ]]; then
if [[ "$candidate_version" == "${{ steps.package-infos.outputs.package_version }}"* || "v$candidate_version" == "${{ steps.package-infos.outputs.package_version }}"* ]]; then
echo "::warning::Package ${{ steps.package-infos.outputs.package_name }} already exists in the official ${{ matrix.distrib }} repository with the same version."
do_not_build="true"
else
@ -455,6 +536,10 @@ jobs:
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_names, matrix.build_name) && matrix.use_dh_make_perl == 'false' }}
run: |
# Install needed cpan libs
for CPANLIB_PREINSTALL in `echo "${{ matrix.preinstall_cpanlibs }}"`; do
cpanm $CPANLIB_PREINSTALL
done
if [ -z "${{ matrix.deb_dependencies }}" ]; then
PACKAGE_DEPENDENCIES=""
else
@ -462,28 +547,50 @@ jobs:
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --depends $PACKAGE_DEPENDENCY"
done
fi
if [ ! -z "${{ matrix.no-auto-depends }}" ]; then
if [ "${{ matrix.no-auto-depends }}" == "true" ]; then
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends"
fi
if [ -z "${{ matrix.deb_provides }}" ]; then
PACKAGE_PROVIDES=""
else
for PACKAGE_PROVIDE in `echo "${{ matrix.deb_provides }}"`; do
PACKAGE_PROVIDES="$PACKAGE_PROVIDES --provides $PACKAGE_PROVIDE"
done
fi
temp_file=$(mktemp)
created_package=$(fpm -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ steps.parse-distrib.outputs.package_distrib_name }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES -v ${{ steps.package-infos.outputs.package_version }} ${{ matrix.name }} | tee "$temp_file" | grep "Created package" | grep -oP '(?<=:path=>").*?(?=")') || { echo "Error: fpm command failed"; exit 1; }
echo "default.local" | tee /etc/mailname
# Handle specific case for libssh-session
if [[ "${{ matrix.name }}" == "Libssh::Session" ]]; then
created_package=$(fpm -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ matrix.revision }}${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES$PACKAGE_PROVIDES -v ${{ steps.package-infos.outputs.package_version }} --name ssh-session ${{ matrix.name }} | tee "$temp_file" | grep "Created package" | grep -oP '(?<=:path=>").*?(?=")') || { echo "Error: fpm command failed"; exit 1; }
else
created_package=$(fpm -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ matrix.revision }}${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES$PACKAGE_PROVIDES -v ${{ steps.package-infos.outputs.package_version }} ${{ matrix.name }} | tee "$temp_file" | grep "Created package" | grep -oP '(?<=:path=>").*?(?=")') || { echo "Error: fpm command failed"; exit 1; }
fi
# Check package name
if [ -z "$created_package" ]; then
echo "Error: fpm command failed"
exit 1
fi
# Check deb
dpkg-deb --contents $created_package || { echo "Error: dpkg-deb failed for package $created_package"; exit 1; }
dpkg-deb --verbose --contents $created_package || { echo "Error: dpkg-deb failed for package $created_package"; exit 1; }
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_names, matrix.build_name) && matrix.use_dh_make_perl == 'true' }}
run: |
# Install needed cpan libs
for CPANLIB_PREINSTALL in `echo "${{ matrix.preinstall_cpanlibs }}"`; do
cpanm $CPANLIB_PREINSTALL
done
temp_file=$(mktemp)
created_package=$(DEB_BUILD_OPTIONS="nocheck nodocs notest" dh-make-perl make --dist ${{ matrix.distrib }} --build --version ${{ steps.package-infos.outputs.package_version }}${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} --cpan ${{ matrix.name }} | tee "$temp_file" | grep "building package" | grep -oP "(?<=in '..\/).*.deb(?=')") || { echo "Error: dh-make-perl command failed"; exit 1; }
created_package=$(DEB_BUILD_OPTIONS="nocheck nodocs notest" dh-make-perl make --dist ${{ matrix.distrib }} --build --version ${{ steps.package-infos.outputs.package_version }} --revision ${{ matrix.revision }}${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} --cpan ${{ matrix.name }} | tee "$temp_file" | grep "building package" | grep -oP "(?<=in '..\/).*.deb(?=')") || { echo "Error: dh-make-perl command failed"; exit 1; }
# Check package name
if [ -z "$created_package" ]; then
echo "Error: fpm command failed"
echo "Error: dh-make-perl command failed"
exit 1
fi
# Check deb
@ -515,7 +622,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]
distrib: [bullseye, bookworm, jammy, noble]
steps:
- name: Merge Artifacts
@ -540,14 +647,14 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy]
distrib: [bullseye, bookworm, jammy, noble]
steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: packages-deb-${{ matrix.distrib }}
path: ./
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
@ -583,11 +690,15 @@ jobs:
distrib: jammy
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: ubuntu:noble
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: debian:bullseye
distrib: bullseye
arch: arm64
runner_name: ["self-hosted", "collect-arm64"]
runner_name: centreon-collect-arm64
runs-on: ${{ matrix.runner_name }}
container:
@ -595,114 +706,15 @@ jobs:
name: Test perl CPAN libs packages on ${{ matrix.package_extension }} ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- if: ${{ matrix.package_extension == 'rpm' }}
name: Install zstd, perl and Centreon repositories
run: |
dnf install -y zstd perl epel-release 'dnf-command(config-manager)'
dnf config-manager --set-enabled powertools || true # alma 8
dnf config-manager --set-enabled crb || true # alma 9
# Import Centreon GPG key
GPG_KEY_URL="https://yum-gpg.centreon.com/RPM-GPG-KEY-CES"
curl -sSL $GPG_KEY_URL -o RPM-GPG-KEY-CES
rpm --import RPM-GPG-KEY-CES
shell: bash
- if: ${{ matrix.package_extension == 'deb' }}
name: Install zstd, perl and Centreon repositories
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y zstd perl wget gpg apt-utils procps
wget -O- https://apt-key.centreon.com | gpg --dearmor | tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1
# Avoid apt to clean packages cache directory
rm -f /etc/apt/apt.conf.d/docker-clean
apt-get update
shell: bash
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Restore packages from cache
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
- name: Test packaged libs
uses: ./.github/actions/test-cpan-libs
with:
path: ./*.${{ matrix.package_extension }}
key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
fail-on-cache-miss: true
- if: ${{ matrix.package_extension == 'rpm' }}
name: Install packages
run: |
error_log="install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log"
for package in ./*.rpm; do
echo "Installing package: $package"
# List dependencies, and remove version and comparison operators
dependencies=$(rpm -qpR $package | sed 's/ [0-9.-]*\(\s\|$\)/ /g' | sed 's/ [<>!=]*\(\s\|$\)/ /g')
for dependency in $dependencies; do
# Skip non-perl dependencies
if [[ $dependency != perl* ]]; then
continue
else
echo "Check dependency: $dependency"
# Update the dependency name to match the package name
dependency=$(echo $dependency | sed 's/(/-/g' | sed 's/)//g' | sed 's/::/-/g')
fi
# If the dependency has been built in the same workflow, install it
if [[ -n $(find . -maxdepth 1 -regex "\.\/$dependency-[0-9v].*\.rpm") ]]; then
echo "Installing dependency: $dependency"
error_output=$(dnf install -y ./$dependency*.rpm 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
fi
done
# Install package, then uninstall it with all his dependencies
echo "Package installation..."
error_output=$(dnf install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
echo "Package uninstallation..."
error_output=$(dnf autoremove --setopt=keepcache=True -y $(echo $package | sed 's/_[0-9].*\.rpm//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
done
# If the file error_log exists and is not empty, the workflow is in error
if [[ -s $error_log ]]; then
cat $error_log
exit 1
fi
shell: bash
- if: ${{ matrix.package_extension == 'deb' }}
name: Install packages
run: |
error_log="install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log"
for package in ./*.deb; do
# If the debian package name ends with amd64 or arm64, we only install it if the tested architecture is the same, otherwise we skip it
if [[ $package == *amd64.deb && ${{ matrix.arch }} != "amd64" || $package == *arm64.deb && ${{ matrix.arch }} != "arm64" ]]; then
continue
fi
echo "Installing package: $package"
# List dependencies
dependencies=$(dpkg-deb -I $package | grep Depends | sed 's/Depends: //' | sed 's/,//g' | sed 's/(\(.*\)//g') || { echo "$error_output" >> $error_log; echo "Error while listing dependencies of the package $package" >> $error_log; true; }
for dependency in $dependencies; do
# If the dependency exists in the Debian repository, don't check the local dependencies
dependency_info=$(apt-cache policy $dependency)
if [[ -n $dependency_info ]]; then
echo "Dependency $dependency exists in debian repository."
else
# If the dependency has been built in the same workflow, install it
for dependency_package in $(find . -maxdepth 1 -regex "\.\/${dependency}_[0-9].*all\.deb" -o -regex "\.\/${dependency}_[0-9].*${{ matrix.arch }}\.deb"); do
echo "Installing dependency: $dependency_package"
error_output=$(apt-get install -y ./$dependency_package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the dependency $dependency" >> $error_log; true; }
done
fi
done
# Install package, then uninstall it with all his dependencies
echo "Package installation..."
error_output=$(apt-get install -y $package 2>&1) || { echo "$error_output" >> $error_log; echo "Error during installation of the package $package" >> $error_log; true; }
echo "Package installation done."
echo "Package uninstallation..."
error_output=$(apt-get autoremove -y --purge $(echo $package | sed 's/_[0-9].*\.deb//' | sed 's/.\///') 2>&1) || { echo "$error_output" >> $error_log; echo "Error during autoremove of the package $package" >> $error_log; true; }
echo "Package uninstallation done."
done
# If the file error_log exists and is not empty, the workflow is in error
if [[ -s $error_log ]]; then
cat $error_log
exit 1
fi
shell: bash
package_extension: ${{ matrix.package_extension }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
- name: Upload error log
if: failure()
@ -734,6 +746,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -1,201 +0,0 @@
name: perl-crypt-argon2
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-crypt-argon2/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- "dependencies/perl-crypt-argon2/**"
tags:
- perl-crypt-argon2-*
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-alma9
distrib: el9
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye
distrib: bullseye
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bookworm
distrib: bookworm
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-jammy
distrib: jammy
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: ["self-hosted", "collect-arm64"]
arch: arm64
runs-on: ${{ matrix.runner }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: package ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install locally Crypt::Argon2
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get update
apt-get install -y cpanminus gcc
else
dnf install -y cpanminus gcc
fi
cpanm -v -l /tmp Crypt::Argon2@0.020
shell: bash
- name: Set package name and paths according to distrib
run: |
PERL_VERSION=$(perl -E "say $^V" | sed -E "s/v([0-9]+\.[0-9]+).+/\1/g")
echo "Perl version is $PERL_VERSION"
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
NAME="libcrypt-argon2-perl"
if [ "${{ matrix.arch }}" = "amd64" ]; then
PERL_VENDORARCH="/usr/lib/x86_64-linux-gnu/perl/$PERL_VERSION"
else
PERL_VENDORARCH="/usr/lib/aarch64-linux-gnu/perl/$PERL_VERSION"
fi
else
NAME="perl-Crypt-Argon2"
if [ "${{ matrix.distrib }}" = "el8" ]; then
PERL_VENDORARCH="/usr/local/lib64/perl5"
else
PERL_VENDORARCH="/usr/local/lib64/perl5/$PERL_VERSION"
fi
fi
sed -i "s/@NAME@/$NAME/g" dependencies/perl-crypt-argon2/perl-crypt-argon2.yaml
sed -i "s#@PERL_VENDORARCH@#$PERL_VENDORARCH#g" dependencies/perl-crypt-argon2/perl-crypt-argon2.yaml
cat dependencies/perl-crypt-argon2/perl-crypt-argon2.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-crypt-argon2/perl-crypt-argon2.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
release: 1
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-crypt-argon2-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
retention-days: 1
deliver-packages:
needs: [get-environment, package]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- distrib: el8
package_extension: rpm
arch: amd64
- distrib: el9
package_extension: rpm
arch: amd64
- distrib: bullseye
package_extension: deb
arch: amd64
- distrib: bullseye
package_extension: deb
arch: arm64
- distrib: bookworm
package_extension: deb
arch: amd64
- distrib: jammy
package_extension: deb
arch: amd64
name: deliver ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: perl-crypt-argon2-${{ matrix.arch }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
cache_key: cache-${{ github.sha }}-rpm-perl-crypt-argon2-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
set-skip-label:
needs: [get-environment, deliver-packages]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/set-pull-request-skip-label.yml

View File

@ -63,7 +63,7 @@ jobs:
cp -r ~/rpmbuild/RPMS/x86_64/*.rpm .
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -97,7 +97,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -108,7 +108,7 @@ jobs:
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -129,6 +129,9 @@ jobs:
distrib: bookworm
- image: packaging-plugins-jammy
distrib: jammy
- image: packaging-plugins-noble
distrib: noble
name: package ${{ matrix.distrib }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
@ -155,7 +158,7 @@ jobs:
DEB_BUILD_OPTIONS="nocheck nodocs notest noautodbgsym" dh-make-perl make --dist ${{ matrix.distrib }} --verbose --build --version 4.0${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }} perl-filesys-smbclient/
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
@ -183,6 +186,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -1,177 +0,0 @@
name: perl-json-path
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-json-path/**"
- ".github/workflows/perl-json-path.yml"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- "dependencies/perl-json-path/**"
- ".github/workflows/perl-json-path.yml"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
package_extension: rpm
- image: packaging-plugins-alma9
distrib: el9
package_extension: rpm
- image: packaging-plugins-bullseye
distrib: bullseye
package_extension: deb
- image: packaging-plugins-bookworm
distrib: bookworm
package_extension: deb
- image: packaging-plugins-jammy
distrib: jammy
package_extension: deb
runs-on: ubuntu-22.04
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: package ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install locally JSON::Path
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get update
apt-get install -y cpanminus gcc
else
dnf install -y cpanminus gcc
fi
cpanm -v -l /tmp JSON::Path@1.0.4
shell: bash
- name: Set package name and paths according to distrib
run: |
VERSION="1.0.4"
PERL_VERSION=$(perl -E "say $^V" | sed -E "s/v([0-9]+\.[0-9]+).+/\1/g")
echo "Perl version is $PERL_VERSION"
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
NAME="libjson-path-perl"
PERL_VENDORLIB="/usr/share/perl5"
else
NAME="perl-JSON-Path"
if [ "${{ matrix.distrib }}" = "el8" ]; then
PERL_VENDORLIB="/usr/local/share/perl5"
else
PERL_VENDORLIB="/usr/local/share/perl5/$PERL_VERSION"
fi
fi
sed -i "s/@NAME@/$NAME/g" dependencies/perl-json-path/perl-json-path.yaml
sed -i "s/@VERSION@/$VERSION/g" dependencies/perl-json-path/perl-json-path.yaml
sed -i "s#@PERL_VENDORLIB@#$PERL_VENDORLIB#g" dependencies/perl-json-path/perl-json-path.yaml
cat dependencies/perl-json-path/perl-json-path.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-json-path/perl-json-path.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
release: 3
arch: all
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-json-path-${{ matrix.distrib }}-${{ github.head_ref || github.ref_name }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.${{ matrix.package_extension}}
retention-days: 1
deliver-packages:
needs: [get-environment, package]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- distrib: el8
package_extension: rpm
- distrib: el9
package_extension: rpm
- distrib: bullseye
package_extension: deb
- distrib: bookworm
package_extension: deb
- distrib: jammy
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: perl-json-path
distrib: ${{ matrix.distrib }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-json-path-${{ matrix.distrib }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
set-skip-label:
needs: [get-environment, deliver-packages]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/set-pull-request-skip-label.yml

View File

@ -50,6 +50,9 @@ jobs:
- image: packaging-plugins-jammy
distrib: jammy
package_extension: deb
- image: packaging-plugins-noble
distrib: noble
package_extension: deb
runs-on: ubuntu-22.04
@ -142,6 +145,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:

View File

@ -1,199 +0,0 @@
name: perl-libssh-session
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-libssh-session/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- "dependencies/perl-libssh-session/**"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-alma9
distrib: el9
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye
distrib: bullseye
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bookworm
distrib: bookworm
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-jammy
distrib: jammy
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: ["self-hosted", "collect-arm64"]
arch: arm64
runs-on: ${{ matrix.runner }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: package ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install locally Libssh::Session
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get update
apt-get install -y cpanminus gcc libssh-dev
else
dnf install -y cpanminus gcc libssh-devel
fi
cpanm -v -l /tmp Libssh::Session@0.8
shell: bash
- name: Set package name and paths according to distrib
run: |
PERL_VERSION=$(perl -E "say $^V" | sed -E "s/v([0-9]+\.[0-9]+).+/\1/g")
echo "Perl version is $PERL_VERSION"
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
NAME="libssh-session-perl"
if [ "${{ matrix.arch }}" = "amd64" ]; then
PERL_VENDORARCH="/usr/lib/x86_64-linux-gnu/perl/$PERL_VERSION"
else
PERL_VENDORARCH="/usr/lib/aarch64-linux-gnu/perl/$PERL_VERSION"
fi
else
NAME="perl-Libssh-Session"
if [ "${{ matrix.distrib }}" = "el8" ]; then
PERL_VENDORARCH="/usr/local/lib64/perl5"
else
PERL_VENDORARCH="/usr/local/lib64/perl5/$PERL_VERSION"
fi
fi
sed -i "s/@NAME@/$NAME/g" dependencies/perl-libssh-session/perl-libssh-session.yaml
sed -i "s#@PERL_VENDORARCH@#$PERL_VENDORARCH#g" dependencies/perl-libssh-session/perl-libssh-session.yaml
cat dependencies/perl-libssh-session/perl-libssh-session.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-libssh-session/perl-libssh-session.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
release: 5
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-libssh-session-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension}}
retention-days: 1
deliver-packages:
needs: [get-environment, package]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- distrib: el8
package_extension: rpm
arch: amd64
- distrib: el9
package_extension: rpm
arch: amd64
- distrib: bullseye
package_extension: deb
arch: amd64
- distrib: bullseye
package_extension: deb
arch: arm64
- distrib: bookworm
package_extension: deb
arch: amd64
- distrib: jammy
package_extension: deb
arch: amd64
name: deliver ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: perl-libssh-session-${{ matrix.arch }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-libssh-session-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
set-skip-label:
needs: [get-environment, deliver-packages]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/set-pull-request-skip-label.yml

View File

@ -1,199 +0,0 @@
name: perl-net-curl
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-net-curl/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- "dependencies/perl-net-curl/**"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-alma9
distrib: el9
package_extension: rpm
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye
distrib: bullseye
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bookworm
distrib: bookworm
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-jammy
distrib: jammy
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: ["self-hosted", "collect-arm64"]
arch: arm64
runs-on: ${{ matrix.runner }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: package ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install locally Net::Curl
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get update
apt-get install -y libcurl4-openssl-dev cpanminus gcc
else
dnf install -y libcurl-devel cpanminus gcc
fi
cpanm -v -l /tmp Net::Curl@0.55
shell: bash
- name: Set package name and paths according to distrib
run: |
PERL_VERSION=$(perl -E "say $^V" | sed -E "s/v([0-9]+\.[0-9]+).+/\1/g")
echo "Perl version is $PERL_VERSION"
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
NAME="libnet-curl-perl"
if [ "${{ matrix.arch }}" = "amd64" ]; then
PERL_VENDORARCH="/usr/lib/x86_64-linux-gnu/perl/$PERL_VERSION"
else
PERL_VENDORARCH="/usr/lib/aarch64-linux-gnu/perl/$PERL_VERSION"
fi
else
NAME="perl-Net-Curl"
if [ "${{ matrix.distrib }}" = "el8" ]; then
PERL_VENDORARCH="/usr/local/lib64/perl5"
else
PERL_VENDORARCH="/usr/local/lib64/perl5/$PERL_VERSION"
fi
fi
sed -i "s/@NAME@/$NAME/g" dependencies/perl-net-curl/perl-net-curl.yaml
sed -i "s#@PERL_VENDORARCH@#$PERL_VENDORARCH#g" dependencies/perl-net-curl/perl-net-curl.yaml
cat dependencies/perl-net-curl/perl-net-curl.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-net-curl/perl-net-curl.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
commit_hash: ${{ github.sha }}
release: 1
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-net-curl-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
rpm_gpg_key: ${{ secrets.RPM_GPG_SIGNING_KEY }}
rpm_gpg_signing_key_id: ${{ secrets.RPM_GPG_SIGNING_KEY_ID }}
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
# set condition to true if artifacts are needed
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.distrib }}-${{ matrix.arch }}
path: ./*.${{ matrix.package_extension }}
retention-days: 1
deliver-packages:
needs: [get-environment, package]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
(contains(fromJson('["testing", "unstable"]'), needs.get-environment.outputs.stability) || ( needs.get-environment.outputs.stability == 'stable' && github.event_name != 'workflow_dispatch')) &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- distrib: el8
package_extension: rpm
arch: amd64
- distrib: el9
package_extension: rpm
arch: amd64
- distrib: bullseye
package_extension: deb
arch: amd64
- distrib: bullseye
package_extension: deb
arch: arm64
- distrib: bookworm
package_extension: deb
arch: amd64
- distrib: jammy
package_extension: deb
arch: amd64
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: perl-net-curl-${{ matrix.arch }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-net-curl-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
set-skip-label:
needs: [get-environment, deliver-packages]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
uses: ./.github/workflows/set-pull-request-skip-label.yml

View File

@ -55,10 +55,15 @@ jobs:
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-noble
distrib: noble
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: ["self-hosted", "collect-arm64"]
runner: centreon-collect-arm64
arch: arm64
runs-on: ${{ matrix.runner }}
@ -208,7 +213,7 @@ jobs:
rpm_gpg_signing_passphrase: ${{ secrets.RPM_GPG_SIGNING_PASSPHRASE }}
stability: ${{ needs.get-environment.outputs.stability }}
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ matrix.package_extension }}
key: cache-${{ github.sha }}-${{ matrix.package_extension }}-wsman-${{ matrix.distrib }}-${{ matrix.arch }}-${{ github.head_ref || github.ref_name }}
@ -244,6 +249,10 @@ jobs:
- distrib: jammy
package_extension: deb
arch: amd64
- distrib: noble
package_extension: deb
arch: amd64
name: deliver ${{ matrix.distrib }} ${{ matrix.arch }}
steps:

View File

@ -43,7 +43,7 @@ jobs:
shell: bash
- name: Cache vsphere cli sources
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: vmware-vsphere-cli-distrib
key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere
@ -82,10 +82,15 @@ jobs:
distrib: jammy
runner: ubuntu-22.04
arch: amd64
- package_extension: deb
image: packaging-plugins-noble
distrib: noble
runner: ubuntu-22.04
arch: amd64
- package_extension: deb
image: packaging-plugins-bullseye-arm64
distrib: bullseye
runner: ["self-hosted", "collect-arm64"]
runner: centreon-collect-arm64
arch: arm64
runs-on: ${{ matrix.runner }}
@ -103,7 +108,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Import source files
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: vmware-vsphere-cli-distrib
key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere

View File

@ -57,7 +57,7 @@ jobs:
cp -r ~/rpmbuild/RPMS/x86_64/*.rpm .
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -91,7 +91,7 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
@ -102,7 +102,7 @@ jobs:
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}

View File

@ -37,7 +37,7 @@ jobs:
with:
fetch-depth: 0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.9'
@ -98,7 +98,7 @@ jobs:
strategy:
fail-fast: false
matrix:
image: [unit-tests-alma8, unit-tests-alma9, unit-tests-bullseye, unit-tests-bullseye-arm64, unit-tests-bookworm, unit-tests-jammy]
image: [unit-tests-alma8, unit-tests-alma9, unit-tests-bullseye, unit-tests-bullseye-arm64, unit-tests-bookworm, unit-tests-jammy, unit-tests-noble]
include:
- runner_name: ubuntu-24.04
- package_extension: rpm
@ -112,7 +112,7 @@ jobs:
distrib: bullseye
- package_extension: deb
image: unit-tests-bullseye-arm64
runner_name: ["self-hosted", "collect-arm64"]
runner_name: centreon-collect-arm64
distrib: bullseye
- package_extension: deb
image: unit-tests-bookworm
@ -120,6 +120,9 @@ jobs:
- package_extension: deb
image: unit-tests-jammy
distrib: jammy
- package_extension: deb
image: unit-tests-noble
distrib: noble
runs-on: ${{ matrix.runner_name }}
container:
@ -157,7 +160,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare FatPacker
uses: shogo82148/actions-setup-perl@98dfedee230bcf1ee68d5b021931fc8d63f2016e # v1.31.4
uses: shogo82148/actions-setup-perl@49c14f24551d2de3bf56fb107a869c3760b1875e # v1.33.0
with:
perl-version: '5.34'
install-modules-with: cpm
@ -168,7 +171,7 @@ jobs:
COMMIT=$(git log -1 HEAD --pretty=format:%h)
perl .github/scripts/plugins-source.container.pl "${{ needs.get-plugins.outputs.plugins }}" "${{ needs.get-environment.outputs.version }} ($COMMIT)"
- uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
@ -206,6 +209,9 @@ jobs:
- package_extension: deb
image: packaging-plugins-jammy
distrib: jammy
- package_extension: deb
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
@ -219,7 +225,7 @@ jobs:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
@ -311,7 +317,7 @@ jobs:
strategy:
fail-fast: false
matrix:
image: [testing-plugins-alma8, testing-plugins-alma9, testing-plugins-jammy, testing-plugins-bullseye, testing-plugins-bookworm]
image: [testing-plugins-alma8, testing-plugins-alma9, testing-plugins-jammy, testing-plugins-bullseye, testing-plugins-bookworm, testing-plugins-noble, testing-plugins-bullseye-arm64]
include:
- runner_name: ubuntu-24.04
- package_extension: rpm
@ -329,11 +335,14 @@ jobs:
- package_extension: deb
image: testing-plugins-jammy
distrib: jammy
- package_extension: deb
image: testing-plugins-noble
distrib: noble
- package_extension: deb
image: testing-plugins-bullseye-arm64
distrib: bullseye
arch: arm64
runner_name: ["self-hosted", "collect-arm64"]
runner_name: centreon-collect-arm64
runs-on: ${{ matrix.runner_name }}
container:
@ -385,6 +394,8 @@ jobs:
package_extension: deb
- distrib: jammy
package_extension: deb
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:
@ -406,13 +417,13 @@ jobs:
if: |
needs.get-environment.outputs.stability == 'stable' &&
github.event_name == 'push'
runs-on: [self-hosted, common]
runs-on: centreon-common
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}

View File

@ -30,7 +30,7 @@ jobs:
- added|modified: 'src/**/*.pm'
- name: Install CPAN Libraries
uses: shogo82148/actions-setup-perl@98dfedee230bcf1ee68d5b021931fc8d63f2016e # v1.31.4
uses: shogo82148/actions-setup-perl@49c14f24551d2de3bf56fb107a869c3760b1875e # v1.33.0
with:
perl-version: '5.34'
install-modules-with: cpm

19
.gitleaks.toml Normal file
View File

@ -0,0 +1,19 @@
title = "Gitleaks custom rules"
[extend]
useDefault = true
[allowlist]
paths = [
'''vendor\/''',
'''(.*?)\.rptlibrary''',
'''pnpm-lock\.yaml''',
'''\.gitleaks\.toml$''',
'''(.*?)(jpg|gif|doc|pdf|bin)$'''
]
regexTarget = "match"
regexes = [
'''ABCDEFG1234567890''',
'''s\.aBCD123DEF456GHI789JKL012'''
]

1
.version.plugins Normal file
View File

@ -0,0 +1 @@
20250303

View File

@ -26,6 +26,7 @@ import java.text.NumberFormat;
import java.util.Locale;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.SecureAS400;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.ConnectionEvent;
import com.ibm.as400.access.ConnectionListener;
@ -44,11 +45,13 @@ public abstract class AbstractHandler {
protected String host = null;
protected String login = null;
protected String password = null;
protected Integer ssl = 0;
public AbstractHandler(final String host, final String login, final String password) {
public AbstractHandler(final String host, final String login, final String password, final Integer ssl) {
this.host = host;
this.login = login;
this.password = password;
this.ssl = ssl;
}
static {
@ -77,7 +80,28 @@ public abstract class AbstractHandler {
properties.setLoginTimeout(Conf.as400LoginTimeout);
properties.setSoTimeout(Conf.as400ReadTimeout);
final AS400 system = new AS400(this.host, this.login, this.password);
if (this.ssl == 1) {
SecureAS400 system = new SecureAS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
public void connected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Connect event service : " + event.getService());
}
@Override
public void disconnected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Disconnect event service : " + event.getService());
}
});
system.validateSignon();
return (AS400)system;
}
AS400 system = new AS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override

View File

@ -34,8 +34,8 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
*/
public class CommandHandler extends AbstractHandler implements ICommandHandler {
public CommandHandler(final String host, final String login, final String password) {
super(host, login, password);
public CommandHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}
@Override

View File

@ -38,10 +38,10 @@ public class DiskHandler extends AbstractHandler implements IDiskHandler {
private QyaspolYasp0300PcmlHandler qyaspolPcmlHandler = null;
public DiskHandler(final String host, final String login, final String password)
public DiskHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
this.qyaspolPcmlHandler = new QyaspolYasp0300PcmlHandler(host, login, password);
super(host, login, password, ssl);
this.qyaspolPcmlHandler = new QyaspolYasp0300PcmlHandler(host, login, password, ssl);
}
@Override

View File

@ -37,8 +37,8 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
public class JobHandler extends AbstractHandler implements IJobHandler {
private final JobCache jobCache;
public JobHandler(final String host, final String login, final String password) {
super(host, login, password);
public JobHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
this.jobCache = new JobCache(this);
}

View File

@ -37,8 +37,8 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
*/
public class JobQueueHandler extends AbstractHandler implements IJobQueueHandler {
public JobQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public JobQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}
@Override

View File

@ -42,9 +42,9 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
*/
public class SubSystemHandler extends AbstractHandler implements ISubSystemHandler {
public SubSystemHandler(final String host, final String login, final String password)
public SubSystemHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
super(host, login, password, ssl);
}
@Override

View File

@ -45,14 +45,14 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
public class SystemHandler extends AbstractHandler implements ISystemHandler {
private SystemStatus status = null;
public SystemHandler(final String host, final String login, final String password)
public SystemHandler(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException {
this(host, login, password, null);
this(host, login, password, null, ssl);
}
public SystemHandler(final String host, final String login, final String password, SystemStatus as400Status)
public SystemHandler(final String host, final String login, final String password, SystemStatus as400Status, final Integer ssl)
throws AS400SecurityException, IOException {
super(host, login, password);
super(host, login, password, ssl);
this.status = as400Status == null ? new SystemStatus(getNewAs400()) : as400Status;
}

View File

@ -26,6 +26,7 @@ import java.util.LinkedList;
import java.util.List;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.SecureAS400;
import com.ibm.as400.access.AS400Message;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.ConnectionEvent;
@ -61,11 +62,13 @@ public class QyaspolYasp0300PcmlHandler {
String host = null;
String login = null;
String password = null;
Integer ssl = 0;
public QyaspolYasp0300PcmlHandler(final String host, final String login, final String password) {
public QyaspolYasp0300PcmlHandler(final String host, final String login, final String password, final Integer ssl) {
this.host = host;
this.login = login;
this.password = password;
this.ssl = ssl;
}
public void addYasp0300Data(final Yasp0300Data data) {
@ -238,7 +241,27 @@ public class QyaspolYasp0300PcmlHandler {
properties.setLoginTimeout(Conf.as400LoginTimeout);
properties.setSoTimeout(Conf.as400ReadTimeout);
final AS400 system = new AS400(this.host, this.login, this.password);
if (this.ssl == 1) {
SecureAS400 system = new SecureAS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override
public void connected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Connect event service : " + event.getService());
}
@Override
public void disconnected(final ConnectionEvent event) {
ConnectorLogger.getInstance().getLogger().debug("Disconnect event service : " + event.getService());
}
});
system.validateSignon();
return (AS400)system;
}
AS400 system = new AS400(this.host, this.login, this.password);
system.setSocketProperties(properties);
system.addConnectionListener(new ConnectionListener() {
@Override

View File

@ -102,8 +102,8 @@ public class CachedMessageQueueHandler extends AbstractHandler implements ICache
return sb.toString();
}
public CachedMessageQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public CachedMessageQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}
@Override

View File

@ -42,8 +42,8 @@ import com.centreon.connector.as400.dispatcher.check.ResponseData;
*/
public class MessageQueueHandler extends AbstractHandler implements IMessageQueueHandler {
public MessageQueueHandler(final String host, final String login, final String password) {
super(host, login, password);
public MessageQueueHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
}
@Override

View File

@ -69,8 +69,8 @@ public class WorkWithProblemHandler extends AbstractHandler {
private final boolean SSL = false;
private final String logPrefix;
public WorkWithProblemHandler(final String host, final String login, final String password) {
super(host, login, password);
public WorkWithProblemHandler(final String host, final String login, final String password, final Integer ssl) {
super(host, login, password, ssl);
this.logPrefix = "[" + WorkWithProblemHandler.INSTANCE_ID++ + "]";
}

View File

@ -40,5 +40,7 @@ public interface IClient {
String getAs400CheckType();
Integer getAs400Ssl();
Object getAs400Arg(String key);
}

View File

@ -42,6 +42,7 @@ abstract class AbstractClient implements IClient {
private String as400Password = null;
private String as400CheckType = null;
private String as400Args = null;
private Integer as400Ssl = 0;
private List<Map<String, String>> argList = new ArrayList<Map<String, String>>();
@Override
@ -77,6 +78,11 @@ abstract class AbstractClient implements IClient {
return this.input.getArg(key);
}
@Override
public Integer getAs400Ssl() {
return this.input.getSsl();
}
public List<Map<String , String>> getAs400ArgList(String key) {
Object arg = this.input.getArg(key);
if (arg == null) {

View File

@ -87,6 +87,7 @@ public class CheckDispatcher {
private String host = null;
private String login = null;
private String password = null;
private Integer ssl = 0;
private volatile ConcurrentHashMap<String, Long> filter = new ConcurrentHashMap<String, Long>();
@ -135,10 +136,11 @@ public class CheckDispatcher {
}
}
public CheckDispatcher(final String host, final String login, final String password) {
public CheckDispatcher(final String host, final String login, final String password, final Integer ssl) {
this.host = host;
this.login = login;
this.password = password;
this.ssl = ssl;
this.executorGlobal = new ThreadPoolExecutorPostFilter(5, 10, Conf.workerQueueTimeout, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
@ -165,6 +167,10 @@ public class CheckDispatcher {
return this.password;
}
public Integer getSsl() {
return this.ssl;
}
public synchronized void dispatch(final NetworkClient client) {
if (this.filter.containsKey(client.getRawRequest())) {
@ -190,52 +196,52 @@ public class CheckDispatcher {
public ICommandHandler getCommandHandler() throws AS400SecurityException, IOException {
if (this.commandHandler == null) {
this.commandHandler = new CommandHandler(this.host, this.login, this.password);
this.commandHandler = new CommandHandler(this.host, this.login, this.password, this.ssl);
}
return this.commandHandler;
}
public IDiskHandler getDiskHandler() throws AS400SecurityException, IOException {
if (this.diskHandler == null) {
this.diskHandler = new DiskHandler(this.host, this.login, this.password);
this.diskHandler = new DiskHandler(this.host, this.login, this.password, this.ssl);
}
return this.diskHandler;
}
public IJobHandler getJobHandler() throws AS400SecurityException, IOException {
if (this.jobHandler == null) {
this.jobHandler = new JobHandler(this.host, this.login, this.password);
this.jobHandler = new JobHandler(this.host, this.login, this.password, this.ssl);
}
return this.jobHandler;
}
public ISubSystemHandler getSubSystemHandler() throws AS400SecurityException, IOException {
if (this.subSystemHandler == null) {
this.subSystemHandler = new SubSystemHandler(this.host, this.login, this.password);
this.subSystemHandler = new SubSystemHandler(this.host, this.login, this.password, this.ssl);
}
return this.subSystemHandler;
}
public ISystemHandler getSystemHandler() throws AS400SecurityException, IOException {
if (this.systemHandler == null) {
this.systemHandler = new SystemHandler(this.host, this.login, this.password);
this.systemHandler = new SystemHandler(this.host, this.login, this.password, this.ssl);
}
return this.systemHandler;
}
public ICachedMessageQueueHandler getCachedMessageQueueHandler() throws AS400SecurityException, IOException {
return new CachedMessageQueueHandler(this.host, this.login, this.password);
return new CachedMessageQueueHandler(this.host, this.login, this.password, this.ssl);
}
public IMessageQueueHandler getMessageQueueHandler() throws AS400SecurityException, IOException {
return new MessageQueueHandler(this.host, this.login, this.password);
return new MessageQueueHandler(this.host, this.login, this.password, this.ssl);
}
public IJobQueueHandler getJobQueueHandler() throws AS400SecurityException, IOException {
return new JobQueueHandler(this.host, this.login, this.password);
return new JobQueueHandler(this.host, this.login, this.password, this.ssl);
}
public WorkWithProblemHandler getWrkPrbHandler() throws AS400SecurityException, IOException {
return new WorkWithProblemHandler(this.host, this.login, this.password);
return new WorkWithProblemHandler(this.host, this.login, this.password, this.ssl);
}
}

View File

@ -31,6 +31,7 @@ public class InputData {
private String password = null;
private String host = null;
private String command = null;
private Integer ssl = null;
Map<String, Object> args = null;
public InputData() {
@ -44,6 +45,13 @@ public class InputData {
return this.password;
}
public Integer getSsl() {
if (this.ssl == null || this.ssl == 0) {
return 0;
}
return 1;
}
public String getHost() {
return this.host;
}

View File

@ -52,37 +52,37 @@ public class ClientDispatcherImpl implements ClientDispatcher {
}
private synchronized CheckDispatcher createNewCheckDispatcher(final String host, final String login,
final String password) throws AS400SecurityException, IOException, DelayedConnectionException, Exception {
final String password, final Integer ssl) throws AS400SecurityException, IOException, DelayedConnectionException, Exception {
ConnectorLogger.getInstance().info("create new As400 : " + host);
CheckDispatcher resource = null;
resource = new CheckDispatcher(host, login, password);
resource = new CheckDispatcher(host, login, password, ssl);
this.pool.put(resource, System.currentTimeMillis());
return resource;
}
private CheckDispatcher getAs400(final String host, final String login, final String password)
private CheckDispatcher getAs400(final String host, final String login, final String password, final Integer ssl)
throws AS400SecurityException, IOException, DelayedConnectionException, Exception {
for (final CheckDispatcher resource : this.pool.keySet()) {
if (resource.getHost().equalsIgnoreCase(host) && resource.getLogin().equalsIgnoreCase(login)
&& resource.getPassword().equalsIgnoreCase(password)) {
&& resource.getPassword().equalsIgnoreCase(password) && resource.getSsl() == ssl) {
this.pool.put(resource, System.currentTimeMillis());
return resource;
}
}
return this.createNewCheckDispatcher(host, login, password);
return this.createNewCheckDispatcher(host, login, password, ssl);
}
@Override
public synchronized void dispatch(final NetworkClient client)
throws AS400SecurityException, IOException, DelayedConnectionException, Exception {
final CheckDispatcher checkDispatcher = this.getAs400(client.getAs400Host(), client.getAs400Login(),
client.getAs400Password());
client.getAs400Password(), client.getAs400Ssl());
checkDispatcher.dispatch(client);
}
}

View File

@ -35,7 +35,7 @@ public class SystemHandlerTest {
try {
SystemStatus as400 = mock(SystemStatus.class);
when(as400.getSystemPools()).thenReturn(new Vector<Object>().elements());
SystemHandler sh = new SystemHandler(null, null, null, as400);
SystemHandler sh = new SystemHandler(null, null, null, as400, null);
sh.dumpSystem();
} finally {
System.setOut(originalOut);

View File

@ -1,77 +0,0 @@
name: "@NAME@"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
version: "0.020"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
This module implements the Argon2 key derivation function, which is suitable to convert any password into a cryptographic key.
This is most often used to for secure storage of passwords but can also be used to derive a encryption key from a password.
It offers variable time and memory costs as well as output size.
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://www.centreon.com"
license: "Apache-2.0"
contents:
- src: "/tmp/bin/argon2-calibrate"
dst: "/usr/local/bin/"
file_info:
mode: 0755
packager: rpm
- src: "/tmp/bin/argon2-calibrate"
dst: "/usr/bin/"
file_info:
mode: 0755
packager: deb
- src: "/tmp/lib/perl5/*/auto/Crypt/Argon2/"
dst: "@PERL_VENDORARCH@/auto/Crypt/Argon2/"
file_info:
mode: 0644
- src: "/tmp/lib/perl5/*/Crypt/Argon2.pm"
dst: "@PERL_VENDORARCH@/Crypt/"
file_info:
mode: 0644
- src: "/tmp/man/man3/Crypt::Argon2*"
dst: "/usr/share/man/man3/"
file_info:
mode: 0644
overrides:
rpm:
depends:
- perl(Exporter)
- perl(Time::HiRes)
- perl(XSLoader)
- perl(strict)
- perl(warnings)
conflicts:
- perl-Crypt-Argon2-debuginfo
replaces:
- perl-Crypt-Argon2-debuginfo
provides:
- perl-Crypt-Argon2-debuginfo
- perl(Crypt::Argon2)
deb:
depends:
- perl
- libc6
conflicts:
- libcrypt-argon2-perl-dbgsym
replaces:
- libcrypt-argon2-perl-dbgsym
provides:
- libcrypt-argon2-perl-dbgsym
rpm:
summary: Perl interface to the Argon2 key derivation functions
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -1,63 +0,0 @@
name: "@NAME@"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
version: "@VERSION@"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
This module implements JSONPath, an XPath-like language for searching JSON-like structures.
JSONPath is described at http://goessner.net/articles/JsonPath/.
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://www.centreon.com"
license: "Apache-2.0"
contents:
- src: "/tmp/lib/perl5/JSON/Path.pm"
dst: "@PERL_VENDORLIB@/JSON/"
file_info:
mode: 0644
- src: "/tmp/lib/perl5/JSON/Path/"
dst: "@PERL_VENDORLIB@/JSON/Path/"
file_info:
mode: 0644
- src: "/tmp/man/man3/JSON::Path*"
dst: "/usr/share/man/man3/"
file_info:
mode: 0644
overrides:
rpm:
depends:
- perl(Carp::Assert)
- perl(Exporter::Tiny)
- perl(JSON::MaybeXS)
- perl(JSON::Parse)
- perl(LV)
- perl(List::Util)
- perl(Readonly)
- perl(Tie::IxHash)
- perl(Try::Tiny)
provides:
- perl(JSON::Path)
deb:
depends:
- libcarp-assert-perl
- libexporter-tiny-perl
- libjson-parse-perl
- liblv-perl
- libreadonly-perl
- libtie-ixhash-perl
- libtry-tiny-perl
rpm:
summary: This module implements JSONPath, an XPath-like language for searching JSON-like structures
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -1,64 +0,0 @@
name: "@NAME@"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
version: "0.8"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
Perl interface to the libssh library
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://www.centreon.com"
license: "Apache-2.0"
contents:
- src: "/tmp/lib/perl5/*/auto/Libssh/Session/Session.so"
dst: "@PERL_VENDORARCH@/auto/Libssh/Session/"
file_info:
mode: 0644
- src: "/tmp/lib/perl5/*/Libssh/"
dst: "@PERL_VENDORARCH@/Libssh/"
file_info:
mode: 0644
- src: "/tmp/man/man3/Libssh::*"
dst: "/usr/share/man/man3/"
file_info:
mode: 0644
overrides:
rpm:
depends:
- perl-interpreter
- libssh
conflicts:
- perl-Libssh-Session-debuginfo
replaces:
- perl-Libssh-Session-debuginfo
provides:
- perl-Libssh-Session-debuginfo
- perl(Libssh::Session)
- perl(Libssh::Sftp)
deb:
depends:
- perl
- libc6
- libssh-4
conflicts:
- libssh-session-perl-dbgsym
replaces:
- libssh-session-perl-dbgsym
provides:
- libssh-session-perl-dbgsym
- libssh-session-sftp
rpm:
summary: Perl interface to the libssh library
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -1,78 +0,0 @@
name: "@NAME@"
arch: "${ARCH}"
platform: "linux"
version_schema: "none"
version: "0.55"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
Net::Curl provides a Perl interface to libcurl created with object-oriented implementations in mind.
This documentation contains Perl-specific details and quirks.
For more information consult libcurl man pages and documentation at http://curl.haxx.se.
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://www.centreon.com"
license: "Apache-2.0"
contents:
- src: "/tmp/lib/perl5/*/auto/Net/Curl/Curl.so"
dst: "@PERL_VENDORARCH@/auto/Net/Curl/"
file_info:
mode: 0644
- src: "/tmp/lib/perl5/*/Net/Curl.pm"
dst: "@PERL_VENDORARCH@/Net/"
file_info:
mode: 0644
- src: "/tmp/lib/perl5/*/Net/Curl/"
dst: "@PERL_VENDORARCH@/Net/Curl/"
file_info:
mode: 0644
- src: "/tmp/man/man3/Net::Curl*"
dst: "/usr/share/man/man3/"
file_info:
mode: 0644
overrides:
rpm:
depends:
- perl-interpreter
- libcurl
conflicts:
- perl-Net-Curl-debuginfo
replaces:
- perl-Net-Curl-debuginfo
provides:
- perl-Net-Curl-debuginfo
- perl(Net::Curl)
- perl(Net::Curl::Compat)
- perl(Net::Curl::Easy)
- perl(Net::Curl::Form)
- perl(Net::Curl::Share)
- perl(Net::Curl::Multi)
deb:
depends:
- perl
- libcurl4
conflicts:
- libnet-curl-perl-dbgsym
replaces:
- libnet-curl-perl-dbgsym
provides:
- libnet-curl-perl-dbgsym
- libnet-curl-compat-perl
- libnet-curl-easy-perl
- libnet-curl-form-perl
- libnet-curl-share-perl
- libnet-curl-multi-perl
rpm:
summary: Perl interface for libcurl
compression: zstd
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

View File

@ -0,0 +1,4 @@
{
"dependencies": [
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Applications-Exense-Step-Restapi",
"pkg_summary": "Centreon Plugin",
"plugin_name": "centreon_exense_step_restapi.pl",
"files": [
"centreon/plugins/script_custom.pm",
"apps/exense/step/restapi/"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(DateTime)"
]
}

View File

@ -5,9 +5,12 @@
"files": [
"centreon/plugins/script_snmp.pm",
"centreon/plugins/snmp.pm",
"snmp_standard/mode/interfaces.pm",
"snmp_standard/mode/listinterfaces.pm",
"snmp_standard/mode/listspanningtrees.pm",
"snmp_standard/mode/resources/",
"snmp_standard/mode/interfaces.pm",
"snmp_standard/mode/spanningtree.pm",
"snmp_standard/mode/uptime.pm",
"network/aruba/aoscx/snmp/"
]
}

View File

@ -0,0 +1,4 @@
{
"dependencies": [
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Notification-Foxbox",
"pkg_summary": "Centreon Plugin to send notifications by Foxbox",
"plugin_name": "centreon_notification_foxbox.pl",
"files": [
"centreon/plugins/script_simple.pm",
"notification/foxbox"
]
}

View File

@ -0,0 +1,4 @@
{
"dependencies": [
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"liburi-encode-perl"
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Notification-Jasminsms-Httpapi",
"pkg_summary": "Centreon Plugin to send notifications by Jasmin SMS HTTP-API",
"plugin_name": "centreon_notification_jasminsms-httpapi.pl",
"files": [
"centreon/plugins/script_custom.pm",
"notification/jasminsms/httpapi"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(URI::Encode)"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"libjson-perl"
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Notification-Ovhsms",
"pkg_summary": "Centreon Plugin to send notifications by OVH SMS API",
"plugin_name": "centreon_notification_ovhsms.pl",
"files": [
"centreon/plugins/script_simple.pm",
"notification/ovhsms"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(JSON::XS)"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"libjson-perl"
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Notification-Telegram",
"pkg_summary": "Centreon Plugin to send notifications by Telegram",
"plugin_name": "centreon_notification_telegram.pl",
"files": [
"centreon/plugins/script_simple.pm",
"notification/telegram"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(JSON::XS)"
]
}

View File

@ -310,11 +310,11 @@ Filter job type (can be a regexp).
=item B<--filter-start-time>
Filter job with start time greater than current time less value in seconds.
Tolerance value in seconds, to avoid skipping jobs whose start time is earlier than the current time.
=item B<--filter-end-time>
Filter job with end time greater than current time less value in seconds (default: 86400).
Tolerance value in seconds, to avoid skipping jobs whose end time is earlier than the current time (default: 86400).
=item B<--ok-status>

View File

@ -251,6 +251,7 @@ sub cache_backup_job_session {
return $datas;
}
sub cache_repository {
my ($self, %options) = @_;
@ -281,6 +282,24 @@ sub get_backup_job_session {
);
}
sub get_replica_job_session {
my ($self, %options) = @_;
return $self->get_cache_file_response(statefile => 'replica_job_session')
if (defined($self->{option_results}->{cache_use}) && !defined($options{disable_cache}));
my $creation_time = DateTime->now->subtract(seconds => $options{timeframe})->iso8601();
return $self->request_api(
endpoint => '/api/query',
get_param => [
'type=ReplicaJobSession',
'format=Entities',
'filter=CreationTime>=' . $creation_time
]
);
}
sub get_repository {
my ($self, %options) = @_;

View File

@ -229,6 +229,7 @@ sub manage_selection {
my ($self, %options) = @_;
my $jobs_exec = $options{custom}->get_backup_job_session(timeframe => $self->{option_results}->{timeframe});
my $jobs_replica = $options{custom}->get_replica_job_session(timeframe => $self->{option_results}->{timeframe});
my $ctime = time();
@ -278,6 +279,50 @@ sub manage_selection {
$self->{jobs}->{ $job->{JobUid} }->{failed}->{failed}++;
}
}
foreach my $job (@{$jobs_replica->{Entities}->{ReplicaJobSessions}->{ReplicaJobSessions}}) {
next if (defined($self->{option_results}->{filter_uid}) && $self->{option_results}->{filter_uid} ne '' && $job->{JobUid} !~ /$self->{option_results}->{filter_uid}/);
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $job->{JobName} !~ /$self->{option_results}->{filter_name}/);
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && $job->{JobType} !~ /$self->{option_results}->{filter_type}/);
if (!defined($self->{jobs}->{ $job->{JobUid} })) {
$self->{jobs}->{ $job->{JobUid} } = {
name => $job->{JobName},
type => $job->{JobType},
failed => { name => $job->{JobName}, total => 0, failed => 0 }
};
$self->{global}->{detected}++;
}
$job->{CreationTimeUTC} =~ /^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)/;
my $dt = DateTime->new(year => $1, month => $2, day => $3, hour => $4, minute => $5, second => $6);
my $epoch = $dt->epoch();
if (!defined($self->{jobs}->{ $job->{JobUid} }->{executions}) || $epoch > $self->{jobs}->{ $job->{JobUid} }->{executions}->{last}->{epoch}) {
$self->{jobs}->{ $job->{JobUid} }->{executions}->{last} = {
jobName => $job->{JobName},
started => $job->{CreationTimeUTC},
status => $job->{Result},
epoch => $epoch
};
$self->{jobs}->{ $job->{JobUid} }->{timers} = {
name => $job->{JobName},
lastExecSeconds => $ctime - $epoch,
lastExecHuman => centreon::plugins::misc::change_seconds(value => $ctime - $epoch)
};
if ($job->{State} =~ /Starting|Working|Resuming/i) {
my $duration = $ctime - $epoch;
$self->{jobs}->{ $job->{JobUid} }->{timers}->{durationSeconds} = $duration;
$self->{jobs}->{ $job->{JobUid} }->{timers}->{durationHuman} = centreon::plugins::misc::change_seconds(value => $duration);
}
}
$self->{jobs}->{ $job->{JobUid} }->{failed}->{total}++;
if (defined($job->{Result}) && $job->{Result} =~ /Failed/i) {
$self->{jobs}->{ $job->{JobUid} }->{failed}->{failed}++;
}
}
foreach my $uid (keys %{$self->{jobs}}) {
$self->{jobs}->{$uid}->{failed}->{failedPrct} = $self->{jobs}->{$uid}->{failed}->{total} > 0 ? $self->{jobs}->{$uid}->{failed}->{failed} * 100 / $self->{jobs}->{$uid}->{failed}->{total} : 0;
@ -308,7 +353,7 @@ Filter jobs by type.
=item B<--timeframe>
Timeframe to get BackupJobSession (in seconds. Default: 86400).
Timeframe to get BackupJobSession and ReplicaJobSession (in seconds. Default: 86400).
=item B<--unit>

View File

@ -51,6 +51,8 @@ sub manage_selection {
my $results = {};
my $jobs_exec = $options{custom}->cache_backup_job_session(timeframe => $self->{option_results}->{timeframe});
my $jobs_replica = $options{custom}->get_replica_job_session(timeframe => $self->{option_results}->{timeframe});
foreach my $job (@{$jobs_exec->{Entities}->{BackupJobSessions}->{BackupJobSessions}}) {
next if (defined($results->{ $job->{JobUid} }));
@ -60,6 +62,15 @@ sub manage_selection {
}
}
foreach my $job (@{$jobs_replica->{Entities}->{ReplicaJobSessions}->{ReplicaJobSessions}}) {
next if (defined($results->{ $job->{JobUid} }));
$results->{ $job->{JobUid} } = {
jobName => $job->{JobName},
jobType => $job->{JobType}
}
}
return $results;
}
@ -67,7 +78,7 @@ sub run {
my ($self, %options) = @_;
my $results = $self->manage_selection(%options);
foreach my $uid (keys %$results) {
foreach my $uid (sort keys %$results) {
$self->{output}->output_add(
long_msg => sprintf(
'[uid: %s][jobName: %s][jobType: %s]',
@ -117,7 +128,7 @@ List jobs.
=item B<--timeframe>
Timeframe to get BackupJobSession (in seconds. Default: 86400).
Timeframe to get BackupJobSession and ReplicaJobSession (in seconds. Default: 86400).
=back

View File

@ -38,7 +38,7 @@ sub set_counters {
{ label => 'clients-' . $label,
nlabel => 'clients.' . $label . '.count',
set => {
key_values => [{ name => $label }],
key_values => [ { name => $label } ],
output_template => ucfirst($label) . ' clients: %d',
perfdatas => [
{ label => $label . '_clients', template => '%d',
@ -51,7 +51,7 @@ sub set_counters {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
return $self;
@ -62,7 +62,7 @@ sub manage_selection {
my %results = $options{mqtt}->queries(
base_topic => '$SYS/broker/clients/',
topics => ['connected', 'maximum', 'active', 'inactive']
topics => [ 'connected', 'maximum', 'active', 'inactive' ]
);
for my $topic (keys %results) {
@ -80,10 +80,37 @@ Check clients statistics.
=over 8
=item B<--warning-*> B<--critical-*>
=item B<--warning-clients-connected>
Thresholds.
Can be: 'clients-connected', 'clients-maximum', 'clients-active', 'clients-inactive'.
Warning threshold for connected clients.
=item B<--critical-clients-connected>
Critical threshold for connected clients.
=item B<--warning-clients-maximum>
Warning threshold for maximum clients.
=item B<--critical-clients-maximum>
Critical threshold for maximum clients.
=item B<--warning-clients-active>
Warning threshold for active clients.
=item B<--critical-clients-active>
Critical threshold for active clients.
=item B<--warning-clients-inactive>
Warning threshold for inactive clients.
=item B<--critical-clients-inactive>
Critical threshold for inactive clients.
=back

View File

@ -38,7 +38,7 @@ sub set_counters {
{ label => 'messages-' . $label,
nlabel => 'messages.' . $label . '.count',
set => {
key_values => [{ name => $label }],
key_values => [ { name => $label } ],
output_template => ucfirst($label) . ' messages: %d',
perfdatas => [
{ label => $label . '_messages', template => '%d',
@ -51,7 +51,7 @@ sub set_counters {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
return $self;
@ -62,7 +62,7 @@ sub manage_selection {
my %results = $options{mqtt}->queries(
base_topic => '$SYS/broker/messages/',
topics => ['stored', 'received', 'sent']
topics => [ 'stored', 'received', 'sent' ]
);
for my $topic (keys %results) {
$self->{global}->{$topic} = $results{$topic};
@ -79,10 +79,29 @@ Check messages statistics.
=over 8
=item B<--warning-*> B<--critical-*>
=item B<--warning-messages-stored>
Thresholds.
Can be: 'messages-stored', 'messages-received', 'messages-sent'.
Warning threshold for stored messages.
=item B<--critical-messages-stored>
Critical threshold for stored messages.
=item B<--warning-messages-received>
Warning threshold for received messages.
=item B<--critical-messages-received>
Critical threshold for received messages.
=item B<--warning-messages-sent>
Warning threshold for sent messages.
=item B<--critical-messages-sent>
Critical threshold for sent messages.
=back

View File

@ -30,13 +30,13 @@ use POSIX qw(floor);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'topic:s' => { name => 'topic' },
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' },
'warning:s' => { name => 'warning', redirect => 'warning-generic' },
'critical:s' => { name => 'critical', redirect => 'critical-generic' },
'extracted-pattern:s' => { name => 'extracted_pattern' },
'format:s' => { name => 'format' },
'format-custom:s' => { name => 'format_custom' },
@ -57,25 +57,20 @@ sub custom_generic_output {
$format = $self->{instance_mode}{option_results}->{format};
}
my $value = $self->{result_values}->{numericvalue};
if (!centreon::plugins::misc::is_empty($self->{instance_mode}{option_results}->{format_custom})) {
$value = eval "$value $self->{instance_mode}{option_results}->{format_custom}";
}
return sprintf($format, $value);
return sprintf($format, $self->{result_values}->{numericvalue});
}
sub custom_generic_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
label => $options{option_results}->{perfdata_name},
unit => $options{option_results}->{perfdata_unit},
label => $self->{instance_mode}->{option_results}->{perfdata_name},
unit => $self->{instance_mode}->{option_results}->{perfdata_unit},
value => $self->{result_values}->{numericvalue},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => $options{option_results}->{perfdata_min},
max => $options{option_results}->{perfdata_max}
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-generic'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-generic'),
min => $self->{instance_mode}->{option_results}->{perfdata_min},
max => $self->{instance_mode}->{option_results}->{perfdata_max}
);
}
@ -85,9 +80,9 @@ sub custom_generic_threshold {
return $self->{perfdata}->threshold_check(
value => $self->{result_values}->{numericvalue},
threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' },
{ label => 'unknown-' . $self->{thlabel}, exit_litteral => 'unknown' }
{ label => 'critical-generic', exit_litteral => 'critical' },
{ label => 'warning-generic', exit_litteral => 'warning' },
{ label => 'unknown-generic', exit_litteral => 'unknown' }
]
);
}
@ -102,7 +97,7 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'generic',
set => {
key_values => [{ name => 'numericvalue' }],
key_values => [ { name => 'numericvalue' } ],
closure_custom_output => $self->can('custom_generic_output'),
closure_custom_perfdata => $self->can('custom_generic_perfdata'),
closure_custom_threshold_check => $self->can('custom_generic_threshold')
@ -146,6 +141,10 @@ sub manage_selection {
$self->{output}->option_exit();
}
if (!centreon::plugins::misc::is_empty($self->{option_results}->{format_custom})) {
$value = eval "$value $self->{option_results}->{format_custom}";
}
$self->{global} = { numericvalue => $value };
}
@ -177,7 +176,7 @@ Define a pattern to extract a number from the returned string.
=item B<--format>
Output format (default: 'current value is %s')
Output format (default: 'current value is %s').
=item B<--format-custom>
@ -186,19 +185,19 @@ Apply a custom change on the value
=item B<--perfdata-unit>
Perfdata unit in perfdata output (default: '')
Perfdata unit in perfdata output (default: '').
=item B<--perfdata-name>
Perfdata name in perfdata output (default: 'value')
Perfdata name in perfdata output (default: 'value').
=item B<--perfdata-min>
Minimum value to add in perfdata output (default: '')
Minimum value to add in perfdata output (default: '').
=item B<--perfdata-max>
Maximum value to add in perfdata output (default: '')
Maximum value to add in perfdata output (default: '').
=back

View File

@ -28,7 +28,7 @@ use centreon::plugins::misc;
use Time::HiRes qw(time);
use POSIX qw(floor);
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
my $unitdiv_long = { s => 'seconds', w => 'weeks', d => 'days', h => 'hours', m => 'minutes' };
sub custom_uptime_output {
@ -76,7 +76,7 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'uptime',
set => {
key_values => [{ name => 'uptime' }],
key_values => [ { name => 'uptime' } ],
closure_custom_output => $self->can('custom_uptime_output'),
closure_custom_perfdata => $self->can('custom_uptime_perfdata'),
closure_custom_threshold_check => $self->can('custom_uptime_threshold')
@ -87,7 +87,7 @@ sub set_counters {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
@ -109,7 +109,7 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $topic = '$SYS/broker/uptime';
my $topic = '$SYS/broker/uptime';
my $uptime = $options{mqtt}->query(
topic => $topic
);

View File

@ -0,0 +1,319 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::exense::step::restapi::custom::api;
use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON::XS;
use Digest::MD5 qw(md5_hex);
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'api-username:s' => { name => 'api_username' },
'api-password:s' => { name => 'api_password' },
'token:s' => { name => 'token' },
'timeout:s' => { name => 'timeout' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl');
$self->{cache_connect} = centreon::plugins::statefile->new(%options);
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : '';
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
$self->{token} = (defined($self->{option_results}->{token})) ? $self->{option_results}->{token} : '';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300' ;
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
if ($self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => 'Need to specify hostname option.');
$self->{output}->option_exit();
}
if ($self->{token} ne '') {
return 0;
}
if ($self->{api_username} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-username or --token option.");
$self->{output}->option_exit();
}
if ($self->{api_password} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
$self->{output}->option_exit();
}
$self->{cache_connect}->check_options(option_results => $self->{option_results});
return 0;
}
sub get_connection_infos {
my ($self, %options) = @_;
return $self->{hostname} . '_' . $self->{http}->get_port();
}
sub get_hostname {
my ($self, %options) = @_;
return $self->{hostname};
}
sub get_port {
my ($self, %options) = @_;
return $self->{port};
}
sub build_options_for_httplib {
my ($self, %options) = @_;
$self->{option_results}->{hostname} = $self->{hostname};
$self->{option_results}->{port} = $self->{port};
$self->{option_results}->{proto} = $self->{proto};
}
sub settings {
my ($self, %options) = @_;
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
$self->{http}->set_options(%{$self->{option_results}});
}
sub clean_session_id {
my ($self, %options) = @_;
my $datas = { updated => time() };
$self->{cache_connect}->write(data => $datas);
}
sub get_session_id {
my ($self, %options) = @_;
my $has_cache_file = $self->{cache_connect}->read(statefile => 'exense_step_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username}));
my $session_id = $self->{cache_connect}->get(name => 'session_id');
my $md5_secret_cache = $self->{cache_connect}->get(name => 'md5_secret');
my $md5_secret = md5_hex($self->{api_username} . $self->{api_password});
if ($has_cache_file == 0 ||
!defined($session_id) ||
(defined($md5_secret_cache) && $md5_secret_cache ne $md5_secret)
) {
my $json_request = { username => $self->{api_username}, password => $self->{api_password} };
my $encoded = centreon::plugins::misc::json_encode($json_request);
unless($encoded) {
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
$self->{output}->option_exit();
}
my ($content) = $self->{http}->request(
method => 'POST',
url_path => '/rest/access/login',
query_form_post => $encoded,
warning_status => '', unknown_status => '', critical_status => ''
);
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => "Authentication error [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}
my (@cookies) = $self->{http}->get_first_header(name => 'Set-Cookie');
foreach my $cookie (@cookies) {
$session_id = $1 if ($cookie =~ /sessionid=(.+?);/);
}
if (!defined($session_id)) {
$self->{output}->add_option_msg(short_msg => "Cannot get cookie");
$self->{output}->option_exit();
}
my $datas = {
updated => time(),
session_id => $session_id,
md5_secret => $md5_secret
};
$self->{cache_connect}->write(data => $datas);
}
return $session_id;
}
sub credentials {
my ($self, %options) = @_;
my $creds = {};
if ($self->{token} ne '') {
$creds = {
header => ['Authorization: Bearer ' . $self->{token}],
unknown_status => $self->{unknown_http_status},
warning_status => $self->{warning_http_status},
critical_status => $self->{critical_http_status}
};
} else {
my $session_id = $self->get_session_id();
$creds = {
header => ['Cookie: sessionid=' . $session_id],
warning_status => '',
unknown_status => '',
critical_status => ''
};
}
return $creds;
}
sub request {
my ($self, %options) = @_;
my $endpoint = $options{endpoint};
$self->settings();
my $creds = $self->credentials();
my $content = $self->{http}->request(
method => $options{method},
url_path => $endpoint,
get_param => $options{get_param},
query_form_post => $options{query_form_post},
%$creds
);
# Maybe there is an issue with the token. So we retry.
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
$self->clean_session_id();
$creds = $self->credentials();
$creds->{unknown_status} = $self->{unknown_http_status};
$creds->{warning_status} = $self->{warning_status};
$creds->{critical_http_status} = $self->{critical_http_status};
$content = $self->{http}->request(
method => $options{method},
url_path => $endpoint,
get_param => $options{get_param},
query_form_post => $options{query_form_post},
%$creds
);
}
return if (defined($options{skip_decode}));
my $decoded = centreon::plugins::misc::json_decode($content);
if (!defined($decoded)) {
$self->{output}->add_option_msg(short_msg => 'Error while retrieving data (add --debug option for detailed message)');
$self->{output}->option_exit();
}
return $decoded;
}
1;
__END__
=head1 NAME
Exense Step API
=head1 SYNOPSIS
Exense Step API
=head1 REST API OPTIONS
=over 8
=item B<--hostname>
API hostname.
=item B<--port>
API port (default: 443)
=item B<--proto>
Specify https if needed (default: 'https')
=item B<--token>
Use token authentication.
=item B<--api-username>
Set API username
=item B<--api-password>
Set API password
=item B<--timeout>
Set HTTP timeout
=back
=head1 DESCRIPTION
B<custom>.
=cut

View File

@ -0,0 +1,147 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::exense::step::restapi::mode::listplans;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'tenant-name:s' => { name => 'tenant_name' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{tenant_name}) || $self->{option_results}->{tenant_name} eq '') {
$self->{option_results}->{tenant_name} = '[All]';
}
}
sub manage_selection {
my ($self, %options) = @_;
my $payload = $self->{option_results}->{tenant_name};
$options{custom}->request(method => 'POST', endpoint => '/rest/tenants/current', query_form_post => $payload, skip_decode => 1);
$payload = {
skip => 0,
limit => 4000000,
filters => [
{
collectionFilter => { type => 'True', field => 'visible' }
}
],
'sort' => {
'field' => 'attributes.name',
'direction' => 'ASCENDING'
}
};
$payload = centreon::plugins::misc::json_encode($payload);
unless($payload) {
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
$self->{output}->option_exit();
}
my $plans = $options{custom}->request(method => 'POST', endpoint => '/rest/table/plans', query_form_post => $payload);
my $results = [];
foreach my $plan (@{$plans->{data}}) {
# skip plans created by keyword single execution
next if ($plan->{visible} =~ /false|0/);
push @$results, {
id => $plan->{id},
name => $plan->{attributes}->{name}
};
}
return $results;
}
sub run {
my ($self, %options) = @_;
my $results = $self->manage_selection(%options);
foreach (@$results) {
$self->{output}->output_add(
long_msg => sprintf(
'[id: %s][name: %s]',
$_->{id},
$_->{name}
)
);
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List plans:'
);
$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 => ['id', 'name']);
}
sub disco_show {
my ($self, %options) = @_;
my $results = $self->manage_selection(%options);
foreach (@$results) {
$self->{output}->add_disco_entry(
id => $_->{id},
name => $_->{name}
);
}
}
1;
__END__
=head1 MODE
List plans.
=over 8
=item B<--tenant-name>
Check plan of a tenant (default: '[All]').
=back
=cut

View File

@ -0,0 +1,111 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::exense::step::restapi::mode::listtenants;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $tenants = $options{custom}->request(method => 'GET', endpoint => '/rest/tenants');
my $results = [];
foreach my $tenant (@$tenants) {
push @$results, {
name => $tenant->{name},
projectId => defined($tenant->{projectId}) ? $tenant->{projectId} : '',
global => $tenant->{global} =~ /true|1/i ? 1 : 0
};
}
return $results;
}
sub run {
my ($self, %options) = @_;
my $results = $self->manage_selection(%options);
foreach (@$results) {
$self->{output}->output_add(
long_msg => sprintf(
'[name: %s][projectId: %s][global: %s]',
$_->{name},
$_->{projectId},
$_->{global}
)
);
}
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List tenants:'
);
$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 => ['name', 'projectId', 'global']);
}
sub disco_show {
my ($self, %options) = @_;
my $results = $self->manage_selection(%options);
foreach (@$results) {
$self->{output}->add_disco_entry(%$_);
}
}
1;
__END__
=head1 MODE
List tenants.
=over 8
=back
=cut

View File

@ -0,0 +1,507 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::exense::step::restapi::mode::plans;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use DateTime;
use POSIX;
use JSON::XS;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use centreon::plugins::misc;
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
my $unitdiv_long = { s => 'seconds', w => 'weeks', d => 'days', h => 'hours', m => 'minutes' };
sub custom_last_exec_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel} . '.' . $unitdiv_long->{ $self->{instance_mode}->{option_results}->{unit} },
instances => $self->{result_values}->{name},
unit => $self->{instance_mode}->{option_results}->{unit},
value => $self->{result_values}->{lastExecSeconds} >= 0 ? floor($self->{result_values}->{lastExecSeconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }) : $self->{result_values}->{lastExecSeconds},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0
);
}
sub custom_last_exec_threshold {
my ($self, %options) = @_;
return $self->{perfdata}->threshold_check(
value => $self->{result_values}->{lastExecSeconds} >= 0 ? floor($self->{result_values}->{lastExecSeconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }) : $self->{result_values}->{lastExecSeconds},
threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' },
{ label => 'unknown-'. $self->{thlabel}, exit_litteral => 'unknown' }
]
);
}
sub custom_duration_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel} . '.' . $unitdiv_long->{ $self->{instance_mode}->{option_results}->{unit} },
instances => $self->{result_values}->{name},
unit => $self->{instance_mode}->{option_results}->{unit},
value => floor($self->{result_values}->{durationSeconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0
);
}
sub custom_duration_threshold {
my ($self, %options) = @_;
return $self->{perfdata}->threshold_check(
value => floor($self->{result_values}->{durationSeconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' },
{ label => 'unknown-'. $self->{thlabel}, exit_litteral => 'unknown' }
]
);
}
sub custom_execution_status_output {
my ($self, %options) = @_;
return sprintf(
"result: %s, status: %s",
$self->{result_values}->{result},
$self->{result_values}->{status}
);
}
sub plan_long_output {
my ($self, %options) = @_;
return sprintf(
"checking plan '%s'",
$options{instance_value}->{name}
);
}
sub prefix_plan_output {
my ($self, %options) = @_;
my $plan_name = defined $options{instance_value}->{name} ? $options{instance_value}->{name} : 'unknown';
return sprintf("plan '%s' ", $plan_name);
}
sub prefix_global_output {
my ($self, %options) = @_;
return 'Number of plans ';
}
sub prefix_execution_output {
my ($self, %options) = @_;
return sprintf(
"execution '%s' [env: %s] [started: %s] ",
$options{instance_value}->{executionId},
$options{instance_value}->{environment},
$options{instance_value}->{started}
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'plans', type => 3, cb_prefix_output => 'prefix_plan_output', cb_long_output => 'prefix_plan_output', indent_long_output => ' ', message_multiple => 'All plans are ok',
group => [
{ name => 'exec_detect', type => 0 },
{ name => 'failed', type => 0 },
{ name => 'timers', type => 0, skipped_code => { -10 => 1 } },
{ name => 'executions', type => 1, cb_prefix_output => 'prefix_execution_output', message_multiple => 'executions are ok', display_long => 1, sort_method => 'num', skipped_code => { -10 => 1 } }
]
}
];
$self->{maps_counters}->{global} = [
{ label => 'plans-detected', display_ok => 0, nlabel => 'plans.detected.count', set => {
key_values => [ { name => 'detected' } ],
output_template => 'detected: %s',
perfdatas => [
{ template => '%s', min => 0 }
]
}
}
];
$self->{maps_counters}->{exec_detect} = [
{ label => 'plan-executions-detected', nlabel => 'plan.executions.detected.count', set => {
key_values => [ { name => 'detected' }, { name => 'name' } ],
output_template => 'number of plan executions detected: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'name' }
]
}
}
];
$self->{maps_counters}->{failed} = [
{ label => 'plan-executions-failed-prct', nlabel => 'plan.executions.failed.percentage', set => {
key_values => [ { name => 'failedPrct' }, { name => 'name' } ],
output_template => 'number of failed executions: %.2f %%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'name' }
]
}
}
];
$self->{maps_counters}->{timers} = [
{ label => 'plan-execution-last', nlabel => 'plan.execution.last', set => {
key_values => [ { name => 'lastExecSeconds' }, { name => 'lastExecHuman' }, { name => 'name' } ],
output_template => 'last execution %s',
output_use => 'lastExecHuman',
closure_custom_perfdata => $self->can('custom_last_exec_perfdata'),
closure_custom_threshold_check => $self->can('custom_last_exec_threshold')
}
},
{ label => 'plan-running-duration', nlabel => 'plan.running.duration', set => {
key_values => [ { name => 'durationSeconds' }, { name => 'durationHuman' }, { name => 'name' } ],
output_template => 'running duration %s',
output_use => 'durationHuman',
closure_custom_perfdata => $self->can('custom_duration_perfdata'),
closure_custom_threshold_check => $self->can('custom_duration_threshold')
}
}
];
$self->{maps_counters}->{executions} = [
{
label => 'plan-execution-status',
type => 2,
set => {
key_values => [
{ name => 'status' }, {name => 'result' }, { name => 'planName' }
],
closure_custom_output => $self->can('custom_execution_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-plan-id:s' => { name => 'filter_plan_id' },
'filter-plan-name:s' => { name => 'filter_plan_name' },
'filter-environment:s' => { name => 'filter_environment' },
'since-timeperiod:s' => { name => 'since_timeperiod' },
'status-failed:s' => { name => 'status_failed' },
'only-last-execution' => { name => 'only_last_execution' },
'tenant-name:s' => { name => 'tenant_name' },
'timezone:s' => { name => 'timezone' },
'unit:s' => { name => 'unit', default => 's' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
$self->{option_results}->{unit} = 's';
}
if (!defined($self->{option_results}->{since_timeperiod}) || $self->{option_results}->{since_timeperiod} eq '') {
$self->{option_results}->{since_timeperiod} = 86400;
}
if (!defined($self->{option_results}->{tenant_name}) || $self->{option_results}->{tenant_name} eq '') {
$self->{option_results}->{tenant_name} = '[All]';
}
$self->{tz} = {};
if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') {
$self->{tz} = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone});
}
$self->{option_results}->{timezone} = 'UTC' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone}
eq '');
if (!defined($self->{option_results}->{status_failed}) || $self->{option_results}->{status_failed} eq '') {
$self->{option_results}->{status_failed} = '%{result} =~ /technical_error|failed|interrupted/i';
}
$self->{option_results}->{status_failed} =~ s/%\{(.*?)\}/\$values->{$1}/g;
$self->{option_results}->{status_failed} =~ s/%\((.*?)\)/\$values->{$1}/g;
}
sub manage_selection {
my ($self, %options) = @_;
my $status_filter = {};
if (defined($self->{option_results}->{filter_status}) && $self->{option_results}->{filter_status}[0] ne '') {
$status_filter->{statusFilter} = $self->{option_results}->{filter_status};
}
my $payload = $self->{option_results}->{tenant_name};
$options{custom}->request(method => 'POST', endpoint => '/rest/tenants/current', query_form_post => $payload, skip_decode => 1);
$payload = {
skip => 0,
limit => 4000000,
filters => [
{
collectionFilter => { type => 'True', field => 'visible' }
}
],
'sort' => {
'field' => 'attributes.name',
'direction' => 'ASCENDING'
}
};
eval {
$payload = encode_json($payload);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
$self->{output}->option_exit();
}
my $plans = $options{custom}->request(method => 'POST', endpoint => '/rest/table/plans', query_form_post => $payload);
my $ctime = time();
my $filterTime = ($ctime - $self->{option_results}->{since_timeperiod}) * 1000;
$payload = {
skip => 0,
limit => 4000000,
filters => [
{
collectionFilter => { type => 'Gte', field => 'startTime', value => $filterTime }
}
],
'sort' => {
'field' => 'startTime',
'direction' => 'DESCENDING'
}
};
eval {
$payload = encode_json($payload);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
$self->{output}->option_exit();
}
my $executions = $options{custom}->request(method => 'POST', endpoint => '/rest/table/executions', query_form_post => $payload);
$self->{global} = { detected => 0 };
$self->{plans} = {};
foreach my $plan (@{$plans->{data}}) {
# skip plans created by keyword single execution
next if (defined $plan->{visible} && $plan->{visible} =~ /false|0/);
next if (defined($self->{option_results}->{filter_plan_id}) && $self->{option_results}->{filter_plan_id} ne '' &&
$plan->{id} !~ /$self->{option_results}->{filter_plan_id}/);
next if (defined($self->{option_results}->{filter_plan_name}) && $self->{option_results}->{filter_plan_name} ne '' &&
$plan->{attributes}->{name} !~ /$self->{option_results}->{filter_plan_name}/);
$self->{global}->{detected}++;
$self->{plans}->{ $plan->{id} } = {
name => $plan->{attributes}->{name},
exec_detect => { detected => 0, name => $plan->{attributes}->{name} },
failed => { failedPrct => 0, name => $plan->{attributes}->{name} },
timers => {},
executions => {}
};
my ($last_exec, $older_running_exec);
my ($failed, $total) = (0, 0);
my $i = 0;
foreach my $plan_exec (@{$executions->{data}}) {
next if (!defined($plan_exec->{planId}));
next if ($plan_exec->{planId} ne $plan->{id});
$plan_exec->{startTimeSec} = $plan_exec->{startTime} / 1000;
next if ($plan_exec->{startTimeSec} < ($ctime - $self->{option_results}->{since_timeperiod}));
next if (defined($self->{option_results}->{filter_environment}) && $self->{option_results}->{filter_environment} ne '' &&
$plan_exec->{executionParameters}->{customParameters}->{env} !~ /$self->{option_results}->{filter_environment}/);
# if the endTime is empty, we store this older running execution for later
if (!defined($plan_exec->{endTime}) || $plan_exec->{endTime} eq '') {
$older_running_exec = $plan_exec;
}
if (!defined($last_exec)) {
$last_exec = $plan_exec;
}
$self->{plans}->{ $plan->{id} }->{exec_detect}->{detected}++;
$failed++ if ($self->{output}->test_eval(test => $self->{option_results}->{status_failed}, values => { result => lc($plan_exec->{result}), status => lc($plan_exec->{status}) }));
$total++;
my $dt = DateTime->from_epoch(epoch => $plan_exec->{startTimeSec}, %{$self->{tz}});
my $timeraised = sprintf(
'%02d-%02d-%02dT%02d:%02d:%02d (%s)', $dt->year, $dt->month, $dt->day, $dt->hour, $dt->minute, $dt->second, $self->{option_results}->{timezone}
);
$self->{plans}->{ $plan->{id} }->{executions}->{$i} = {
executionId => $plan_exec->{id},
planName => $plan->{attributes}->{name},
environment => $plan_exec->{executionParameters}->{customParameters}->{env},
started => $timeraised,
status => lc($plan_exec->{status}),
result => lc($plan_exec->{result})
};
$i++;
last if (defined($self->{option_results}->{only_last_execution}));
}
$self->{plans}->{ $plan->{id} }->{failed}->{failedPrct} = $total > 0 ? $failed * 100 / $total : 0;
if (defined($last_exec)) {
$self->{plans}->{ $plan->{id} }->{timers} = {
name => $plan->{attributes}->{name},
lastExecSeconds => defined($last_exec->{startTime}) ? $ctime - $last_exec->{startTimeSec} : -1,
lastExecHuman => defined($last_exec->{startTime}) ? centreon::plugins::misc::change_seconds(value => $ctime - $last_exec->{startTimeSec}) : 'never'
};
}
if (defined($older_running_exec)) {
my $duration = $ctime - $older_running_exec->{startTime};
$self->{plans}->{ $plan->{name} }->{timers}->{durationSeconds} = $duration;
$self->{plans}->{ $plan->{name} }->{timers}->{durationHuman} = centreon::plugins::misc::change_seconds(value => $duration);
}
}
}
1;
__END__
=head1 MODE
Check plans.
=over 8
=item B<--tenant-name>
Check plan of a tenant (default: '[All]').
=item B<--filter-plan-id>
Filter plans by plan ID.
=item B<--filter-plan-name>
Filter plans by plan name.
=item B<--filter-environment>
Filter plan executions by environment name.
=item B<--since-timeperiod>
Time period to get plans executions information (in seconds. default: 86400).
=item B<--only-last-execution>
Check only last plan execution.
=item B<--timezone>
Define timezone for start/end plan execution time (default is 'UTC').
=item B<--status-failed>
Expression to define status failed (default: '%{result} =~ /technical_error|failed|interrupted/i').
=item B<--unknown-plan-execution-status>
Set unknown threshold for last plan execution status.
You can use the following variables: %{status}, %{planName}
=item B<--warning-plan-execution-status>
Set warning threshold for last plan execution status.
You can use the following variables: %{status}, %{planName}
=item B<--critical-plan-execution-status>
Set critical threshold for last plan execution status.
You can use the following variables: %{status}, %{planName}
=item B<--warning-plans-detected>
Thresholds.
=item B<--critical-plans-detected>
Thresholds.
=item B<--warning-plan-executions-detected>
Thresholds.
=item B<--critical-plan-executions-detected>
Thresholds.
=item B<--warning-plan-executions-failed-prct>
Thresholds.
=item B<--critical-plan-executions-failed-prct>
Thresholds.
=item B<--warning-plan-execution-last>
Thresholds.
=item B<--critical-plan-execution-last>
Thresholds.
=item B<--warning-plan-running-duration>
Thresholds.
=item B<--critical-plan-running-duration>
Thresholds.
=back
=cut

View File

@ -0,0 +1,51 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::exense::step::restapi::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{modes} = {
'list-plans' => 'apps::exense::step::restapi::mode::listplans',
'list-tenants' => 'apps::exense::step::restapi::mode::listtenants',
'plans' => 'apps::exense::step::restapi::mode::plans'
};
$self->{custom_modes}->{api} = 'apps::exense::step::restapi::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Exense Step using Rest API.
=cut

View File

@ -43,7 +43,7 @@ sub prefix_scenario_output {
sub prefix_steps_output {
my ($self, %options) = @_;
return sprintf(" Step: %s, last exec: %s, ", $options{instance_value}->{display}, $options{instance_value}->{last_exec});
return sprintf("Step: %s, last exec: %s, ", $options{instance_value}->{display}, $options{instance_value}->{last_exec});
}
sub set_counters {
@ -53,7 +53,16 @@ sub set_counters {
{ name => 'scenarios', type => 3, cb_prefix_output => 'prefix_scenario_output', cb_long_output => 'prefix_scenario_output', indent_long_output => ' ', message_multiple => 'All scenarios are ok',
group => [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
{ name => 'steps', display_long => 1, cb_prefix_output => 'prefix_steps_output', message_multiple => 'All steps are ok', type => 1, skipped_code => { -10 => 1 } }
{
name => 'steps',
type => 1,
cb_prefix_output => 'prefix_steps_output',
display_long => 1,
message_multiple => 'All steps are ok',
skipped_code => { -10 => 1 },
sort_method => 'num',
sort_attribute => 'index'
}
]
}
];
@ -61,9 +70,9 @@ sub set_counters {
$self->{maps_counters}->{global} = [
{ label => 'scenario-status',
type => 2,
warning_default => '%{status} =~ /(Aborted|Stopped|Excluded|Degraded)/',
warning_default => '%{status} =~ "Degraded"',
critical_default => '%{status} =~ "Failure"',
unknown_default => '%{status} =~ /(Unknown|No execution)/',
unknown_default => '%{status} =~ /(Unknown|No execution|Aborted|Stopped|Excluded)/',
set => {
key_values => [ { name => 'status' }, { name => 'num_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_status_output'),
@ -98,7 +107,7 @@ sub set_counters {
];
$self->{maps_counters}->{steps} = [
{ label => 'time-step', nlabel => 'scenario.step.time.milliseconds', set => {
key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' } ],
key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ],
output_template => 'time step: %s ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
@ -106,7 +115,7 @@ sub set_counters {
}
},
{ label => 'time-total', nlabel => 'scenario.steps.time.total.milliseconds', set => {
key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' } ],
key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ],
output_template => 'time total: %s ms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }
@ -182,7 +191,7 @@ sub manage_selection {
}
};
if (!defined $scenario_detail->{results} or scalar(@{$scenario_detail->{results}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "Scenario '" . $scenario->{scenarioName} . "' Don't have any performance data, please try to add a bigger timeframe");
$self->{output}->add_option_msg(short_msg => "No execution, please try again with a bigger timeframe");
next;
}
foreach my $kpi (@{$scenario_detail->{kpis}}) {
@ -194,12 +203,22 @@ sub manage_selection {
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{$steps->{index} - 1} = $steps->{name};
}
}
# The API is expected to sort the output to get the most recent data at the end of the array.
# We store the last execution date, and check it for every data point sent back by the api.
# If a step has failed, no data is sent by the api for this step, but the results of the previous executions are present.
# This allows to get perfdata for the last execution with a successful first step.
# If the first step fails, the script will take older data.
my $last_execution = @{$scenario_detail->{results}}[-1]->{planningTime};
foreach my $step_metrics (@{$scenario_detail->{results}}) {
if ($step_metrics->{planningTime} ne $last_execution){
$self->{output}->add_option_msg(long_msg => "Execution $step_metrics->{planningTime} of step $step_metrics->{stepId} is older than $last_execution, not taking it into account.", debug => 1);
next;
}
my $exec_time = str2time($step_metrics->{planningTime}, 'GMT');
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{ $step_metrics->{metric} } = $step_metrics->{value};
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{last_exec} = POSIX::strftime('%d-%m-%Y %H:%M:%S %Z', localtime($exec_time));
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{display} = $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} };
$self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{index} = $step_metrics->{stepId};
}
}
@ -245,14 +264,53 @@ Syntax: C<--warning-scenario-status='%{status} =~ "xxx"'>
Critical threshold for scenario status (default: '%{status} =~ "Failure"').
Syntax: --critical-scenario-status='%{status} =~ "xxx"'
=item B<--warning-*> B<--critical-*>
=item B<--warning-availability>
Thresholds.
Common: 'availability' (%),
For WEB scenarios: 'time-total-allsteps' (ms), 'time-step' (ms),
For HTTPR scenarios: 'time-total' (ms),
FOR BPL scenarios: 'time-interaction' (ms), 'time-total' (ms).
Thresholds in %.
=item B<--critical-availability>
Thresholds in %.
=item B<--warning-time-total-allsteps>
Thresholds in ms for WEB scenarios.
=item B<--critical-time-total-allsteps>
Thresholds in ms for WEB scenarios.
=item B<--warning-time-step>
Thresholds in ms for WEB scenarios.
=item B<--critical-time-step>
Thresholds in ms for WEB scenarios.
=item B<--warning-time-total>
Thresholds in ms for HTTPR scenarios.
=item B<--critical-time-total>
Thresholds in ms for HTTPR scenarios.
=item B<--warning-time-interaction>
Thresholds in ms for BPL scenarios.
=item B<--critical-time-interaction>
Thresholds in ms for BPL scenarios.
=item B<--warning-time-total>
Thresholds in ms for BPL scenarios.
=item B<--critical-time-total>
Thresholds in ms for BPL scenarios.
=back

View File

@ -47,7 +47,7 @@ sub custom_select_threshold {
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
$status = 'warning';
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{unknown})) {
$status = 'unknown';
}
if ($@) {

View File

@ -42,7 +42,7 @@ sub custom_select_threshold {
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{warning})) {
$status = 'warning';
} elsif (defined($self->{result_values}->{config}->{unknown}) && $self->{result_values}->{config}->{unknown} &&
$self->{instance_mode}->reval($self->{result_values}->{config}->{unknown})) {
$self->{instance_mode}->{safe}->reval($self->{result_values}->{config}->{unknown})) {
$status = 'unknown';
}
if ($@) {

View File

@ -1,5 +1,5 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
@ -24,6 +24,7 @@ use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON::XS;
use MIME::Base64;
use Digest::MD5 qw(md5_hex);
@ -44,12 +45,14 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(
arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'username:s' => { name => 'username' },
'password:s' => { name => 'password' },
'timeout:s' => { name => 'timeout' }
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port', default => '443' },
'proto:s' => { name => 'proto', default => 'https' },
'username:s' => { name => 'username' },
'password:s' => { name => 'password' },
'vstats-interval:s' => { name => 'vstats_interval', default => 60 },
'vstats-duration:s' => { name => 'vstats_duration', default => 2764800 }, # 2764800 seconds in 32 days
'timeout:s' => { name => 'timeout', default => 10 }
}
);
}
@ -73,12 +76,14 @@ sub set_defaults {}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : '';
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : '';
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{port} = $self->{option_results}->{port};
$self->{proto} = $self->{option_results}->{proto};
$self->{timeout} = $self->{option_results}->{timeout};
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : '';
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : '';
$self->{vstats_interval} = $self->{option_results}->{vstats_interval};
$self->{vstats_duration} = $self->{option_results}->{vstats_duration};
if ($self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
@ -146,15 +151,12 @@ sub get_token {
$self->settings();
my $content = $self->{http}->request(
method => 'POST',
url_path => '/api/session',
method => 'POST',
url_path => '/api/session',
query_form_post => '',
unknown_status => $self->{unknown_http_status},
warning_status => $self->{warning_http_status},
critical_status => $self->{critical_http_status},
header => [
'Authorization: Basic ' . $auth_string,
'Content-Type: application/x-www-form-urlencoded'
header => [
'Authorization: Basic ' . $auth_string,
'Content-Type: application/x-www-form-urlencoded'
]
);
@ -175,22 +177,33 @@ sub try_request_api {
my ($self, %options) = @_;
my $token = $self->get_token(%options);
my $method = centreon::plugins::misc::is_empty($options{method}) ? 'GET' : $options{method};
my $headers = [ 'vmware-api-session-id: ' . $token ];
if ($method =~ /^(PATCH|POST)$/) {
push @$headers, 'content-type: application/json';
}
my $unknown_status = (defined($options{unknown_status})) ? $options{unknown_status} : undef;
my ($content) = $self->{http}->request(
url_path => '/api' . $options{endpoint},
get_param => $options{get_param},
header => [ 'vmware-api-session-id: ' . $token ],
unknown_status => '',
insecure => (defined($self->{option_results}->{insecure}) ? 1 : 0)
method => $method,
url_path => '/api' . $options{endpoint},
get_param => $options{get_param},
header => $headers,
query_form_post => $options{query_form_post},
unknown_status => $unknown_status,
insecure => (defined($self->{option_results}->{insecure}) ? 1 : 0)
);
if (!defined($content) || $content eq '') {
if (!defined($content)) {
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '"
. $self->{http}->get_code() . "'] [message: '"
. $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}
my $decoded = centreon::plugins::misc::json_decode($content);
my $decoded = ($method eq 'GET') ? centreon::plugins::misc::json_decode($content) : {};
return $decoded;
}
@ -199,14 +212,18 @@ sub request_api {
my ($self, %options) = @_;
$self->settings();
my $api_response = $self->try_request_api(%options);
# first call using the available token with unknown_status = 0 in order to avoid exiting at first attempt in case it has expired
my $api_response = $self->try_request_api(%options, unknown_status => '0');
# if the token is invalid, we try to authenticate again
if (ref($api_response) eq 'HASH'
&& defined($api_response->{error_type})
&& $api_response->{error_type} eq 'UNAUTHENTICATED') {
# if the first attempt failed, try again forcing to authenticate
$api_response = $self->try_request_api('force_authentication' => 1, %options);
}
# if we could not authenticate, we exit
if (ref($api_response) eq 'HASH' && defined($api_response->{error_type})) {
my $full_message = '';
@ -219,6 +236,191 @@ sub request_api {
return $api_response;
}
sub get_all_acq_specs {
my ($self, %options) = @_;
# Get all acq specs and store them in cache
# FIXME: cache management
# FIXME: any pagination issue ?
$self->{all_acq_specs} = $self->request_api(endpoint => '/stats/acq-specs')->{acq_specs} if ( !defined($self->{all_acq_specs}));
return $self->{all_acq_specs};
}
sub compose_type_from_rsrc_id {
my ($self, $rsrc_id) = @_;
if ($rsrc_id =~ /^([a-z]+)-(\d+)$/) {
return uc($1);
} else {
$self->{output}->add_option_msg(short_msg => "compose_type_from_rsrc_id: cannot extract type from '$rsrc_id'");
$self->{output}->option_exit();
}
}
sub compose_acq_specs_json_payload {
my ($self, %options) = @_;
my $payload = {
counters => {
cid_mid => {
cid => $options{cid}
}
},
resources => [
{
predicate => 'EQUAL',
scheme => 'moid',
type => $self->compose_type_from_rsrc_id($options{rsrc_id}),
id_value => $options{rsrc_id}
}
],
expiration => time() + $self->{vstats_duration},
interval => $self->{vstats_interval}
};
return(centreon::plugins::misc::json_encode($payload));
}
sub create_acq_spec {
my ($self, %options) = @_;
if (centreon::plugins::misc::is_empty($options{cid})) {
$self->{output}->add_option_msg(short_msg => "ERR: need a cid to create an acq_spec");
$self->{output}->option_exit();
}
if (centreon::plugins::misc::is_empty($options{rsrc_id})) {
$self->{output}->add_option_msg(short_msg => "ERR: need a rsrc_id to create an acq_spec");
$self->{output}->option_exit();
}
$self->request_api(
method => 'POST',
endpoint => '/stats/acq-specs/',
query_form_post => $self->compose_acq_specs_json_payload(%options)
) or return undef;
$self->{output}->add_option_msg(long_msg => "The counter $options{cid} was not recorded for resource $options{rsrc_id} before. It will now (creating acq_spec).");
return 1;
}
sub extend_acq_spec {
my ($self, %options) = @_;
if (centreon::plugins::misc::is_empty($options{cid})) {
$self->{output}->add_option_msg(short_msg => "ERR: need a cid to extend an acq_spec");
$self->{output}->option_exit();
}
if (centreon::plugins::misc::is_empty($options{rsrc_id})) {
$self->{output}->add_option_msg(short_msg => "ERR: need a rsrc_id to extend an acq_spec");
$self->{output}->option_exit();
}
if (centreon::plugins::misc::is_empty($options{acq_spec_id})) {
$self->{output}->add_option_msg(long_msg => "ERR: need a acq_spec_id to extend an acq_spec_id") ;
$self->{output}->option_exit();
}
$self->{output}->add_option_msg(long_msg => "The acq_spec entry has to be extended to get more stats for $options{rsrc_id} / $options{cid}");
my $json_payload = $self->compose_acq_specs_json_payload(%options);
my $response = $self->request_api(
method => 'PATCH',
endpoint => '/stats/acq-specs/' . $options{acq_spec_id},
query_form_post => $json_payload
);
# The response must be empty if the patch succeeds
return undef if (defined($response) && ref($response) eq 'HASH' && scalar(keys %$response) > 0);
# reset stored acq_specs since it's no longer accurate
$self->{all_acq_specs} = [];
return 1;
}
sub get_acq_spec {
my ($self, %options) = @_;
# If it is not available in cache call get_all_acq_specs()
my $acq_specs = $self->get_all_acq_specs();
# FIXME: opt exit if centreon::plugins::misc::is_empty($options{cid})
for my $spec (@$acq_specs) {
# Ignore acq_specs not related to the counter_id
next if ($options{cid} ne $spec->{counters}->{cid_mid}->{cid});
# Check if this acq_spec is related to the given resource
my @matching_rsrcs = grep {
$_->{id_value} eq $options{rsrc_id}
&& $_->{predicate} eq 'EQUAL'
&& $_->{scheme} eq 'moid'
} @{$spec->{resources}};
return $spec if (@matching_rsrcs > 0);
}
return undef;
}
sub check_acq_spec {
my ($self, %options) = @_;
my $acq_spec = $self->get_acq_spec(%options);
if ( !defined($acq_spec) ) {
# acq_spec not found => we need to create it
$self->create_acq_spec(%options) or return(undef);
# acq_spec is created => check is ok
return 1;
} elsif ($acq_spec->{status} eq 'EXPIRED' || $acq_spec->{expiration} <= time() + 3600) {
# acq_spec exists but expired => we need to extend it
$self->extend_acq_spec(%options, acq_spec_id => $acq_spec->{id}) or return(undef);
# acq_spec is extended => check is ok
return 1;
}
# acq_spec exists and is not expired => check is ok
return 1;
}
sub get_stats {
my ($self, %options) = @_;
if ( centreon::plugins::misc::is_empty($options{rsrc_id})) {
$self->{output}->add_option_msg(short_msg => "get_stats method called without rsrc_id, won't query");
$self->{output}->option_exit();
}
if ( centreon::plugins::misc::is_empty($options{cid}) ) {
$self->{output}->add_option_msg(short_msg => "get_stats method called without cid, will get all available stats for resource");
$self->{output}->option_exit();
}
if ( !$self->check_acq_spec(%options) ) {
$self->{output}->add_option_msg(short_msg => "get_stats method failed to check_acq_spec()");
$self->{output}->option_exit();
}
# compose the endpoint
my $endpoint = '/stats/data/dp?'
. 'rsrcs=type.' . $self->compose_type_from_rsrc_id($options{rsrc_id}) . '.moid=' . $options{rsrc_id}
. '&cid=' . $options{cid}
. '&start=' . (time() - 120); # get the last two minutes to be sure to get at least one value
my $result = $self->request_api(
method => 'GET',
endpoint => $endpoint
);
# FIXME: check if ( !defined($result) || ref($result) ne 'HASH' || scalar(@{ $result->{data_points} }) == 0 ) {
# FIXME: the existence of the resource id must be checked at one moment
# return only the last value (if there are several)
if ( scalar(@{ $result->{data_points} }) == 0 ) {
$self->{output}->add_option_msg(short_msg => "no data for host " . $options{rsrc_id} . " counter " . $options{cid} . " at the moment.");
return undef;
}
# Return the `val` field of the last object of the array
return $result->{data_points}->[ @{ $result->{data_points} } - 1 ]->{val};
# FIXME: handle arrays in get_stats and check_acq_specs
}
1;
__END__
@ -238,6 +440,9 @@ apps::vmware::vsphere8::custom::api - Custom module for VMware vSphere 8 API.
$api->set_options(option_results => $option_results);
$api->check_options();
my $response = $api->request_api(endpoint => '/vcenter/host');
my $host_cpu_capacity = $api->get_stats(
cid => 'cpu.capacity.provisioned.HOST',
rsrc_id => 'host-18');
=head1 DESCRIPTION
@ -249,7 +454,7 @@ This module provides methods to interact with the VMware vSphere 8 REST API. It
my $api = apps::vmware::vsphere8::custom::api->new(%options);
Creates a new `apps::vmware::vsphere8::custom::api` object.
Creates a new C<apps::vmware::vsphere8::custom::api> object.
=over 4
@ -357,6 +562,128 @@ Calls try_request_api and recalls it forcing authentication if the first call fa
=back
=head2 get_acq_spec
my $spec = $self->get_acq_spec(%options);
Retrieves the acquisition specification (acq_spec) for the given counter ID (C<cid>) and resource ID (rsrc_id).
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<cid> - The counter ID for which to retrieve the acq_spec. This option is required.
=item * C<rsrc_id> - The resource ID for which to retrieve the acq_spec. This option is required.
=back
=back
Returns the matching acq_spec if found, otherwise returns undef.
=cut
=head2 create_acq_spec
$api->create_acq_spec(%options);
Creates a new acquisition specification (acq_spec) for the given options.
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<cid> - The counter ID for which to create the acq_spec. This option is required.
=item * C<rsrc_id> - The resource ID for which to create the acq_spec. This option is required.
=back
=back
Returns 1 if the acq_spec is successfully created, otherwise returns undef.
=cut
=head2 extend_acq_spec
$api->extend_acq_spec(%options);
Extends the acquisition specification (acq_spec) for the given options.
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<cid> - The counter ID for which to extend the acq_spec. This option is required.
=item * C<rsrc_id> - The resource ID for which to extend the acq_spec. This option is required.
=item * C<acq_spec_id> - The acquisition specification ID to extend. This option is required.
=back
=back
Returns 1 if the acq_spec is successfully extended, otherwise returns undef.
=cut
=head2 check_acq_spec
$api->check_acq_spec(%options);
Checks the acquisition specification (acq\_spec) for the given options. If the acq\_spec does not exist, it creates a new one. If the acq\_spec exists but is expired or about to expire, it extends the acq\_spec.
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<cid> - The counter ID for which to check the acq\_spec. This option is required.
=item * C<rsrc_id> - The resource ID for which to check the acq\_spec. This option is required.
=back
=back
Returns 1 if the acq\_spec is valid or has been successfully created/extended, undef otherwise.
=cut
=head2 get_stats
my $value = $api->get_stats(%options);
Retrieves the latest statistics for a given resource and counter.
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<rsrc_id> - The resource ID for which to retrieve statistics. This option is required.
=item * C<cid> - The counter ID for which to retrieve statistics. This option is required.
=back
=back
Returns the latest value for the specified resource and counter.
=cut
=head1 REST API OPTIONS
Command-line options for VMware vSphere 8 API:
@ -383,6 +710,16 @@ Define the username for authentication.
Define the password for authentication.
=item B<--vstats-interval>
Define the interval (in seconds) at which the C<vstats> must be recorded (default: 300).
Used to create entries at the C</api/stats/acq-specs> endpoint.
=item B<--vstats-duration>
Define the time (in seconds) after which the C<vstats> will stop being recorded (default: 2764800, meaning 32 days).
Used to create entries at the C</api/stats/acq-specs> endpoint.
=item B<--timeout>
Define the timeout for API requests (default: 10 seconds).
@ -397,4 +734,4 @@ Centreon
Licensed under the Apache License, Version 2.0.
=cut
=cut

View File

@ -0,0 +1,176 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::vmware::vsphere8::esx::mode;
use strict;
use warnings FATAL => 'all';
use base qw(centreon::plugins::templates::counter);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
$options{options}->add_options(
arguments => {
'esx-id:s' => { name => 'esx_id' },
'esx-name:s' => { name => 'esx_name' }
}
);
$options{options}->add_help(package => __PACKAGE__, sections => 'VMWARE 8 HOST OPTIONS', once => 1);
return $self;
}
sub get_esx_id_from_name {
my ($self, %options) = @_;
if ( centreon::plugins::misc::is_empty($self->{esx_name}) ) {
$self->{output}->add_option_msg(short_msg => "get_esx_id_from_name method called without esx_name option. Please check configuration.");
$self->{output}->option_exit();
}
my $response = $options{custom}->request_api(
'endpoint' => '/vcenter/host',
'method' => 'GET'
);
for my $rsrc (@$response) {
next if ($rsrc->{name} ne $self->{esx_name});
$self->{esx_id} = $rsrc->{host};
$self->{output}->add_option_msg(long_msg => "get_esx_id_from_name method called to get " . $self->{esx_name}
. "'s id: " . $self->{esx_id} . ". Prefer using --esx-id to spare a query to the API.");
return $rsrc->{host};
}
return undef;
}
sub get_esx_stats {
my ($self, %options) = @_;
if ( centreon::plugins::misc::is_empty($options{esx_id}) && !$self->get_esx_id_from_name(%options) ) {
$self->{output}->add_option_msg(short_msg => "get_esx_stats method cannot get host ID from host name");
$self->{output}->option_exit();
}
return $options{custom}->get_stats(
%options,
rsrc_id => $self->{esx_id}
);
}
sub request_api {
my ($self, %options) = @_;
return $options{custom}->request_api(%options);
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (centreon::plugins::misc::is_empty($self->{option_results}->{esx_id})
&& centreon::plugins::misc::is_empty($self->{option_results}->{esx_name})) {
$self->{output}->add_option_msg(short_msg => 'Need to specify either --esx-id or --esx-name option.');
$self->{output}->option_exit();
}
$self->{esx_id} = $self->{option_results}->{esx_id};
$self->{esx_name} = $self->{option_results}->{esx_name};
}
1;
__END__
=head1 VMWARE 8 HOST OPTIONS
=over 4
=item B<--esx-id>
Define which physical server to monitor based on its resource ID (example: C<host-16>).
=item B<--esx-name>
Define which physical server to monitor based on its name (example: C<esx01.mydomain.tld>).
When possible, it is recommended to use C<--esx-id> instead.
=back
=cut
=head1 NAME
apps::vmware::vsphere8::esx::mode - Template for modes monitoring VMware physical hosts
=head1 SYNOPSIS
use base apps::vmware::vsphere8::esx::mode;
sub set_counters {...}
sub manage_selection {
my ($self, %options) = @_;
$api->set_options(option_results => $option_results);
$api->check_options();
my $response = $api->request_api(endpoint => '/vcenter/host');
my $host_cpu_capacity = $self->get_esx_stats(
cid => 'cpu.capacity.provisioned.HOST',
rsrc_id => 'host-18');
=head1 DESCRIPTION
This module provides methods to interact with the VMware vSphere 8 REST API. It handles authentication, caching, and API requests.
=head1 METHODS
=head2 get_esx_stats
$self->get_esx_stats(%options);
Retrieves the ESX statistics for the given options using package apps::vmware::vsphere8::custom::api::get_stats()
=over 4
=item * C<%options> - A hash of options. The following keys are supported:
=over 8
=item * C<cid> - The C<cid> (counter id) of the desired metric.
=item * C<esx_id> - The ESX's C<rsrc_id> (resource ID) for which to retrieve the statistics. This option is optional if C<esx_name> is provided.
=item * C<esx_name> - The ESX's name for which to retrieve the statistics. This option is not used if C<esx_id> is provided, which is the nominal usage of this function.
=back
=back
Returns the statistics for the specified ESX.
=cut

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