Compare commits

..

No commits in common. "20220113" and "develop" have entirely different histories.

10154 changed files with 798141 additions and 409871 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
tests/resources/spellcheck/*.txt diff

26
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,26 @@
* @centreon/owners-connectors
*.md @centreon/owners-doc
*.mdx @centreon/owners-doc
*.cmake @centreon/owners-cpp
CMakeLists.txt @centreon/owners-cpp
Makefile @centreon/owners-cpp
*.pm @centreon/owners-perl
*.pl @centreon/owners-perl
*.t @centreon/owners-perl
*.py @centreon/owners-python
*.sh @centreon/owners-bash
tests/** @centreon/owners-robot-e2e
.github/** @centreon/owners-pipelines
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

83
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,83 @@
# Community contributors
## Description
Please include a short resume of the changes and what is the purpose of this pull request.
Any relevant information should be added to help **reviewers** to understand what are the stakes
of the pull request.
**Fixes** # (issue)
If you are fixing a github Issue already existing, mention it here.
## Type of change
- [ ] Patch fixing an issue (non-breaking change)
- [ ] New functionality (non-breaking change)
- [ ] Functionality enhancement or optimization (non-breaking change)
- [ ] Breaking change (patch or feature) that might cause side effects breaking part of the Software
## How this pull request can be tested ?
Please describe the **procedure** to verify that the goal of the PR is matched.
Provide clear instructions so that it can be **correctly tested**.
Any **relevant details** of the configuration to perform the test should be added.
To integrate this pull request into our core we need to add some **automated tests** to check the proper
functioning of this PR. Ideally we need the following informations:
* **SNMP**: MIB files and full snmpwalk of enterprise branch (`snmpwalk -ObentU -v 2c -c public address .1.3.6.1.4.1 > equipment.snmpwalk`) or [SNMP collections](https://thewatch.centreon.com/product-how-to-21/snmp-collection-tutorial-132).
* **HTTP API (SOAP, Rest/Json, XML-RPC)**: the documentation and some curl examples (command with -v + output) or HTTP [collections](https://thewatch.centreon.com/data-collection-6/centreon-plugins-discover-collection-modes-131).
* **CLI**: command line examples (command + result).
* **SQL**: queries + results + column types or [SQL collections](https://thewatch.centreon.com/product-how-to-21/sql-collection-tutorial-134).
* **JMX**: mbean names and attributes.
If some information is confidential, such as logins or IP addresses, obfuscate them in what is sent
publicly and we'll get in touch with you by private message if this information is needed.
## Checklist
- [ ] I have followed the **[coding style guidelines](https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/plugins_global.md#5-code-style-guidelines)** provided by Centreon
- [ ] I have commented my code, especially **hard-to-understand areas** of the PR.
- [ ] I have **rebased** my development branch on the base branch (develop).
- [ ] I have provide data or shown output displaying the result of this code in the plugin area concerned.
------------------------------------------------------------------------------------------------------
# Centreon team (internal PR)
## Description
**PLEASE MAKE SURE THAT THE BRANCH PR INCLUDES JIRA TICKET ID**
Please include a short resume of the changes and what is the purpose of this pull request.
Any relevant information should be added to help **reviewers** to understand what are the stakes
of the pull request.
**Fixes** # (issue)
If you are fixing a github Issue already existing, mention it here.
If you are fixing one or more JIRA ticket, mention it here too.
## Type of change
- [ ] Patch fixing an issue (non-breaking change)
- [ ] New functionality (non-breaking change)
- [ ] Functionality enhancement or optimization (non-breaking change)
- [ ] Breaking change (patch or feature) that might cause side effects breaking part of the Software
## How this pull request can be tested ?
Please describe the **procedure** to verify that the goal of the PR is matched.
Provide clear instructions so that it can be **correctly tested**.
Mention the automated tests included in this FOR (what they test like mode/option combinations).
## Checklist
- [ ] I have followed the **[coding style guidelines](https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/plugins_global.md#5-code-style-guidelines)** provided by Centreon
- [ ] I have commented my code, especially **hard-to-understand areas** of the PR.
- [ ] I have **rebased** my development branch on the base branch (develop).
- [ ] In case of a new plugin, I have created the new packaging directory accordingly.
- [ ] I have implemented automated tests related to my commits.
- [ ] Data used for automated tests are anonymized.
- [ ] I have reviewed all the help messages in all the .pm files I have modified.
- [ ] All sentences begin with a capital letter.
- [ ] All sentences end with a period.
- [ ] I am able to understand all the help messages, if not, exchange with the PO or TW to rewrite them.
- [ ] After having created the PR, I will make sure that all the tests provided in this PR have run and passed.

View File

@ -0,0 +1,65 @@
name: 'Merge Artifacts'
description: 'Merge Artifacts'
inputs:
target_name:
description: 'The name of the result artifact'
required: true
source_paths:
description: 'The path to the files that will be uplaoded'
required: true
source_name_pattern:
description: "Artifact's pattern to be merged"
required: true
github_token:
description: 'The Github Token to use'
required: true
runs:
using: 'composite'
steps:
- name: Download Artifacts
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
pattern: ${{ inputs.source_name_pattern }}*
path: ${{ inputs.target_name }}
merge-multiple: true
- name: Upload the Regrouped Artifact
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: ${{ inputs.target_name }}
path: |
${{ inputs.source_paths }}
retention-days: 1
- name: Delete Artifacts
run: |
artifact_pattern="${{ inputs.source_name_pattern }}"
TOKEN="${{ inputs.github_token }}"
artifact_exists=true
while [ "$artifact_exists" = true ]; do
artifact_exists=false
artifacts_response=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts?per_page=100")
artifacts=$(echo $artifacts_response | jq -c '.artifacts[]')
echo "Those are the artifacts : $artifacts"
while read row; do
artifact_name=$(echo "$row" | jq -r '.name')
if [[ "$artifact_name" =~ ^.*"$artifact_pattern".* ]]; then
artifact_exists=true
echo "Deleting : $artifact_name"
artifact_id=$(echo "$row" | jq -r '.id')
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/${artifact_id}"
fi
done <<< "$artifacts"
done
echo "End of Deleting"
shell: bash

View File

@ -0,0 +1,210 @@
name: "package-delivery"
description: "Deliver packages"
inputs:
module_name:
description: "The package module name"
required: true
distrib:
description: "The distribution used for packaging"
required: true
arch:
description: "The target distribution architecture"
required: false
cache_key:
description: "The cached package key"
required: true
stability:
description: "The package stability (stable, testing, unstable)"
required: true
release_type:
description: "Type of release (hotfix, release)"
required: true
artifactory_token:
description: "token for artifactory"
required: true
runs:
using: "composite"
steps:
- name: Validate inputs
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
if ('${{ inputs.module_name }}' === '') {
throw new Error('module_name input must be defined');
}
if (! ['stable', 'testing', 'unstable'].includes('${{ inputs.stability }}')) {
throw new Error(`Stability ${{ inputs.stability }} should not deliver packages`);
}
if ('${{ inputs.stability }}' === 'testing' && ! ['release', 'hotfix'].includes('${{ inputs.release_type }}')) {
throw new Error('release_type input must be defined when stability is testing');
}
- name: Parse distrib name
id: parse-distrib
uses: ./.github/actions/parse-distrib
with:
distrib: ${{ inputs.distrib }}
- name: Get repository stability path
id: get_repository_stability_path
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
let stabilitySubdirectory = '${{ inputs.stability }}';
if ('${{ inputs.stability }}' === 'testing' && '${{ inputs.release_type }}' === 'hotfix') {
stabilitySubdirectory = '${{ inputs.stability }}-${{ inputs.release_type }}';
}
let repositoryStabilityPath = '';
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') {
repositoryStabilityPath = `rpm-plugins/${{ inputs.distrib }}/${stabilitySubdirectory}`;
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'ubuntu') {
repositoryStabilityPath = `ubuntu-plugins-${{ inputs.stability }}`;
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'debian') {
repositoryStabilityPath = `apt-plugins-${{ inputs.stability }}`;
} else {
throw new Error(`Repository cannot be find for distribution: ${{ inputs.distrib }}`);
}
core.setOutput(
'repository_stability_path',
repositoryStabilityPath,
);
- if: ${{ inputs.stability != 'stable' }}
name: Restore packages from cache
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ steps.parse-distrib.outputs.package_extension }}
key: ${{ inputs.cache_key }}
fail-on-cache-miss: true
- uses: jfrog/setup-jfrog-cli@9fe0f98bd45b19e6e931d457f4e98f8f84461fb5 # v4.4.1
with:
disable-job-summary: true
disable-auto-build-publish: true
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
- if: ${{ inputs.stability == 'testing' }}
name: Clean existing testing packages
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') {
await exec.exec(
`jf rt del "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/*/${{ inputs.module_name }}/*.rpm" --exclusions "*/RPMS/*" --quiet`
);
} else if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'deb') {
await exec.exec(
`jf rt del "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --quiet --props "release_type=${{ inputs.release_type }}"`
);
}
- name: Download packages from testing
if: ${{ inputs.stability == 'stable' && github.event_name == 'push' && (inputs.distrib != 'jammy' || inputs.distrib != 'noble') }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const commitSha = context.sha;
const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
sort: 'updated',
direction: 'desc',
state: 'closed',
per_page: 100
});
core.startGroup(`Checking pull request linked to commit ${commitSha}`);
const pr = pulls.data.find(p => {
console.log(`Checking pull request ${p.number}("${p.title}") with merge commit ${p.merge_commit_sha}`);
return p.merge_commit_sha === commitSha;
});
core.endGroup();
if (!pr) {
core.error(`No pull request found for merge commit ${commitSha}`);
return;
}
const prHeadRef = pr?.head?.ref || 'unknown';
let releaseType = '';
switch (true) {
case /^release.+/.test(prHeadRef):
releaseType = 'release';
break;
case /^hotfix.+/.test(prHeadRef):
releaseType = 'hotfix';
break;
default:
core.error(`No packages are promoted because push of branch ${prHeadRef} is not related to a hotfix/release pull request.`);
return;
}
console.log(`Release type: ${releaseType}`);
let fromStabilitySubdirectory = 'testing';
if (releaseType === 'hotfix' ) {
fromStabilitySubdirectory = `testing-${releaseType}`;
}
if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'el') {
await exec.exec(
`jf rt download "rpm-plugins/${{ inputs.distrib }}/${fromStabilitySubdirectory}/*/${{ inputs.module_name }}/*.rpm" --flat`
);
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'ubuntu') {
await exec.exec(
`jf rt download "ubuntu-plugins-testing/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --props "release_type=${releaseType}" --flat`
);
} else if ('${{ steps.parse-distrib.outputs.distrib_family }}' === 'debian') {
await exec.exec(
`jf rt download "apt-plugins-testing/pool/${{ inputs.module_name }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb" --props "release_type=${releaseType}" --flat`
);
}
- name: Publish packages to ${{ inputs.stability }}
if: |
contains(fromJson('["testing", "unstable"]'), inputs.stability) ||
(inputs.stability == 'stable' && github.event_name == 'push' && (inputs.distrib != 'jammy' || inputs.distrib != 'noble'))
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const path = require('path');
const globber = await glob.create('*.${{ steps.parse-distrib.outputs.package_extension }}');
let stableRpmSubdirectory = '';
if ('${{ inputs.stability }}' === 'stable') {
stableRpmSubdirectory = 'RPMS/';
}
const debTargetProps = '${{ inputs.stability }}' == 'testing' ? '--target-props "release_type=${{ inputs.release_type }}"' : '';
for await (const file of globber.globGenerator()) {
const fileName = path.basename(file);
if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'rpm') {
let arch = 'noarch';
if (/x86_64/.test(fileName)) {
arch = 'x86_64';
}
await exec.exec(
`jf rt upload "${fileName}" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/${arch}/${stableRpmSubdirectory}${{ inputs.module_name }}/" --flat`
);
} else if ('${{ steps.parse-distrib.outputs.package_extension }}' === 'deb') {
let arch = 'all';
const matches = fileName.match(/_([^_]+)\.deb/);
if (matches !== null && matches.length > 1) {
arch = matches[1];
}
if ('${{ inputs.arch }}' === '' || '${{ inputs.arch }}' === arch) {
await exec.exec(
`jf rt upload "${fileName}" "${{ steps.get_repository_stability_path.outputs.repository_stability_path }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/${arch}" ${debTargetProps} --flat`
);
}
}
}

137
.github/actions/package-nfpm/action.yml vendored Normal file
View File

@ -0,0 +1,137 @@
name: package-nfpm
description: Package module using nfpm
inputs:
nfpm_file_pattern:
description: The pattern of the nfpm configuration file(s)
required: true
package_extension:
description: The package extension (deb or rpm)
required: true
distrib:
description: The package distrib
required: true
version:
description: The package version ([major_version].[minor_version])
required: false
major_version:
description: The major version
required: false
minor_version:
description: The minor version
required: false
release:
description: The package release number
required: true
arch:
description: The package architecture
required: false
commit_hash:
description: The commit hash
required: true
cache_key:
description: The package files cache key
required: true
rpm_gpg_key:
description: The rpm gpg key
required: true
rpm_gpg_signing_key_id:
description: The rpm gpg signing key identifier
required: true
rpm_gpg_signing_passphrase:
description: The rpm gpg signing passphrase
required: true
stability:
description: "Branch stability (stable, testing, unstable, canary)"
required: true
runs:
using: composite
steps:
- name: Parse distrib name
id: parse-distrib
uses: ./.github/actions/parse-distrib
with:
distrib: ${{ inputs.distrib }}
- name: Import gpg key
env:
RPM_GPG_SIGNING_KEY: ${{ inputs.rpm_gpg_key }}
run: echo -n "$RPM_GPG_SIGNING_KEY" > key.gpg
shell: bash
- name: Build ${{ inputs.package_extension }} files
env:
RPM_GPG_SIGNING_KEY_ID: ${{ inputs.rpm_gpg_signing_key_id }}
RPM_GPG_SIGNING_PASSPHRASE: ${{ inputs.rpm_gpg_signing_passphrase }}
run: |
if [ -z ${{ inputs.version }} ]; then
export VERSION="${{ inputs.major_version }}.${{ inputs.minor_version }}"
export MAJOR_VERSION="${{ inputs.major_version }}"
export MINOR_VERSION="${{ inputs.minor_version }}"
elif [ -z ${{ inputs.major_version }} ]; then
export VERSION="${{ inputs.version }}"
export MAJOR_VERSION=$( echo $VERSION | cut -d "-" -f1 )
export MINOR_VERSION=$( echo $VERSION | cut -d "-" -f2 )
fi
export RELEASE="${{ inputs.release }}"
export ARCH="${{ inputs.arch }}"
if [ "${{ inputs.package_extension }}" = "rpm" ]; then
export DIST=".${{ inputs.distrib }}"
export APACHE_USER="apache"
export APACHE_GROUP="apache"
else
export DIST=""
if [ "${{ inputs.stability }}" == "unstable" ] || [ "${{ inputs.stability }}" == "canary" ]; then
export RELEASE="$RELEASE${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
else
export RELEASE="1${{ steps.parse-distrib.outputs.package_distrib_separator }}${{ steps.parse-distrib.outputs.package_distrib_name }}"
fi
export APACHE_USER="www-data"
export APACHE_GROUP="www-data"
fi
if [ -z "$MAJOR_VERSION" ]; then
MAJOR_LEFT=$( echo $VERSION | cut -d "." -f1 )
MAJOR_RIGHT=$( echo $VERSION | cut -d "-" -f1 | cut -d "." -f2 )
if [ "$MAJOR_RIGHT" == "04" ]; then
BUMP_MAJOR_LEFT="$MAJOR_LEFT"
BUMP_MAJOR_RIGHT="10"
else
BUMP_MAJOR_LEFT=$(( $MAJOR_LEFT + 1 ))
BUMP_MAJOR_RIGHT="04"
fi
export NEXT_MAJOR_VERSION="$BUMP_MAJOR_LEFT.$BUMP_MAJOR_RIGHT"
fi
export RPM_SIGNING_KEY_FILE="$(pwd)/key.gpg"
export RPM_SIGNING_KEY_ID="$RPM_GPG_SIGNING_KEY_ID"
export NFPM_RPM_PASSPHRASE="$RPM_GPG_SIGNING_PASSPHRASE"
for FILE in ${{ inputs.nfpm_file_pattern }}; do
DIRNAME=$(dirname $FILE)
BASENAME=$(basename $FILE)
cd $DIRNAME
sed -i "s/@APACHE_USER@/$APACHE_USER/g" $BASENAME
sed -i "s/@APACHE_GROUP@/$APACHE_GROUP/g" $BASENAME
sed -i "s/@COMMIT_HASH@/${{ inputs.commit_hash }}/g" $BASENAME
nfpm package --config $BASENAME --packager ${{ inputs.package_extension }}
cd -
mv $DIRNAME/*.${{ inputs.package_extension }} ./
done
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ inputs.package_extension }}
key: ${{ inputs.cache_key }}
# Add to your PR the label upload-artifacts to get packages as artifacts
- if: ${{ contains(github.event.pull_request.labels.*.name, 'upload-artifacts') }}
name: Upload package artifacts
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ inputs.distrib }}
path: ./*.${{ inputs.package_extension}}
retention-days: 1

View File

@ -0,0 +1,70 @@
name: "parse-distrib"
description: "parse distrib name."
inputs:
distrib:
description: "The distribution name"
required: true
outputs:
package_distrib_separator:
description: "Separator between package version and distrib number"
value: ${{ steps.parse-distrib.outputs.package_distrib_separator }}
package_distrib_name:
description: "Distribution suffix in package name"
value: ${{ steps.parse-distrib.outputs.package_distrib_name }}
package_extension:
description: "Package extension (rpm or deb)"
value: ${{ steps.parse-distrib.outputs.package_extension }}
distrib_family:
description: "Distrib family (el, debian, ubuntu)"
value: ${{ steps.parse-distrib.outputs.distrib_family }}
runs:
using: "composite"
steps:
- name: Parse distrib
id: parse-distrib
run: |
if [[ "${{ inputs.distrib }}" == "centos7" || "${{ inputs.distrib }}" == "el7" ]]; then
PACKAGE_DISTRIB_SEPARATOR="."
PACKAGE_DISTRIB_NAME="el7"
PACKAGE_EXTENSION="rpm"
DISTRIB_FAMILY="el"
elif [[ "${{ inputs.distrib }}" == "alma8" || "${{ inputs.distrib }}" == "el8" ]]; then
PACKAGE_DISTRIB_SEPARATOR="."
PACKAGE_DISTRIB_NAME="el8"
PACKAGE_EXTENSION="rpm"
DISTRIB_FAMILY="el"
elif [[ "${{ inputs.distrib }}" == "alma9" || "${{ inputs.distrib }}" == "el9" ]]; then
PACKAGE_DISTRIB_SEPARATOR="."
PACKAGE_DISTRIB_NAME="el9"
PACKAGE_EXTENSION="rpm"
DISTRIB_FAMILY="el"
elif [[ "${{ inputs.distrib }}" == "bullseye" ]]; then
PACKAGE_DISTRIB_SEPARATOR="+"
PACKAGE_DISTRIB_NAME="deb11u1"
PACKAGE_EXTENSION="deb"
DISTRIB_FAMILY="debian"
elif [[ "${{ inputs.distrib }}" == "bookworm" ]]; then
PACKAGE_DISTRIB_SEPARATOR="+"
PACKAGE_DISTRIB_NAME="deb12u1"
PACKAGE_EXTENSION="deb"
DISTRIB_FAMILY="debian"
elif [[ "${{ inputs.distrib }}" == "jammy" ]]; then
PACKAGE_DISTRIB_SEPARATOR="-"
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
fi
echo "package_distrib_separator=$PACKAGE_DISTRIB_SEPARATOR" >> $GITHUB_OUTPUT
echo "package_distrib_name=$PACKAGE_DISTRIB_NAME" >> $GITHUB_OUTPUT
echo "package_extension=$PACKAGE_EXTENSION" >> $GITHUB_OUTPUT
echo "distrib_family=$DISTRIB_FAMILY" >> $GITHUB_OUTPUT
shell: bash

View File

@ -0,0 +1,110 @@
name: "promote testing to stable"
description: "Promote testing packages to stable."
inputs:
artifactory_token:
description: "Artifactory token"
required: true
module:
description: "Module"
required: true
distrib:
description: "The distribution used for packaging"
required: true
stability:
description: "The package stability (stable, testing, unstable)"
required: true
runs:
using: "composite"
steps:
- uses: jfrog/setup-jfrog-cli@26da2259ee7690e63b5410d7451b2938d08ce1f9 # v4.0.0
env:
JF_URL: https://centreon.jfrog.io
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
- name: Parse distrib name
id: parse-distrib
uses: ./.github/actions/parse-distrib
with:
distrib: ${{ inputs.distrib }}
- name: Promote RPM packages to stable
if: ${{ startsWith(inputs.distrib, 'el') }}
run: |
set -x
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
for ARCH in "noarch" "x86_64"; do
echo "[DEBUG] - Get path of $ARCH testing artifacts to promote to stable."
SRC_PATHS=$(jf rt s --include-dirs rpm-plugins/${{ inputs.distrib }}/testing/$ARCH/${{ inputs.module }}/*.rpm | jq -r '.[].path')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Source path found: $SRC_PATH"
done
else
echo "[DEBUG] - No source path found."
continue
fi
echo "[DEBUG] - Build $ARCH target path."
TARGET_PATH="rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting $ARCH testing artifacts to stable."
for ARTIFACT in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Downloading $ARTIFACT from TESTING."
jf rt download $ARTIFACT --flat
done
for ARTIFACT_DL in $(dir|grep -E "*.rpm"); do
echo "[DEBUG] - Promoting (upload) $ARTIFACT_DL to stable $TARGET_PATH."
jf rt upload "$ARTIFACT_DL" "$TARGET_PATH" --flat
done
rm -f *.rpm
done
shell: bash
- name: Promote DEB package to stable
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" || "${{ inputs.distrib }}" == "noble" ]]; then
repo="ubuntu-plugins"
else
repo="apt-plugins"
fi
echo "[DEBUG] - Get path of testing DEB packages to promote to stable."
SRC_PATHS=$(jf rt search --include-dirs $repo-testing/pool/${{ inputs.module }}/*${{ steps.parse-distrib.outputs.package_distrib_name }}*.deb | jq -r '.[].path')
if [[ ${SRC_PATHS[@]} ]]; then
for SRC_PATH in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Source path found: $SRC_PATH"
done
else
echo "::warning::No source path found."
exit 0
fi
echo "[DEBUG] - Build target path."
TARGET_PATH="$repo-${{ inputs.stability }}/pool/${{ inputs.module }}/"
echo "[DEBUG] - Target path: $TARGET_PATH"
echo "[DEBUG] - Promoting DEB testing artifacts to stable."
for ARTIFACT in ${SRC_PATHS[@]}; do
echo "[DEBUG] - Downloading $ARTIFACT from TESTING."
jf rt download $ARTIFACT --flat
done
for ARTIFACT_DL in $(dir -1|grep -E ".+${{ steps.parse-distrib.outputs.package_distrib_name }}.+\.deb"); do
ARCH=$(echo $ARTIFACT_DL | cut -d '_' -f3 | cut -d '.' -f1)
echo "[DEBUG] - Promoting (upload) $ARTIFACT_DL to stable $TARGET_PATH."
jf rt upload "$ARTIFACT_DL" "$TARGET_PATH" --deb "${{ inputs.distrib }}/main/$ARCH"
done
rm -f *.deb
shell: bash

View File

@ -0,0 +1,45 @@
name: "release-sources"
description: "Release sources on download.centreon.com"
inputs:
bucket_directory:
description: The bucket directory
required: true
module_directory:
description: The module directory
required: true
module_name:
description: The module name
required: true
version:
description: The module version
required: true
release:
description: The module release
required: true
token_download_centreon_com:
description: The token to call download.centreon.com api
required: true
runs:
using: "composite"
steps:
- name: Setup awscli
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo unzip -q awscliv2.zip
sudo ./aws/install
shell: bash
- name: Publish on download.centreon.com
run: |
SRC_FILE="${{ inputs.module_name }}-${{ inputs.version }}.tar.gz"
mv "${{ inputs.module_directory }}" "${{ inputs.module_name }}-${{ inputs.version }}"
tar czf $SRC_FILE "${{ inputs.module_name }}-${{ inputs.version }}"
SRC_HASH=$(md5sum $SRC_FILE | cut -d ' ' -f 1)
SRC_SIZE=$(stat -c '%s' $SRC_FILE)
aws s3 cp --acl public-read "$SRC_FILE" "s3://centreon-download/public/${{ inputs.bucket_directory }}/$SRC_FILE"
curl --fail "https://download.centreon.com/api/?token=${{ inputs.token_download_centreon_com }}&product=${{ inputs.module_name }}&release=${{ inputs.release }}&version=${{ inputs.version }}&extension=tar.gz&md5=$SRC_HASH&size=$SRC_SIZE&ddos=0&dryrun=0"
shell: bash

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

29
.github/actions/test-plugins/action.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: "test-plugins"
description: "Test plugin that are passed as parameters"
inputs:
cache-key:
description: "The packaged plugin's cache key"
required: true
plugin-list:
description: "List of plugins to install from the cache"
required: true
package-extension:
description: "Either 'rpm' or 'deb'. Needed to determine the package manager command (dnf or apt-get)."
required: true
runs:
using: "composite"
steps:
- name: get the cached plugin
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ inputs.package-extension }}
key: ${{ inputs.cache-key }}
fail-on-cache-miss: true
- name: Install, test and remove plugin
shell: bash
run: |
[[ -f /.venv/bin/activate ]] && source /.venv/bin/activate
python3 .github/scripts/test-all-plugins.py ${{ inputs.package-extension }} ${{ inputs.plugin-list }}

10
.github/actions/unit-tests/action.yml vendored Normal file
View File

@ -0,0 +1,10 @@
name: "unit-tests"
description: "Unit tests that control the code itself"
runs:
using: "composite"
steps:
- name: Recursively run all unit tests
shell: bash
run: yath -L test ./tests

10
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: monthly
open-pull-requests-limit: 50
labels:
- 'dependencies'
- 'gha'

View File

@ -0,0 +1,33 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:8
RUN bash -e <<EOF
echo '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm-2.41.0 openssl-devel jq zstd selinux-policy-devel yum-utils
dnf config-manager --set-enabled powertools
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive
# For cpan libs
dnf install -y cpio libcurl-devel libssh-devel expat-devel libuuid-devel zeromq-devel libxml2-devel libffi-devel perl-DBI perl-Net-Pcap freetds freetds-devel perl-Module-Build-Tiny
cpanm Module::Build::Tiny
cpanm Module::Install
# Install fpm (ruby 3 is required)
dnf module reset -y ruby
dnf module enable -y ruby:3.1
dnf install -y ruby ruby-devel
gem install fpm
dnf clean all
EOF
WORKDIR /src

View File

@ -0,0 +1,33 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:9
RUN bash -e <<EOF
echo '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm-2.41.0 openssl-devel jq zstd selinux-policy-devel yum-utils
dnf config-manager --set-enabled crb
dnf -y install perl-App-cpanminus perl-JSON
cpanm App::FatPacker
cpanm File::Copy::Recursive
# For cpan libs
dnf install -y cpio libcurl-devel libssh-devel expat-devel libuuid-devel zeromq-devel libxml2-devel libffi-devel perl-DBI perl-Net-Pcap freetds freetds-devel perl-Module-Build-Tiny
cpanm Module::Build::Tiny
cpanm Module::Install
# Install fpm (ruby 3 is required)
dnf module reset -y ruby
dnf module enable -y ruby:3.1
dnf install -y ruby ruby-devel
gem install fpm
dnf clean all
EOF
WORKDIR /src

View File

@ -0,0 +1,72 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bookworm
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 \
libcrypt-openssl-guess-perl \
libcurl4-openssl-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

@ -0,0 +1,70 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bullseye
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
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 \
libfile-copy-recursive-perl \
libjson-perl \
libmodule-build-tiny-perl \
libmodule-install-perl \
libssh-dev \
lintian \
pbuilder \
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

@ -0,0 +1,72 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:jammy
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

@ -0,0 +1,29 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/almalinux:8
RUN bash -e <<EOF
dnf install -y \
git \
java-17-openjdk-devel \
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 '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf install -y nfpm-2.41.0
dnf clean all
EOF
WORKDIR /src

View File

@ -0,0 +1,29 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/almalinux:9
RUN bash -e <<EOF
dnf install -y \
git \
java-17-openjdk-devel \
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 '[goreleaser]
name=GoReleaser
baseurl=https://repo.goreleaser.com/yum/
enabled=1
gpgcheck=0' | tee /etc/yum.repos.d/goreleaser.repo
dnf install -y nfpm-2.41.0
dnf clean all
EOF
WORKDIR /src

View File

@ -0,0 +1,24 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/debian:bookworm
RUN bash -e <<EOF
apt-get update
apt-get install -y \
ca-certificates \
git \
maven=3.8.7-1 \
openjdk-17-jdk \
zstd
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,24 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/debian:bullseye
RUN bash -e <<EOF
apt-get update
apt-get install -y \
ca-certificates \
git \
maven=3.6.3-5 \
openjdk-17-jdk \
zstd
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,30 @@
ARG REGISTRY_URL
FROM ${REGISTRY_URL}/ubuntu:jammy
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,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

@ -0,0 +1,68 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:8
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled powertools
dnf clean all
# Install Robotframework
dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples
# Install snmpsim
pip3.11 install snmpsim
# Install node
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
yum install -y nodejs
# Install mockoon
npm install -g -D @mockoon/cli
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
dnf clean all
EOF

View File

@ -0,0 +1,67 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:9
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled crb
dnf clean all
# Install Robotframework
dnf install -y python3.11 python3.11-pip
pip3.11 install robotframework robotframework-examples
# Install snmpsim
pip3.11 install snmpsim
# Install node
curl -fsSL https://rpm.nodesource.com/setup_21.x | bash -
yum install -y nodejs
# Install mockoon
npm install -g -D @mockoon/cli
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
dnf clean all
EOF

View File

@ -0,0 +1,52 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bookworm
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 Robotframework
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
# 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/apt-plugins-stable/ bookworm main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bookworm main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bookworm 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,51 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bullseye
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 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/apt-plugins-stable/ bullseye main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bullseye main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bullseye 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,49 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:jammy
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 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/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-unstable/ jammy 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,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,59 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:8
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled powertools
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el8/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
dnf install -y gcc make cpan perl-Test2-Suite.noarch perl-Test2-Plugin-NoWarnings.noarch 'perl(Authen::Radius)' 'perl(Convert::Binary::C)' 'perl(Crypt::OpenSSL::RSA)' 'perl(Data::Dumper)' 'perl(Date::Parse)' 'perl(DateTime)' 'perl(DateTime::Duration)' 'perl(DateTime-Format-Duration-ISO8601)' 'perl(DateTime::Format::Strptime)' 'perl(DBD::mysql)' 'perl(DBD::ODBC)' 'perl(DBD::Pg)' 'perl(DBD::Sybase)' 'perl(DBI)' 'perl(Device::Modbus::RTU::Client)' 'perl(Device::Modbus::TCP::Client)' 'perl(Digest::CRC)' 'perl(Digest::MD5)' 'perl(Digest::SHA)' 'perl(Email::MIME)' 'perl(Email::Sender)' 'perl(Email::Send::SMTP::Gmail)' 'perl(Email::Simple)' 'perl(File::Basename)' 'perl(Filesys::SmbClient)' 'perl(Hash::Ordered)' 'perl(HTML::Template)' 'perl(IO::Select)' 'perl(IO::Socket)' 'perl(IO::Socket::INET)' 'perl(IO::Socket::INET6)' 'perl(IO::Socket::SSL)' 'perl(JMX::Jmx4Perl)' 'perl(JSON)' 'perl(JSON::Path)' 'perl(JSON::WebToken)' 'perl(JSON::XS)' 'perl(Libssh::Session)' 'perl-Mail-IMAPClient' 'perl(MIME::Base64)' 'perl(MongoDB)' 'perl(NetAddr::IP)' 'perl(Net::DHCP::Constants)' 'perl(Net::DHCP::Packet)' 'perl(Net::DNS)' 'perl(Net::FTP)' 'perl(Net::FTPSSL)' 'perl(Net::LDAP)' 'perl(Net::MQTT::Simple)' 'perl(Net::NTP)' 'perl(Net::SSLeay)' 'perl(Net::Subnet)' 'perl(Net::Telnet)' 'perl(Net::TFTP)' 'perl(openwsman)' 'perl(Pod::Parser)' 'perl(POSIX)' 'perl(Redis)' 'perl(RRDs)' 'perl(SNMP)' 'perl(Socket)' 'perl(Text::CSV)' 'perl(Time::HiRes)' 'perl(URI::Encode)' 'perl(URI::Escape)' 'perl(UUID)' 'perl(WWW::Selenium)' 'perl(XML::LibXML)' 'perl(XML::LibXML::Simple)' 'perl(XML::Simple)' 'perl(XML::XPath)' 'perl(ZMQ::LibZMQ4)' 'perl(Data::UUID)'
# this image is used by centreon-perl-libs unit test and centreon-gorgone unit tests.
dnf -y install 'perl(Crypt::OpenSSL::AES)' 'perl-Net-Curl' 'perl(YAML::XS)' 'perl(Hash::Merge)' 'perl(Clone)' 'perl(CryptX)' 'perl(JSON::XS)' 'perl(JSON::PP)'
dnf -y install 'perl(Hash::Merge)' 'perl(YAML::XS)' 'perl(ZMQ::FFI)' 'perl-CryptX' 'perl(EV)'
dnf clean all
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness UUID
rm -fr /root/.cpan*
EOF

View File

@ -0,0 +1,57 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/almalinux:9
RUN bash -e <<EOF
dnf install -y 'dnf-command(config-manager)' epel-release zstd jq
dnf config-manager --set-enabled crb
# Add Centreon plugins repositories
echo -e '[centreon-plugins-stable]\n\
name=centreon plugins stable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-stable-noarch]\n\
name=centreon plugins stable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/stable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing]\n\
name=centreon plugins testing x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-testing-noarch]\n\
name=centreon plugins testing noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/testing/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable]\n\
name=centreon plugins unstable x86_64\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/x86_64\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n\
[centreon-plugins-unstable-noarch]\n\
name=centreon plugins unstable noarch\n\
baseurl=https://packages.centreon.com/rpm-plugins/el9/unstable/noarch\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://yum-gpg.centreon.com/RPM-GPG-KEY-CES\n'\
>> /etc/yum.repos.d/centreon-plugins.repo
dnf install -y make cpan perl-Test2-Suite.noarch 'perl(Authen::Radius)' 'perl(Convert::Binary::C)' 'perl(Crypt::OpenSSL::RSA)' 'perl(Data::Dumper)' 'perl(Date::Parse)' 'perl(DateTime)' 'perl(DateTime::Duration)' 'perl(DateTime-Format-Duration-ISO8601)' 'perl(DateTime::Format::Strptime)' 'perl(DBD::mysql)' 'perl(DBD::ODBC)' 'perl(DBD::Pg)' 'perl(DBD::Sybase)' 'perl(DBI)' 'perl(Device::Modbus::RTU::Client)' 'perl(Device::Modbus::TCP::Client)' 'perl(Digest::CRC)' 'perl(Digest::MD5)' 'perl(Digest::SHA)' 'perl(Email::MIME)' 'perl(Email::Sender)' 'perl(Email::Send::SMTP::Gmail)' 'perl(Email::Simple)' 'perl(File::Basename)' 'perl(Filesys::SmbClient)' 'perl(Hash::Ordered)' 'perl(HTML::Template)' 'perl(IO::Select)' 'perl(IO::Socket)' 'perl(IO::Socket::INET)' 'perl(IO::Socket::INET6)' 'perl(IO::Socket::SSL)' 'perl(JMX::Jmx4Perl)' 'perl(JSON)' 'perl(JSON::Path)' 'perl(JSON::WebToken)' 'perl(JSON::XS)' 'perl(Libssh::Session)' 'perl-Mail-IMAPClient' 'perl(MIME::Base64)' 'perl(MongoDB)' 'perl(NetAddr::IP)' 'perl(Net::DHCP::Constants)' 'perl(Net::DHCP::Packet)' 'perl(Net::DNS)' 'perl(Net::FTP)' 'perl(Net::FTPSSL)' 'perl(Net::LDAP)' 'perl(Net::MQTT::Simple)' 'perl(Net::NTP)' 'perl(Net::SSLeay)' 'perl(Net::Subnet)' 'perl(Net::Telnet)' 'perl(Net::TFTP)' 'perl(openwsman)' 'perl(Pod::Parser)' 'perl(POSIX)' 'perl(Redis)' 'perl(RRDs)' 'perl(SNMP)' 'perl(Socket)' 'perl(Text::CSV)' 'perl(Time::HiRes)' 'perl(URI::Encode)' 'perl(URI::Escape)' 'perl(UUID)' 'perl(WWW::Selenium)' 'perl(XML::LibXML)' 'perl(XML::LibXML::Simple)' 'perl(XML::Simple)' 'perl(XML::XPath)' 'perl(ZMQ::LibZMQ4)' 'perl(Data::UUID)'
# this image is used by centreon-perl-libs unit test and centreon-gorgone unit tests.
dnf -y install 'perl(Crypt::OpenSSL::AES)' 'perl-Net-Curl' 'perl(YAML::XS)' 'perl(Hash::Merge)' 'perl(Clone)' 'perl(CryptX)' 'perl(JSON::XS)' 'perl(JSON::PP)'
dnf -y install 'perl(Hash::Merge)' 'perl(YAML::XS)' 'perl(ZMQ::FFI)' 'perl-CryptX' 'perl(EV)'
dnf clean all
mkdir -p /var/lib/centreon/centplugins/
chmod 777 /var/lib/centreon/centplugins/
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness Test2::Plugin::NoWarnings UUID
rm -fr /root/.cpan*
EOF

View File

@ -0,0 +1,33 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bookworm
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/apt-plugins-stable/ bookworm main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bookworm main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bookworm 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 libtest2-harness-perl 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 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 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 -y install libhash-merge-perl libyaml-libyaml-perl libzmq-ffi-perl libcryptx-perl libev-perl
apt-get clean
EOF

View File

@ -0,0 +1,32 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/debian:bullseye
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/apt-plugins-stable/ bullseye main" | tee /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-testing/ bullseye main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/apt-plugins-unstable/ bullseye 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 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 perl perl-modules libdata-uuid-perl
# 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 -y install libhash-merge-perl libyaml-libyaml-perl libzmq-ffi-perl libcryptx-perl libev-perl libcpanel-json-xs-perl
apt-get clean
NONINTERACTIVE_TESTING=1 PERL_MM_USE_DEFAULT=1 cpan Test2::Harness UUID
EOF

View File

@ -0,0 +1,37 @@
ARG REGISTRY_URL=docker.io
FROM ${REGISTRY_URL}/ubuntu:jammy
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/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-testing/ jammy main" | tee -a /etc/apt/sources.list.d/centreon-plugins.list
echo "deb https://packages.centreon.com/ubuntu-plugins-unstable/ jammy 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

@ -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

@ -1,23 +1,55 @@
Thanks for using centreon-plugins! Please follow the indications shown below according to your issue and describe it in English.
Thank you for using Centreon plugins!
Please use this form for actual **bugs** only. See **[Other requests](#other-requests)** for more details.
All existing and future issues related to questions, new plugins or enhancements will be closed.
# Bug report
If you are certain it is a bug, please ensure that there aren't any [similar issues already open](https://github.com/centreon/centreon-plugins/issues) on the same bug.
If the same bug has already been logged, please close your issue and add a comment pointing to the existing one instead.
**For the sake of clarity, please remove the explanations from the issue template before submitting your issue.**
## Quick description
*In one or two sentences, what it your bug about?*
## How to reproduce
*Please provide below the initial conditions to reproduce the bug*
- **Environment**: result of `uname -a ; cat /etc/redhat-release /etc/debian_version`.
- **Version of the plugin**: version of the package or last commit date if using a clone of this repository.
- **Information about the monitored resource**: the exact model and version of the device, software or product you are trying to monitor.
- **Command line**: the command line that is used.
## Expected result
*What you were expecting to have as a result (output, exit return).*
## Actual result
*What you actually got. Please put emphasis on what seems wrong to you.*
# Other requests
## Questions
If you have trouble using our plugins, but are not sure whether it's due to a bug or a misuse, please take the time to ask for help on [The Watch, Data Collection section](https://thewatch.centreon.com/data-collection-6) and become certain that it is a bug before submitting it here.
## New Plugins and modes
To develop a Plugin/mode, we need the following:
* SNMP: MIBs files and full snmpwalk of entreprise branch (snmpwalk -ObentU -v 2c -c public address .1.3.6.1.4.1 > equipment.snmpwalk)
* HTTP API (SOAP, Rest/Json, XML-RPC): the documentation and some curls examples
* CLI: command line examples
* SQL: requests
* JMX: mbean names and attributes
There is high demand for new plugins and new functionalities on existing plugins, so we have to rely on our community to help us prioritize them.
How? Post your suggestion on [The Watch Ideas](https://thewatch.centreon.com/ideas) with as much detail as possible and we will pick the most voted topics to add them to our product roadmap.
If some parts of information are confidentials, please send them directly by email to qgarnier@centreon.com and sbomm@centreon.com.
To develop a plugin/mode, we need the following information, depending on the protocol:
* **SNMP**: MIB files and full snmpwalk of enterprise branch (`snmpwalk -ObentU -v 2c -c public address .1.3.6.1.4.1 > equipment.snmpwalk`) or [SNMP collections](https://thewatch.centreon.com/product-how-to-21/snmp-collection-tutorial-132).
* **HTTP API (SOAP, Rest/Json, XML-RPC)**: the documentation and some curl examples or HTTP [collections](https://thewatch.centreon.com/data-collection-6/centreon-plugins-discover-collection-modes-131).
* **CLI**: command line examples (command + result).
* **SQL**: queries + results + column types or [SQL collections](https://thewatch.centreon.com/product-how-to-21/sql-collection-tutorial-134).
* **JMX**: mbean names and attributes.
Please note that all the developments are open-source. We can't give a date for the development, achievement or release. If it's a priority for you,
send us an email about it (qgarnier@centreon.com and sbomm@centreon.com) and we'll put you in touch with our company.
If some information is confidential, such as logins or IP addresses, obfuscate them in what is sent publicly and we'll get in touch with you by private message if this information is needed.
Please note that all the developments are open source, we will not commit to a release date. If it is an emergency for you, please contact [Centreon's sales team](https://www.centreon.com/contact/).
## Bug/Question
If you are reporting a bug/question, make sure that there aren't any similar/duplicates issues already open. You
can ensure this by searching the issue list for this repository. If so, please close your issue and add a comment to the existing one instead.
Otherwise, open a new issue and provide all parts of information you can (full command line used, actual output, expected output, error message...).

View File

@ -0,0 +1,96 @@
name: "@PACKAGE_NAME@"
arch: "all"
platform: "linux"
version_schema: "none"
version: "${VERSION}"
release: "${RELEASE}${DIST}"
section: "default"
priority: "optional"
maintainer: "Centreon <contact@centreon.com>"
description: |
@SUMMARY@
Commit: @COMMIT_HASH@
vendor: "Centreon"
homepage: "https://centreon.com"
license: "Apache-2.0"
contents:
- src: "../../build/@PLUGIN_NAME@/*"
dst: "/usr/lib/centreon/plugins/"
file_info:
mode: 0775
conflicts:
[@CONFLICTS@]
replaces:
[@REPLACES@]
provides:
[@PROVIDES@]
overrides:
rpm:
depends: [
perl(Crypt::OpenSSL::AES),
perl(Digest::MD5),
perl(Pod::Find),
perl-Net-Curl,
perl(URI::Encode),
perl(LWP::UserAgent),
perl(LWP::Protocol::https),
perl(IO::Socket::SSL),
perl(URI),
perl(HTTP::ProxyPAC),
perl-CryptX,
perl(MIME::Base64),
perl(JSON::XS),
perl-JSON-Path,
perl-KeePass-Reader,
perl(Safe),
perl(Storable),
perl(POSIX),
perl(Encode),
perl(XML::LibXML),
perl(FindBin),
perl(lib),
perl(sort),
@RPM_DEPENDENCIES@
]
conflicts:
[@RPM_CONFLICTS@]
replaces:
[@RPM_REPLACES@]
provides:
[@RPM_PROVIDES@]
deb:
depends: [
libcrypt-openssl-aes-perl,
libpod-parser-perl,
libnet-curl-perl,
liburi-encode-perl,
libwww-perl,
liblwp-protocol-https-perl,
libhttp-cookies-perl,
libio-socket-ssl-perl,
liburi-perl,
libhttp-proxypac-perl,
libcryptx-perl,
libjson-xs-perl,
libjson-path-perl,
libcrypt-argon2-perl,
libkeepass-reader-perl,
libdatetime-perl,
libxml-libxml-perl,
@DEB_DEPENDENCIES@
]
conflicts:
[@DEB_CONFLICTS@]
replaces:
[@DEB_REPLACES@]
provides:
[@DEB_PROVIDES@]
rpm:
compression: xz
signature:
key_file: ${RPM_SIGNING_KEY_FILE}
key_id: ${RPM_SIGNING_KEY_ID}

32
.github/patch/fpm-deb.rb.diff vendored Normal file
View File

@ -0,0 +1,32 @@
--- deb-save.rb 2024-07-12 16:04:30.785256976 +0000
+++ deb.rb 2024-07-12 16:21:22.035244607 +0000
@@ -709,10 +709,19 @@
end.flatten
if origin == FPM::Package::CPAN
+
+ # By default, we'd prefer to name Debian-targeted Perl packages using the
+ # same naming scheme that Debian itself uses, which is usually something
+ # like "lib<module-name-hyphenated>-perl", such as libregexp-common-perl
+ #
+ logger.info("Changing package name to match Debian's typical libmodule-name-perl style")
+ self.name = "lib#{self.name.sub(/^perl-/, "")}-perl"
+
# The fpm cpan code presents dependencies and provides fields as perl(ModuleName)
# so we'll need to convert them to something debian supports.
- # Replace perl(ModuleName) > 1.0 with Debian-style perl-ModuleName (> 1.0)
+ # Replace perl(Module::Name) > 1.0 with Debian-style libmodule-name-perl (> 1.0)
+ # per: https://www.debian.org/doc/packaging-manuals/perl-policy/ch-module_packages.html
perldepfix = lambda do |dep|
m = dep.match(/perl\((?<name>[A-Za-z0-9_:]+)\)\s*(?<op>.*$)/)
if m.nil?
@@ -723,7 +732,7 @@
modulename = m["name"].gsub("::", "-")
# Fix any upper-casing or other naming concerns Debian has about packages
- name = "#{attributes[:cpan_package_name_prefix]}-#{modulename}"
+ name = "lib#{modulename}-perl"
if m["op"].empty?
name

35
.github/scripts/create-spec-file.py vendored Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
import json
from sys import argv
package_path = argv[1]
package_name = argv[2]
package_version = argv[3]
package_release = argv[4]
with open('.github/packaging/rpm/plugin.spectemplate', 'r') as rfile:
specfile = rfile.read()
with open('packaging/%s/pkg.json' % package_path, 'r') as rfile:
plugincfg = json.load(rfile)
with open('packaging/%s/rpm.json' % package_path, 'r') as rfile:
pluginrpm = json.load(rfile)
specfile = specfile.replace('@NAME@', package_name)
specfile = specfile.replace('@VERSION@', package_version)
specfile = specfile.replace('@RELEASE@', package_release)
specfile = specfile.replace('@SUMMARY@', plugincfg['pkg_summary'])
specfile = specfile.replace('@PLUGIN_NAME@', plugincfg['plugin_name'])
specfile = specfile.replace(
'@REQUIRES@',
"\n".join(["Requires:\t%s" % x for x in pluginrpm.get('dependencies', '')])
)
specfile = specfile.replace(
'@CUSTOM_PKG_DATA@', pluginrpm.get('custom_pkg_data', '')
)
# write final specfile
with open('plugin.specfile', 'w+') as wfile:
wfile.write(specfile)

View File

@ -0,0 +1,113 @@
#!/usr/bin/env perl
use App::FatPacker;
use File::Copy::Recursive;
use File::Path;
use File::Basename;
use JSON;
use Cwd qw(getcwd);
my $pwd = (getcwd . '/');
my $plugins_dir = ($pwd . 'src');
my $packaging_dir = ($pwd . 'packaging');
my $build_dir = ($pwd . 'build');
# Prepare destination directory.
File::Path::remove_tree($build_dir);
File::Path::make_path($build_dir);
# Set version within sources.
my $plugins = $ARGV[0];
my $global_version = $ARGV[1];
do {
local $^I = '.bak';
local @ARGV = ($plugins_dir . '/centreon/plugins/script.pm');
while (<>) {
s/^my \$global_version = .*$/my \$global_version = '$global_version';/ig;
print;
}
};
do {
local $^I = '.bak';
local @ARGV = ($plugins_dir . '/centreon/plugins/script.pm');
while (<>) {
s/^my \$alternative_fatpacker = 0;$/my \$alternative_fatpacker = 1;/ig;
print;
}
};
chdir($packaging_dir);
my @plugins = split / /, $plugins;
foreach my $plugin (@plugins) {
chdir($packaging_dir);
# Load plugin configuration file.
my $package_path = $plugin;
if (! -f $package_path . '/pkg.json') {
if ($package_path =~ /(.+)=>(.+)/) {
$package_path = $1;
$plugin = $2;
}
}
if (-f $package_path . '/pkg.json') {
my $plugin_build_dir = $build_dir . '/' . $plugin;
File::Path::make_path($plugin_build_dir);
open($fh, '<', $package_path . '/pkg.json');
my $json_content = do { local $/; <$fh> };
close($fh);
$config = JSON::decode_json($json_content);
# Prepare plugin layout.
chdir($plugins_dir);
File::Path::remove_tree('lib');
File::Path::make_path('lib');
my @common_files = (
'centreon/plugins/http.pm',
'centreon/plugins/misc.pm',
'centreon/plugins/mode.pm',
'centreon/plugins/multi.pm',
'centreon/plugins/options.pm',
'centreon/plugins/output.pm',
'centreon/plugins/perfdata.pm',
'centreon/plugins/script.pm',
'centreon/plugins/statefile.pm',
'centreon/plugins/values.pm',
'centreon/plugins/backend/http/curl.pm',
'centreon/plugins/backend/http/curlconstants.pm',
'centreon/plugins/backend/http/lwp.pm',
'centreon/plugins/backend/http/useragent.pm',
'centreon/plugins/alternative/Getopt.pm',
'centreon/plugins/alternative/FatPackerOptions.pm',
'centreon/plugins/passwordmgr/centreonvault.pm',
'centreon/plugins/passwordmgr/environment.pm',
'centreon/plugins/passwordmgr/file.pm',
'centreon/plugins/passwordmgr/hashicorpvault.pm',
'centreon/plugins/passwordmgr/keepass.pm',
'centreon/plugins/passwordmgr/teampass.pm',
'centreon/plugins/templates/catalog_functions.pm',
'centreon/plugins/templates/counter.pm',
'centreon/plugins/templates/hardware.pm'
);
foreach my $file ((@common_files, @{$config->{files}})) {
if (-f $file) {
File::Copy::Recursive::fcopy($file, 'lib/' . $file);
} elsif (-d $file) {
File::Copy::Recursive::dircopy($file, 'lib/' . $file);
}
}
# Remove __END__ for Centreon Connector Perl compatibility.
system 'find', 'lib', '-name', '*.pm', '-exec', 'sed', '-i', ' /__END__/d', '{}', ';';
# Fatpack plugin.
my $fatpacker = App::FatPacker->new();
my $content = $fatpacker->fatpack_file("centreon_plugins.pl");
open($fh, '>', "$plugin_build_dir/$config->{plugin_name}");
print $fh $content;
close($fh);
chmod 0755, "$plugin_build_dir/$config->{plugin_name}"; # Add execution permission
}
}

62
.github/scripts/pod_spell_check.t vendored Normal file
View File

@ -0,0 +1,62 @@
use strict;
use warnings;
use Test::Spelling;
use List::MoreUtils qw(uniq);
# the command must have at least one argument
if (!@ARGV) {
die "Usage: perl pod_spell_check.t module.pm stopwords.t";
}
# the first argument is the module to check
my $module_to_check = $ARGV[0];
# the second (optional) argument is the additional dictionary
my $stopword_filename='tests/resources/spellcheck/stopwords.txt';
if(defined($ARGV[1])){
$stopword_filename=$ARGV[1];
}
# get_stopwords(): reads the text file and returns its content as an array or strings
sub get_stopwords {
my ($file) = @_;
open(FILE, "<", $stopword_filename)
or die "Could not open $stopword_filename";
printf("Using dictionary: ".$stopword_filename." \n");
my @stop_words;
for my $line (<FILE>) {
chomp $line;
push @stop_words, $line;
}
close(FILE);
return @stop_words;
}
# get_module_options(): reads the Perl module file's POD and returns all the encountered --options
sub get_module_options {
my ($module) = @_;
my @cmd_result = `perldoc -T $module_to_check`;
my @new_words;
for my $pod_line (@cmd_result) {
chomp $pod_line;
my @parsed_options = $pod_line =~ /(--[\w-]+){1,}\s?/mg or next;
push @new_words, @parsed_options;
}
return uniq(sort(@new_words));
}
my @known_words = get_stopwords($stopword_filename);
my @module_options = get_module_options($module_to_check);
# take all words from the text file and the module's options as valid words
add_stopwords(@known_words, @module_options);
# prepare the spelling check command
set_spell_cmd('hunspell -d en_US -l');
# check that all is correct in the Perl module file given as an argument
all_pod_files_spelling_ok($module_to_check);

68
.github/scripts/process-plugins.py vendored Normal file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env python3
from sys import argv
import re
import os
import json
common = argv[1] == 'true'
with open('package_directories.txt') as f:
line_packages = f.readline().strip('\n')
n = len(line_packages)
a = line_packages[1:n-1]
input_packages = a.split(',')
packages = set()
for package in input_packages:
packages.add(package.strip('"/').removeprefix('src/'))
with open('plugins.txt') as f:
line_plugins = f.readline().strip('\n')
n = len(line_plugins)
a = line_plugins[1:n-1]
input_plugins = a.split(',')
plugins = set()
for plugin in input_plugins:
plugins.add(plugin.strip('"/').removeprefix('src/'))
list_plugins = set()
list_packages = set()
for plugin in plugins:
list_plugins.add(plugin)
try:
found = re.search('(.*)\/(?:plugin\.pm|(?:lib|mode|custom)\/.+)', plugin).group(1)
list_plugins.add(found)
except AttributeError:
pass
for filepath in os.popen('find packaging -type f -name pkg.json').read().split('\n')[0:-1]:
packaging_file = open(filepath)
packaging = json.load(packaging_file)
packaging_file.close()
packaging_path = packaging["pkg_name"]
directory_path = re.search('^(.+)\/pkg.json', filepath).group(1)
if common:
# if the common flag is true, then all packages are included
list_packages.add(packaging_path)
elif directory_path in packages:
# if a package file is changed or created, then the package is included
list_packages.add(packaging_path)
else:
# if we don't build all the plugins and no modification have been made to this package's
# specification, then examine if its source code has been changed
for pkg_file in packaging["files"]:
# for each source code file or directory included in the current package
pkg_file_dir = pkg_file.strip('/').removeprefix('src/')
# the current package is impacted by the changes if one of the changed files
# is located inside one of the directories of the package
for modified_file in list_plugins:
# if the beginning of the changed file path includes one of the package's directories
if modified_file.find(pkg_file_dir) == 0:
# then the package is included
list_packages.add(packaging_path)
break
print(*list_packages)

163
.github/scripts/test-all-plugins.py vendored Normal file
View File

@ -0,0 +1,163 @@
#!/usr/bin/env python3
import glob
import subprocess
import sys
import os
import json
def get_tests_folders(plugin_name):
folder_list = []
pkg_file = open("./packaging/" + plugin_name + "/pkg.json")
packaging = json.load(pkg_file)
for file in packaging["files"]: # loop on "files" array in pkg.json file.
if os.path.isdir("tests/" + file): # check if the path is a directory in the "tests" folder
folder_list.append("tests/" + file)
return folder_list
def get_plugin_full_path(plugin_name):
pkg_file = open("./packaging/" + plugin_name + "/pkg.json")
packaging = json.load(pkg_file)
return "/usr/lib/centreon/plugins/" + packaging["plugin_name"]
def test_plugin(plugin_name):
folders_list = get_tests_folders(plugin_name)
print(f"{plugin_name} folders_list : {folders_list}")
if len(folders_list) == 0:
return 0 # no tests present at the moment, but we still have tested the plugin can be installed.
robot_results = subprocess.run("robot --exclude notauto -v ''CENTREON_PLUGINS:" + get_plugin_full_path(plugin_name) + " " + " ".join(folders_list),
shell=True, check=False)
return robot_results.returncode
def try_command(cmd, error):
return_obj = subprocess.run(cmd, shell=True, check=False)
print(return_obj)
if return_obj.returncode != 0:
print(error)
sys.exit(1)
def launch_snmp_sim():
subprocess.run("useradd snmp", shell=True, check=False)
# we don't want to quit if this fail because it often means the user already exist.
# this folder seem needed to launch snmp plugins. I didn't reproduce in my env, but without it,
# the first snmp plugin launched by robot prepend the message "Created directory: /var/lib/snmp/cert_indexes".
try_command(cmd="mkdir -p /var/lib/snmp/cert_indexes/", error="can't create /var/lib/snmp/cert_indexes/ dir")
try_command(cmd="chown snmp:snmp -R /var/lib/snmp/cert_indexes/", error="can't set cert_indexes folder permissions")
snmpsim_cmd = "snmpsim-command-responder --logging-method=null --agent-udpv4-endpoint=127.0.0.1:2024 --process-user=snmp --process-group=snmp --data-dir='./tests' &"
try_command(cmd=snmpsim_cmd, error="can't launch snmp sim daemon.")
def refresh_packet_manager(archi):
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
if archi == "deb":
outfile.write("apt-get update\n")
output_status = (subprocess.run(
"apt-get update",
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
elif archi == "rpm":
return 0
else:
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
exit(1)
return output_status
def install_plugin(plugin, archi):
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
if archi == "deb":
outfile.write("apt-get install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb\n")
output_status = (subprocess.run(
"apt-get install -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' -y ./" + plugin.lower() + "*.deb",
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
elif archi == "rpm":
outfile.write("dnf install --setopt=keepcache=True -y ./" + plugin + "*.rpm\n")
output_status = (subprocess.run("dnf install --setopt=keepcache=True -y ./" + plugin + "*.rpm", shell=True, check=False,
stderr=subprocess.STDOUT, stdout=outfile)).returncode
else:
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
exit(1)
return output_status
def remove_plugin(plugin, archi):
with open('/var/log/robot-plugins-installation-tests.log', "a") as outfile:
if archi == "deb":
outfile.write("apt-get -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower() + "\n")
output_status = (subprocess.run(
"apt-get -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' autoremove -y " + plugin.lower(),
shell=True, check=False, stderr=subprocess.STDOUT, stdout=outfile)).returncode
# -o 'Binary::apt::APT::Keep-Downloaded-Packages=1;' is an option to force apt to keep the package in
# /var/cache/apt/archives, so it do not re download them for every installation.
# 'autoremove', contrary to 'remove' all dependancy while removing the original package.
elif archi == "rpm":
outfile.write("dnf remove --setopt=keepcache=True -y " + plugin + "\n")
output_status = (subprocess.run("dnf remove --setopt=keepcache=True -y " + plugin, shell=True, check=False,
stderr=subprocess.STDOUT, stdout=outfile)).returncode
else:
print(f"Unknown architecture, expected deb or rpm, got {archi}. Exiting.")
exit(1)
# Remove cache files
tmp_files = glob.glob('/dev/shm/*')
for file in tmp_files:
try:
os.remove(file)
except Exception as e:
print(f"Erreur while removing file {file} : {str(e)}")
return output_status
if __name__ == '__main__':
print("starting program")
if len(sys.argv) < 2:
print("please provide architecture (deb or rpm) and list of plugin to test as arguments (one plugin name per "
"argument, separated by space)")
sys.exit(1)
launch_snmp_sim()
archi = sys.argv.pop(1) # expected either deb or rpm.
script_name = sys.argv.pop(0)
error_install = 0
error_tests = 0
error_purge = 0
nb_plugins = 0
list_plugin_error = []
# call apt update (or maybe dnf clean all if needed)
refresh_packet_manager(archi)
for plugin in sys.argv:
print("plugin : ", plugin)
folders_list = get_tests_folders(plugin)
if len(folders_list) == 0:
print(f"we don't test {plugin} as it don't have any robots tests.")
continue
nb_plugins += 1
tmp = install_plugin(plugin, archi)
if tmp > 0:
list_plugin_error.append(plugin)
error_install += tmp
tmp = test_plugin(plugin)
if tmp > 0:
list_plugin_error.append(plugin)
error_tests += tmp
tmp = remove_plugin(plugin, archi)
if tmp > 0:
list_plugin_error.append(plugin)
error_purge += tmp
print(f"{nb_plugins} plugins tested.\n there was {error_install} installation error, {error_tests} test "
f"errors, and {error_purge} removal error list of error : {list_plugin_error}",)
if error_install != 0 or error_tests != 0 or error_purge != 0:
exit(1)
exit(0)
# the snmpsim daemon is still runing when we exit, as this script is mainly run in a docker on CI, it will be
# cleared up eventually.
# to clear it up manually, use ps -ax | grep snmpsim-command-respond | cut -dp -f1 | sudo xargs kill

76
.github/workflows/actionlint.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: actionlint
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
branches:
- develop
- master
- hotfix-*
- release-*
paths:
- ".github/**"
jobs:
action-lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
shell: bash
- name: Check workflow files
run: |
${{ steps.get_actionlint.outputs.executable }} \
-ignore 'label "centreon-common" is unknown' \
-ignore 'label "centreon-collect-arm64" is unknown' \
-ignore '"github.head_ref" is potentially untrusted' \
-shellcheck= \
-pyflakes= \
-color
shell: bash
yaml-lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Yaml
run: |
pip install yamllint==1.32.0
- name: Add Yaml Lint Rules
run: |
cat <<EOF >>./yamllint_rules.yml
extends: default
rules:
document-start: disable
line-length: disable
truthy:
check-keys: false
level: error
indentation:
spaces: 2
indent-sequences: true
check-multi-line-strings: false
comments:
ignore-shebangs: true
min-spaces-from-content: 1
comments-indentation: disable
new-lines:
type: unix
new-line-at-end-of-file: enable
EOF
- name: Lint YAML files
run: |
yamllint -c ./yamllint_rules.yml ./.github/actions/ ./.github/workflows/

160
.github/workflows/as400.yml vendored Normal file
View File

@ -0,0 +1,160 @@
name: as400
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'as400/**'
push:
branches:
- develop
- master
paths:
- 'as400/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: as400/connector.as400/pom.xml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-plugins-java-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-java-alma9
distrib: el9
- package_extension: deb
image: packaging-plugins-java-bullseye
distrib: bullseye
- package_extension: deb
image: packaging-plugins-java-bookworm
distrib: bookworm
- 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 }}
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: Prepare files for packaging
run: |
find . \
-type f \
-exec grep -E '(@CONNECTOR_VERSION@)|(@CONNECTOR_HOME@)|(@CONNECTOR_ETC@)|(@CONNECTOR_LOG@)|(@CONNECTOR_USER@)|(@JAVA_BIN@)' {} ';' \
-exec sed -i \
-e 's|@CONNECTOR_VERSION@|'"${{ needs.get-environment.outputs.version }}"'|g' \
-e 's|@CONNECTOR_HOME@|'"/usr/share/centreon-as400"'|g' \
-e 's|@CONNECTOR_ETC@|'"/etc/centreon-as400/"'|g' \
-e 's|@CONNECTOR_LOG@|'"/var/log/centreon-as400/"'|g' \
-e 's|@CONNECTOR_USER@|'"centreon-as400"'|g' \
-e 's|@JAVA_BIN@|'"/usr/bin/java"'|g' \
{} ';'
shell: bash
- name: Set JAVA_HOME
run: export JAVA_HOME=$( java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' | tr -s ' ' | cut -d ' ' -f 4)
- name: Build JAR using maven
run: mvn -version && mvn clean install -f as400/connector.as400/pom.xml
- name: Remove me after debug
run: find / -name "centreon-as400*.jar"
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "as400/packaging/centreon-as400-daemon.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: 1
arch: all
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-as400-${{ matrix.distrib }}
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 }}
- name: Save to cache
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.${{ matrix.package_extension }}
key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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
- distrib: noble
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: as400
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

180
.github/workflows/check-status.yml vendored Normal file
View File

@ -0,0 +1,180 @@
name: check-status
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request:
branches:
- develop
- master
- hotfix-*
- release-*
jobs:
check-status:
runs-on: ubuntu-24.04
steps:
- name: Check workflow statuses and display token usage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "current rest api rate usage:"
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .rate
echo ""
echo ""
echo "current graphql rate usage:"
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit | jq .resources.graphql
echo ""
echo ""
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
with:
script: |
await exec.exec("sleep 20s");
for (let i = 0; i < 120; i++) {
const failure = [];
const cancelled = [];
const pending = [];
const result = await github.rest.checks.listSuitesForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "${{ github.head_ref }}"
});
result.data.check_suites.forEach(({ app: { slug }, conclusion, id}) => {
if (slug === 'github-actions') {
if (conclusion === 'failure' || conclusion === 'cancelled') {
failure.push(id);
} else if (conclusion === null) {
pending.push(id);
}
console.log(`check suite ${id} => ${conclusion === null ? 'pending' : conclusion}`);
}
});
if (pending.length === 0) {
core.setFailed("Cannot get pull request check status");
return;
}
if (failure.length > 0) {
let failureMessage = '';
const failedCheckRuns = [];
for await (const suite_id of failure) {
const resultCheckRuns = await github.rest.checks.listForSuite({
owner: context.repo.owner,
repo: context.repo.repo,
check_suite_id: suite_id
});
resultCheckRuns.data.check_runs.forEach(({ conclusion, name, html_url }) => {
if (conclusion === 'failure' || conclusion === 'cancelled') {
failedCheckRuns.push(`<a href="${html_url}">${name} (${conclusion})</a>`);
}
});
}
core.summary.addRaw(`${failedCheckRuns.length} job(s) failed:`, true)
core.summary.addList(failedCheckRuns);
core.summary.write()
if (failedCheckRuns.length > 0) {
core.setFailed(`${failedCheckRuns.length} job(s) failed`);
return;
}
}
if (pending.length === 1) {
core.info("All workflows are ok");
return;
}
core.info(`${pending.length} workflows in progress`);
await exec.exec("sleep 30s");
}
core.setFailed("Timeout: some jobs are still in progress");
get-environment:
if: |
contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) &&
(startsWith(github.base_ref, 'release-') || startsWith(github.base_ref, 'hotfix-'))
uses: ./.github/workflows/get-environment.yml
check-cherry-pick:
needs: [get-environment, check-status]
runs-on: ubuntu-24.04
if: |
contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) &&
needs.get-environment.outputs.target_stability == 'testing' &&
! contains(needs.get-environment.outputs.labels, 'skip-cherry-pick')
steps:
- name: Check if the PR is a cherry-pick from dev branch
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
LINKED_DEV_BRANCH: develop
with:
script: |
let linkedPrs = [];
let errorMessage = `This pull request is not a cherry-pick from ${process.env.LINKED_DEV_BRANCH} or has no reference to a pull request which has been merged on ${process.env.LINKED_DEV_BRANCH}\n`;
try {
const pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const { title, body } = pull.data;
[title, body].forEach((text) => {
const linkedPrMatches = text.matchAll(/(?:#|\/pull\/)(\d+)/g);
if (linkedPrMatches) {
[...linkedPrMatches].forEach((match) => {
linkedPrs.push(Number(match[1]));
});
}
});
// remove duplicates
linkedPrs = [...new Set(linkedPrs)];
console.log(`Linked pull requests found in PR title and body: ${linkedPrs.join(', ')}`);
} catch (e) {
throw new Error(`Failed to get information of pull request #${context.issue.number}: ${e}`);
}
for await (const prNumber of linkedPrs) {
try {
const pull = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
if (pull.data.base.ref === process.env.LINKED_DEV_BRANCH) {
if (pull.data.state === 'closed' && pull.data.merged === true) {
console.log(`This pull request is a cherry-pick from pull request #${prNumber} on ${process.env.LINKED_DEV_BRANCH}`);
return;
} else {
errorMessage += `This pull request seems to be a cherry-pick from pull request #${prNumber} on ${process.env.LINKED_DEV_BRANCH} but it is not merged yet\n`;
}
} else {
errorMessage += `Pull request #${prNumber} is linked to ${pull.data.base.ref} instead of ${process.env.LINKED_DEV_BRANCH}\n`;
}
} catch (e) {
errorMessage += `Failed to get information on pull request #${prNumber}: ${e}\n`;
}
}
errorMessage += `\nIf you are sure this PR does not need to be a cherry-pick from ${process.env.LINKED_DEV_BRANCH} or must be merged urgently, `;
errorMessage += `open the pull request on ${process.env.LINKED_DEV_BRANCH} and add label "skip-cherry-pick" to the PR and re-run all jobs of workflow check-status\n`;
throw new Error(errorMessage);

137
.github/workflows/connector-vmware.yml vendored Normal file
View File

@ -0,0 +1,137 @@
name: connector-vmware
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'connectors/vmware/src/**'
- 'connectors/vmware/packaging/**'
push:
branches:
- develop
- master
paths:
- 'connectors/vmware/src/**'
- 'connectors/vmware/packaging/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: connectors/vmware/src/centreon/script/centreon_vmware.pm
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
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
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
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: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "connectors/vmware/packaging/centreon-plugin-virtualization-vmware-daemon.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: 1
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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 }}
- name: Upload apt/dnf packages as artifacts if asked
if: ${{ contains(github.event.pull_request.labels.*.name, 'upload-artifacts') }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: vmware-connector-daemon-${{ matrix.distrib }}
path: centreon-plugin*
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
- distrib: noble
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: connector-vmware
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

@ -0,0 +1,111 @@
name: docker-builder-packaging-plugins
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- ".github/workflows/docker-builder-packaging-plugins.yml"
- ".github/docker/packaging/*"
pull_request:
paths:
- ".github/workflows/docker-builder-packaging-plugins.yml"
- ".github/docker/packaging/*"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
dockerize:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
dockerfile: packaging-plugins-alma8
image: packaging-plugins-alma8
- runner: ubuntu-22.04
dockerfile: packaging-plugins-alma9
image: packaging-plugins-alma9
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-alma8
image: packaging-plugins-java-alma8
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-alma9
image: packaging-plugins-java-alma9
- runner: ubuntu-22.04
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye
- runner: centreon-collect-arm64
dockerfile: packaging-plugins-bullseye
image: packaging-plugins-bullseye-arm64
- runner: ubuntu-22.04
dockerfile: packaging-plugins-bookworm
image: packaging-plugins-bookworm
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-bullseye
image: packaging-plugins-java-bullseye
- runner: ubuntu-22.04
dockerfile: packaging-plugins-java-bookworm
image: packaging-plugins-java-bookworm
- runner: ubuntu-22.04
dockerfile: packaging-plugins-jammy
image: packaging-plugins-jammy
- 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 }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- name: Login to proxy registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/packaging/Dockerfile.${{ matrix.dockerfile }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
set-skip-label:
needs: [get-environment, dockerize]
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

@ -0,0 +1,94 @@
name: docker-builder-testing-plugins
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- ".github/workflows/docker-builder-testing-plugins.yml"
- ".github/docker/testing/*"
pull_request:
paths:
- ".github/workflows/docker-builder-testing-plugins.yml"
- ".github/docker/testing/*"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
dockerize:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
dockerfile: alma8
image: alma8
- runner: ubuntu-24.04
dockerfile: alma9
image: alma9
- runner: ubuntu-24.04
dockerfile: bullseye
image: bullseye
- runner: centreon-collect-arm64
dockerfile: bullseye
image: bullseye-arm64
- runner: ubuntu-24.04
dockerfile: bookworm
image: bookworm
- runner: ubuntu-24.04
dockerfile: jammy
image: jammy
- runner: ubuntu-24.04
dockerfile: noble
image: noble
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- name: Login to proxy registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/testing/Dockerfile.testing-plugins-${{ matrix.dockerfile }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/testing-plugins-${{ matrix.image }}:latest
set-skip-label:
needs: [get-environment, dockerize]
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

@ -0,0 +1,93 @@
name: docker-builder-unit-tests
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- develop
paths:
- ".github/workflows/docker-builder-unit-tests.yml"
- ".github/docker/unit-tests/*"
pull_request:
paths:
- ".github/workflows/docker-builder-unit-tests.yml"
- ".github/docker/unit-tests/*"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
dockerize:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-22.04
dockerfile: alma8
image: alma8
- runner: ubuntu-22.04
dockerfile: alma9
image: alma9
- runner: ubuntu-22.04
dockerfile: bullseye
image: bullseye
- runner: centreon-collect-arm64
dockerfile: bullseye
image: bullseye-arm64
- runner: ubuntu-22.04
dockerfile: bookworm
image: bookworm
- runner: ubuntu-22.04
dockerfile: jammy
image: jammy
- runner: ubuntu-22.04
dockerfile: noble
image: noble
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- name: Login to proxy registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_PROXY_REGISTRY_URL }}
username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}
- uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
- uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0
with:
file: .github/docker/unit-tests/Dockerfile.unit-tests-${{ matrix.dockerfile }}
context: .
build-args: "REGISTRY_URL=${{ vars.DOCKER_PROXY_REGISTRY_URL }}"
pull: true
push: true
tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/unit-tests-${{ matrix.image }}:latest
set-skip-label:
needs: [get-environment, dockerize]
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

374
.github/workflows/get-environment.yml vendored Normal file
View File

@ -0,0 +1,374 @@
on:
workflow_call:
inputs:
version_file:
required: false
type: string
outputs:
version:
description: "version"
value: ${{ jobs.get-environment.outputs.version }}
release:
description: "release"
value: ${{ jobs.get-environment.outputs.release }}
stability:
description: "branch stability (stable, testing, unstable, canary)"
value: ${{ jobs.get-environment.outputs.stability }}
target_stability:
description: "Final target branch stability (stable, testing, unstable, canary or not defined if not a pull request)"
value: ${{ jobs.get-environment.outputs.target_stability }}
release_type:
description: "type of release (hotfix, release or not defined if not a release)"
value: ${{ jobs.get-environment.outputs.release_type }}
is_targeting_feature_branch:
description: "if it is a PR, check if targeting a feature branch"
value: ${{ jobs.get-environment.outputs.is_targeting_feature_branch }}
skip_workflow:
description: "if the current workflow should be skipped"
value: ${{ jobs.get-environment.outputs.skip_workflow }}
labels:
description: "list of labels on the PR"
value: ${{ jobs.get-environment.outputs.labels }}
jobs:
get-environment:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.get_version.outputs.version }}
release: ${{ steps.get_release.outputs.release }}
stability: ${{ steps.get_stability.outputs.stability }}
target_stability: ${{ steps.get_stability.outputs.target_stability }}
release_type: ${{ steps.get_release_type.outputs.release_type }}
is_targeting_feature_branch: ${{ steps.get_stability.outputs.is_targeting_feature_branch }}
skip_workflow: ${{ steps.skip_workflow.outputs.result }}
labels: ${{ steps.has_skip_label.outputs.labels }}
steps:
- name: Check if PR has skip label
id: has_skip_label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
let hasSkipLabel = false;
let labels = [];
if (${{ contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) }} === true) {
try {
const fetchedLabels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
fetchedLabels.data.forEach(({ name }) => {
labels.push(name);
if (name === '${{ format('skip-workflow-{0}', github.workflow) }}') {
hasSkipLabel = true;
}
});
} catch (e) {
core.warning(`failed to list labels: ${e}`);
}
}
core.setOutput('labels', labels);
return hasSkipLabel;
- name: Checkout sources (current branch)
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: ${{ steps.has_skip_label.outputs.result == 'true' && 100 || 1 }}
- if: ${{ steps.has_skip_label.outputs.result == 'true' }}
name: Get workflow triggered paths
id: get_workflow_triggered_paths
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const fs = require('fs');
let paths = [];
const workflowFilePath = '${{ github.workflow_ref }}'.replace('${{ github.repository }}/', '').split('@').shift();
if (fs.existsSync(workflowFilePath)) {
const workflowFileContent = fs.readFileSync(workflowFilePath, 'utf8');
const workflowFileContentLines = workflowFileContent.split('\n');
let hasReadOn = false;
let hasReadPullRequest = false;
let hasReadPaths = false;
for (const line of workflowFileContentLines) {
if (line.match(/^on:\s*$/)) {
hasReadOn = true;
continue;
}
if (line.match(/^\s{2}pull_request(_target)?:\s*$/)) {
hasReadPullRequest = true;
continue;
}
if (line.match(/^\s{4}paths:\s*$/)) {
hasReadPaths = true;
continue;
}
if (hasReadOn && hasReadPullRequest && hasReadPaths) {
const matches = line.match(/^\s{6}-\s['"](.+)['"]\s*$/);
if (matches) {
paths.push(matches[1].trim());
} else {
break;
}
}
}
}
if (paths.length === 0) {
paths = ['**'];
}
console.log(paths);
return paths;
- if: ${{ steps.has_skip_label.outputs.result == 'true' }}
name: Get push changes
id: get_push_changes
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
with:
since_last_remote_commit: true
json: true
escape_json: false
files: ${{ join(fromJSON(steps.get_workflow_triggered_paths.outputs.result), ';') }}
files_separator: ';'
- name: Check if current workflow should be skipped
id: skip_workflow
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
if (${{ steps.has_skip_label.outputs.result }} === false) {
return false;
}
const label = '${{ format('skip-workflow-{0}', github.workflow) }}';
if ('${{ steps.get_push_changes.outputs.any_changed }}' === 'true') {
try {
await github.rest.issues.removeLabel({
name: label,
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
core.notice(`label ${label} removed because changes were detected on last push.`);
} catch (e) {
core.warning(`failed to remove label ${label}: ${e}`);
}
return false;
}
return true;
- if: ${{ github.event_name == 'pull_request' }}
name: Get nested pull request path
id: pr_path
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const prPath = ['${{ github.head_ref }}', '${{ github.base_ref }}'];
const result = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
state: 'open'
});
let found = true;
while (found) {
found = false;
result.data.forEach(({ head: { ref: headRef }, base: { ref: baseRef} }) => {
if (headRef === prPath[prPath.length - 1] && ! prPath.includes(baseRef)) {
found = true;
prPath.push(baseRef);
}
});
}
return prPath;
- name: Get stability
id: get_stability
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const getStability = (branchName) => {
switch (true) {
case /(^develop$)|(^dev-\d{2}\.\d{2}\.x$)/.test(branchName):
return 'unstable';
case /(^release.+)|(^hotfix.+)/.test(branchName):
return 'testing';
case /(^master$)|(^\d{2}\.\d{2}\.x$)/.test(branchName):
return 'stable';
default:
return 'canary';
}
};
core.setOutput('stability', getStability('${{ github.head_ref || github.ref_name }}'));
let isTargetingFeatureBranch = false;
if ("${{ github.event_name }}" === "pull_request") {
let targetStability = 'canary';
const prPath = ${{ steps.pr_path.outputs.result || '[]' }};
prPath.shift(); // remove current branch
if (prPath.length && getStability(prPath[0]) === 'canary') {
isTargetingFeatureBranch = true;
}
prPath.every((branchName) => {
console.log(`checking stability of ${branchName}`)
targetStability = getStability(branchName);
if (targetStability !== 'canary') {
return false;
}
return true;
});
core.setOutput('target_stability', targetStability);
}
core.setOutput('is_targeting_feature_branch', isTargetingFeatureBranch);
- name: Get version
id: get_version
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();
} 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) {
version = matches[1];
} else {
throw new Error('invalid version');
}
} else if ('${{ steps.get_stability.outputs.stability }}' === 'unstable') {
const currentDate = new Date();
version = `${currentDate.getFullYear()}${("0" + (currentDate.getMonth() + 1)).slice(-2)}${String(currentDate.getDate()).padStart(2, '0')}`;
} else {
const currentDate = new Date();
version = `${currentDate.getFullYear()}${("0" + (currentDate.getMonth() + 1)).slice(-2)}00`;
}
core.setOutput('version', version);
- name: "Get release: 1 for testing / stable, <date> for others"
id: get_release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
let release = '';
if (${{ contains(fromJSON('["testing", "unstable"]') , steps.get_stability.outputs.stability) }} === true) {
release = "1"
} else {
release = Date.now()
}
core.setOutput('release', release);
- name: "Get release type: hotfix, release or not defined if not a release"
id: get_release_type
run: |
RELEASE_TYPE=$(echo "${{ github.head_ref || github.ref_name }}" | cut -d '-' -f 1)
if [[ "$RELEASE_TYPE" == "hotfix" || "$RELEASE_TYPE" == "release" ]]; then
echo "release_type=$RELEASE_TYPE" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Display info in job summary
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const outputTable = [
[{data: 'Name', header: true}, {data: 'Value', header: true}],
['version', '${{ steps.get_version.outputs.version }}'],
['release', '${{ steps.get_release.outputs.release }}'],
['stability', '${{ steps.get_stability.outputs.stability }}'],
['release_type', '${{ steps.get_release_type.outputs.release_type || '<em>not defined because this is not a release</em>' }}'],
['is_targeting_feature_branch', '${{ steps.get_stability.outputs.is_targeting_feature_branch }}'],
['target_stability', '${{ steps.get_stability.outputs.target_stability || '<em>not defined because current run is not triggered by pull request event</em>' }}'],
['skip_workflow', '${{ steps.skip_workflow.outputs.result }}'],
['labels', '${{ steps.has_skip_label.outputs.labels }}'],
];
core.summary
.addHeading(`${context.workflow} environment outputs`)
.addTable(outputTable);
if ("${{ github.event_name }}" === "pull_request") {
const prPath = ${{ steps.pr_path.outputs.result || '[]' }};
const mainBranchName = prPath.pop();
let codeBlock = `
%%{ init: { 'gitGraph': { 'mainBranchName': '${mainBranchName}', 'showCommitLabel': false } } }%%
gitGraph
commit`;
prPath.reverse().forEach((branchName) => {
codeBlock = `${codeBlock}
branch ${branchName}
checkout ${branchName}
commit`;
});
core.summary
.addHeading('Git workflow')
.addCodeBlock(
codeBlock,
"mermaid"
);
}
core.summary.write();

172
.github/workflows/nrpe.yml vendored Normal file
View File

@ -0,0 +1,172 @@
name: nrpe
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'nrpe/packaging/**'
push:
branches:
- develop
- master
paths:
- 'nrpe/packaging/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: nrpe/packaging/centreon-nrpe4-daemon.yaml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
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
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
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: Download nrpe sources
run: |
curl -sLo - "https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-${{ needs.get-environment.outputs.version }}/nrpe-${{ needs.get-environment.outputs.version }}.tar.gz" | tar zxpf -
mv nrpe-${{ needs.get-environment.outputs.version }} nrpe-src
shell: bash
- name: Compile sources
run: |
cd nrpe-src
patch -p1 < ../nrpe/packaging/files/nrpe4_add_centreon_cmd.patch
if [ "${{ matrix.package_extension }}" = "deb" ]; then
NAGIOS_PLUGINS_PATH="/usr/lib/nagios/plugins"
else
NAGIOS_PLUGINS_PATH="/usr/lib64/nagios/plugins"
fi
CXXFLAGS="-Wall -Wextra" ./configure \
--libexecdir="$NAGIOS_PLUGINS_PATH" \
--localstatedir="/var/log/nrpe" \
--sysconfdir="/etc/nrpe" \
--enable-command-args \
--with-nrpe-user="centreon-engine" \
--with-nrpe-group="centreon-engine" \
--with-nrpe-port="5666" \
--with-nagios-user="centreon-engine" \
--with-nagios-group="centreon-engine"
make all
shell: bash
- name: Generate debug files
run: |
cd nrpe-src/src
for file in "nrpe" "check_nrpe"; do
objcopy --only-keep-debug $file $file.debug
objcopy --strip-debug $file
objcopy --add-gnu-debuglink $file.debug $file
done
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "nrpe/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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 }}
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
- distrib: noble
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: nrpe
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

@ -0,0 +1,774 @@
name: perl-cpan-libraries
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/perl-cpan-libraries.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:
- ".github/workflows/perl-cpan-libraries.yml"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package-rpm:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
distrib: [el8, el9]
name:
[
"ARGV::Struct",
"Authen::SASL::SASLprep",
"Authen::SCRAM::Client",
"BSON",
"BSON::XS",
"Config::AWS",
"Convert::Binary::C",
"Convert::EBCDIC",
"Crypt::Argon2",
"Crypt::Blowfish_PP",
"Crypt::OpenSSL::AES",
"DataStruct::Flat",
"DateTime::Format::Duration::ISO8601",
"DBD::Sybase",
"Device::Modbus",
"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",
"Net::NTP",
"Net::SMTPS",
"Net::SMTP_auth",
"Net::Subnet",
"Net::TFTP",
"Paws",
"PBKDF2::Tiny",
"Statistics::Descriptive",
"Statistics::Regression",
"Term::Clui",
"Unicode::Stringprep",
"URI::Template",
"URL::Encode",
"URL::Encode::XS",
"UUID",
"UUID::URandom",
"WWW::Selenium",
"XML::LibXML::Simple",
"ZMQ::Constants",
"ZMQ::FFI",
"ZMQ::LibZMQ4"
]
include:
- build_distribs: "el8,el9"
- rpm_dependencies: ""
- rpm_provides: ""
- version: ""
- spec_file: ""
- no-auto-depends: "false"
- preinstall_cpanlibs: ""
- revision: "1"
- distrib: el8
package_extension: rpm
image: packaging-plugins-alma8
- distrib: el9
package_extension: rpm
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"
version: "0.022"
- name: "Device::Modbus::TCP::Client"
version: "0.026"
- name: "FFI::CheckLib"
rpm_dependencies: "perl(Env)"
- 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"
- 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"
- 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"
build_distribs: el9
- name: "Statistics::Descriptive"
build_distribs: el9
- name: "Statistics::Regression"
version: "0.53"
- name: "URL::Encode::XS"
build_distribs: el9
- name: "UUID"
version: "0.31"
- name: "ZMQ::Constants"
build_distribs: "el9"
- name: "ZMQ::FFI"
rpm_dependencies: "zeromq"
- name: "ZMQ::LibZMQ4"
version: "0.01"
rpm_dependencies: "zeromq"
name: package ${{ matrix.distrib }} ${{ matrix.name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- if: ${{ contains(matrix.build_distribs, matrix.distrib) }}
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
id: check-package-existence
run: |
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\($(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
echo "::warning::Package ${{ matrix.name }} exists in the official ${{ matrix.distrib }} repository with a different version."
do_not_build="false"
fi
fi
echo "do_not_build=$do_not_build" >> $GITHUB_OUTPUT
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_distribs, matrix.distrib) && matrix.spec_file == '' }}
run: |
PACKAGE_VERSION=" -v ${{ steps.package-infos.outputs.package_version }}"
if [ -z "${{ matrix.rpm_dependencies }}" ]; then
PACKAGE_DEPENDENCIES=""
else
for PACKAGE_DEPENDENCY in `echo "${{ matrix.rpm_dependencies }}"`; do
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --depends "$PACKAGE_DEPENDENCY""
done
fi
if [ "${{ matrix.no-auto-depends }}" == "true" ]; then
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends"
fi
if [ -z "${{ matrix.rpm_provides }}" ]; then
PACKAGE_PROVIDES=""
else
for PACKAGE_PROVIDE in `echo "${{ matrix.rpm_provides }}"`; do
PACKAGE_PROVIDES="$PACKAGE_PROVIDES --provides $PACKAGE_PROVIDE"
done
fi
for CPANLIB_PREINSTALL in `echo "${{ matrix.preinstall_cpanlibs }}"`; do
cpanm $CPANLIB_PREINSTALL
done
export SYBASE="/usr"
temp_file=$(mktemp)
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"
exit 1
fi
# Check rpm
rpm2cpio $created_package | cpio -t
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_distribs, matrix.distrib) && matrix.spec_file != '' }}
run: |
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
rpmbuild --undefine=_disable_source_fetch -ba ${{ matrix.spec_file }}
cp -r ~/rpmbuild/RPMS/noarch/*.rpm .
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_distribs, matrix.distrib) }}
name: Replace '::' with - in the feature path
id: package-name
run: |
name="${{ matrix.name }}"
name_with_dash="${name//::/-}"
echo "Modified Name: $name_with_dash"
echo "name_with_dash=$name_with_dash" >> $GITHUB_OUTPUT
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_distribs, matrix.distrib) }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ steps.package-name.outputs.name_with_dash }}
path: ./*.${{ matrix.package_extension }}
retention-days: 1
merge-package-rpm-artifacts:
needs: [get-environment, package-rpm]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [el8, el9]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-rpm-${{ matrix.distrib }}
pattern: packages-rpm-${{ matrix.distrib }}-*
delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET
retention-days: 1
- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: packages-rpm-${{ matrix.distrib }}-*
failOnError: false
sign-rpm:
needs: [get-environment, merge-package-rpm-artifacts]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [el8, el9]
name: sign rpm ${{ matrix.distrib }}
container:
image: docker.centreon.com/centreon-private/rpm-signing:latest
options: -t
credentials:
username: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_USERNAME }}
password: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_TOKEN }}
steps:
- run: apt-get install -y zstd
shell: bash
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: packages-rpm-${{ matrix.distrib }}
path: ./
- run: echo "HOME=/root" >> $GITHUB_ENV
shell: bash
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
package-deb:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ${{ matrix.runner_name }}
strategy:
fail-fast: false
matrix:
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",
"DateTime::Format::Duration::ISO8601",
"Device::Modbus",
"Device::Modbus::RTU::Client",
"Device::Modbus::TCP::Client",
"Digest::SHA1",
"Email::Send::SMTP::Gmail",
"Hash::Ordered",
"HTTP::ProxyPAC",
"JMX::Jmx4Perl",
"Libssh::Session",
"Mojo::IOLoop::Signal",
"Net::Amazon::Signature::V4",
"Net::Curl",
"Net::FTPSSL",
"Net::HTTPTunnel",
"Net::MQTT::Simple",
"Paws",
"Statistics::Regression",
"XS::Loader",
"ZMQ::Constants",
"ZMQ::LibZMQ4"
]
include:
- runner_name: ubuntu-24.04
- arch: amd64
- build_names: "bullseye-amd64,bookworm,jammy,noble"
- deb_dependencies: ""
- 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
image: packaging-plugins-bullseye
- build_name: bookworm
distrib: bookworm
package_extension: deb
image: packaging-plugins-bookworm
- build_name: jammy
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: 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,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,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", "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"
- name: "Statistics::Regression"
build_names: "bullseye-amd64"
version: "0.53"
- name: "ZMQ::LibZMQ4"
use_dh_make_perl: "false"
version: "0.01"
deb_dependencies: "libzmq5"
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
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
name: Parse distrib name
id: parse-distrib
uses: ./.github/actions/parse-distrib
with:
distrib: ${{ matrix.distrib }}
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
name: Get package infos
id: package-infos
run: |
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/.*\-//')
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' | tr '[:upper:]' '[:lower:]')
# 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
- if: ${{ contains(matrix.build_names, matrix.build_name) }}
name: Check if package already exists
id: check-package-existence
run: |
package_info=$(apt-cache policy ${{ steps.package-infos.outputs.package_name }})
if [[ -n $package_info && "${{ steps.package-infos.outputs.package_name }}" =~ "_" ]]; then
package_info=$(apt-cache policy $(echo ${{ steps.package-infos.outputs.package_name }} | sed 's/_//g'))
fi
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 }}"* || "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
echo "::warning::Package ${{ steps.package-infos.outputs.package_name }} exists in the official ${{ matrix.distrib }} repository with a different version."
do_not_build="false"
fi
fi
echo "do_not_build=$do_not_build" >> $GITHUB_OUTPUT
shell: bash
- 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
for PACKAGE_DEPENDENCY in `echo ${{ matrix.deb_dependencies }}`; do
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --depends $PACKAGE_DEPENDENCY"
done
fi
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)
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 --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 }} --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: dh-make-perl command failed"
exit 1
fi
# Check deb
dpkg-deb --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) }}
name: Replace '::' with - in the feature path
id: package-name
run: |
name="${{ matrix.name }}"
name_with_dash="${name//::/-}"
echo "Modified Name: $name_with_dash"
echo "name_with_dash=$name_with_dash" >> $GITHUB_OUTPUT
shell: bash
- if: ${{ steps.check-package-existence.outputs.do_not_build == 'false' && contains(matrix.build_names, matrix.build_name) }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ matrix.arch }}-${{ steps.package-name.outputs.name_with_dash}}
path: ./*.${{ matrix.package_extension }}
retention-days: 1
merge-package-deb-artifacts:
needs: [get-environment, package-deb]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy, noble]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-deb-${{ matrix.distrib }}
pattern: packages-deb-${{ matrix.distrib }}-*
delete-merged: false # cannot be set to true due to random fails: Failed to DeleteArtifact: Unable to make request: ECONNRESET
retention-days: 1
- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: packages-deb-${{ matrix.distrib }}-*
failOnError: false
download-and-cache-deb:
needs: [get-environment, merge-package-deb-artifacts]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-24.04
strategy:
matrix:
distrib: [bullseye, bookworm, jammy, noble]
steps:
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: packages-deb-${{ matrix.distrib }}
path: ./
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
test-packages:
needs: [get-environment, sign-rpm, download-and-cache-deb]
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: almalinux:8
distrib: el8
arch: amd64
runner_name: ubuntu-24.04
- package_extension: rpm
image: almalinux:9
distrib: el9
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: debian:bullseye
distrib: bullseye
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: debian:bookworm
distrib: bookworm
arch: amd64
runner_name: ubuntu-24.04
- package_extension: deb
image: ubuntu:jammy
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: centreon-collect-arm64
runs-on: ${{ matrix.runner_name }}
container:
image: ${{ matrix.image }}
name: Test perl CPAN libs packages on ${{ matrix.package_extension }} ${{ matrix.distrib }} ${{ matrix.arch }}
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Test packaged libs
uses: ./.github/actions/test-cpan-libs
with:
package_extension: ${{ matrix.package_extension }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
- name: Upload error log
if: failure()
uses: actions/upload-artifact@v4
with:
name: install_error_log_${{ matrix.distrib }}-${{ matrix.arch }}
path: install_error_${{ matrix.distrib }}_${{ matrix.arch }}.log
deliver-packages:
needs: [get-environment, sign-rpm, download-and-cache-deb, test-packages]
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
- distrib: noble
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-cpan-libraries
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

@ -0,0 +1,214 @@
name: perl-filesys-smbclient
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-filesys-smbclient/**"
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-filesys-smbclient/**"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package-rpm:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
- image: packaging-plugins-alma9
distrib: el9
name: package ${{ matrix.distrib }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: |
yum install -y yum-utils
yum config-manager --set-enabled crb || true # alma 9
yum config-manager --set-enabled powertools || true # alma 8
yum install -y libsmbclient-devel make gcc perl perl-devel perl-ExtUtils-MakeMaker
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp -rp dependencies/perl-filesys-smbclient/src perl-Filesys-SmbClient/
tar czf ~/rpmbuild/SOURCES/perl-Filesys-SmbClient.tar.gz perl-Filesys-SmbClient
rpmbuild -ba dependencies/perl-filesys-smbclient/packaging/rpm/perl-Filesys-SmbClient.spec
cp -r ~/rpmbuild/RPMS/x86_64/*.rpm .
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
sign-rpm:
needs: [get-environment, package-rpm]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- image: packaging-alma8
distrib: el8
- image: packaging-alma9
distrib: el9
name: sign rpm ${{ matrix.distrib }}
container:
image: docker.centreon.com/centreon-private/rpm-signing:latest
options: -t
credentials:
username: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_USERNAME }}
password: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_TOKEN }}
steps:
- run: |
apt-get update
apt-get install -y zstd
shell: bash
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
- run: echo "HOME=/root" >> $GITHUB_ENV
shell: bash
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
package-deb:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- image: packaging-plugins-bullseye
distrib: bullseye
- image: packaging-plugins-bookworm
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
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Parse distrib name
id: parse-distrib
uses: ./.github/actions/parse-distrib
with:
distrib: ${{ matrix.distrib }}
- run: |
apt update
apt install -y dh-make-perl perl libsmbclient-dev
mv dependencies/perl-filesys-smbclient/src/ perl-filesys-smbclient
tar czf perl-filesys-smbclient.tar.gz perl-filesys-smbclient
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@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.deb
key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
deliver-packages:
needs: [get-environment, sign-rpm, package-deb]
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
- distrib: noble
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-filesys-smbclient
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

@ -0,0 +1,173 @@
name: perl-keepass-reader
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-keepass-reader/**"
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-keepass-reader/**"
env:
module_name: perl-keepass-reader
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
- image: packaging-plugins-noble
distrib: noble
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: Build library
run: |
if [[ "${{ matrix.package_extension }}" == "rpm" ]]; then
dnf install -y make perl
else
apt-get update
apt-get install -y make perl
fi
cd dependencies/perl-keepass-reader/src
perl Makefile.PL INSTALL_BASE=/tmp/perl-keepass-reader
make
make pure_install
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="libkeepass-reader-perl"
PERL_VENDORLIB="/usr/share/perl5"
else
NAME="perl-KeePass-Reader"
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-keepass-reader/packaging/perl-keepass-reader.yaml
sed -i "s#@PERL_VENDORLIB@#$PERL_VENDORLIB#g" dependencies/perl-keepass-reader/packaging/perl-keepass-reader.yaml
cat dependencies/perl-keepass-reader/packaging/perl-keepass-reader.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-keepass-reader/packaging/perl-keepass-reader.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: "0.2"
release: "3"
arch: all
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.run_id }}-${{ matrix.package_extension }}-${{ env.module_name }}-${{ matrix.distrib }}
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 }}
deliver-packages:
needs: [get-environment, package]
if: |
(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
- distrib: noble
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: ${{ env.module_name }}
distrib: ${{ matrix.distrib }}
cache_key: cache-${{ github.run_id }}-${{ matrix.package_extension }}-${{ env.module_name }}-${{ matrix.distrib }}
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

280
.github/workflows/perl-openwsman.yml vendored Normal file
View File

@ -0,0 +1,280 @@
name: perl-openwsman
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/perl-openwsman/**"
push:
branches:
- develop
- master
paths:
- "dependencies/perl-openwsman/**"
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-noble
distrib: noble
package_extension: deb
runner: ubuntu-22.04
arch: amd64
- image: packaging-plugins-bullseye-arm64
distrib: bullseye
package_extension: deb
runner: centreon-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 }}
env:
version: "2.7.2"
release: "6"
steps:
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install locally sblim-sfcc
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get update
apt-get install -y libcurl4-openssl-dev
cd /tmp
wget -O - https://github.com/kkaempf/sblim-sfcc/archive/refs/tags/SFCC_2_2_8.tar.gz|tar zxvf -
cd sblim-sfcc-SFCC_2_2_8
./autoconfiscate.sh
./configure --prefix=/usr
make
make install
else
dnf install -y 'dnf-command(config-manager)'
if [ "${{ matrix.distrib }}" = "el8" ]; then
dnf config-manager --set-enabled powertools
else
dnf config-manager --set-enabled crb
fi
dnf install -y sblim-sfcc-devel
fi
shell: bash
- name: Build openwsman
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get install -y cmake libssl-dev libpam-dev swig libxml2-dev
else
dnf install -y wget cmake gcc-c++ libcurl-devel pam-devel swig libxml2-devel openssl-devel
fi
cd /tmp
wget -O - https://github.com/Openwsman/openwsman/archive/refs/tags/v${{ env.version }}.tar.gz|tar zxvf -
cd openwsman-${{ env.version }}/
mkdir build
cd build
cmake .. -DBUILD_PYTHON=No -DBUILD_PYTHON3=No -DBUILD_JAVA=No -DBUILD_RUBY=No -DBUILD_PERL=Yes
make
shell: bash
- name: Set package name and paths according to distrib
run: |
if [[ "${{ matrix.package_extension }}" == "deb" ]]; then
apt-get install -y perl
else
dnf install -y perl
fi
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_PERL="libopenwsman-perl"
USRLIB="/usr/lib/"
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="openwsman-perl"
USRLIB="/usr/lib64/"
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#@USRLIB@#$USRLIB#g" dependencies/perl-openwsman/libwsman.yaml
sed -i "s/@NAME@/$NAME_PERL/g" dependencies/perl-openwsman/perl-openwsman.yaml
sed -i "s#@PERL_VENDORARCH@#$PERL_VENDORARCH#g" dependencies/perl-openwsman/perl-openwsman.yaml
cat dependencies/perl-openwsman/sblim-sfcc.yaml
cat dependencies/perl-openwsman/libwsman.yaml
cat dependencies/perl-openwsman/perl-openwsman.yaml
shell: bash
- name: Package sblim-sfcc
if: ${{ matrix.package_extension == 'deb' }}
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-openwsman/sblim-sfcc.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
version: ${{ env.version }}
release: ${{ env.release }}
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-sblim-sfcc-${{ 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 }}
- name: Package libwsman
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-openwsman/libwsman.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
version: ${{ env.version }}
release: ${{ env.release }}
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-libwsman-${{ 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 }}
- name: Package perl-openwsman
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-openwsman/perl-openwsman.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
version: ${{ env.version }}
release: ${{ env.release }}
commit_hash: ${{ github.sha }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-perl-openwsman-${{ 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 }}
- 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 }}
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
- distrib: noble
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: wsman-${{ matrix.arch }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
cache_key: cache-${{ github.sha }}-${{ matrix.package_extension }}-wsman-${{ 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

@ -0,0 +1,213 @@
name: perl-vmware-vsphere
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'dependencies/perl-vmware-vsphere/**'
push:
branches:
- develop
- master
paths:
- 'dependencies/perl-vmware-vsphere/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: connectors/vmware/src/centreon/script/centreon_vmware.pm
get-sources:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
steps:
- name: Download vsphere cli sources
run: |
wget https://gitlab.labexposed.com/centreon-lab/perl-VMware-vSphere/-/raw/master/storage/VMware-vSphere-Perl-SDK-7.0.0-17698549.x86_64.tar.gz
tar zxf VMware-vSphere-Perl-SDK-7.0.0-17698549.x86_64.tar.gz
shell: bash
- name: Build vsphere cli sources
run: |
cd vmware-vsphere-cli-distrib
perl Makefile.PL
sudo make pure_install
shell: bash
- name: Cache vsphere cli sources
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: vmware-vsphere-cli-distrib
key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere
package:
needs: [get-environment, get-sources]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
strategy:
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
runner: ubuntu-22.04
arch: amd64
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
runner: ubuntu-22.04
arch: amd64
- package_extension: deb
image: packaging-plugins-bullseye
distrib: bullseye
runner: ubuntu-22.04
arch: amd64
- package_extension: deb
image: packaging-plugins-bookworm
distrib: bookworm
runner: ubuntu-22.04
arch: amd64
- package_extension: deb
image: packaging-plugins-jammy
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: centreon-collect-arm64
arch: arm64
runs-on: ${{ matrix.runner }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
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: Import source files
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: vmware-vsphere-cli-distrib
key: ${{ github.sha }}-${{ github.run_id }}-sources-perl-vmware-vsphere
fail-on-cache-miss: true
- name: Set 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
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
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#@PERL_VENDORARCH@#$PERL_VENDORARCH#g" dependencies/perl-vmware-vsphere/packaging/perl-vmware-vsphere.yaml
cat dependencies/perl-vmware-vsphere/packaging/perl-vmware-vsphere.yaml
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "dependencies/perl-vmware-vsphere/packaging/perl-vmware-vsphere.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
arch: ${{ matrix.arch }}
commit_hash: ${{ github.sha }}
version: "7.0.1"
release: "17698549"
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ matrix.arch }}
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 }}
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-vmware-vsphere-${{ matrix.arch }}
distrib: ${{ matrix.distrib }}
arch: ${{ matrix.arch }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}-${{ matrix.arch }}
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

156
.github/workflows/plink.yml vendored Normal file
View File

@ -0,0 +1,156 @@
name: plink
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- "dependencies/plink/**"
push:
branches:
- develop
- dev-[2-9][0-9].[0-9][0-9].x
- master
- "[2-9][0-9].[0-9][0-9].x"
paths:
- ".github/workflows/plink.yml"
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
package-rpm:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- image: packaging-plugins-alma8
distrib: el8
- image: packaging-plugins-alma9
distrib: el9
name: package ${{ matrix.distrib }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}:latest
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- run: |
yum install -y wget gcc make
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
wget -P ~/rpmbuild/SOURCES/ https://the.earth.li/~sgtatham/putty/0.74/putty-0.74.tar.gz
rpmbuild -ba dependencies/plink/packaging/rpm/plink.spec
cp -r ~/rpmbuild/RPMS/x86_64/*.rpm .
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
sign-rpm:
needs: [get-environment, package-rpm]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- image: packaging-alma8
distrib: el8
- image: packaging-alma9
distrib: el9
name: sign rpm ${{ matrix.distrib }}
container:
image: docker.centreon.com/centreon-private/rpm-signing:latest
options: -t
credentials:
username: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_USERNAME }}
password: ${{ secrets.HARBOR_RPM_GPG_SIGNING_REPO_TOKEN }}
steps:
- run: |
apt-get update
apt-get install -y zstd
shell: bash
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: unsigned-${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
- run: echo "HOME=/root" >> $GITHUB_ENV
shell: bash
- run: rpmsign --addsign ./*.rpm
shell: bash
- uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./*.rpm
key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
- uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: packages-${{ matrix.distrib }}
path: ./*.rpm
retention-days: 1
deliver-packages:
needs: [get-environment, sign-rpm]
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
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: plink
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

115
.github/workflows/plugins-selinux.yml vendored Normal file
View File

@ -0,0 +1,115 @@
name: plugins-selinux
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- 'selinux/**'
push:
branches:
- develop
- master
paths:
- 'selinux/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
with:
version_file: selinux/packaging/centreon-plugins-selinux.yaml
package:
needs: [get-environment]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable'
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
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: Generate selinux binary
run: |
cd selinux/src
sed -i "s/@VERSION@/${{ needs.get-environment.outputs.version }}/g" centreon-plugins.te
make -f /usr/share/selinux/devel/Makefile
shell: bash
- name: Package
uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: "selinux/packaging/centreon-plugins-selinux.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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 }}
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
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: plugins-selinux
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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

475
.github/workflows/plugins.yml vendored Normal file
View File

@ -0,0 +1,475 @@
name: plugins
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/plugins.yml'
- '.github/scripts/plugins-source.container.pl'
- '.github/packaging/centreon-plugin.yaml.template'
- 'src/**'
- 'packaging/**'
push:
branches:
- develop
- master
paths:
- '.github/workflows/plugins.yml'
- '.github/scripts/plugins-source.container.pl'
- '.github/packaging/centreon-plugin.yaml.template'
- 'src/**'
- 'packaging/**'
jobs:
get-environment:
uses: ./.github/workflows/get-environment.yml
get-plugins:
runs-on: ubuntu-24.04
outputs:
plugins: ${{ steps.get_plugins.outputs.plugins }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.9'
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
base: ${{ github.ref }}
list-files: shell
filters: |
common:
- added|deleted|modified: src/centreon/**
- modified: .github/packaging/centreon-plugin.yaml.template
packages:
- added|modified: packaging/**
plugins:
- added|modified: src/**
- name: transform to directories
run: |
folders=()
for f in ${{ steps.filter.outputs.packages_files }}; do
echo "Adding $(dirname $f) to folders"
folders+=($(dirname $f))
done
unique_folders=($(printf "%s\n" "${folders[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_folders[@]} > package_directories.txt
files=()
for f in ${{ steps.filter.outputs.plugins_files }}; do
echo "Adding $f to files"
files+=($f)
done
unique_files=($(printf "%s\n" "${files[@]}" | sort -u | tr '\n' ' '))
jq --compact-output --null-input '$ARGS.positional' --args -- ${unique_files[@]} > plugins.txt
shell: bash
- name: Get plugins for build
id: get_plugins
if: ${{ steps.filter.outputs.common == 'true' || steps.filter.outputs.packages == 'true' || steps.filter.outputs.plugins == 'true' }}
run: |
PLUGINS="$(python3 .github/scripts/process-plugins.py '${{ steps.filter.outputs.common == 'true' }}')"
echo "plugins=$(echo $PLUGINS)" >> $GITHUB_OUTPUT
if [ "$PLUGINS" == '' ]; then
echo "::notice::There are no modifications to the plugins packages"
fi
shell: bash
unit-tests:
needs: [get-environment, get-plugins]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-environment.outputs.stability != 'stable' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
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, unit-tests-noble]
include:
- runner_name: ubuntu-24.04
- package_extension: rpm
image: unit-tests-alma8
distrib: el8
- package_extension: rpm
image: unit-tests-alma9
distrib: el9
- package_extension: deb
image: unit-tests-bullseye
distrib: bullseye
- package_extension: deb
image: unit-tests-bullseye-arm64
runner_name: centreon-collect-arm64
distrib: bullseye
- package_extension: deb
image: unit-tests-bookworm
distrib: bookworm
- package_extension: deb
image: unit-tests-jammy
distrib: jammy
- package_extension: deb
image: unit-tests-noble
distrib: noble
runs-on: ${{ matrix.runner_name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run unit tests
uses: ./.github/actions/unit-tests
- name: Upload logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: plugin-installation-${{ matrix.distrib }}
path: ./lastlog.jsonl
retention-days: 1
fatpacker:
needs: [get-environment, get-plugins, unit-tests]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.plugins != '' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare FatPacker
uses: shogo82148/actions-setup-perl@49c14f24551d2de3bf56fb107a869c3760b1875e # v1.33.0
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: App::FatPacker File::Copy::Recursive JSON
- name: Run FatPacker
run: |
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@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
package:
runs-on: ubuntu-24.04
needs: [get-environment, get-plugins, fatpacker]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.plugins != '' &&
needs.get-environment.outputs.stability != 'stable' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
matrix:
include:
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el7
- package_extension: rpm
image: packaging-plugins-alma8
distrib: el8
- package_extension: rpm
image: packaging-plugins-alma9
distrib: el9
- package_extension: deb
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
image: packaging-plugins-noble
distrib: noble
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
name: "package ${{ matrix.distrib }}"
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- run: |
PLUGINS="${{ needs.get-plugins.outputs.plugins }}"
for PLUGIN in $PLUGINS; do
PACKAGE_PATH=$PLUGIN
if [[ "$PLUGIN" =~ (.+)"=>"(.+) ]]; then
PACKAGE_PATH=$(echo ${BASH_REMATCH[1]})
PLUGIN=$(echo ${BASH_REMATCH[2]})
fi
PLUGIN_NAME_LOWER=$(echo "$PLUGIN" | tr '[:upper:]' '[:lower:]')
echo "::group::Preparing $PLUGIN_NAME_LOWER"
# Process package files
pkg_values=($(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.pkg_name,.plugin_name'))
pkg_summary=$(echo "${pkg_values[0]}")
plugin_name=$(echo "${pkg_values[1]}")
conflicts=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.conflicts // [] | join(",")')
replaces=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.replaces // [] | join(",")')
provides=$(cat "packaging/$PACKAGE_PATH/pkg.json" | jq -r '.provides // [] | join(",")')
deb_dependencies=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.dependencies // [] | join(",")')
deb_conflicts=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.conflicts // [] | join(",")')
deb_replaces=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.replaces // [] | join(",")')
deb_provides=$(cat "packaging/$PACKAGE_PATH/deb.json" | jq -r '.provides // [] | join(",")')
rpm_dependencies=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.dependencies // [] | join(",")')
rpm_conflicts=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.conflicts // [] | join(",")')
rpm_replaces=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.replaces // [] | join(",")')
rpm_provides=$(cat "packaging/$PACKAGE_PATH/rpm.json" | jq -r '.provides // [] | join(",")')
sed -e "s/@PLUGIN_NAME@/$PLUGIN/g;" \
-e "s/@SUMMARY@/$pkg_summary/g" \
-e "s/@CONFLICTS@/$conflicts/g" \
-e "s/@REPLACES@/$replaces/g" \
-e "s/@PROVIDES@/$provides/g" \
-e "s/@DEB_DEPENDENCIES@/$deb_dependencies/g" \
-e "s/@DEB_CONFLICTS@/$deb_conflicts/g" \
-e "s/@DEB_REPLACES@/$deb_replaces/g" \
-e "s/@DEB_PROVIDES@/$deb_provides/g" \
-e "s/@RPM_DEPENDENCIES@/$rpm_dependencies/g" \
-e "s/@RPM_CONFLICTS@/$rpm_conflicts/g" \
-e "s/@RPM_REPLACES@/$rpm_replaces/g" \
-e "s/@RPM_PROVIDES@/$rpm_provides/g" \
< .github/packaging/centreon-plugin.yaml.template \
>> .github/packaging/$PLUGIN.yaml
if [ "${{ matrix.package_extension }}" = "rpm" ]; then
sed -i "s/@PACKAGE_NAME@/$PLUGIN/g" \
.github/packaging/$PLUGIN.yaml
else
sed -i "s/@PACKAGE_NAME@/$PLUGIN_NAME_LOWER/g" \
.github/packaging/$PLUGIN.yaml
fi
cat .github/packaging/$PLUGIN.yaml
echo "::endgroup::"
done
shell: bash
- uses: ./.github/actions/package-nfpm
with:
nfpm_file_pattern: ".github/packaging/*.yaml"
distrib: ${{ matrix.distrib }}
package_extension: ${{ matrix.package_extension }}
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
commit_hash: ${{ github.sha }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
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 }}
test-plugins:
needs: [get-environment, get-plugins, package]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.plugins != '' &&
needs.get-environment.outputs.stability != 'stable' &&
! cancelled() &&
! contains(needs.*.result, 'failure') &&
! contains(needs.*.result, 'cancelled')
strategy:
fail-fast: false
matrix:
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
image: testing-plugins-alma8
distrib: el8
- package_extension: rpm
image: testing-plugins-alma9
distrib: el9
- package_extension: deb
image: testing-plugins-bullseye
distrib: bullseye
- package_extension: deb
image: testing-plugins-bookworm
distrib: bookworm
- 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: centreon-collect-arm64
runs-on: ${{ matrix.runner_name }}
container:
image: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/${{ matrix.image }}
credentials:
username: ${{ secrets.HARBOR_CENTREON_PULL_USERNAME }}
password: ${{ secrets.HARBOR_CENTREON_PULL_TOKEN }}
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/test-plugins
with:
cache-key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
package-extension: ${{ matrix.package_extension }}
plugin-list: ${{ needs.get-plugins.outputs.plugins }}
- name: Upload apt/dnf logs as artifacts if tests failed
if: failure()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: plugin-installation-${{ matrix.distrib }}
path: /var/log/robot-plugins-installation-tests.log
retention-days: 1
deliver-packages:
needs: [get-environment, get-plugins, test-plugins]
if: |
needs.get-environment.outputs.skip_workflow == 'false' &&
needs.get-plugins.outputs.plugins != '' &&
(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: el7
package_extension: rpm
- 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
- distrib: noble
package_extension: deb
name: deliver ${{ matrix.distrib }}
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Delivery
uses: ./.github/actions/package-delivery
with:
module_name: plugins
distrib: ${{ matrix.distrib }}
cache_key: ${{ github.sha }}-${{ github.run_id }}-${{ matrix.package_extension }}-${{ matrix.distrib }}
stability: ${{ needs.get-environment.outputs.stability }}
release_type: ${{ needs.get-environment.outputs.release_type }}
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
deliver-sources:
needs: [get-environment, fatpacker]
if: |
needs.get-environment.outputs.stability == 'stable' &&
github.event_name == 'push'
runs-on: centreon-common
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
with:
path: ./build/
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
fail-on-cache-miss: true
- name: Deliver sources
uses: ./.github/actions/release-sources
with:
bucket_directory: centreon-plugins
module_directory: build
module_name: centreon-plugins
version: ${{ needs.get-environment.outputs.version }}
release: ${{ needs.get-environment.outputs.release }}
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
release-tag:
needs: [get-environment]
if: ${{ needs.get-environment.outputs.stability == 'stable' && github.event_name == 'push' }}
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Push git release tag
run: |
RELEASE=plugins-${{ needs.get-environment.outputs.version }}
EXISTING_TAG=$(git tag --list "$RELEASE" | head -n 1)
git config --global user.email "release@centreon.com"
git config --global user.name "Centreon"
if [ -z "$EXISTING_TAG" ]; then
git tag -a "$RELEASE" -m "release $RELEASE"
git push --follow-tags
else
echo "::warning::Release tag $RELEASE already exists"
fi
shell: bash
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

@ -0,0 +1,32 @@
name: set-pull-request-external-label
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
pull_request_target:
jobs:
set-pull-request-external-label:
if: |
github.event.pull_request.head.repo.fork &&
! contains(github.event.pull_request.labels.*.name, 'external')
runs-on: ubuntu-24.04
steps:
- name: Set PR external label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const label = 'external';
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
} catch (e) {
core.warning(`failed to add label ${label}: ${e}`);
}

View File

@ -0,0 +1,26 @@
name: set-pull-request-skip-label
on:
workflow_call:
jobs:
set-pull-request-skip-label:
if: ${{ success() && contains(fromJSON('["pull_request", "pull_request_target"]') , github.event_name) }}
runs-on: ubuntu-24.04
steps:
- name: Set PR skip label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const label = '${{ format('skip-workflow-{0}', github.workflow) }}';
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
} catch (e) {
core.warning(`failed to add label ${label}: ${e}`);
}

54
.github/workflows/spellchecker.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: spell-checker
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/spellchecker.yml'
- 'src/**'
- '.github/scripts/pod_spell_check.t'
jobs:
pod-spell-check:
if: ${{ !contains(github.event.pull_request.labels.*.name, 'do-not-spellcheck') }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
base: ${{ github.ref }}
list-files: shell
filters: |
plugins:
- added|modified: 'src/**/*.pm'
- name: Install CPAN Libraries
uses: shogo82148/actions-setup-perl@49c14f24551d2de3bf56fb107a869c3760b1875e # v1.33.0
with:
perl-version: '5.34'
install-modules-with: cpm
install-modules: Test::More Test::Spelling List::MoreUtils
- name: Install librairies
continue-on-error: true
run: |
sudo apt-get update
sudo apt-get install -y hunspell
shell: bash
- name: Run spell check
id: run_check
run: |
set +e
for f in ${{ steps.filter.outputs.plugins_files }}; do
echo "perl .github/scripts/pod_spell_check.t $f"
output=$(perl .github/scripts/pod_spell_check.t $f)
done
shell: bash

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
log.html
output.xml
report.html
.editorconfig
.idea

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

62
Jenkinsfile vendored
View File

@ -1,62 +0,0 @@
env.REF_BRANCH = 'master'
if ((env.BRANCH_NAME == env.REF_BRANCH)) {
env.BUILD = 'REFERENCE'
} else {
env.BUILD = 'CI'
}
stage('Source') {
node {
sh 'setup_centreon_build.sh'
dir('centreon-plugins') {
checkout scm
}
sh './centreon-build/jobs/plugins/plugins-source.sh'
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
// Run sonarQube analysis
withSonarQubeEnv('SonarQubeDev') {
sh './centreon-build/jobs/plugins/plugins-analysis.sh'
}
timeout(time: 10, unit: 'MINUTES') {
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
}
}
}
stage('RPM Packaging') {
parallel 'all': {
node {
sh 'setup_centreon_build.sh'
sh './centreon-build/jobs/plugins/plugins-package.sh'
archiveArtifacts artifacts: 'rpms-centos7.tar.gz'
archiveArtifacts artifacts: 'rpms-centos8.tar.gz'
stash name: "rpms-centos7", includes: 'output-centos7/noarch/*.rpm'
stash name: "rpms-centos8", includes: 'output-centos8/noarch/*.rpm'
sh 'rm -rf output'
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}
stage('RPM Delivery') {
parallel 'all': {
node {
sh 'setup_centreon_build.sh'
unstash 'rpms-centos7'
unstash 'rpms-centos8'
sh './centreon-build/jobs/plugins/plugins-delivery.sh'
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}

View File

@ -8,26 +8,55 @@
[![Forks][forks-shield]][forks-url]
[![Issues][issues-shield]][issues-url]
## What are Centreon Plugins
“centreon-plugins” is a free and open source project to monitor systems. The project can be used with Centreon and all monitoring softwares compatible with Nagios plugins.
[Centreon plugins](https://github.com/centreon/centreon-plugins/) is a free and open source project to monitor systems. The project can be used with Centreon and all monitoring softwares compatible with Nagios plugins.
### Principles
[Centreon plugins](https://github.com/centreon/centreon-plugins/) should comply with [Monitoring Plugins Development Guidelines](https://www.monitoring-plugins.org/doc/guidelines.html).
In short, they return:
- An error code:
- `0` for `OK`
- `1` for `WARNING`
- `2` for `CRITICAL`
- `3` for `UNKNOWN`
- A human understandable output message (example: `OK: CPU(s) average usage is 2.66 % - CPU '0' usage : 2.66 %`).
- A set of metrics provided as *perfdata* after a `|` character (example: `'cpu.utilization.percentage'=2.66%;;;0;100 '0#core.cpu.utilization.percentage'=2.66%;;;0;100`).
### What can Centreon Plugins monitor?
You can monitor many systems:
* application: Apache, Asterisk, Elasticsearch, Github, Jenkins, Kafka, Nginx, Pfsense, Redis, Tomcat, Varnish,...
* cloud: AWS, Azure, Docker, Office365, Nutanix, Prometheus,...
* database: Firebird, Informix, MS SQL, MySQL, Oracle, Postgres, Cassandra
* hardware: printers (rfc3805), UPS (Powerware, Mge, Standard), Sun Hardware, Cisco UCS, SensorIP, HP Proliant, HP Bladechassis, Dell Openmanage, Dell CMC, Raritan,...
* network: Aruba, Brocade, Bluecoat, Brocade, Checkpoint, Cisco AP/IronPort/ASA/Standard, Extreme, Fortigate, H3C, Hirschmann, HP Procurve, F5 BIG-IP, Juniper, PaloAlto, Redback, Riverbed, Ruggedcom, Stonesoft,...
* os: Linux (SNMP, NRPE), Freebsd (SNMP), AIX (SNMP), Solaris (SNMP)...
* storage: EMC Clariion, Netapp, Nimble, HP MSA p2000, Dell EqualLogic, Qnap, Panzura, Synology...
* **Application**: Apache, Asterisk, Elasticsearch, Github, Jenkins, Kafka, Nginx, Pfsense, Redis, Tomcat, Varnish, etc.
* **Cloud**: AWS, Azure, Docker, Office365, Nutanix, Prometheus, etc.
* **Databases**: Firebird, Informix, MS SQL, MySQL, Oracle, Postgres, Cassandra.
* **Hardware**: printers (RFC3805), UPS (Powerware, Mge, Standard), Sun Hardware, Cisco UCS, SensorIP, HP Proliant, HP Bladechassis, Dell Openmanage, Dell CMC, Raritan, etc.
* **Network**: Aruba, Brocade, Bluecoat, Brocade, Checkpoint, Cisco AP/IronPort/ASA/Standard, Extreme, Fortigate, H3C, Hirschmann, HP Procurve, F5 BIG-IP, Juniper, PaloAlto, Redback, Riverbed, Ruggedcom, Stonesoft, etc.
* **Operating systems**: Linux (SNMP, NRPE), Freebsd (SNMP), AIX (SNMP), Solaris (SNMP), etc.
* **Storage**: EMC Clariion, Netapp, Nimble, HP MSA p2000, Dell EqualLogic, Qnap, Panzura, Synology, etc.
## Basic Usage
To get a complete list, run:
```bash
perl src/centreon_plugins.pl --list-plugin
```
### Basic Usage
We'll use a basic example to show you how to monitor a system. I have finished the install section and I want to monitor a Linux in SNMP.
First, I need to find the plugin to use in the list:
$ perl centreon_plugins.pl --list-plugin | grep -i linux | grep 'PLUGIN'
PLUGIN: os::linux::local::plugin
PLUGIN: os::linux::snmp::plugin
```bash
perl centreon_plugins.pl --list-plugin | grep -i linux | grep 'PLUGIN'
```
It will return:
```
PLUGIN: os::linux::local::plugin
PLUGIN: os::linux::snmp::plugin
```
It seems that 'os::linux::snmp::plugin' is the good one. So I verify with the option ``--help`` to be sure:
@ -81,6 +110,42 @@ I can set threshold with options ``--warning`` and ``--critical``:
For more information or help, please read ['doc/en/user/guide.rst'](./doc/en/user/guide.rst).
## Contributions
### Code contributions/pull requests
If you want to contribute by submitting new functionalities, enhancements or bug fixes, first thank you for participating :-)
Then have a look, if not already done, to our **[development guide](https://github.com/centreon/centreon-plugins/blob/develop/doc/en/developer/guide.md)**.
Then create a [fork](https://github.com/centreon/centreon-plugins/fork) and a development branch, and once it's done, you may submit a [pull request](https://github.com/centreon/centreon-plugins/pulls) that the corporate development team will examine.
### Issues/bug reports
If you encounter a behaviour that is clearly a bug or a regression, you are welcome to submit an [issue](https://github.com/centreon/centreon-plugins/issues). Please be aware that this is an open source project and that there is no guaranteed response time.
### Questions/search for help
If you have trouble using our plugins, but are not sure whether it's due to a bug or a misuse, please take the time to ask for help on [The Watch, Data Collection section](https://thewatch.centreon.com/data-collection-6) and become certain that it is a bug before submitting it here.
### Feature/enhancement request
There is high demand for new plugins and new functionalities on existing plugins, so we have to rely on our community to help us prioritize them.
How? Post your suggestion on [The Watch Ideas](https://thewatch.centreon.com/ideas) with as much detail as possible and we will pick the most voted topics to add them to our product roadmap.
To develop a plugin/mode, we need the following information, depending on the protocol:
* **SNMP**: MIB files and full snmpwalk of enterprise branch (`snmpwalk -ObentU -v 2c -c public address .1.3.6.1.4.1 > equipment.snmpwalk`) or [SNMP collections](https://thewatch.centreon.com/product-how-to-21/snmp-collection-tutorial-132).
* **HTTP API (SOAP, Rest/Json, XML-RPC)**: the documentation and some curl examples or HTTP [collections](https://thewatch.centreon.com/data-collection-6/centreon-plugins-discover-collection-modes-131).
* **CLI**: command line examples (command + result).
* **SQL**: queries + results + column types or [SQL collections](https://thewatch.centreon.com/product-how-to-21/sql-collection-tutorial-134).
* **JMX**: mbean names and attributes.
If some information is confidential, such as logins or IP addresses, obfuscate them in what is sent publicly and we'll get in touch with you by private message if this information is needed.
Please note that all the developments are open source, we will not commit to a release date. If it is an emergency for you, please contact [Centreon's sales team](https://www.centreon.com/contact/).
### Continuous integration
Please follow documentation [here](./doc/CI.md)
<!-- URL AND IMAGES FOR SHIELDS -->
[contributors-shield]: https://img.shields.io/github/contributors/centreon/centreon-plugins?color=%2384BD00&label=CONTRIBUTORS&style=for-the-badge
[stars-shield]: https://img.shields.io/github/stars/centreon/centreon-plugins?color=%23433b02a&label=STARS&style=for-the-badge

View File

@ -1,328 +0,0 @@
#
# Copyright 2022 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::antivirus::clamav::local::mode::updatestatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use Net::DNS;
use DateTime;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_engine_status_output {
my ($self, %options) = @_;
return sprintf(
"clamav engine version '%s/%s'",
$self->{result_values}->{current_engine_version},
$self->{result_values}->{last_engine_version}
);
}
sub custom_maindb_status_output {
my ($self, %options) = @_;
return sprintf(
"main.cvd version '%s/%s', last update %s",
$self->{result_values}->{current_maindb_version},
$self->{result_values}->{last_maindb_version},
centreon::plugins::misc::change_seconds(
value => $self->{result_values}->{current_maindb_timediff}
)
);
}
sub custom_dailydb_status_output {
my ($self, %options) = @_;
return sprintf(
"daily.cvd version '%s/%s', last update %s",
$self->{result_values}->{current_dailydb_version},
$self->{result_values}->{last_dailydb_version},
centreon::plugins::misc::change_seconds(
value => $self->{result_values}->{current_dailydb_timediff}
)
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'update', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{update} = [
{ label => 'engine-status', type => 2, critical_default => '%{last_engine_version} ne %{current_engine_version}', set => {
key_values => [ { name => 'last_engine_version' }, { name => 'current_engine_version' } ],
closure_custom_output => $self->can('custom_engine_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'maindb-status', type => 2, critical_default => '%{last_maindb_version} ne %{current_maindb_version}', set => {
key_values => [ { name => 'last_maindb_version' }, { name => 'current_maindb_version' }, { name => 'current_maindb_timediff' } ],
closure_custom_output => $self->can('custom_maindb_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'dailydb-status', type => 2, critical_default => '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000', set => {
key_values => [ { name => 'last_dailydb_version' }, { name => 'current_dailydb_version' }, { name => 'current_dailydb_timediff' } ],
closure_custom_output => $self->can('custom_dailydb_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);
bless $self, $class;
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options' },
'nameservers:s@' => { name => 'nameservers' },
'maindb-file:s' => { name => 'maindb_file', default => '/var/lib/clamav/main.cvd' },
'dailydb-file:s' => { name => 'dailydb_file', default => '/var/lib/clamav/daily.cvd' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->{clamav_command} = 'echo "==== CLAMD ===" ; clamd -V ; echo "==== DAILY ===="; sigtool --info ' . $self->{option_results}->{dailydb_file} . '; echo "==== MAIN ====" ; sigtool --info ' . $self->{option_results}->{maindb_file};
}
sub get_clamav_last_update {
my ($self, %options) = @_;
#0.99.2:57:23114:1487851834:1:63:45614:290
# field 2 = main.cvd version number
# field 3 = daily.cvd version number
my $nameservers = [];
if (defined($self->{option_results}->{nameservers})) {
$nameservers = [@{$self->{option_results}->{nameservers}}];
}
my $handle = Net::DNS::Resolver->new(
nameservers => $nameservers
);
my $txt_query = $handle->query("current.cvd.clamav.net", "TXT");
if (!$txt_query) {
$self->{output}->add_option_msg(short_msg => "Unable to get TXT Record : " . $handle->errorstring . ".");
$self->{output}->option_exit();
}
my @fields = split /:/, ($txt_query->answer)[0]->txtdata;
($self->{last_engine_version}, $self->{last_maindb_version}, $self->{last_dailydb_version}) =
($fields[0], $fields[1], $fields[2]);
}
sub get_clamav_current_signature_info {
my ($self, %options) = @_;
if ($options{content} !~ /====\s+$options{label}.*?Build\s+time:\s+(.*?)\n.*?Version:\s+(\d+)/msi) {
return ;
}
$self->{'current_' . $options{label} . 'db_version'} = $2;
#13 Jun 2016 09:53 -0400
my $time = $1;
if ($time =~ /^\s*(\d+)\s+(\S+)\s+(\d+)\s+(\d+):(\d+)\s+(\S+)/) {
my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
my $dt = DateTime->new(
year => $3,
month => $months{$2},
day => $1,
hour => $4,
minute => $5,
second => 0,
time_zone => $6,
);
$self->{'current_' . $options{label} . 'db_timediff'} = time() - $dt->epoch;
}
}
sub manage_selection {
my ($self, %options) = @_;
$self->get_clamav_last_update();
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{clamav_command},
command_path => $self->{option_results}->{command_path},
command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef
);
#==== CLAMD ===
#ClamAV 0.99.2/21723/Mon Jun 13 14:53:00 2016
#==== DAILY ====
#File: /var/lib/clamav/daily.cvd
#Build time: 13 Jun 2016 09:53 -0400
#Version: 21723
#Signatures: 276682
#Functionality level: 63
#Builder: neo
#MD5: 280928f25d175359e6e6a0270d9d4fb2
#Digital signature: yLfcgb9dbgKO2rWpXGa238252jqH7VDsAjnqQsHc+9cbIwiM9wnz3fqyl33G15S4YsMbRR6CYbSTxccKXBJvvxRhgZQJmpCYiThslUKBPo5QhIFcI1QBMfoHKCpf8riB2/xAgI401UkZVJip+6eWFpUJ9aeaFai+Mvinif5BRzi
#LibClamAV Warning: **************************************************
#LibClamAV Warning: *** The virus database is older than 7 days! ***
#LibClamAV Warning: *** Please update it as soon as possible. ***
#LibClamAV Warning: **************************************************
#Verification OK.
#==== MAIN ====
#File: /var/lib/clamav/main.cvd
#Build time: 16 Mar 2016 23:17 +0000
#Version: 57
#Signatures: 4218790
#Functionality level: 60
#Builder: amishhammer
#MD5: 06386f34a16ebeea2733ab037f0536be
#Digital signature: AIzk/LYbX8K9OEbR5GMyJ6LWTqSu9ffa5bONcA0FN3+onMlZ2BMRzuyvVURBvAZvOaGPdtMBcgDJSl7fGxDfcxRWhIrQ98f8FPdAQaFPgWu3EX46ufw+IRZnM4irKKYuh1GdCIbsGs6jejWo9iNErsbDqkFSobVBkUJYxBgvqfd
#Verification OK.
$self->get_clamav_current_signature_info(label => 'daily', content => $stdout);
$self->get_clamav_current_signature_info(label => 'main', content => $stdout);
if ($stdout =~ /==== CLAMD.*?ClamAV (.*?)\//msi) {
$self->{current_engine_version} = $1;
}
$self->{update} = {
last_engine_version => $self->{last_engine_version}, last_maindb_version => $self->{last_maindb_version}, last_dailydb_version => $self->{last_dailydb_version},
current_engine_version => $self->{current_engine_version},
current_maindb_version => $self->{current_maindb_version}, current_maindb_timediff => $self->{current_maindb_timediff},
current_dailydb_version => $self->{current_dailydb_version}, current_dailydb_timediff => $self->{current_dailydb_timediff},
};
}
1;
__END__
=head1 MODE
Check antivirus update status.
=over 8
=item B<--nameservers>
Set nameserver to query (can be multiple).
The system configuration is used by default.
=item B<--remote>
Execute command remotely in 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=item B<--ssh-path>
Specify ssh command path (default: none)
=item B<--ssh-command>
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
=item B<--timeout>
Timeout in seconds for the command (Default: 30).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information. Used it you have output in a file.
=item B<--command-path>
Command path.
=item B<--command-options>
Command options (Default: '-report -most_columns').
=item B<--maindb-file>
Antivirus main.cvd file (Default: '/var/lib/clamav/main.cvd').
=item B<--dailydb-file>
Antivirus daily.cvd file (Default: '/var/lib/clamav/daily.cvd').
=item B<--warning-engine-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_engine_version}, %{current_engine_version}
=item B<--critical-engine-status>
Set critical threshold for status (Default: '%{last_engine_version} ne %{current_engine_version}').
Can used special variables like: %{last_engine_version}, %{current_engine_version}
=item B<--warning-maindb-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_maindb_version}, %{current_maindb_version}, %{current_maindb_timediff}
=item B<--critical-maindb-status>
Set critical threshold for status (Default: '%{last_maindb_version} ne %{current_maindb_version}').
Can used special variables like: %{last_maindb_version}, %{current_maindb_version}, %{current_maindb_timediff}
=item B<--warning-dailydb-status>
Set warning threshold for status (Default: '')
Can used special variables like: %{last_dailydb_version}, %{current_dailydb_version}, %{current_dailydb_timediff}
=item B<--critical-dailydb-status>
Set critical threshold for status (Default: '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000').
Can used special variables like: %{last_dailydb_version}, %{current_dailydb_version}, %{current_dailydb_timediff}
=back
=cut

View File

@ -1,48 +0,0 @@
#
# Copyright 2022 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::antivirus::clamav::local::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
$self->{modes} = {
'update-status' => 'apps::antivirus::clamav::local::mode::updatestatus',
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check ClamAV Antivirus through local commands (the plugin can use SSH).
=cut

View File

@ -1,143 +0,0 @@
#
# Copyright 2022 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::antivirus::kaspersky::snmp::mode::events;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
return sprintf("Events status is '%s'", $self->{result_values}->{status});
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_eventsStatus'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' },
];
$self->{maps_counters}->{global} = [
{
label => 'status',
type => 2,
warning_default => '%{status} =~ /Warning/i',
critical_default => '%{status} =~ /Critical/i',
set => {
key_values => [ { name => 'eventsStatus' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'events', nlabel => 'events.critical.count', set => {
key_values => [ { name => 'criticalEventsCount' } ],
output_template => '%d critical event(s)',
perfdatas => [
{ label => 'events', template => '%d', min => 0 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my %map_status = (
0 => 'OK',
1 => 'Info',
2 => 'Warning',
3 => 'Critical'
);
my $oid_eventsStatus = '.1.3.6.1.4.1.23668.1093.1.6.1';
my $oid_criticalEventsCount = '.1.3.6.1.4.1.23668.1093.1.6.3';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_eventsStatus, $oid_criticalEventsCount
],
nothing_quit => 1
);
$self->{global} = {
eventsStatus => $map_status{$snmp_result->{$oid_eventsStatus}},
criticalEventsCount => $snmp_result->{$oid_criticalEventsCount}
};
}
1;
__END__
=head1 MODE
Check events status.
=over 8
=item B<--warning-status>
Set warning threshold for status. (Default: '%{status} =~ /Warning/i').
Can use special variables like: %{status}
=item B<--critical-status>
Set critical threshold for status. (Default: '%{status} =~ /Critical/i').
Can use special variables like: %{status}
=item B<--warning-*>
Threshold warning.
Can be: 'events'.
=item B<--critical-*>
Threshold critical.
Can be: 'events'.
=back
=cut

View File

@ -1,224 +0,0 @@
#
# Copyright 2022 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::antivirus::kaspersky::snmp::mode::updates;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use DateTime;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
return sprintf("Updates status is '%s'", $self->{result_values}->{status});
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_updatesStatus'};
return 0;
}
sub custom_last_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
label => 'last_server_update',
nlabel => $self->{nlabel},
value => $self->{result_values}->{diff},
unit => 's',
min => 0
);
}
sub custom_last_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(
value => $self->{result_values}->{diff},
threshold => [
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
]
);
return $exit;
}
sub custom_last_output {
my ($self, %options) = @_;
return sprintf(
'Last server update: %s [%s]',
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{diff}), $self->{result_values}->{date_time}
);
}
sub custom_last_calc {
my ($self, %options) = @_;
my $time = $options{new_datas}->{$self->{instance} . '_lastServerUpdateTime'};
#2018-3-30,7:43:58.0
if ($time =~ /^\s*(\d+)-(\d+)-(\d+),(\d+):(\d+):(\d+)\.(\d+)/) {
my $dt = DateTime->new(
year => $1,
month => $2,
day => $3,
hour => $4,
minute => $5,
second => $6,
%{$self->{instance_mode}->{tz}}
);
$self->{result_values}->{diff} = time() - $dt->epoch;
$self->{result_values}->{date_time} = $dt->datetime();
}
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }
];
$self->{maps_counters}->{global} = [
{
label => 'status',
type => 2,
warning_default => '%{status} =~ /Warning/i',
critical_default => '%{status} =~ /Critical/i',
set => {
key_values => [ { name => 'updatesStatus' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'last-server-update', nlabel => 'update.server.freshness.seconds', set => {
key_values => [ { name => 'lastServerUpdateTime' } ],
closure_custom_calc => $self->can('custom_last_calc'),
closure_custom_output => $self->can('custom_last_output'),
closure_custom_threshold_check => $self->can('custom_last_threshold'),
closure_custom_perfdata => $self->can('custom_last_perfdata')
}
},
{ label => 'not-updated', nlabel => 'update.hosts.outdated.count', set => {
key_values => [ { name => 'hostsNotUpdated' } ],
output_template => '%d host(s) not up to date',
perfdatas => [
{ label => 'not_updated', template => '%d', min => 0 }
]
}
}
];
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->{tz} = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone});
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'timezone:s' => { name => 'timezone', default => 'GMT' }
});
return $self;
}
my $map_status = {
0 => 'OK',
1 => 'Info',
2 => 'Warning',
3 => 'Critical'
};
my $oid_updatesStatus = '.1.3.6.1.4.1.23668.1093.1.2.1';
my $oid_lastServerUpdateTime = '.1.3.6.1.4.1.23668.1093.1.2.3';
my $oid_hostsNotUpdated = '.1.3.6.1.4.1.23668.1093.1.2.4';
sub manage_selection {
my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_leef(
oids => [
$oid_updatesStatus, $oid_lastServerUpdateTime,
$oid_hostsNotUpdated
],
nothing_quit => 1
);
$self->{global} = {
updatesStatus => $map_status->{$snmp_result->{$oid_updatesStatus}},
lastServerUpdateTime => $snmp_result->{$oid_lastServerUpdateTime},
hostsNotUpdated => $snmp_result->{$oid_hostsNotUpdated},
};
}
1;
__END__
=head1 MODE
Check updates status.
=over 8
=item B<--warning-status>
Set warning threshold for status. (Default: '%{status} =~ /Warning/i').
Can use special variables like: %{status}
=item B<--critical-status>
Set critical threshold for status. (Default: '%{status} =~ /Critical/i').
Can use special variables like: %{status}
=item B<--warning-*>
Threshold warning.
Can be: 'last-server-update', 'not-updated'.
=item B<--critical-*>
Threshold critical.
Can be: 'last-server-update', 'not-updated'.
=item B<--timezone>
Timezone options. Default is 'GMT'.
=back
=cut

View File

@ -1,53 +0,0 @@
#
# Copyright 2022 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::antivirus::kaspersky::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
$self->{modes} = {
'deployment' => 'apps::antivirus::kaspersky::snmp::mode::deployment',
'events' => 'apps::antivirus::kaspersky::snmp::mode::events',
'full-scan' => 'apps::antivirus::kaspersky::snmp::mode::fullscan',
'logical-network' => 'apps::antivirus::kaspersky::snmp::mode::logicalnetwork',
'protection' => 'apps::antivirus::kaspersky::snmp::mode::protection',
'updates' => 'apps::antivirus::kaspersky::snmp::mode::updates',
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Kaspersky Security Center through SNMP
=cut

View File

@ -1,111 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::clients;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'clients', nlabel => 'clients.connected.count', set => {
key_values => [ { name => 'stClientCount' } ],
output_template => 'Connected clients: %d',
perfdatas => [
{ label => 'connected_clients', template => '%d',
min => 0, unit => 'clients' }
]
}
},
{ label => 'sockets', nlabel => 'sockets.connected.count', set => {
key_values => [ { name => 'stConnectedSockets' } ],
output_template => 'Open network sockets: %d',
perfdatas => [
{ label => 'open_sockets', template => '%d',
min => 0, unit => 'sockets' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stClientCount = '.1.3.6.1.4.1.1230.2.7.2.5.2.0';
my $oid_stConnectedSockets = '.1.3.6.1.4.1.1230.2.7.2.5.3.0';
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{snmp}->get_leef(
oids => [ $oid_stClientCount, $oid_stConnectedSockets ],
nothing_quit => 1
);
$self->{global} = {
stClientCount => $results->{$oid_stClientCount},
stConnectedSockets => $results->{$oid_stConnectedSockets},
};
}
1;
__END__
=head1 MODE
Check connected clients and open network sockets.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='clients')
=item B<--warning-*>
Threshold warning.
Can be: 'clients', 'sockets'.
=item B<--critical-*>
Threshold critical.
Can be: 'clients', 'sockets'.
=back
=cut

View File

@ -1,157 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::connections;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_connection_output' }
];
$self->{maps_counters}->{global} = [
{ label => 'legitimate', nlabel => 'connections.legitimate.persecond', set => {
key_values => [ { name => 'stConnectionsLegitimate', per_second => 1 } ],
output_template => 'Legitimate: %d',
perfdatas => [
{ label => 'legitimate_connections', template => '%d', min => 0, unit => 'connections/s' }
]
}
},
{ label => 'blocked', nlabel => 'connections.blocked.persecond', set => {
key_values => [ { name => 'stConnectionsBlocked', per_second => 1 } ],
output_template => 'Blocked: %d',
perfdatas => [
{ label => 'blocked_connections', template => '%d', min => 0, unit => 'connections/s' }
]
}
},
{ label => 'blocked-by-am', nlabel => 'connections.antimalware.blocked.persecond', set => {
key_values => [ { name => 'stBlockedByAntiMalware', per_second => 1 } ],
output_template => 'Blocked by Anti Malware: %d',
perfdatas => [
{ label => 'blocked_by_am', template => '%d', min => 0, unit => 'connections/s' }
]
}
},
{ label => 'blocked-by-mf', nlabel => 'connections.mediafilter.blocked.persecond', set => {
key_values => [ { name => 'stBlockedByMediaFilter', per_second => 1 } ],
output_template => 'Blocked by Media Filter: %d',
perfdatas => [
{ label => 'blocked_by_mf', template => '%d', min => 0, unit => 'connections/s' }
]
}
},
{ label => 'blocked-by-uf', nlabel => 'connections.urlfilter.blocked.persecond', set => {
key_values => [ { name => 'stBlockedByURLFilter', per_second => 1 } ],
output_template => 'Blocked by URL Filter: %d',
perfdatas => [
{ label => 'blocked_by_uf', template => '%d', min => 0, unit => 'connections/s' }
]
}
}
];
}
sub prefix_connection_output {
my ($self, %options) = @_;
return 'Connections (per sec) ';
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stConnectionsLegitimate = '.1.3.6.1.4.1.1230.2.7.2.1.3.0';
my $oid_stBlockedByAntiMalware = '.1.3.6.1.4.1.1230.2.7.2.1.4.0';
my $oid_stConnectionsBlocked = '.1.3.6.1.4.1.1230.2.7.2.1.5.0';
my $oid_stBlockedByMediaFilter = '.1.3.6.1.4.1.1230.2.7.2.1.6.0';
my $oid_stBlockedByURLFilter = '.1.3.6.1.4.1.1230.2.7.2.1.7.0';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(
oids => [
$oid_stConnectionsLegitimate, $oid_stBlockedByAntiMalware,
$oid_stConnectionsBlocked, $oid_stBlockedByMediaFilter,
$oid_stBlockedByURLFilter
],
nothing_quit => 1
);
$self->{global} = {
stConnectionsLegitimate => $results->{$oid_stConnectionsLegitimate},
stBlockedByAntiMalware => $results->{$oid_stBlockedByAntiMalware},
stConnectionsBlocked => $results->{$oid_stConnectionsBlocked},
stBlockedByMediaFilter => $results->{$oid_stBlockedByMediaFilter},
stBlockedByURLFilter => $results->{$oid_stBlockedByURLFilter},
};
}
1;
__END__
=head1 MODE
Check connections statistics.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='blocked')
=item B<--warning-*>
Threshold warning.
Can be: 'legitimate', 'blocked', 'blocked-by-am',
'blocked-by-mf', 'blocked-by-uf'.
=item B<--critical-*>
Threshold critical.
Can be: 'legitimate', 'blocked', 'blocked-by-am',
'blocked-by-mf', 'blocked-by-uf'.
=back
=cut

View File

@ -1,157 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::detections;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'categories', type => 1, cb_prefix_output => 'prefix_categories_output',
message_multiple => 'All categories are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'malware-detected', nlabel => 'malwares.detected.persecond', set => {
key_values => [ { name => 'stMalwareDetected', per_second => 1 } ],
output_template => 'Malware detected (per sec): %d',
perfdatas => [
{ label => 'malware_detected', template => '%d', min => 0, unit => 'detections/s' }
]
}
}
];
$self->{maps_counters}->{categories} = [
{ label => 'category', nlabel => 'category.malwares.detected.persecond', set => {
key_values => [ { name => 'stCategoryCount', per_second => 1 }, { name => 'stCategoryName' } ],
output_template => 'detections (per sec): %d',
perfdatas => [
{ label => 'category', template => '%d',
min => 0, unit => 'detections/s', label_extra_instance => 1,
instance_use => 'stCategoryName' }
]
}
}
];
}
sub prefix_categories_output {
my ($self, %options) = @_;
return "Category '" . $options{instance_value}->{stCategoryName} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
my $oid_stMalwareDetected = '.1.3.6.1.4.1.1230.2.7.2.1.2.0';
my $mapping = {
stCategoryName => { oid => '.1.3.6.1.4.1.1230.2.7.2.1.10.1.1' },
stCategoryCount => { oid => '.1.3.6.1.4.1.1230.2.7.2.1.10.1.2' },
};
my $oid_stCategoriesEntry = '.1.3.6.1.4.1.1230.2.7.2.1.10.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(oids => [ $oid_stMalwareDetected ], nothing_quit => 1);
my $results2 = $options{snmp}->get_table(oid => $oid_stCategoriesEntry, nothing_quit => 1);
$self->{global} = {
stMalwareDetected => $results->{$oid_stMalwareDetected},
};
$self->{categories} = {};
foreach my $oid (keys %{$results2}) {
next if ($oid !~ /^$mapping->{stCategoryName}->{oid}\.(\d+)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results2, instance => $instance);
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$result->{stCategoryName} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $result->{stCategoryName} . "': no matching filter name.", debug => 1);
next;
}
$self->{categories}->{ $result->{stCategoryName} } = {
stCategoryName => $result->{stCategoryName},
stCategoryCount => $result->{stCategoryCount}
}
}
if (scalar(keys %{$self->{categories}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No categories found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check detections statistics.
=over 8
=item B<--filter-name>
Filter category name (can be a regexp).
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='^(?!(category)$)')
=item B<--warning-*>
Threshold warning.
Can be: 'malware-detected', 'category'
=item B<--critical-*>
Threshold critical.
Can be: 'malware-detected', 'category'
=back
=cut

View File

@ -1,150 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'traffics', type => 0, cb_prefix_output => 'prefix_traffic_output' }
];
$self->{maps_counters}->{traffics} = [
{ label => 'client-to-proxy', nlabel => 'ftp.traffic.client2proxy.bitspersecond', set => {
key_values => [ { name => 'stFtpBytesFromClient', per_second => 1 } ],
output_template => 'from client to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'ftp_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'server-to-proxy', nlabel => 'ftp.traffic.server2proxy.bitspersecond', set => {
key_values => [ { name => 'stFtpBytesFromServer', per_second => 1 } ],
output_template => 'from server to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'ftp_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-client', nlabel => 'ftp.traffic.proxy2client.bitspersecond', set => {
key_values => [ { name => 'stFtpBytesToClient', per_second => 1 } ],
output_template => 'from proxy to client: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'ftp_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-server', nlabel => 'ftp.traffic.proxy2server.bitspersecond', set => {
key_values => [ { name => 'stFtpBytesToServer', per_second => 1 } ],
output_template => 'from proxy to server: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'ftp_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }
]
}
}
];
}
sub prefix_traffic_output {
my ($self, %options) = @_;
return "FTP Traffic ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stFtpBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.4.2.0';
my $oid_stFtpBytesFromServer = '.1.3.6.1.4.1.1230.2.7.2.4.3.0';
my $oid_stFtpBytesToClient = '.1.3.6.1.4.1.1230.2.7.2.4.4.0';
my $oid_stFtpBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.4.5.0';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(
oids => [
$oid_stFtpBytesFromClient, $oid_stFtpBytesFromServer,
$oid_stFtpBytesToClient, $oid_stFtpBytesToServer
],
nothing_quit => 1
);
$self->{traffics} = {
stFtpBytesFromClient => $results->{$oid_stFtpBytesFromClient} * 8,
stFtpBytesFromServer => $results->{$oid_stFtpBytesFromServer} * 8,
stFtpBytesToClient => $results->{$oid_stFtpBytesToClient} * 8,
stFtpBytesToServer => $results->{$oid_stFtpBytesToServer} * 8,
};
}
1;
__END__
=head1 MODE
Check FTP statistics.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='^proxy')
=item B<--warning-*>
Threshold warning.
Can be: 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=item B<--critical-*>
Threshold critical.
Can be: 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=back
=cut

View File

@ -1,166 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'traffics', type => 0, cb_prefix_output => 'prefix_traffic_output' }
];
$self->{maps_counters}->{global} = [
{ label => 'requests', nlabel => 'https.requests.persecond', set => {
key_values => [ { name => 'stHttpsRequests', per_second => 1 } ],
output_template => 'HTTPS Requests (per sec): %d',
perfdatas => [
{ label => 'https_requests', template => '%d', min => 0, unit => 'requests/s' }
]
}
}
];
$self->{maps_counters}->{traffics} = [
{ label => 'client-to-proxy', nlabel => 'https.traffic.client2proxy.bitspersecond', set => {
key_values => [ { name => 'stHttpsBytesFromClient', per_second => 1 } ],
output_template => 'from client to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'https_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'server-to-proxy', nlabel => 'https.traffic.server2proxy.bitspersecond', set => {
key_values => [ { name => 'stHttpsBytesFromServer', per_second => 1 } ],
output_template => 'from server to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'https_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-client', nlabel => 'https.traffic.proxy2client.bitspersecond', set => {
key_values => [ { name => 'stHttpsBytesToClient', per_second => 1 } ],
output_template => 'from proxy to client: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'https_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-server', nlabel => 'https.traffic.proxy2server.bitspersecond', set => {
key_values => [ { name => 'stHttpsBytesToServer', per_second => 1 } ],
output_template => 'from proxy to server: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'https_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }
]
}
}
];
}
sub prefix_traffic_output {
my ($self, %options) = @_;
return "HTTPS Traffic ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stHttpsRequests = '.1.3.6.1.4.1.1230.2.7.2.3.1.0';
my $oid_stHttpsBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.3.3.0';
my $oid_stHttpsBytesFromServer = '.1.3.6.1.4.1.1230.2.7.2.3.4.0';
my $oid_stHttpsBytesToClient = '.1.3.6.1.4.1.1230.2.7.2.3.5.0';
my $oid_stHttpsBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.3.6.0';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(
oids => [
$oid_stHttpsRequests, $oid_stHttpsBytesFromClient,
$oid_stHttpsBytesFromServer, $oid_stHttpsBytesToClient,
$oid_stHttpsBytesToServer
],
nothing_quit => 1
);
$self->{global} = {
stHttpsRequests => $results->{$oid_stHttpsRequests}
};
$self->{traffics} = {
stHttpsBytesFromClient => $results->{$oid_stHttpsBytesFromClient} * 8,
stHttpsBytesFromServer => $results->{$oid_stHttpsBytesFromServer} * 8,
stHttpsBytesToClient => $results->{$oid_stHttpsBytesToClient} * 8,
stHttpsBytesToServer => $results->{$oid_stHttpsBytesToServer} * 8
};
}
1;
__END__
=head1 MODE
Check HTTPS statistics.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='^proxy')
=item B<--warning-*>
Threshold warning.
Can be: 'request', 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=item B<--critical-*>
Threshold critical.
Can be: 'request', 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=back
=cut

View File

@ -1,167 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::httpstatistics;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'traffics', type => 0, cb_prefix_output => 'prefix_traffic_output' }
];
$self->{maps_counters}->{global} = [
{ label => 'requests', nlabel => 'http.requests.persecond', set => {
key_values => [ { name => 'stHttpRequests', per_second => 1 } ],
output_template => 'HTTP Requests (per sec): %d',
perfdatas => [
{ label => 'http_requests', template => '%d', min => 0, unit => 'requests/s' }
]
}
}
];
$self->{maps_counters}->{traffics} = [
{ label => 'client-to-proxy', nlabel => 'http.traffic.client2proxy.bitspersecond', set => {
key_values => [ { name => 'stHttpBytesFromClient', per_second => 1 } ],
output_template => 'from client to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'http_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'server-to-proxy', nlabel => 'http.traffic.server2proxy.bitspersecond', set => {
key_values => [ { name => 'stHttpBytesFromServer', per_second => 1 } ],
output_template => 'from server to proxy: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'http_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-client', nlabel => 'http.traffic.proxy2client.bitspersecond', set => {
key_values => [ { name => 'stHttpBytesToClient', per_second => 1 } ],
output_template => 'from proxy to client: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'http_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }
]
}
},
{ label => 'proxy-to-server', nlabel => 'http.traffic.proxy2server.bitspersecond', set => {
key_values => [ { name => 'stHttpBytesToServer', per_second => 1 } ],
output_template => 'from proxy to server: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ label => 'http_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }
]
}
}
];
}
sub prefix_traffic_output {
my ($self, %options) = @_;
return "HTTP Traffic ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
return $self;
}
my $oid_stHttpRequests = '.1.3.6.1.4.1.1230.2.7.2.2.1.0';
my $oid_stHttpBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.2.3.0';
my $oid_stHttpBytesFromServer = '.1.3.6.1.4.1.1230.2.7.2.2.4.0';
my $oid_stHttpBytesToClient = '.1.3.6.1.4.1.1230.2.7.2.2.5.0';
my $oid_stHttpBytesToServer = '.1.3.6.1.4.1.1230.2.7.2.2.6.0';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache_name} = 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $results = $options{snmp}->get_leef(
oids => [
$oid_stHttpRequests, $oid_stHttpBytesFromClient,
$oid_stHttpBytesFromServer, $oid_stHttpBytesToClient,
$oid_stHttpBytesToServer
],
nothing_quit => 1
);
$self->{global} = {
stHttpRequests => $results->{$oid_stHttpRequests}
};
$self->{traffics} = {
stHttpBytesFromClient => $results->{$oid_stHttpBytesFromClient} * 8,
stHttpBytesFromServer => $results->{$oid_stHttpBytesFromServer} * 8,
stHttpBytesToClient => $results->{$oid_stHttpBytesToClient} * 8,
stHttpBytesToServer => $results->{$oid_stHttpBytesToServer} * 8
};
}
1;
__END__
=head1 MODE
Check HTTP statistics.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='^proxy')
=item B<--warning-*>
Threshold warning.
Can be: 'request', 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=item B<--critical-*>
Threshold critical.
Can be: 'request', 'client-to-proxy', 'server-to-proxy',
'proxy-to-client', 'proxy-to-server'.
=back
=cut

View File

@ -1,104 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::system;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 }
];
$self->{maps_counters}->{global} = [
{ label => 'cpu-utilization', nlabel => 'system.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_util' } ],
output_template => 'cpu usage: %.2f%%',
perfdatas => [
{ template => '%.2f', unit => '%', min => 0, max => 100 }
]
}
},
{ label => 'dns-resolve-time', nlabel => 'system.dns.resolve.time.milliseconds', set => {
key_values => [ { name => 'dns_time' } ],
output_template => 'time to resolve dns: %sms',
perfdatas => [
{ template => '%s', unit => 'ms', min => 0 }
]
}
}
];
}
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 => {
});
return $self;
}
my $oid_stCPULoad = '.1.3.6.1.4.1.1230.2.7.2.5.1.0';
my $oid_stResolveHostViaDNS = '.1.3.6.1.4.1.1230.2.7.2.5.6.0';
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{snmp}->get_leef(
oids => [ $oid_stCPULoad, $oid_stResolveHostViaDNS ],
nothing_quit => 1
);
$self->{global} = {
cpu_util => $results->{$oid_stCPULoad},
dns_time => $results->{$oid_stResolveHostViaDNS}
};
}
1;
__END__
=head1 MODE
Check system.
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='cpu')
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'cpu-utilization', 'dns-resolve-time'.
=back
=cut

View File

@ -1,182 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::mode::versions;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
sub custom_version_calc {
my ($self, %options) = @_;
$self->{result_values}->{output} = $options{extra_options}->{output_ref};
$self->{result_values}->{version} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}};
$self->{result_values}->{timestamp} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref} . '_timestamp'};
$self->{result_values}->{since} = time() - $self->{result_values}->{timestamp};
return 0;
}
sub custom_version_threshold {
my ($self, %options) = @_;
return $self->{perfdata}->threshold_check(
value => $self->{result_values}->{since},
threshold => [
{ label => 'critical-' . $self->{label}, exit_litteral => 'critical' },
{ label => 'warning-' . $self->{label}, exit_litteral => 'warning' }
]
);
}
sub custom_version_output {
my ($self, %options) = @_;
return sprintf(
"%s: %s [Last update: %s]",
$self->{result_values}->{output},
$self->{result_values}->{version},
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{since})
);
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }
];
$self->{maps_counters}->{global} = [
{ label => 'dat-version', set => {
key_values => [ { name => 'pMFEDATVersion' }, { name => 'pMFEDATVersion_timestamp' } ],
closure_custom_calc => $self->can('custom_version_calc'),
closure_custom_calc_extra_options => { label_ref => 'pMFEDATVersion', output_ref => 'DAT Version' },
closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold')
}
},
{ label => 'tsdb-version', set => {
key_values => [ { name => 'pTSDBVersion' }, { name => 'pTSDBVersion_timestamp' } ],
closure_custom_calc => $self->can('custom_version_calc'),
closure_custom_calc_extra_options => { label_ref => 'pTSDBVersion', output_ref => 'TrustedSource Database Version' },
closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold')
}
},
{ label => 'proactive-version', set => {
key_values => [ { name => 'pAMProactiveVersion' }, { name => 'pAMProactiveVersion_timestamp' } ],
closure_custom_calc => $self->can('custom_version_calc'),
closure_custom_calc_extra_options => { label_ref => 'pAMProactiveVersion', output_ref => 'ProActive Database Version' },
closure_custom_output => $self->can('custom_version_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => $self->can('custom_version_threshold')
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
});
$self->{cache} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->{cache}->check_options(%options);
}
my $oid_pMFEDATVersion = '.1.3.6.1.4.1.1230.2.7.1.20.4.0';
my $oid_pAMProactiveVersion = '.1.3.6.1.4.1.1230.2.7.1.20.5.0';
my $oid_pTSDBVersion = '.1.3.6.1.4.1.1230.2.7.1.20.6.0';
sub manage_selection {
my ($self, %options) = @_;
$self->{cache}->read(statefile => 'mcafee_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')));
my $results = $options{snmp}->get_leef(
oids => [ $oid_pMFEDATVersion, $oid_pAMProactiveVersion, $oid_pTSDBVersion ],
nothing_quit => 1
);
$self->{new_datas} = {
pMFEDATVersion => $results->{$oid_pMFEDATVersion},
pAMProactiveVersion => $results->{$oid_pAMProactiveVersion},
pTSDBVersion => $results->{$oid_pTSDBVersion}
};
foreach my $version (('pMFEDATVersion', 'pAMProactiveVersion', 'pTSDBVersion')) {
next if (!defined($self->{new_datas}->{$version}) || $self->{new_datas}->{$version} eq '');
$self->{new_datas}->{$version . '_timestamp'} = ($self->{new_datas}->{$version} > $self->{cache}->{datas}->{$version}) ? time() : $self->{cache}->{datas}->{$version . '_timestamp'};
$self->{new_datas}->{$version . '_timestamp'} = time() if (!defined($self->{new_datas}->{$version . '_timestamp'}));
}
$self->{global} = { %{$self->{new_datas}} };
$self->{cache}->write(data => $self->{new_datas});
}
1;
__END__
=head1 MODE
Check signature databases versions
(last update is only guessed by version's changement,
it does not appear clearly in the MIB).
=over 8
=item B<--filter-counters>
Only display some counters (regexp can be used).
(Example: --filter-counters='dat')
=item B<--warning-*>
Threshold warning on last update.
Can be: 'dat-version', 'tsdb-version', 'proactive-version'.
=item B<--critical-*>
Threshold critical on last update.
Can be: 'dat-version', 'tsdb-version', 'proactive-version'.
=back
=cut

View File

@ -1,56 +0,0 @@
#
# Copyright 2022 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::antivirus::mcafee::webgateway::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
$self->{modes} = {
'clients' => 'apps::antivirus::mcafee::webgateway::snmp::mode::clients',
'connections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::connections',
'detections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::detections',
'ftp-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics',
'http-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpstatistics',
'https-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics',
'system' => 'apps::antivirus::mcafee::webgateway::snmp::mode::system',
'versions' => 'apps::antivirus::mcafee::webgateway::snmp::mode::versions',
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check McAfee Web Gateway through SNMP.
=cut

View File

@ -1,163 +0,0 @@
#
# Copyright 2022 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::apache::serverstatus::mode::cpuload;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"basic" => { name => 'basic' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"header:s@" => { name => 'header' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = $self->{http}->request();
# If not present: cpuload is 0
my ($cpuload) = 0;
if ($webcontent !~ /^ReqPerSec:\s+([^\s]+)/mi) {
$self->{output}->add_option_msg(short_msg => "Apache 'ExtendedStatus' option is off.");
$self->{output}->option_exit();
}
if ($webcontent =~ /^CPULoad:\s+([^\s]+)/mi) {
$cpuload = $1;
$cpuload = '0' . $cpuload if ($cpuload =~ /^\./);
}
my $exit = $self->{perfdata}->threshold_check(value => $cpuload, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Load: %.2f %%", $cpuload));
$self->{output}->perfdata_add(label => "cpuload", unit => '%',
value => sprintf("%.2f", $cpuload),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Apache WebServer CpuLoad
=over 8
=item B<--hostname>
IP Addr/FQDN of the webserver host
=item B<--port>
Port used by Apache
=item B<--proto>
Specify https if needed
=item B<--urlpath>
Set path to get server-status page in auto mode (Default: '/server-status/?auto')
=item B<--credentials>
Specify this option if you access server-status page with authentication
=item B<--username>
Specify username for authentication (Mandatory if --credentials is specified)
=item B<--password>
Specify password for authentication (Mandatory if --credentials is specified)
=item B<--basic>
Specify this option if you access server-status page over basic authentication and don't want a '401 UNAUTHORIZED' error to be logged on your webserver.
Specify this option if you access server-status page over hidden basic authentication or you'll get a '404 NOT FOUND' error.
(Use with --credentials)
=item B<--timeout>
Threshold for HTTP timeout
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--warning>
Warning Threshold for CpuLoad
=item B<--critical>
Critical Threshold for CpuLoad
=back
=cut

View File

@ -1,285 +0,0 @@
#
# Copyright 2022 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::apache::serverstatus::mode::requests;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::statefile;
use centreon::plugins::misc;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port', },
'proto:s' => { name => 'proto' },
'urlpath:s' => { name => 'url_path', default => "/server-status/?auto" },
'credentials' => { name => 'credentials' },
'basic' => { name => 'basic' },
'username:s' => { name => 'username' },
'password:s' => { name => 'password' },
'header:s@' => { name => 'header' },
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' },
'warning-bytes:s' => { name => 'warning_bytes' },
'critical-bytes:s' => { name => 'critical_bytes' },
'warning-access:s' => { name => 'warning_access' },
'critical-access:s' => { name => 'critical_access' },
'timeout:s' => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(%options);
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning-bytes', value => $self->{option_results}->{warning_bytes})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning-bytes threshold '" . $self->{option_results}->{warning_bytes} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-bytes', value => $self->{option_results}->{critical_bytes})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical-bytes threshold '" . $self->{option_results}->{critical_bytes} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning-access', value => $self->{option_results}->{warning_access})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning-access threshold '" . $self->{option_results}->{warning_access} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical-access', value => $self->{option_results}->{critical_access})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical-access threshold '" . $self->{option_results}->{critical_access} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
$self->{statefile_value}->check_options(%options);
}
sub run {
my ($self, %options) = @_;
my $webcontent = $self->{http}->request();
#Total accesses: 7323 - Total Traffic: 243.7 MB - Total Duration: 7175675
#CPU Usage: u1489.98 s1118.39 cu0 cs0 - .568% CPU load
#.0159 requests/sec - 555 B/second - 34.1 kB/request - 979.882 ms/request
my ($rPerSec, $bPerReq, $total_access, $total_bytes, $avg_bPerSec);
$total_access = $1 if ($webcontent =~ /^Total Accesses:\s+([^\s]+)/mi);
$total_bytes = $1 * 1024 if ($webcontent =~ /^Total kBytes:\s+([^\s]+)/mi);
if ($webcontent =~ /Total\s+Traffic:\s+(\S+)\s+(.|)B\s+/mi) {
$total_bytes = centreon::plugins::misc::convert_bytes(value => $1, unit => $2 . 'B');
}
$rPerSec = $1 if ($webcontent =~ /^ReqPerSec:\s+([^\s]+)/mi);
if ($webcontent =~ /^(\S+)\s+requests\/sec/mi) {
$rPerSec = $1;
$rPerSec = '0' . $rPerSec if ($rPerSec =~ /^\./);
}
# Need a little time to init
$bPerReq = $1 if ($webcontent =~ /^BytesPerReq:\s+([^\s]+)/mi);
if ($webcontent =~ /(\S+)\s+(.|)B\/request/mi) {
$bPerReq = centreon::plugins::misc::convert_bytes(value => $1, unit => $2 . 'B');
}
$avg_bPerSec = $1 if ($webcontent =~ /^BytesPerSec:\s+([^\s]+)/mi);
if ($webcontent =~ /(\S+)\s+(.|)B\/second/mi) {
$avg_bPerSec = centreon::plugins::misc::convert_bytes(value => $1, unit => $2 . 'B');
}
if (!defined($avg_bPerSec)) {
$self->{output}->add_option_msg(short_msg => "Apache 'ExtendedStatus' option is off.");
$self->{output}->option_exit();
}
$rPerSec = '0' . $rPerSec if ($rPerSec =~ /^\./);
$avg_bPerSec = '0' . $avg_bPerSec if ($avg_bPerSec =~ /^\./);
$bPerReq = '0' . $bPerReq if ($bPerReq =~ /^\./);
$self->{statefile_value}->read(statefile => 'apache_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode});
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $old_total_access = $self->{statefile_value}->get(name => 'total_access');
my $old_total_bytes = $self->{statefile_value}->get(name => 'total_bytes');
my $new_datas = {};
$new_datas->{last_timestamp} = time();
$new_datas->{total_bytes} = $total_bytes;
$new_datas->{total_access} = $total_access;
$self->{statefile_value}->write(data => $new_datas);
if (!defined($old_timestamp) || !defined($old_total_access)) {
$self->{output}->output_add(severity => 'OK',
short_msg => "Buffer creation...");
$self->{output}->display();
$self->{output}->exit();
}
$old_total_access = 0 if ($old_total_access > $new_datas->{total_access});
$old_total_bytes = 0 if ($old_total_bytes > $new_datas->{total_bytes});
my $delta_time = $new_datas->{last_timestamp} - $old_timestamp;
$delta_time = 1 if ($delta_time == 0); # One seconds ;)
my $bPerSec = ($new_datas->{total_bytes} - $old_total_bytes) / $delta_time;
my $aPerSec = ($new_datas->{total_access} - $old_total_access) / $delta_time;
my $exit1 = $self->{perfdata}->threshold_check(value => $rPerSec, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $bPerSec, threshold => [ { label => 'critical-bytes', 'exit_litteral' => 'critical' }, { label => 'warning-bytes', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $aPerSec, threshold => [ { label => 'critical-access', 'exit_litteral' => 'critical' }, { label => 'warning-access', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
my ($bPerSec_value, $bPerSec_unit) = $self->{perfdata}->change_bytes(value => $bPerSec);
my ($bPerReq_value, $bPerReq_unit) = $self->{perfdata}->change_bytes(value => $bPerReq);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("BytesPerSec: %s AccessPerSec: %.2f RequestPerSec: %.2f BytesPerRequest: %s ",
$bPerSec_value . ' ' . $bPerSec_unit,
$aPerSec,
$rPerSec,
$bPerReq_value . ' ' . $bPerReq_unit
));
$self->{output}->perfdata_add(label => "avg_RequestPerSec",
value => sprintf("%.2f", $rPerSec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0
);
$self->{output}->perfdata_add(label => "bytesPerSec", unit => 'B',
value => sprintf("%.2f", $bPerSec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-bytes'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-bytes'),
min => 0);
$self->{output}->perfdata_add(label => "avg_bytesPerRequest", unit => 'B',
value => $bPerReq,
min => 0
);
$self->{output}->perfdata_add(label => "avg_bytesPerSec", unit => 'B',
value => $avg_bPerSec,
min => 0
);
$self->{output}->perfdata_add(label => "accessPerSec",
value => sprintf("%.2f", $aPerSec),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-access'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-access'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Apache WebServer Request statistics
=over 8
=item B<--hostname>
IP Addr/FQDN of the webserver host
=item B<--port>
Port used by Apache
=item B<--proto>
Specify https if needed
=item B<--urlpath>
Set path to get server-status page in auto mode (Default: '/server-status/?auto')
=item B<--credentials>
Specify this option if you access server-status page with authentication
=item B<--username>
Specify username for authentication (Mandatory if --credentials is specified)
=item B<--password>
Specify password for authentication (Mandatory if --credentials is specified)
=item B<--basic>
Specify this option if you access server-status page over basic authentication and don't want a '401 UNAUTHORIZED' error to be logged on your webserver.
Specify this option if you access server-status page over hidden basic authentication or you'll get a '404 NOT FOUND' error.
(Use with --credentials)
=item B<--timeout>
Threshold for HTTP timeout
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--warning>
Warning Threshold for Request per seconds
=item B<--critical>
Critical Threshold for Request per seconds
=item B<--warning-bytes>
Warning Threshold for Bytes per seconds
=item B<--critical-bytes>
Critical Threshold for Bytes per seconds
=item B<--warning-access>
Warning Threshold for Access per seconds
=item B<--critical-access>
Critical Threshold for Access per seconds
=back
=cut

View File

@ -1,171 +0,0 @@
#
# Copyright 2022 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::apache::serverstatus::mode::responsetime;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Time::HiRes qw(gettimeofday tv_interval);
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"basic" => { name => 'basic' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"header:s@" => { name => 'header' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout' },
"unknown-status:s" => { name => 'unknown_status', default => '' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
});
$self->{http} = centreon::plugins::http->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $timing0 = [gettimeofday];
my $webcontent = $self->{http}->request();
my $timeelapsed = tv_interval ($timing0, [gettimeofday]);
my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Response time %.3fs", $timeelapsed));
$self->{output}->perfdata_add(label => "time", unit => 's',
value => sprintf('%.3f', $timeelapsed),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Apache WebServer Time Response
=over 8
=item B<--hostname>
IP Addr/FQDN of the webserver host
=item B<--port>
Port used by Apache
=item B<--proto>
Specify https if needed
=item B<--urlpath>
Set path to get server-status page in auto mode (Default: '/server-status/?auto')
=item B<--credentials>
Specify this option if you access server-status page with authentication
=item B<--username>
Specify username for authentication (Mandatory if --credentials is specified)
=item B<--password>
Specify password for authentication (Mandatory if --credentials is specified)
=item B<--basic>
Specify this option if you access server-status page over basic authentication and don't want a '401 UNAUTHORIZED' error to be logged on your webserver.
Specify this option if you access server-status page over hidden basic authentication or you'll get a '404 NOT FOUND' error.
(Use with --credentials)
=item B<--timeout>
Threshold for HTTP timeout
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--unknown-status>
Threshold warning for http response code
=item B<--warning-status>
Threshold warning for http response code
=item B<--critical-status>
Threshold critical for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300')
=item B<--warning>
Threshold warning in seconds (server-status page response time)
=item B<--critical>
Threshold critical in seconds (server-status page response time)
=back
=cut

View File

@ -1,167 +0,0 @@
#
# Copyright 2022 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::apache::serverstatus::mode::workers;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::http;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"port:s" => { name => 'port', },
"proto:s" => { name => 'proto' },
"urlpath:s" => { name => 'url_path', default => "/server-status/?auto" },
"credentials" => { name => 'credentials' },
"basic" => { name => 'basic' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"header:s@" => { name => 'header' },
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout' },
});
$self->{http} = centreon::plugins::http->new(%options);
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub run {
my ($self, %options) = @_;
my $webcontent = $self->{http}->request();
my ($BusyWorkers, $IdleWorkers, $ScoreBoard);
if ($webcontent =~ /^BusyWorkers:\s+([^\s]+)/mi) {
$BusyWorkers = $1;
}
if ($webcontent =~ /^IdleWorkers:\s+([^\s]+)/mi) {
$IdleWorkers = $1;
}
if ($webcontent =~ /^Scoreboard:\s+([^\s]+)/mi) {
$ScoreBoard = $1;
}
my $srvLimit = length($ScoreBoard);
my $prct_busy = $BusyWorkers / $srvLimit * 100;
my $exit = $self->{perfdata}->threshold_check(value => $prct_busy,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Busy workers: %d Idle workers: %d (Server Limit: %d - %d %% Busy)", $BusyWorkers, $IdleWorkers, $srvLimit, $prct_busy));
$self->{output}->perfdata_add(label => "idle_workers",
value => $IdleWorkers,
min => 0,
max => $srvLimit);
$self->{output}->perfdata_add(label => "busy_workers",
value => $BusyWorkers,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $srvLimit, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $srvLimit, cast_int => 1),
min => 0, max => $srvLimit);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Apache WebServer busy processes.
=over 8
=item B<--hostname>
IP Addr/FQDN of the webserver host
=item B<--port>
Port used by Apache
=item B<--proto>
Protocol to use http or https, http is default
=item B<--urlpath>
Set path to get server-status page in auto mode (Default: '/server-status/?auto')
=item B<--credentials>
Specify this option if you access server-status page with authentication
=item B<--username>
Specify username for authentication (Mandatory if --credentials is specified)
=item B<--password>
Specify password for authentication (Mandatory if --credentials is specified)
=item B<--basic>
Specify this option if you access server-status page over basic authentication and don't want a '401 UNAUTHORIZED' error to be logged on your webserver.
Specify this option if you access server-status page over hidden basic authentication or you'll get a '404 NOT FOUND' error.
(Use with --credentials)
=item B<--timeout>
Threshold for HTTP timeout
=item B<--header>
Set HTTP headers (Multiple option)
=item B<--warning>
Warning Threshold (%) of busy workers
=item B<--critical>
Critical Threshold (%) of busy workers
=back
=cut

View File

@ -1,52 +0,0 @@
#
# Copyright 2022 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::apache::serverstatus::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
$self->{modes} = {
'cpuload' => 'apps::apache::serverstatus::mode::cpuload',
'responsetime' => 'apps::apache::serverstatus::mode::responsetime',
'requests' => 'apps::apache::serverstatus::mode::requests',
'slotstates' => 'apps::apache::serverstatus::mode::slotstates',
'workers' => 'apps::apache::serverstatus::mode::workers'
};
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Apache and Apache 2 Web Servers through server-status webpage
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::batterycharge;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'BCHARGE' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::batteryvoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'BATTV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,63 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::libgetdata;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::misc;
sub getdata {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{apchost} . ":" . $self->{option_results}->{apcport} . $self->{option_results}->{command_options2});
my $searchpattern = $self->{option_results}->{searchpattern};
my ($valueok);
my ($value);
#print $stdout;
foreach (split(/\n/, $stdout)) {
if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) {
$valueok = "1";
$value = $1;
#print $value;
#print "\n";
};
};
if ($valueok == "1") {
#print $value;
return $value;
} else {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => 'NO DATA FOUND');
$self->{output}->display();
$self->{output}->exit();
};
};
1;

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::linefrequency;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LINEFREQ' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::linevoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LINEV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::loadpercentage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'LOADPCT' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::outputvoltage;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'OUTPUTV' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::temperature;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'ITEMP' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,138 +0,0 @@
#
# Copyright 2022 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::apcupsd::local::mode::timeleft;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use apps::apcupsd::local::mode::libgetdata;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'apcaccess' },
"command-path:s" => { name => 'command_path', default => '/sbin/' },
"command-options:s" => { name => 'command_options', default => ' status ' },
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
"apchost:s" => { name => 'apchost', default => 'localhost' },
"apcport:s" => { name => 'apcport', default => '3551' },
"searchpattern:s" => { name => 'searchpattern', default => 'TIMELEFT' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (!defined($self->{option_results}->{apchost})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
$self->{output}->option_exit();
}
if (!defined($self->{option_results}->{apcport})) {
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
value => $result,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check apcupsd Status
=over 8
=item B<--apchost>
IP used by apcupsd
=item B<--apcport>
Port used by apcupsd
=item B<--warning>
Warning Threshold
=item B<--critical>
Critical Threshold
=item B<--remote>
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
=item B<--hostname>
Hostname to query (need --remote).
=item B<--ssh-option>
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
=back
=cut

View File

@ -1,108 +0,0 @@
#
# Copyright 2022 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.
#
#
# see http://manned.org/apcaccess
#
#sprung:~# apcaccess #
#APC : 001,048,1163 # version, number of records and number of bytes following
#DATE : 2014-03-15 19:30:58 +0100 # Date and time of last update from UPS
#HOSTNAME : sprung # hostname of computer running apcupsd
#VERSION : 3.14.8 (16 January 2010) debian # apcupsd version number, date and operating system
#UPSNAME : APC_ESX_SERVER # UPS name from configuration file (dumb) or EEPROM (smart)
#CABLE : Custom Cable Smart # Cable type specified in the configuration file
#MODEL : Smart-UPS 620 # UPS model derived from UPS information
#UPSMODE : ShareUPS Master # Mode in which UPS is operating
#STARTTIME: 2014-03-13 22:40:39 +0100 # Date and time apcupsd was started
#STATUS : ONLINE # UPS status (online, charging, on battery etc)
#LINEV : 224.6 Volts # Current input line voltage
#LOADPCT : 58.5 Percent Load Capacity # Percentage of UPS load capacity used as estimated by UPS
#BCHARGE : 100.0 Percent # Current battery capacity charge percentage
#TIMELEFT : 11.0 Minutes # Remaining runtime left on battery as estimated by UPS
#MBATTCHG : 10 Percent # Min battery charge % (BCHARGE) required for system shutdown
#MINTIMEL : 4 Minutes # Min battery runtime (MINUTES) required for system shutdown
#MAXTIME : 0 Seconds # Max battery runtime (TIMEOUT) after which system is shutdown
#MAXLINEV : 227.5 Volts # Maximum input line voltage since apcupsd startup
#MINLINEV : 224.6 Volts # Minimum input line voltage since apcupsd startup
#OUTPUTV : 227.5 Volts # UPS output voltage
#SENSE : High # Current UPS sensitivity setting for voltage fluctuations
#DWAKE : 060 Seconds # Time UPS waits after power off when the power is restored
#DSHUTD : 600 Seconds # Delay before UPS powers down after command received
#DLOWBATT : 02 Minutes # Low battery signal sent when this much runtime remains
#LOTRANS : 208.0 Volts # Input line voltage below which UPS will switch to battery
#HITRANS : 253.0 Volts # Input line voltage above which UPS will switch to battery
#RETPCT : 015.0 Percent # Battery charge % required after power off to restore power
#ALARMDEL : 30 seconds # Delay period before UPS starts sounding alarm
#BATTV : 13.8 Volts # Current battery voltage
#LINEFREQ : 50.0 Hz # Current line frequency in Hertz
#LASTXFER : No transfers since turnon # Reason for last transfer to battery since apcupsd startup
#NUMXFERS : 0 # Number of transfers to battery since apcupsd startup
#TONBATT : 0 seconds # Seconds currently on battery
#CUMONBATT: 0 seconds # Cumulative seconds on battery since apcupsd startup
#XOFFBATT : N/A # Date, time of last transfer off battery since apcupsd startup
#SELFTEST : NO # Date and time of last self test since apcupsd startup
#STESTI : OFF # Self-test interval
#STATFLAG : 0x07000008 Status Flag # UPS status flag in hex
#REG1 : 0x00 Register 1 # Fault register 1 in hex
#REG2 : 0x00 Register 2 # Fault register 2 in hex
#REG3 : 0x00 Register 3 # Fault register 3 in hex
#MANDATE : 08/09/01 # UPS date of manufacture
#SERIALNO : NS0132263041 # UPS serial number
#BATTDATE : 11/01/08 # Date battery last replaced (if set)
#NOMOUTV : 230 Volts # Nominal output voltage to supply when on battery power
#NOMBATTV : 12.0 Volts # Nominal battery voltage
#FIRMWARE : 22.6.I # UPS firmware version
#APCMODEL : CWI # APC model information
#END APC : 2014-03-15 19:31:00 +0100 # Date and time of status information was written
package apps::apcupsd::local::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_simple);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
'batterycharge' => 'apps::apcupsd::local::mode::batterycharge', # BCHARGE
'temperature' => 'apps::apcupsd::local::mode::temperature', # ITEMP
'timeleft' => 'apps::apcupsd::local::mode::timeleft', # TIMELEFT MAXTIME MINTIMEL
'linevoltage' => 'apps::apcupsd::local::mode::linevoltage', # LINEV
'batteryvoltage' => 'apps::apcupsd::local::mode::batteryvoltage', # BATTV
'outputvoltage' => 'apps::apcupsd::local::mode::outputvoltage', # OUTPUTV
'linefrequency' => 'apps::apcupsd::local::mode::linefrequency', # LINEFREQ
'loadpercentage' => 'apps::apcupsd::local::mode::loadpercentage', # LOADPCT
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check apcupsd through local commands (the plugin can use SSH).
=cut

View File

@ -1,165 +0,0 @@
#
# Copyright 2022 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::automation::ansible::cli::custom::cli;
use strict;
use warnings;
use JSON::XS;
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' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 50 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1);
$self->{output} = $options{output};
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {}
sub check_options {
my ($self, %options) = @_;
return 0;
}
sub execute {
my ($self, %options) = @_;
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1);
my ($response) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options},
no_errors => { 4 => 1 }
);
my $raw_results;
eval {
$raw_results = JSON::XS->new->utf8->decode($response);
};
if ($@) {
$self->{output}->output_add(long_msg => $response, debug => 1);
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
$self->{output}->option_exit();
}
return $raw_results;
}
sub ansible_list_hosts_set_cmd {
my ($self, %options) = @_;
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
my $cmd_options = "$options{host_pattern} --module-name=setup";
return $cmd_options;
}
sub ansible_list_hosts {
my ($self, %options) = @_;
my $cmd_options = $self->ansible_list_hosts_set_cmd(%options);
my $raw_results = $self->execute(cmd_options => $cmd_options);
return $raw_results;
}
1;
__END__
=head1 NAME
Ansible CLI
=head1 CLI OPTIONS
Ansible CLI
=over 8
=item B<--timeout>
Set timeout in seconds (Default: 50).
=item B<--sudo>
Use 'sudo' to execute the command.
=item B<--command>
Command to get information (Default: 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible').
Can be changed if you have output in a file.
=item B<--command-path>
Command path (Default: none).
=item B<--command-options>
Command options (Default: none).
=back
=head1 DESCRIPTION
B<custom>.
=cut

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