Release 20231017 (#4702)
This commit is contained in:
commit
1aacfe2cca
|
@ -1,24 +1,24 @@
|
|||
name: "deb-delivery-legacy"
|
||||
description: "Deliver legacy DEB packages"
|
||||
inputs:
|
||||
module_name:
|
||||
description: "The package module name"
|
||||
required: true
|
||||
distrib:
|
||||
description: "The distribution used for packaging"
|
||||
required: true
|
||||
major_version:
|
||||
description: "The major version"
|
||||
required: true
|
||||
nexus_username:
|
||||
description: The nexus username
|
||||
required: true
|
||||
nexus_password:
|
||||
description: The nexus password
|
||||
required: true
|
||||
cache_key:
|
||||
description: "The cached package key"
|
||||
required: true
|
||||
stability:
|
||||
description: "The package stability (stable, testing, unstable)"
|
||||
required: true
|
||||
artifactory_token:
|
||||
description: "token for artifactory"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
@ -30,18 +30,20 @@ runs:
|
|||
key: ${{ inputs.cache_key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Publish DEBs to Nexus
|
||||
- uses: jfrog/setup-jfrog-cli@v3
|
||||
env:
|
||||
JF_URL: https://centreon.jfrog.io
|
||||
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
|
||||
|
||||
- name: Publish DEBs to artifactory
|
||||
run: |
|
||||
echo "Delivering to ${{ inputs.major_version }} ${{ inputs.stability }}"
|
||||
FILES="*.deb"
|
||||
|
||||
FOLDER_SUFFIX="-${{ inputs.stability }}"
|
||||
if [[ "${{ inputs.stability }}" == "stable" ]]; then
|
||||
FOLDER_SUFFIX=""
|
||||
fi
|
||||
for FILE in $FILES; do
|
||||
echo "[DEBUG] - File: $FILE"
|
||||
|
||||
for FILE in *.deb; do
|
||||
sleep 2
|
||||
echo "Delivering $FILE"
|
||||
curl --connect-timeout 10 --retry 2 --retry-max-time 30 --fail --silent --show-error -u '${{ inputs.nexus_username }}':'${{ inputs.nexus_password }}' -H 'Content-Type: multipart/form-data' --data-binary "@./$FILE" https://apt.centreon.com/repository/${{ inputs.major_version }}$FOLDER_SUFFIX/ || echo "::error::Fail to deliver $FILE ${{ inputs.major_version }}"
|
||||
ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1)
|
||||
|
||||
jf rt upload "$FILE" "apt-standard-${{ inputs.major_version }}-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
|
||||
done
|
||||
shell: bash
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
name: "deb-delivery"
|
||||
description: "Deliver DEB packages"
|
||||
inputs:
|
||||
module_name:
|
||||
description: "The package module name"
|
||||
required: true
|
||||
distrib:
|
||||
description: "The distribution used for packaging"
|
||||
required: true
|
||||
nexus_username:
|
||||
description: The nexus username
|
||||
required: true
|
||||
nexus_password:
|
||||
description: The nexus password
|
||||
required: true
|
||||
cache_key:
|
||||
description: "The cached package key"
|
||||
required: true
|
||||
|
@ -37,5 +34,13 @@ runs:
|
|||
|
||||
- name: Publish DEBs to artifactory
|
||||
run: |
|
||||
jf rt upload "*.deb" "apt-plugins-${{ inputs.stability }}/pool/" --deb "${{ inputs.distrib }}/main/all"
|
||||
FILES="*.deb"
|
||||
|
||||
for FILE in $FILES; do
|
||||
echo "[DEBUG] - File: $FILE"
|
||||
|
||||
ARCH=$(echo $FILE | cut -d '_' -f3 | cut -d '.' -f1)
|
||||
|
||||
jf rt upload "$FILE" "apt-plugins-${{ inputs.stability }}/pool/${{ inputs.module_name }}/" --deb "${{ inputs.distrib }}/main/$ARCH"
|
||||
done
|
||||
shell: bash
|
||||
|
|
|
@ -30,7 +30,8 @@ runs:
|
|||
sudo ./aws/install
|
||||
shell: bash
|
||||
|
||||
- run: |
|
||||
- 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 }}"
|
||||
|
|
|
@ -13,24 +13,12 @@ inputs:
|
|||
cache_key:
|
||||
description: "The cached package key"
|
||||
required: true
|
||||
yum_repo_url:
|
||||
description: "The legacy yum repo url"
|
||||
required: true
|
||||
update_repo_path:
|
||||
description: "The update repo script path"
|
||||
required: true
|
||||
cloudfront_id:
|
||||
description: "The cloudfront ID for repo url"
|
||||
required: true
|
||||
yum_repo_address:
|
||||
description: "The legacy yum repo address"
|
||||
required: true
|
||||
yum_repo_key:
|
||||
description: "The repo key"
|
||||
required: true
|
||||
stability:
|
||||
description: "The package stability (stable, testing, unstable)"
|
||||
required: true
|
||||
artifactory_token:
|
||||
description: "token for artifactory"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
@ -42,56 +30,46 @@ runs:
|
|||
key: ${{ inputs.cache_key }}
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- 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
|
||||
- uses: jfrog/setup-jfrog-cli@v3
|
||||
env:
|
||||
JF_URL: https://centreon.jfrog.io
|
||||
JF_ACCESS_TOKEN: ${{ inputs.artifactory_token }}
|
||||
|
||||
- name: Publish RPMs to standard repositories
|
||||
- name: Publish RPMs to standard repository
|
||||
run: |
|
||||
FILES="*.rpm"
|
||||
|
||||
REPOTYPE="${{ inputs.stability }}"
|
||||
PROJECT_PATH="standard"
|
||||
DISTRIB="${{ inputs.distrib }}"
|
||||
ARCH="noarch"
|
||||
echo "[DEBUG] - Distrib: ${{ inputs.distrib }}"
|
||||
|
||||
eval `ssh-agent`
|
||||
ssh-add - <<< "${{ inputs.yum_repo_key }}"
|
||||
|
||||
echo "Delivering to ${{ inputs.major_version }} $REPOTYPE"
|
||||
|
||||
if [ "$REPOTYPE" == "stable" ]; then
|
||||
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/RPMS"
|
||||
else
|
||||
TARGET="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
|
||||
PROJECT_LOCATION="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/${{ inputs.module_name }}"
|
||||
if [ -z "${{ inputs.module_name }}" ]; then
|
||||
echo "::error::Module name is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[DEBUG] - Target : $TARGET"
|
||||
echo "[DEBUG] - PROJECT_LOCATION : $PROJECT_LOCATION"
|
||||
if [ -z "${{ inputs.distrib }}" ]; then
|
||||
echo "::error::Distrib is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" mkdir -p "$TARGET"
|
||||
scp -o StrictHostKeyChecking=no ./*.rpm "${{ inputs.yum_repo_address }}:$TARGET"
|
||||
mkdir noarch x86_64
|
||||
|
||||
# Update repository metadata
|
||||
METADATAS="/srv/centreon-yum/yum.centreon.com/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH"
|
||||
sleep $((RANDOM % 120)) # wait random time to avoid simultaneous createrepo
|
||||
ssh -o StrictHostKeyChecking=no "${{ inputs.yum_repo_address }}" "sh "${{ inputs.update_repo_path }}" $METADATAS" 2>&-
|
||||
for FILE in $FILES; do
|
||||
echo "[DEBUG] - File: $FILE"
|
||||
|
||||
# Invalidate cloudfront cache
|
||||
ID="${{ inputs.cloudfront_id }}"
|
||||
PATHS="/$PROJECT_PATH/${{ inputs.major_version }}/$DISTRIB/$REPOTYPE/$ARCH/*"
|
||||
ITERATIONS=1
|
||||
ARCH=$(echo $FILE | grep -oP '(x86_64|noarch)')
|
||||
|
||||
until aws cloudfront create-invalidation --distribution-id "$ID" --paths "$PATHS"; do
|
||||
if [ ${ITERATIONS} -eq 10 ]; then
|
||||
return 0
|
||||
echo "[DEBUG] - Arch: $ARCH"
|
||||
|
||||
cp "$FILE" "$ARCH"
|
||||
done
|
||||
|
||||
for ARCH in "noarch" "x86_64"; do
|
||||
if [ "$(ls -A $ARCH)" ]; then
|
||||
if [ "${{ inputs.stability }}" == "stable" ]; then
|
||||
jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat
|
||||
else
|
||||
jf rt upload "$ARCH/*.rpm" "rpm-standard/${{ inputs.major_version }}/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat
|
||||
fi
|
||||
fi
|
||||
echo "couldn't invalidate cache, AWS quota might have been reached, retrying in 30 seconds..."
|
||||
sleep 30s
|
||||
ITERATIONS=$((ITERATIONS+1))
|
||||
done
|
||||
shell: bash
|
||||
|
|
|
@ -63,7 +63,7 @@ runs:
|
|||
for ARCH in "noarch" "x86_64"; do
|
||||
if [ "$(ls -A $ARCH)" ]; then
|
||||
if [ "${{ inputs.stability }}" == "stable" ]; then
|
||||
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/" --flat
|
||||
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/RPMS/${{ inputs.module_name }}/" --flat
|
||||
else
|
||||
jf rt upload "$ARCH/*.rpm" "rpm-plugins/${{ inputs.distrib }}/${{ inputs.stability }}/$ARCH/${{ inputs.module_name }}/" --flat
|
||||
fi
|
||||
|
|
|
@ -10,7 +10,7 @@ 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 openssl-devel jq zstd
|
||||
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm openssl-devel jq zstd selinux-policy-devel
|
||||
dnf -y install perl-App-cpanminus perl-JSON
|
||||
cpanm App::FatPacker
|
||||
cpanm File::Copy::Recursive
|
||||
|
|
|
@ -10,7 +10,7 @@ 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 openssl-devel jq zstd
|
||||
dnf -y install gcc git gettext rpm-build dos2unix python3 epel-release nfpm openssl-devel jq zstd selinux-policy-devel
|
||||
dnf -y install perl-App-cpanminus perl-JSON
|
||||
cpanm App::FatPacker
|
||||
cpanm File::Copy::Recursive
|
||||
|
|
|
@ -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.
|
||||
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 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...).
|
||||
|
|
|
@ -17,8 +17,6 @@ on:
|
|||
paths:
|
||||
- 'connectors/vmware/src/**'
|
||||
- 'connectors/vmware/packaging/**'
|
||||
tags:
|
||||
- centreon-connector-vmware-*
|
||||
|
||||
jobs:
|
||||
get-environment:
|
||||
|
@ -53,7 +51,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Package
|
||||
uses: ./.github/actions/package
|
||||
|
@ -82,7 +80,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery
|
||||
|
@ -106,11 +104,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/deb-delivery
|
||||
with:
|
||||
module_name: connector-vmware
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
|
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
- project: plugins
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@v2
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- id: get_environment
|
||||
run: |
|
||||
|
|
|
@ -15,8 +15,6 @@ on:
|
|||
- master
|
||||
paths:
|
||||
- 'nrpe/packaging/**'
|
||||
tags:
|
||||
- centreon-nrpe-*
|
||||
|
||||
jobs:
|
||||
get-environment:
|
||||
|
@ -51,7 +49,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download nrpe sources
|
||||
run: |
|
||||
|
@ -120,7 +118,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery
|
||||
|
@ -142,11 +140,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/deb-delivery
|
||||
with:
|
||||
module_name: nrpe
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
|
|
|
@ -15,8 +15,6 @@ on:
|
|||
- master
|
||||
paths:
|
||||
- 'dependencies/perl-vmware-vsphere/**'
|
||||
tags:
|
||||
- perl-vmware-vsphere-*
|
||||
|
||||
jobs:
|
||||
get-environment:
|
||||
|
@ -73,7 +71,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Import source files
|
||||
uses: actions/cache/restore@v3
|
||||
|
@ -107,7 +105,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery
|
||||
|
@ -131,11 +129,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/deb-delivery
|
||||
with:
|
||||
module_name: perl-vmware-vsphere
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
|
|
|
@ -14,22 +14,6 @@ on:
|
|||
type: string
|
||||
required: true
|
||||
secrets:
|
||||
nexus_username:
|
||||
required: true
|
||||
nexus_password:
|
||||
required: true
|
||||
update_repo_path:
|
||||
description: "The update repo script path"
|
||||
required: true
|
||||
cloudfront_id:
|
||||
description: "The cloudfront ID for repo url"
|
||||
required: true
|
||||
yum_repo_address:
|
||||
description: "The legacy yum repo address"
|
||||
required: true
|
||||
yum_repo_key:
|
||||
description: "The repo key"
|
||||
required: true
|
||||
artifactory_token:
|
||||
description: "The artifactory token"
|
||||
required: true
|
||||
|
@ -44,7 +28,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache/restore@v3
|
||||
with:
|
||||
|
@ -71,7 +55,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery
|
||||
|
@ -93,7 +77,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery-legacy
|
||||
|
@ -102,11 +86,8 @@ jobs:
|
|||
major_version: ${{ matrix.major_version }}
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
|
||||
update_repo_path: ${{ secrets.update_repo_path }}
|
||||
cloudfront_id: ${{ secrets.cloudfront_id }}
|
||||
yum_repo_address: ${{ secrets.yum_repo_address }}
|
||||
yum_repo_key: ${{ secrets.yum_repo_key }}
|
||||
stability: ${{ inputs.stability }}
|
||||
artifactory_token: ${{ secrets.artifactory_token }}
|
||||
|
||||
deliver-deb:
|
||||
runs-on: [self-hosted, common]
|
||||
|
@ -117,11 +98,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/deb-delivery
|
||||
with:
|
||||
module_name: plugins
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
|
||||
stability: ${{ inputs.stability }}
|
||||
|
@ -138,17 +120,17 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/deb-delivery-legacy
|
||||
with:
|
||||
module_name: plugins
|
||||
distrib: ${{ matrix.distrib }}
|
||||
major_version: ${{ matrix.major_version }}
|
||||
nexus_username: ${{ secrets.nexus_username }}
|
||||
nexus_password: ${{ secrets.nexus_password }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-deb-${{ matrix.distrib }}
|
||||
stability: ${{ inputs.stability }}
|
||||
artifactory_token: ${{ secrets.artifactory_token }}
|
||||
|
||||
release-tag:
|
||||
if: ${{ inputs.stability == 'stable' && github.event_name == 'push' }}
|
||||
|
@ -156,7 +138,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Push git release tag
|
||||
run: |
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
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]
|
||||
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.DOCKER_REGISTRY_ID }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWD }}
|
||||
|
||||
name: package ${{ matrix.distrib }}
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- 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
|
||||
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 }}
|
||||
|
||||
deliver-rpm:
|
||||
needs: [get-environment, package]
|
||||
if: ${{ contains(fromJson('["stable", "testing", "unstable"]'), needs.get-environment.outputs.stability) }}
|
||||
runs-on: [self-hosted, common]
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
distrib: [el8, el9]
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delivery
|
||||
uses: ./.github/actions/rpm-delivery
|
||||
with:
|
||||
module_name: plugins-selinux
|
||||
distrib: ${{ matrix.distrib }}
|
||||
cache_key: ${{ github.sha }}-${{ github.run_id }}-rpm-${{ matrix.distrib }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
outputs:
|
||||
plugins: ${{ steps.get_plugins.outputs.plugins }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
@ -88,7 +88,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
|
@ -140,8 +140,13 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
if: ${{ matrix.distrib == 'el7' }}
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Checkout sources
|
||||
if: ${{ matrix.distrib != 'el7' }}
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ./build/
|
||||
|
@ -230,11 +235,5 @@ jobs:
|
|||
release: ${{ needs.get-environment.outputs.release }}
|
||||
stability: ${{ needs.get-environment.outputs.stability }}
|
||||
secrets:
|
||||
nexus_username: ${{ secrets.NEXUS_USERNAME }}
|
||||
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
|
||||
update_repo_path: ${{ secrets.UPDATE_REPO_PATH }}
|
||||
cloudfront_id: ${{ secrets.CLOUDFRONT_ID }}
|
||||
yum_repo_address: ${{ secrets.YUM_REPO_ADDRESS }}
|
||||
yum_repo_key: ${{ secrets.YUM_REPO_KEY }}
|
||||
artifactory_token: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
|
||||
token_download_centreon_com: ${{ secrets.TOKEN_DOWNLOAD_CENTREON_COM }}
|
||||
|
|
|
@ -19,7 +19,7 @@ jobs:
|
|||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install libs
|
||||
run: |
|
||||
|
|
|
@ -36,12 +36,12 @@ contents:
|
|||
file_info:
|
||||
mode: 0644
|
||||
|
||||
- src: "files/nrpe3.service.rpm"
|
||||
- src: "files/nrpe3.rpm.service"
|
||||
dst: "/lib/systemd/system/centreon-nrpe3.service"
|
||||
packager: rpm
|
||||
file_info:
|
||||
mode: 0644
|
||||
- src: "files/nrpe3.service.deb"
|
||||
- src: "files/nrpe3.deb.service"
|
||||
dst: "/lib/systemd/system/centreon-nrpe3.service"
|
||||
packager: deb
|
||||
file_info:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"libssh-session-perl"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"pkg_name": "centreon-plugin-Applications-Docker-Ssh",
|
||||
"pkg_summary": "Centreon Plugin to monitor Docker",
|
||||
"plugin_name": "centreon_docker_ssh.pl",
|
||||
"files": [
|
||||
"centreon/plugins/script_custom.pm",
|
||||
"centreon/plugins/script_custom/cli.pm",
|
||||
"centreon/plugins/backend/ssh/",
|
||||
"centreon/plugins/ssh.pm",
|
||||
"cloud/docker/local/"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"perl(Libssh::Session)"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"libsnmp-perl"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"pkg_name": "centreon-plugin-Hardware-Ups-Ees-Snmp",
|
||||
"pkg_summary": "Centreon Plugin",
|
||||
"plugin_name": "centreon_ups_ees_snmp.pl",
|
||||
"files": [
|
||||
"centreon/plugins/script_snmp.pm",
|
||||
"centreon/plugins/snmp.pm",
|
||||
"snmp_standard/mode/uptime.pm",
|
||||
"hardware/ups/ees/snmp/"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": [
|
||||
"perl(SNMP)"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
name: "centreon-plugins-selinux"
|
||||
arch: "amd64"
|
||||
platform: "linux"
|
||||
version_schema: "none"
|
||||
version: "0.0.8"
|
||||
release: "${RELEASE}${DIST}"
|
||||
section: "default"
|
||||
priority: "optional"
|
||||
maintainer: "Centreon <contact@centreon.com>"
|
||||
description: |
|
||||
SELinux context for centreon-plugins
|
||||
vendor: "Centreon"
|
||||
homepage: "https://centreon.com"
|
||||
license: "Apache-2.0"
|
||||
|
||||
depends:
|
||||
- policycoreutils
|
||||
- centreon-common-selinux
|
||||
- centreon-engine-selinux
|
||||
- centreon-broker-selinux
|
||||
replaces:
|
||||
- centreon-plugins-selinux-debuginfo
|
||||
conflicts:
|
||||
- centreon-plugins-selinux-debuginfo
|
||||
provides:
|
||||
- centreon-plugins-selinux-debuginfo
|
||||
|
||||
contents:
|
||||
- src: "../src/centreon-plugins.pp"
|
||||
dst: "/usr/share/selinux/packages/centreon/centreon-plugins.pp"
|
||||
file_info:
|
||||
mode: 0655
|
||||
|
||||
scripts:
|
||||
postinstall: ./scripts/centreon-plugins-selinux-postinstall.sh
|
||||
preremove: ./scripts/centreon-plugins-selinux-preremove.sh
|
||||
|
||||
rpm:
|
||||
summary: SELinux context for centreon-plugins
|
||||
signature:
|
||||
key_file: ${RPM_SIGNING_KEY_FILE}
|
||||
key_id: ${RPM_SIGNING_KEY_ID}
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
install() {
|
||||
semodule -i /usr/share/selinux/packages/centreon/centreon-plugins.pp > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
semodule -i /usr/share/selinux/packages/centreon/centreon-plugins.pp > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
action="$1"
|
||||
if [ "$1" = "configure" ] && [ -z "$2" ]; then
|
||||
action="install"
|
||||
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
action="upgrade"
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
"1" | "install")
|
||||
install
|
||||
;;
|
||||
"2" | "upgrade")
|
||||
upgrade
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" -lt "1" ]; then # Final removal
|
||||
semodule -r centreon-plugins > /dev/null 2>&1 || :
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
## <summary>Centreon Plugins monitoring server.</summary>
|
|
@ -0,0 +1,23 @@
|
|||
policy_module(centreon-plugins, @VERSION@)
|
||||
|
||||
########################################
|
||||
#
|
||||
# Declarations
|
||||
#
|
||||
require {
|
||||
type centreon_engine_t;
|
||||
type centreon_broker_t;
|
||||
type snmpd_t;
|
||||
type fixed_disk_device_t;
|
||||
}
|
||||
|
||||
########################################
|
||||
#
|
||||
# Centreon local policy
|
||||
#
|
||||
|
||||
# centreon_centreon_central.pl
|
||||
allow centreon_engine_t centreon_broker_t:fifo_file { open read getattr };
|
||||
|
||||
#============= snmpd_t ==============
|
||||
allow snmpd_t fixed_disk_device_t:blk_file { open read getattr setattr };
|
|
@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Time::HiRes;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
|
@ -46,6 +47,8 @@ sub new {
|
|||
"show-sequence" => { name => 'show_sequence' },
|
||||
"show-index" => { name => 'show_index' },
|
||||
"restart-sequence" => { name => 'restart_sequence' },
|
||||
"min-duration:s" => { name => 'min_duration' },
|
||||
"max-duration:s" => { name => 'max_duration' },
|
||||
});
|
||||
|
||||
$self->{cache} = centreon::plugins::statefile->new(%options);
|
||||
|
@ -100,6 +103,31 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to specify --metrics-values-range where range start is lower than range end.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{min_duration})) {
|
||||
if (!defined($self->{option_results}->{max_duration}) || $self->{option_results}->{max_duration} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --max-duration option if --min_duration is set.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{option_results}->{min_duration} !~ /^[0-9]*\.?[0-9]*$/) {
|
||||
$self->{output}->add_option_msg(short_msg => "--min-duration should be a number.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
if (defined($self->{option_results}->{max_duration})){
|
||||
if (!defined($self->{option_results}->{min_duration}) || $self->{option_results}->{min_duration} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --min-duration option if --max_duration is set.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self-> {option_results}->{max_duration} !~ /^[0-9]*\.?[0-9]*$/){
|
||||
$self->{output}->add_option_msg(short_msg => "--max-duration should be a number.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self-> {option_results}->{max_duration} <= $self->{option_results}->{min_duration} ){
|
||||
$self->{output}->add_option_msg(short_msg => "--max-duration should be higher than min-duration.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
$self->{cache}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
@ -154,6 +182,13 @@ sub get_sequence_output {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
# Adding plugin simulated duration
|
||||
# rand(n) returns a random number between 0 and n value is exclude.
|
||||
if (defined($self->{option_results}->{min_duration}) && defined($self->{option_results}->{max_duration})) {
|
||||
my $sleep_duration = $self->{option_results}->{min_duration} + rand($self->{option_results}->{max_duration} - $self->{option_results}->{min_duration});
|
||||
Time::HiRes::sleep($sleep_duration);
|
||||
}
|
||||
|
||||
my ($status, $index) = $self->get_next_status(statefile => $self->{cache});
|
||||
my $status_label = $status;
|
||||
if (defined($self->{option_results}->{host})) {
|
||||
|
@ -220,15 +255,15 @@ to defined the way cache file is managed.
|
|||
|
||||
Examples:
|
||||
|
||||
perl centreon_plugin.pl --plugin=apps::centreon::local::plugin
|
||||
perl centreon_plugins.pl --plugin=apps::centreon::local::plugin
|
||||
--mode=not-so-dummy --status-sequence='ok,warning,ok,critical,critical,critical'
|
||||
--output='Not so dummy service' --show-sequence --statefile-dir='/tmp'
|
||||
|
||||
perl centreon_plugin.pl --plugin=apps::centreon::local::plugin
|
||||
perl centreon_plugins.pl --plugin=apps::centreon::local::plugin
|
||||
--mode=not-so-dummy --status-sequence='up,down,down' --host
|
||||
--output='Not so dummy host'
|
||||
|
||||
perl centreon_plugin.pl --plugin=apps::centreon::local::plugin
|
||||
perl centreon_plugins.pl --plugin=apps::centreon::local::plugin
|
||||
--mode=not-so-dummy --status-sequence='ok,ok,ok' --output='Not so dummy'
|
||||
--metrics-count=5 --metrics-name='met.rics' --metrics-values-range='-15:42'
|
||||
|
||||
|
@ -275,6 +310,18 @@ Show the index as a metric (in addition to the defined metrics count).
|
|||
|
||||
Restart the sequence from the beginning (ie. reset the sequence in cache file).
|
||||
|
||||
=item B<--min-duration>
|
||||
|
||||
Min duration thresholds (in seconds) use to set the range used to randomly simulate the execution of a plugin.
|
||||
If this option is set, max-duration is mandatory.
|
||||
The duration is chosen in the [min,max) range.
|
||||
|
||||
=item B<--max-duration>
|
||||
|
||||
Max duration thresholds (in seconds) use to set the range used to randomly simulate the execution of a plugin.
|
||||
If this option is set, min-duration is mandatory.
|
||||
The duration is chosen in the [min,max) range (max is excluded).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -211,7 +211,7 @@ Warning threshold for path length to reach targets.
|
|||
|
||||
Critical threshold for path length to reach targets.
|
||||
|
||||
item B<--warning-packets-loss-prct>
|
||||
=item B<--warning-packets-loss-prct>
|
||||
|
||||
Warning threshold for packets' loss in percentage.
|
||||
|
||||
|
|
|
@ -701,7 +701,7 @@ Display statistics for watchers used by work-from-anywhere users.
|
|||
=item B<--warning-[country|isp|watcher]-*> B<--critical-[country|isp|watcher]-*>
|
||||
|
||||
Thresholds. Can be:
|
||||
'dtt-spent', 'errors-prct', 'full-time-network-spent',
|
||||
'dtt-spent', 'errors-prct', 'full-network-time-spent',
|
||||
'sessions', 'srt-spent', 'requests', 'redirect-time-avg',
|
||||
'loading-page', 'pages', 'processing', 'users', 'waiting-time-avg'.
|
||||
|
||||
|
|
|
@ -51,9 +51,9 @@ sub set_counters {
|
|||
},
|
||||
{ label => 'ping-jitter', nlabel => 'ping.jitter.milliseconds', set => {
|
||||
key_values => [ { name => 'jitter' } ],
|
||||
output_template => 'jitter: %.3f',
|
||||
output_template => 'jitter: %.3f ms',
|
||||
perfdatas => [
|
||||
{ template => '%.3f', min => 0 }
|
||||
{ template => '%.3f', unit => 'ms', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,11 +111,13 @@ sub get_port {
|
|||
|
||||
sub internal_api_list_nodes {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
my $response = $self->{http}->request(
|
||||
hostname => $options{node_name},
|
||||
url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{api_path},
|
||||
unknown_status => '', critical_status => '', warning_status => '');
|
||||
unknown_status => '', critical_status => '', warning_status => ''
|
||||
);
|
||||
|
||||
my $nodes;
|
||||
eval {
|
||||
$nodes = JSON::XS->new->utf8->decode($response);
|
||||
|
@ -139,7 +141,9 @@ sub internal_api_info {
|
|||
my $response = $self->{http}->request(
|
||||
hostname => $options{node_name},
|
||||
url_path => '/api/' . $self->{option_results}->{api_version} . '/machine/',
|
||||
unknown_status => '', critical_status => '', warning_status => '');
|
||||
unknown_status => '', critical_status => '', warning_status => ''
|
||||
);
|
||||
|
||||
my $nodes;
|
||||
eval {
|
||||
$nodes = JSON::XS->new->utf8->decode($response);
|
||||
|
@ -157,12 +161,13 @@ sub internal_api_info {
|
|||
|
||||
sub internal_api_list_containers {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
my $response = $self->{http}->request(
|
||||
hostname => $options{node_name},
|
||||
url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{api_path},
|
||||
unknown_status => '', critical_status => '', warning_status => ''
|
||||
);
|
||||
|
||||
my $containers = [];
|
||||
my $containers_ids;
|
||||
eval {
|
||||
|
@ -209,10 +214,13 @@ sub internal_api_list_containers {
|
|||
|
||||
sub internal_api_get_machine_stats {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $response = $self->{http}->request(
|
||||
hostname => $options{node_name},
|
||||
url_path => '/api/' . $self->{option_results}->{api_version} . '/machine',
|
||||
unknown_status => '', critical_status => '', warning_status => '');
|
||||
unknown_status => '', critical_status => '', warning_status => ''
|
||||
);
|
||||
|
||||
my $machine_stats;
|
||||
my $full_machine_stats;
|
||||
eval {
|
||||
|
@ -239,6 +247,7 @@ sub internal_api_get_container_stats {
|
|||
url_path => '/api/' . $self->{option_results}->{api_version} . $self->{option_results}->{api_path} . '/' . $options{container_id},
|
||||
unknown_status => '', critical_status => '', warning_status => ''
|
||||
);
|
||||
|
||||
my $container_stats;
|
||||
my $full_container_stats;
|
||||
eval {
|
||||
|
@ -251,8 +260,15 @@ sub internal_api_get_container_stats {
|
|||
short_msg => "Node '$options{node_name}': cannot decode json get container stats response: $@"
|
||||
);
|
||||
} else {
|
||||
$container_stats->[0] = $full_container_stats->{stats}[0];
|
||||
$container_stats->[1] = $full_container_stats->{stats}[scalar(@{$full_container_stats->{stats}}) - 1];
|
||||
my $stats;
|
||||
if (defined($full_container_stats->{stats})) {
|
||||
$stats = $full_container_stats->{stats};
|
||||
} else {
|
||||
my @keys = keys(%$full_container_stats);
|
||||
$stats = $full_container_stats->{ $keys[0] }->{stats};
|
||||
}
|
||||
$container_stats->[0] = $stats->[0];
|
||||
$container_stats->[1] = $stats->[scalar(@$stats) - 1];
|
||||
}
|
||||
return $container_stats;
|
||||
}
|
||||
|
|
|
@ -156,6 +156,7 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
my $first_index = 0;
|
||||
my $first_stat = $result->{$container_id}->{Stats}[$first_index];
|
||||
my $first_ts = $first_stat->{timestamp};
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
#
|
||||
# Copyright 2023 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 cloud::docker::local::mode::containerstatus;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub prefix_containers_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Container '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'containers', type => 1, cb_prefix_output => 'prefix_containers_output', message_multiple => 'All containers are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{containers} = [
|
||||
{ label => 'status', type => 2, critical_default => '%{status} !~ /up/i', set => {
|
||||
key_values => [ { name => 'status' }, { name => 'name' } ],
|
||||
output_template => "status is '%s'",
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-id:s' => { name => 'filter_id' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'docker ps',
|
||||
command_options => '-a'
|
||||
);
|
||||
|
||||
$self->{containers} = {};
|
||||
my @lines = split(/\n/, $stdout);
|
||||
# Header not needed
|
||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
# 543c8edfea2b registry/mariadb:10.7 "docker-entrypoint.s…" 5 months ago Up 12 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp db
|
||||
|
||||
shift(@lines);
|
||||
foreach my $line (@lines) {
|
||||
next if ($line !~ /^(\S+)\s{3,}(\S+)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(\S+)$/);
|
||||
|
||||
my ($id, $image, $command, $created, $status, $ports, $name) = ($1, $2, $3, $4, $5, $6, $7);
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$id !~ /$self->{option_results}->{filter_id}/);
|
||||
|
||||
$self->{containers}->{$id} = {
|
||||
name => $name,
|
||||
status => $status
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{containers}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No container found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check container status.
|
||||
|
||||
Command used: docker ps -a
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by container name (can be a regexp).
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter by container ID (can be a regexp).
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{status}, %{name}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{status} !~ /up/i').
|
||||
You can use the following variables: %{status}, %{name}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,272 @@
|
|||
#
|
||||
# Copyright 2023 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 cloud::docker::local::mode::containerusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub custom_memory_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'container.memory.usage.bytes',
|
||||
unit => 'B',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{name} : undef,
|
||||
value => int($self->{result_values}->{used}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
|
||||
min => 0,
|
||||
max => int($self->{result_values}->{total})
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_memory_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{perfdata}->threshold_check(
|
||||
value => $self->{result_values}->{prct_used}, threshold => [
|
||||
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||
{ label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' }
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_memory_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||
|
||||
return sprintf(
|
||||
"memory total: %s used: %s (%.2f%%) free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_memory_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'};
|
||||
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_memory_total'};
|
||||
$self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_memory_usage'};
|
||||
# container is not running
|
||||
return -10 if ($self->{result_values}->{used} == 0);
|
||||
|
||||
$self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used};
|
||||
$self->{result_values}->{prct_free} = $self->{result_values}->{free} * 100 / $self->{result_values}->{total};
|
||||
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_containers_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Container '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'containers', type => 1, cb_prefix_output => 'prefix_containers_output',
|
||||
message_multiple => 'All containers are ok', skipped_code => { -10 => 1, -11 => 1 } }
|
||||
];
|
||||
$self->{maps_counters}->{containers} = [
|
||||
{ label => 'cpu', nlabel => 'container.cpu.utilization.percentage', set => {
|
||||
key_values => [ { name => 'cpu_prct' }, { name => 'name' } ],
|
||||
output_template => 'cpu usage: %.2f %%',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'memory', nlabel => 'container.memory.usage.bytes', set => {
|
||||
key_values => [ { name => 'memory_usage' }, { name => 'memory_total' }, { name => 'name' } ],
|
||||
closure_custom_calc => $self->can('custom_memory_calc'),
|
||||
closure_custom_output => $self->can('custom_memory_output'),
|
||||
closure_custom_perfdata => $self->can('custom_memory_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_memory_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'read-throughput', nlabel => 'container.disk.throughput.read.bytespersecond', set => {
|
||||
key_values => [ { name => 'read_throughput', per_second => 1 }, { name => 'name' } ],
|
||||
output_template => 'disk read throughput: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'write-throughput', nlabel => 'container.disk.throughput.write.bytespersecond', set => {
|
||||
key_values => [ { name => 'write_throughput', per_second => 1 }, { name => 'name' } ],
|
||||
output_template => 'disk write throughput: %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-in', nlabel => 'container.traffic.in.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'name' } ],
|
||||
output_template => 'traffic in: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-out', nlabel => 'container.traffic.out.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'name' } ],
|
||||
output_template => 'traffic out: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub get_bytes {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return undef if ($options{value} !~ /(\d+(?:\.\d+)?)\s*([a-zA-Z]+)/);
|
||||
my ($value, $unit) = ($1, $2);
|
||||
if ($unit =~ /KiB*/i) {
|
||||
$value = $value * 1024;
|
||||
} elsif ($unit =~ /MiB*/i) {
|
||||
$value = $value * 1024 * 1024;
|
||||
} elsif ($unit =~ /GiB*/i) {
|
||||
$value = $value * 1024 * 1024 * 1024;
|
||||
} elsif ($unit =~ /TiB*/i) {
|
||||
$value = $value * 1024 * 1024 * 1024 * 1024;
|
||||
} elsif ($unit =~ /KB*/i) {
|
||||
$value = $value * 1000;
|
||||
} elsif ($unit =~ /MB*/i) {
|
||||
$value = $value * 1000 * 1000;
|
||||
} elsif ($unit =~ /GB*/i) {
|
||||
$value = $value * 1000 * 1000 * 1000;
|
||||
} elsif ($unit =~ /TB*/i) {
|
||||
$value = $value * 1000 * 1000 * 1000 * 1000;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'filter-id:s' => { name => 'filter_id' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'docker stats',
|
||||
command_options => '-a --no-stream'
|
||||
);
|
||||
|
||||
$self->{containers} = {};
|
||||
my @lines = split(/\n/, $stdout);
|
||||
# Header not needed
|
||||
# CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
|
||||
# fe954c63d9ba portainer 4.82% 72.14MiB / 7.79GiB 0.90% 387MB / 261MB 4.1kB / 0B 11
|
||||
|
||||
shift(@lines);
|
||||
foreach my $line (@lines) {
|
||||
next if ($line !~ /^(\S+)\s{3,}(\S+)\s{3,}(\S+)\s{3,}(\S+)\s\/\s(\S+)\s{3,}\S+\s{3,}(\S+)\s\/\s(\S+)\s{3,}(\S+)\s\/\s(\S+).*$/);
|
||||
|
||||
my ($id, $name, $cpu, $mem_usage, $mem_limit, $net_in, $net_out, $block_in, $block_out) = ($1, $2, $3, $4, $5, $6, $7, $8, $9);
|
||||
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/);
|
||||
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||
$id !~ /$self->{option_results}->{filter_id}/);
|
||||
|
||||
$self->{containers}->{$id} = {
|
||||
name => $name,
|
||||
cpu_prct => substr($cpu, 0, -1),
|
||||
memory_usage => $self->get_bytes(value => $mem_usage),
|
||||
memory_total => $self->get_bytes(value => $mem_limit),
|
||||
read_throughput => $self->get_bytes(value => $block_in),
|
||||
write_throughput => $self->get_bytes(value => $block_out),
|
||||
traffic_in => $self->get_bytes(value => $net_in),
|
||||
traffic_out => $self->get_bytes(value => $net_out)
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{containers}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No container found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{cache_name} = 'docker_local_' . $self->{mode} . '_' . $self->{option_results}->{hostname} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')). '_' .
|
||||
(defined($self->{option_results}->{filter_id}) ? md5_hex($self->{option_results}->{filter_id}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check container usage.
|
||||
|
||||
Command used: docker stats -a --no-stream
|
||||
|
||||
Because values are scaled, statistics are not very
|
||||
precise (except for CPU).
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter by container name (can be a regexp).
|
||||
|
||||
=item B<--filter-id>
|
||||
|
||||
Filter by container ID (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'cpu' (%), 'memory' (%), 'read-throughput',
|
||||
'write-throughput', 'traffic-in', 'traffic-out'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,122 @@
|
|||
#
|
||||
# Copyright 2023 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 cloud::docker::local::mode::listcontainers;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'docker ps',
|
||||
command_options => '-a'
|
||||
);
|
||||
|
||||
$self->{containers} = {};
|
||||
my @lines = split(/\n/, $stdout);
|
||||
# Header not needed
|
||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
# 543c8edfea2b registry/mariadb:10.7 "docker-entrypoint.s…" 5 months ago Up 12 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp db
|
||||
|
||||
shift(@lines);
|
||||
foreach my $line (@lines) {
|
||||
next if ($line !~ /^(\S+)\s{3,}(\S+)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(.*?)\s{3,}(\S+)$/);
|
||||
|
||||
my ($id, $image, $command, $created, $status, $ports, $name) = ($1, $2, $3, $4, $5, $6, $7);
|
||||
|
||||
$self->{containers}->{$id} = {
|
||||
name => $name,
|
||||
status => $status
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->manage_selection(%options);
|
||||
foreach my $id (sort keys %{$self->{containers}}) {
|
||||
$self->{output}->output_add(
|
||||
long_msg => '[id: ' . $id . "] [name: " . $self->{containers}->{$id}->{name} . "]" .
|
||||
" [status: " . $self->{containers}->{$id}->{status} . "]"
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => 'List containers:'
|
||||
);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['id', 'name', 'status']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->manage_selection(%options);
|
||||
foreach my $id (sort keys %{$self->{containers}}) {
|
||||
$self->{output}->add_disco_entry(
|
||||
id => $id,
|
||||
name => $self->{containers}->{$id}->{name},
|
||||
status => $self->{containers}->{$id}->{status}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List containers.
|
||||
|
||||
Command used: docker ps -a
|
||||
|
||||
=over 8
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# Copyright 2023 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 cloud::docker::local::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{modes} = {
|
||||
'container-status' => 'cloud::docker::local::mode::containerstatus',
|
||||
'container-usage' => 'cloud::docker::local::mode::containerusage',
|
||||
'list-containers' => 'cloud::docker::local::mode::listcontainers'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Docker through local commands (the plugin can use SSH).
|
||||
|
||||
=cut
|
|
@ -81,7 +81,7 @@ sub check_options {
|
|||
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : '';
|
||||
$self->{no_ssl} = (defined($self->{option_results}->{no_ssl})) ? 1 : 0;
|
||||
|
||||
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
|
||||
if ($self->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ Set timeout in seconds (Default: 10).
|
|||
|
||||
=item B<--ssl-opt>
|
||||
|
||||
Set SSL Options (--ssl-opt="SSL_version => TLSv1" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE").
|
||||
Set SSL Options (--ssl-opt="SSL_version => 'TLSv1'" --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE").
|
||||
|
||||
=item B<--no-ssl>
|
||||
|
||||
|
|
|
@ -25,6 +25,42 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_shard_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => $self->{instance_mode}->{option_results}->{unit},
|
||||
instances => [$self->{result_values}->{dbName}, $self->{result_values}->{collectionName}, $self->{result_values}->{shardName}],
|
||||
value => $self->{result_values}->{ $self->{key_values}->[0]->{name} },
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking database '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_output_collection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "collection '" . $options{instance} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_output_shard {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"collection '%s' shard '%s' ",
|
||||
$options{instance_value}->{collectionName},
|
||||
$options{instance_value}->{shardName}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -34,71 +70,88 @@ sub set_counters {
|
|||
group => [
|
||||
{ name => 'collections', display_long => 1, cb_prefix_output => 'prefix_output_collection',
|
||||
message_multiple => 'All collections statistics are ok', type => 1 },
|
||||
{ name => 'shards', display_long => 1, cb_prefix_output => 'prefix_output_shard',
|
||||
message_multiple => 'All shards collections statistics are ok', type => 1 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{collections} = [
|
||||
{ label => 'storage-size', nlabel => 'collection.size.storage.bytes', set => {
|
||||
key_values => [ { name => 'storageSize' }, { name => 'display' } ],
|
||||
output_template => 'Storage Size: %s %s',
|
||||
key_values => [ { name => 'storageSize' } ],
|
||||
output_template => 'storage size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'storageSize', template => '%s',
|
||||
min => 0, unit => 'B', label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'index-size', nlabel => 'collection.size.index.bytes', set => {
|
||||
key_values => [ { name => 'totalIndexSize' }, { name => 'display' } ],
|
||||
output_template => 'Index Size: %s %s',
|
||||
key_values => [ { name => 'totalIndexSize' } ],
|
||||
output_template => 'index size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'totalIndexSize', template => '%s',
|
||||
min => 0, unit => 'B', label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'documents', nlabel => 'collection.documents.count', set => {
|
||||
key_values => [ { name => 'count' }, { name => 'display' } ],
|
||||
output_template => 'Documents: %s',
|
||||
key_values => [ { name => 'count' } ],
|
||||
output_template => 'documents: %s',
|
||||
perfdatas => [
|
||||
{ value => 'count', template => '%s',
|
||||
min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'indexes', nlabel => 'collection.indexes.count', set => {
|
||||
key_values => [ { name => 'nindexes' }, { name => 'display' } ],
|
||||
output_template => 'Indexes: %s',
|
||||
key_values => [ { name => 'nindexes' } ],
|
||||
output_template => 'indexes: %s',
|
||||
perfdatas => [
|
||||
{ value => 'nindexes', template => '%s',
|
||||
min => 0, label_extra_instance => 1 },
|
||||
],
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{shards} = [
|
||||
{ label => 'shard-storage-size', nlabel => 'collection.size.storage.bytes', set => {
|
||||
key_values => [ { name => 'storageSize' }, { name => 'dbName' }, { name => 'collectionName' }, { name => 'shardName' } ],
|
||||
output_template => 'storage size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-index-size', nlabel => 'collection.size.index.bytes', set => {
|
||||
key_values => [ { name => 'totalIndexSize' }, { name => 'dbName' }, { name => 'collectionName' }, { name => 'shardName' } ],
|
||||
output_template => 'index size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-documents', nlabel => 'collection.documents.count', set => {
|
||||
key_values => [ { name => 'count' }, { name => 'dbName' }, { name => 'collectionName' }, { name => 'shardName' } ],
|
||||
output_template => 'documents: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-indexes', nlabel => 'collection.indexes.count', set => {
|
||||
key_values => [ { name => 'nindexes' }, { name => 'dbName' }, { name => 'collectionName' }, { name => 'shardName' } ],
|
||||
output_template => 'indexes: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Checking database '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_output_collection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Collection '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-database:s" => { name => 'filter_database' },
|
||||
'filter-database:s' => { name => 'filter_database' },
|
||||
'filter-shard:s' => { name => 'filter_shard' },
|
||||
'add-shards' => { name => 'add_shards' }
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -115,21 +168,41 @@ sub manage_selection {
|
|||
|
||||
my $collections = $options{custom}->list_collections(database => $database);
|
||||
|
||||
$self->{databases}->{$database}->{display} = $database;
|
||||
$self->{databases}->{$database} = {
|
||||
display => $database,
|
||||
collections => {},
|
||||
shards => {}
|
||||
};
|
||||
|
||||
foreach my $collection (sort @{$collections}) {
|
||||
my $cl_stats = $options{custom}->run_command(
|
||||
database => $database,
|
||||
command => $options{custom}->ordered_hash(collStats => $collection),
|
||||
command => $options{custom}->ordered_hash(collStats => $collection)
|
||||
);
|
||||
|
||||
|
||||
$self->{databases}->{$database}->{collections}->{$collection} = {
|
||||
display => $collection,
|
||||
storageSize => $cl_stats->{storageSize},
|
||||
totalIndexSize => $cl_stats->{totalIndexSize},
|
||||
count => $cl_stats->{count},
|
||||
nindexes => $cl_stats->{nindexes},
|
||||
nindexes => $cl_stats->{nindexes}
|
||||
};
|
||||
|
||||
if (defined($self->{option_results}->{add_shards}) && defined($cl_stats->{shards})) {
|
||||
foreach my $shard_name (keys %{$cl_stats->{shards}}) {
|
||||
next if (defined($self->{option_results}->{filter_shard}) && $self->{option_results}->{filter_shard} ne ''
|
||||
&& $shard_name !~ /$self->{option_results}->{filter_shard}/);
|
||||
|
||||
$self->{databases}->{$database}->{shards}->{$collection . $shard_name} = {
|
||||
dbName => $database,
|
||||
collectionName => $collection,
|
||||
shardName => $shard_name,
|
||||
storageSize => $cl_stats->{shards}->{$shard_name}->{storageSize},
|
||||
totalIndexSize => $cl_stats->{shards}->{$shard_name}->{totalIndexSize},
|
||||
count => $cl_stats->{shards}->{$shard_name}->{count},
|
||||
nindexes => $cl_stats->{shards}->{$shard_name}->{nindexes}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,27 +224,21 @@ Check collections statistics per databases
|
|||
|
||||
=item B<--filter-database>
|
||||
|
||||
Filter database name (Can use regexp).
|
||||
Filter databases by name (Can use regexp).
|
||||
|
||||
=item B<--warning-subinstance-collection-size-*-bytes>
|
||||
=item B<--filter-shard>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'storage', 'index'.
|
||||
Filter shards by name (Can use regexp).
|
||||
|
||||
=item B<--critical-subinstance-collection-size-*-bytes>
|
||||
=item B<--add-shards>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'storage', 'index'.
|
||||
Add collection statistics by shards.
|
||||
|
||||
=item B<--warning-subinstance-collection-*-count>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'documents', 'indexes'.
|
||||
|
||||
=item B<--critical-subinstance-collection-*-count>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'documents', 'indexes'.
|
||||
Thresholds.
|
||||
Can be: 'storage-size', 'index-size', 'documents', 'indexes',
|
||||
'shard-storage-size', 'shard-index-size', 'shard-documents', 'shard-indexes'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -26,55 +26,55 @@ use strict;
|
|||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Connections ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' },
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'active', nlabel => 'connections.active.count', set => {
|
||||
key_values => [ { name => 'active' } ],
|
||||
output_template => 'Active: %d',
|
||||
output_template => 'active: %d',
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, unit => 'conn' },
|
||||
],
|
||||
{ template => '%d', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'current', nlabel => 'connections.current.count', set => {
|
||||
key_values => [ { name => 'current' } ],
|
||||
output_template => 'Current: %d',
|
||||
output_template => 'current: %d',
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, unit => 'conn' },
|
||||
],
|
||||
{ template => '%d', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'usage', nlabel => 'connections.usage.percentage', set => {
|
||||
key_values => [ { name => 'usage' } ],
|
||||
output_template => 'Usage: %.2f %%',
|
||||
output_template => 'usage: %.2f %%',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'total-created', nlabel => 'connections.created.persecond', set => {
|
||||
key_values => [ { name => 'totalCreated', per_second => 1 } ],
|
||||
output_template => 'Created: %.2f/s',
|
||||
output_template => 'created: %.2f/s',
|
||||
perfdatas => [
|
||||
{ template => '%.2f', min => 0, unit => 'conn/s' },
|
||||
],
|
||||
{ template => '%.2f', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Connections ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
|
||||
|
@ -99,8 +99,8 @@ sub manage_selection {
|
|||
$self->{global}->{current} = $server_stats->{connections}->{current};
|
||||
$self->{global}->{usage} = $server_stats->{connections}->{current} / ($server_stats->{connections}->{current} + $server_stats->{connections}->{available});
|
||||
$self->{global}->{totalCreated} = $server_stats->{connections}->{totalCreated};
|
||||
|
||||
$self->{cache_name} = "mongodb_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
|
||||
$self->{cache_name} = 'mongodb_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
|
@ -110,35 +110,14 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check connections statistics
|
||||
Check connections statistics.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-connections-*-count>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'active', 'current'.
|
||||
|
||||
=item B<--critical-connections-*-count>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'active', 'current'.
|
||||
|
||||
=item B<--warning-connections-usage-percentage>
|
||||
|
||||
Warning threshold for connections usage (current over available)
|
||||
|
||||
=item B<--critical-connections-usage-percentage>
|
||||
|
||||
Critical threshold for connections usage (current over available)
|
||||
|
||||
=item B<--warning-connections-created-persecond>
|
||||
|
||||
Warning threshold for connections created per second.
|
||||
|
||||
=item B<--critical-connections-created-persecond>
|
||||
|
||||
Critical threshold for connections created per second.
|
||||
Thresholds.
|
||||
Can be: 'active', 'current', 'usage', 'total-created'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'global', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
|
@ -38,11 +38,10 @@ sub set_counters {
|
|||
key_values => [ { name => 'connection_time' } ],
|
||||
output_template => 'Connection established in %d ms',
|
||||
perfdatas => [
|
||||
{ value => 'connection_time', template => '%d', unit => 'ms',
|
||||
min => 0 },
|
||||
],
|
||||
{ template => '%d', unit => 'ms', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -25,82 +25,18 @@ use base qw(centreon::plugins::templates::counter);
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
sub custom_shard_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'databases', type => 1, cb_prefix_output => 'prefix_database_output',
|
||||
message_multiple => 'All databases statistics are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{databases} = [
|
||||
{ label => 'storage-size', nlabel => 'database.size.storage.bytes', set => {
|
||||
key_values => [ { name => 'storageSize' }, { name => 'display' } ],
|
||||
output_template => 'Storage Size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'storageSize', template => '%s',
|
||||
min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'data-size', nlabel => 'database.size.data.bytes', set => {
|
||||
key_values => [ { name => 'dataSize' }, { name => 'display' } ],
|
||||
output_template => 'Data Size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'dataSize', template => '%s',
|
||||
min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'index-size', nlabel => 'database.size.index.bytes', set => {
|
||||
key_values => [ { name => 'indexSize' }, { name => 'display' } ],
|
||||
output_template => 'Index Size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'indexSize', template => '%s',
|
||||
min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'collections', nlabel => 'database.collections.count', set => {
|
||||
key_values => [ { name => 'collections' }, { name => 'display' } ],
|
||||
output_template => 'Collections: %s',
|
||||
perfdatas => [
|
||||
{ value => 'collections', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'views', nlabel => 'database.views.count', set => {
|
||||
key_values => [ { name => 'views' }, { name => 'display' } ],
|
||||
output_template => 'Views: %s',
|
||||
perfdatas => [
|
||||
{ value => 'views', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'documents', nlabel => 'database.documents.count', set => {
|
||||
key_values => [ { name => 'documents' }, { name => 'display' } ],
|
||||
output_template => 'Documents: %s',
|
||||
perfdatas => [
|
||||
{ value => 'documents', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'indexes', nlabel => 'database.indexes.count', set => {
|
||||
key_values => [ { name => 'indexes' }, { name => 'display' } ],
|
||||
output_template => 'Indexes: %s',
|
||||
perfdatas => [
|
||||
{ value => 'indexes', template => '%s',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => $self->{instance_mode}->{option_results}->{unit},
|
||||
instances => [$self->{result_values}->{dbName}, $self->{result_values}->{shardName}],
|
||||
value => $self->{result_values}->{ $self->{key_values}->[0]->{name} },
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_database_output {
|
||||
|
@ -109,13 +45,146 @@ sub prefix_database_output {
|
|||
return "Database '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_shard_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"Database '%s' shard '%s' ",
|
||||
$options{instance_value}->{dbName},
|
||||
$options{instance_value}->{shardName}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'databases', type => 1, cb_prefix_output => 'prefix_database_output',
|
||||
message_multiple => 'All databases statistics are ok' },
|
||||
{ name => 'shards', type => 1, cb_prefix_output => 'prefix_shard_output',
|
||||
message_multiple => 'All shards databases statistics are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{databases} = [
|
||||
{ label => 'storage-size', nlabel => 'database.size.storage.bytes', set => {
|
||||
key_values => [ { name => 'storageSize' } ],
|
||||
output_template => 'storage size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'data-size', nlabel => 'database.size.data.bytes', set => {
|
||||
key_values => [ { name => 'dataSize' } ],
|
||||
output_template => 'data size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'index-size', nlabel => 'database.size.index.bytes', set => {
|
||||
key_values => [ { name => 'indexSize' } ],
|
||||
output_template => 'index size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'collections', nlabel => 'database.collections.count', set => {
|
||||
key_values => [ { name => 'collections' } ],
|
||||
output_template => 'collections: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'views', nlabel => 'database.views.count', set => {
|
||||
key_values => [ { name => 'views' } ],
|
||||
output_template => 'views: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'documents', nlabel => 'database.documents.count', set => {
|
||||
key_values => [ { name => 'documents' } ],
|
||||
output_template => 'documents: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'indexes', nlabel => 'database.indexes.count', set => {
|
||||
key_values => [ { name => 'indexes' } ],
|
||||
output_template => 'indexes: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{shards} = [
|
||||
{ label => 'shard-storage-size', nlabel => 'database.size.storage.bytes', set => {
|
||||
key_values => [ { name => 'storageSize' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'storage size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-data-size', nlabel => 'database.size.data.bytes', set => {
|
||||
key_values => [ { name => 'dataSize' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'data size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-index-size', nlabel => 'database.size.index.bytes', set => {
|
||||
key_values => [ { name => 'indexSize' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'index size: %s %s',
|
||||
output_change_bytes => 1,
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-collections', nlabel => 'database.collections.count', set => {
|
||||
key_values => [ { name => 'collections' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'collections: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-views', nlabel => 'database.views.count', set => {
|
||||
key_values => [ { name => 'views' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'views: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-documents', nlabel => 'database.documents.count', set => {
|
||||
key_values => [ { name => 'documents' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'documents: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
},
|
||||
{ label => 'shard-indexes', nlabel => 'database.indexes.count', set => {
|
||||
key_values => [ { name => 'indexes' }, { name => 'dbName' }, { name => 'shardName' } ],
|
||||
output_template => 'indexes: %s',
|
||||
closure_custom_perfdata => $self->can('custom_shard_perfdata')
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-database:s' => { name => 'filter_database' }
|
||||
'filter-database:s' => { name => 'filter_database' },
|
||||
'filter-shard:s' => { name => 'filter_shard' },
|
||||
'add-shards' => { name => 'add_shards' }
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -125,6 +194,7 @@ sub manage_selection {
|
|||
|
||||
my $databases = $options{custom}->list_databases();
|
||||
|
||||
$self->{shards} = {};
|
||||
$self->{databases} = {};
|
||||
foreach my $database (sort @{$databases}) {
|
||||
next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne ''
|
||||
|
@ -132,18 +202,37 @@ sub manage_selection {
|
|||
|
||||
my $db_stats = $options{custom}->run_command(
|
||||
database => $database,
|
||||
command => $options{custom}->ordered_hash(dbStats => 1),
|
||||
command => $options{custom}->ordered_hash(dbStats => 1)
|
||||
);
|
||||
|
||||
$self->{databases}->{$db_stats->{db}} = {
|
||||
display => $db_stats->{db},
|
||||
$self->{databases}->{$database} = {
|
||||
display => $database,
|
||||
collections => $db_stats->{collections},
|
||||
views => $db_stats->{views},
|
||||
documents => $db_stats->{objects},
|
||||
storageSize => $db_stats->{storageSize},
|
||||
indexSize => $db_stats->{indexSize},
|
||||
dataSize => $db_stats->{dataSize},
|
||||
indexes => $db_stats->{indexes},
|
||||
indexes => $db_stats->{indexes}
|
||||
};
|
||||
|
||||
if (defined($self->{option_results}->{add_shards}) && defined($db_stats->{raw})) {
|
||||
foreach my $shard_name (keys %{$db_stats->{raw}}) {
|
||||
next if (defined($self->{option_results}->{filter_shard}) && $self->{option_results}->{filter_shard} ne ''
|
||||
&& $shard_name !~ /$self->{option_results}->{filter_shard}/);
|
||||
|
||||
$self->{shards}->{$database . $shard_name} = {
|
||||
dbName => $database,
|
||||
shardName => $shard_name,
|
||||
collections => $db_stats->{raw}->{$shard_name}->{collections},
|
||||
views => $db_stats->{raw}->{$shard_name}->{views},
|
||||
documents => $db_stats->{raw}->{$shard_name}->{objects},
|
||||
storageSize => $db_stats->{raw}->{$shard_name}->{storageSize},
|
||||
indexSize => $db_stats->{raw}->{$shard_name}->{indexSize},
|
||||
dataSize => $db_stats->{raw}->{$shard_name}->{dataSize},
|
||||
indexes => $db_stats->{raw}->{$shard_name}->{indexes}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,29 +254,21 @@ Check databases statistics
|
|||
|
||||
=item B<--filter-database>
|
||||
|
||||
Filter database name (Can use regexp).
|
||||
Filter databases by name (Can use regexp).
|
||||
|
||||
=item B<--warning-instance-database-size-*-bytes>
|
||||
=item B<--filter-shard>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'storage', 'data', 'index'.
|
||||
Filter shards by name (Can use regexp).
|
||||
|
||||
=item B<--critical-instance-database-size-*-bytes>
|
||||
=item B<--add-shards>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'storage', 'data', 'index'.
|
||||
Add database statistics by shards.
|
||||
|
||||
=item B<--warning-instance-database-*-count>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'collections', 'views', 'documents',
|
||||
'indexes'.
|
||||
|
||||
=item B<--critical-instance-database-*-count>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'collections', 'views', 'documents',
|
||||
'indexes'.
|
||||
Thresholds.
|
||||
Can be: 'storage-size', 'data-size', 'index-size', 'collections', 'views', 'documents', 'indexes',
|
||||
'shard-storage-size', 'shard-data-size', 'shard-index-size', 'shard-collections', 'shard-views', 'shard-documents', 'shard-indexes'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -26,22 +26,28 @@ use strict;
|
|||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Requests ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' },
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'total', nlabel => 'queries.total.persecond', set => {
|
||||
key_values => [ { name => 'total', per_second => 1 } ],
|
||||
output_template => 'Total : %d',
|
||||
output_template => 'total: %d',
|
||||
perfdatas => [
|
||||
{ template => '%d', unit => '/s', min => 0 },
|
||||
],
|
||||
{ template => '%d', unit => '/s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
foreach ('insert', 'query', 'update', 'delete', 'getmore', 'command') {
|
||||
|
@ -54,6 +60,7 @@ sub set_counters {
|
|||
]
|
||||
}
|
||||
};
|
||||
|
||||
push @{$self->{maps_counters}->{global}}, {
|
||||
label => $_ . '-count', , nlabel => 'queries.' . $_ . '.count', display_ok => 0, set => {
|
||||
key_values => [ { name => $_, diff => 1 } ],
|
||||
|
@ -66,12 +73,6 @@ sub set_counters {
|
|||
}
|
||||
}
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Requests ';
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1);
|
||||
|
@ -85,15 +86,15 @@ sub new {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{global} = {};
|
||||
my $server_stats = $options{custom}->run_command(
|
||||
database => 'admin',
|
||||
command => $options{custom}->ordered_hash(serverStatus => 1),
|
||||
command => $options{custom}->ordered_hash(serverStatus => 1)
|
||||
);
|
||||
|
||||
foreach my $querie (keys %{$server_stats->{opcounters}}) {
|
||||
$self->{global}->{$querie} = $server_stats->{opcounters}->{$querie};
|
||||
$self->{global}->{total} += $server_stats->{opcounters}->{$querie};
|
||||
|
||||
$self->{global} = {};
|
||||
foreach my $query (keys %{$server_stats->{opcounters}}) {
|
||||
$self->{global}->{$query} = $server_stats->{opcounters}->{$query};
|
||||
$self->{global}->{total} += $server_stats->{opcounters}->{$query};
|
||||
}
|
||||
|
||||
$self->{cache_name} = 'mongodb_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' .
|
||||
|
@ -110,29 +111,11 @@ Check number of queries executed (absolute and per second).
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-queries-*-persecond>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'total', 'insert', 'query', 'update',
|
||||
'delete', 'getmore', 'command'
|
||||
|
||||
=item B<--critical-queries-*-persecond>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'total', 'insert', 'query', 'update',
|
||||
'delete', 'getmore', 'command'
|
||||
|
||||
=item B<--warning-queries-*-count>
|
||||
|
||||
Warning threshold.
|
||||
Can be: 'insert', 'query', 'update',
|
||||
'delete', 'getmore', 'command'
|
||||
|
||||
=item B<--critical-queries-*-count>
|
||||
|
||||
Critical threshold.
|
||||
Can be: 'insert', 'query', 'update',
|
||||
'delete', 'getmore', 'command'
|
||||
Thresholds.
|
||||
Can be: 'total', 'insert', 'query', 'update', 'delete', 'getmore', 'command',
|
||||
'insert-count', 'query-count', 'update-count', 'delete-count', 'getmore-count', 'command-count'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -24,22 +24,22 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
my %mapping_states = (
|
||||
0 => 'STARTUP', 1 => 'PRIMARY', 2 => 'SECONDARY',
|
||||
3 => 'RECOVERING', 5 => 'STARTUP2', 6 => 'UNKNOWN',
|
||||
7 => 'ARBITER', 8 => 'DOWN', 9 => 'ROLLBACK', 10 => 'REMOVED',
|
||||
7 => 'ARBITER', 8 => 'DOWN', 9 => 'ROLLBACK', 10 => 'REMOVED'
|
||||
);
|
||||
my %mapping_health = (
|
||||
0 => 'down',
|
||||
1 => 'up',
|
||||
1 => 'up'
|
||||
);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf("Current member state is '%s'", $self->{result_values}->{state});
|
||||
my $msg = sprintf("current member state is '%s'", $self->{result_values}->{state});
|
||||
$msg .= sprintf(", syncing to '%s'", $self->{result_values}->{sync_host}) if ($self->{result_values}->{state} ne 'PRIMARY');
|
||||
return $msg;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ sub custom_status_output {
|
|||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{state} = $mapping_states{$options{new_datas}->{$self->{instance} . '_myState'}};
|
||||
$self->{result_values}->{state} = $mapping_states{ $options{new_datas}->{ $self->{instance} . '_myState' } };
|
||||
$self->{result_values}->{sync_host} = $options{new_datas}->{$self->{instance} . '_syncSourceHost'};
|
||||
return 0;
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ sub custom_status_calc {
|
|||
sub custom_member_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf("state is '%s' and health is '%s' [slave delay: %s] [priority: %s]",
|
||||
return sprintf(
|
||||
"state is '%s' and health is '%s' [slave delay: %s] [priority: %s]",
|
||||
$self->{result_values}->{state},
|
||||
$self->{result_values}->{health},
|
||||
$self->{result_values}->{slave_delay},
|
||||
|
@ -75,84 +76,110 @@ sub custom_member_status_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_member_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Member '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_members_counters_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Number of members ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'members', type => 1, cb_prefix_output => 'prefix_output',
|
||||
message_multiple => 'All members statistics are ok', skipped_code => { -10 => 1 } },
|
||||
{ name => 'members_counters', type => 0, cb_prefix_output => 'prefix_members_counters_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'members', type => 1, cb_prefix_output => 'prefix_member_output',
|
||||
message_multiple => 'All members statistics are ok', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{members_counters} = [
|
||||
{ label => 'members-primary', nlabel => 'members.primary.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'primary' } ],
|
||||
output_template => 'primary: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'members-secondary', nlabel => 'members.secondary.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'secondary' } ],
|
||||
output_template => 'secondary: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'members-arbiter', nlabel => 'members.arbiter.count', display_ok => 0, set => {
|
||||
key_values => [ { name => 'arbiter' } ],
|
||||
output_template => 'arbiter: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'status', set => {
|
||||
{ label => 'status', type => 2, set => {
|
||||
key_values => [ { name => 'myState' }, { name => 'syncSourceHost' } ],
|
||||
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,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{members} = [
|
||||
{ label => 'member-status', set => {
|
||||
key_values => [ { name => 'stateStr' }, { name => 'health' }, { name => 'slaveDelay' },
|
||||
{ name => 'priority' }, { name => 'name' } ],
|
||||
{
|
||||
label => 'member-status',
|
||||
type => 2,
|
||||
warning_default => '%{state} !~ /PRIMARY|SECONDARY/',
|
||||
critical_default => '%{health} !~ /up/',
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'stateStr' }, { name => 'health' }, { name => 'slaveDelay' },
|
||||
{ name => 'priority' }, { name => 'name' }
|
||||
],
|
||||
closure_custom_calc => $self->can('custom_member_status_calc'),
|
||||
closure_custom_output => $self->can('custom_member_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'replication-lag', nlabel => 'replication.lag.seconds', set => {
|
||||
key_values => [ { name => 'lag' }, { name => 'name' } ],
|
||||
output_template => 'Replication Lag: %s s',
|
||||
output_template => 'replication lag: %s s',
|
||||
perfdatas => [
|
||||
{ value => 'lag', template => '%d', unit => 's',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'name' },
|
||||
],
|
||||
{ template => '%d', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'name' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Member '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
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 => {
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
||||
'warning-member-status:s' => { name => 'warning_member_status', default => '%{state} !~ /PRIMARY|SECONDARY/' },
|
||||
'critical-member-status:s' => { name => 'critical_member_status', default => '%{health} !~ /up/' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => [
|
||||
'warning_status', 'critical_status',
|
||||
'warning_member_status', 'critical_member_status'
|
||||
]);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $ismaster = $options{custom}->run_command(
|
||||
database => 'admin',
|
||||
command => $options{custom}->ordered_hash(ismaster => 1),
|
||||
command => $options{custom}->ordered_hash(ismaster => 1)
|
||||
);
|
||||
|
||||
if (!defined($ismaster->{me})) {
|
||||
|
@ -161,6 +188,7 @@ sub manage_selection {
|
|||
}
|
||||
|
||||
$self->{global} = {};
|
||||
$self->{members_counters} = { primary => 0, secondary => 0, arbiter => 0 };
|
||||
$self->{members} = {};
|
||||
my $repl_conf = $options{custom}->run_command(
|
||||
database => 'admin',
|
||||
|
@ -169,12 +197,15 @@ sub manage_selection {
|
|||
|
||||
my %config;
|
||||
foreach my $member (sort @{$repl_conf->{config}->{members}}) {
|
||||
$config{$member->{host}} = { priority => $member->{priority}, slaveDelay => $member->{slaveDelay} }
|
||||
$config{ $member->{host} } = {
|
||||
priority => $member->{priority},
|
||||
slaveDelay => defined($member->{secondaryDelaySecs}) ? $member->{secondaryDelaySecs} : $member->{slaveDelay}
|
||||
};
|
||||
}
|
||||
|
||||
my $repl_status = $options{custom}->run_command(
|
||||
database => 'admin',
|
||||
command => $options{custom}->ordered_hash(replSetGetStatus => 1),
|
||||
command => $options{custom}->ordered_hash(replSetGetStatus => 1)
|
||||
);
|
||||
|
||||
$self->{global}->{myState} = $repl_status->{myState};
|
||||
|
@ -182,19 +213,22 @@ sub manage_selection {
|
|||
$self->{global}->{syncSourceHost} = '-' if (!defined($self->{global}->{syncSourceHost}));
|
||||
|
||||
foreach my $member (sort @{$repl_status->{members}}) {
|
||||
$self->{members}->{$member->{name}} = {
|
||||
$self->{members_counters}->{ lc($member->{stateStr}) }++
|
||||
if (defined($self->{members_counters}->{ lc($member->{stateStr}) }));
|
||||
|
||||
$self->{members}->{ $member->{name} } = {
|
||||
name => $member->{name},
|
||||
stateStr => $member->{stateStr},
|
||||
health => $member->{health},
|
||||
optimeDate => $member->{optime}->{ts}->{seconds},
|
||||
slaveDelay => $config{$member->{name}}->{slaveDelay},
|
||||
priority => $config{$member->{name}}->{priority}
|
||||
slaveDelay => $config{ $member->{name} }->{slaveDelay},
|
||||
priority => $config{ $member->{name} }->{priority}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $member (keys %{$self->{members}}) {
|
||||
next if ($self->{members}->{$member}->{stateStr} !~ /SECONDARY/);
|
||||
$self->{members}->{$member}->{lag} = $self->{members}->{$ismaster->{primary}}->{optimeDate} - $self->{members}->{$member}->{optimeDate} - $self->{members}->{$member}->{slaveDelay};
|
||||
$self->{members}->{$member}->{lag} = $self->{members}->{ $ismaster->{primary} }->{optimeDate} - $self->{members}->{$member}->{optimeDate} - $self->{members}->{$member}->{slaveDelay};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{members}}) <= 0) {
|
||||
|
@ -209,41 +243,35 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check replication status
|
||||
Check replication status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for checked instance status (Default: '').
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{state}, %{sync_host}.
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for checked instance status (Default: '').
|
||||
Define the conditions to match for the status to be CRITICAL.
|
||||
You can use the following variables: %{state}, %{sync_host}.
|
||||
|
||||
=item B<--warning-member-status>
|
||||
|
||||
Set warning threshold for members status (Default: '%{state} !~ /PRIMARY|SECONDARY/').
|
||||
You can use the following variables: %{name}, %{state}, %{health},
|
||||
%{slave_delay}, %{priority}.
|
||||
Define the conditions to match for the status to be WARNING (default: '%{state} !~ /PRIMARY|SECONDARY/').
|
||||
You can use the following variables: %{name}, %{state}, %{health}, %{slave_delay}, %{priority}.
|
||||
|
||||
=item B<--critical-member-status>
|
||||
|
||||
Set critical threshold for members status (Default: '%{health} !~ /up/').
|
||||
You can use the following variables: %{name}, %{state}, %{health},
|
||||
%{slave_delay}, %{priority}.
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{health} !~ /up/').
|
||||
You can use the following variables: %{name}, %{state}, %{health}, %{slave_delay}, %{priority}.
|
||||
|
||||
=item B<--warning-instance-replication-lag-seconds>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Warning threshold for replication lag between primary and secondary members.
|
||||
Must not be over 0 (between minus slaveDelay and 0).
|
||||
|
||||
=item B<--critical-instance-replication-lag-seconds>
|
||||
|
||||
Critical threshold for replication lag between primary and secondary members.
|
||||
Must not be over 0 (between minus slaveDelay and 0).
|
||||
Thresholds.
|
||||
Can be: 'members-primary', 'members-secondary', 'members-arbiter',
|
||||
'replication-lag'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -29,18 +29,17 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
$self->{modes} = {
|
||||
'collection-statistics' => 'database::mongodb::mode::collectionstatistics',
|
||||
'connections' => 'database::mongodb::mode::connections',
|
||||
'connection-time' => 'database::mongodb::mode::connectiontime',
|
||||
'database-statistics' => 'database::mongodb::mode::databasestatistics',
|
||||
'list-databases' => 'database::mongodb::mode::listdatabases',
|
||||
'queries' => 'database::mongodb::mode::queries',
|
||||
'replication-status' => 'database::mongodb::mode::replicationstatus',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{driver} = 'database::mongodb::custom::driver';
|
||||
'replication-status' => 'database::mongodb::mode::replicationstatus'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{driver} = 'database::mongodb::custom::driver';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::battery;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
my $map_battery_mode = {
|
||||
1 => 'unknown',
|
||||
2 => 'FloatCharging',
|
||||
3 => 'ShortTest',
|
||||
4 => 'BoostChargingForTest',
|
||||
5 => 'ManualTesting',
|
||||
6 => 'PlanTesting',
|
||||
7 => 'ACFailTesting',
|
||||
8 => 'ACFail',
|
||||
9 => 'ManualBoostCharging',
|
||||
10 => 'AutoBoostCharging',
|
||||
11 => 'CyclicBoostCharging',
|
||||
12 => 'MasterBoostCharging',
|
||||
13 => 'MasterBateryTesting'
|
||||
};
|
||||
|
||||
sub battery_mode_custom_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf("Battery mode: '%s'", $self->{result_values}->{battery_mode});
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'battery', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{battery} = [
|
||||
{
|
||||
label => 'voltage', nlabel => 'battery.voltage.volt',
|
||||
set => {
|
||||
key_values => [ { name => 'voltage' } ],
|
||||
output_template => 'voltage: %.2fV',
|
||||
perfdatas => [ { template => '%.2f', unit => 'V' } ],
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'current', nlabel => 'battery.current.ampere',
|
||||
set => {
|
||||
key_values => [ { name => 'current' } ],
|
||||
output_template => 'current: %.2fA',
|
||||
perfdatas => [ { template => '%.2f', unit => 'A' } ],
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'capacity', nlabel => 'battery.capacity.percentage',
|
||||
set => {
|
||||
key_values => [ { name => 'capacity' } ],
|
||||
output_template => 'capacity: %.2f%%',
|
||||
perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%' } ],
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'nominal-capacity', nlabel => 'battery.nominal.capacity.amperehour',
|
||||
set => {
|
||||
key_values => [ { name => 'nominal_capacity' } ],
|
||||
output_template => 'used capacity: %.2fAh',
|
||||
perfdatas => [ { template => '%.2f', unit => 'Ah' } ],
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'battery-mode',
|
||||
unknown_default => '%{battery_mode} =~ /unknown/i',
|
||||
warning_default => '%{battery_mode} =~ /ShortTest|BoostChargingForTest|ManualTesting|PlanTesting|ManualBoostCharging|AutoBoostCharging|CyclicBoostCharging|MasterBoostCharging|MasterBateryTesting/i',
|
||||
critical_default => '%{battery_mode} =~ /ACFailTesting|ACFail/i',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [ { name => 'battery_mode' } ],
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => sub {return 0;},
|
||||
closure_custom_output => $self->can('battery_mode_custom_output')
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_psStatusBatteryMode = '.1.3.6.1.4.1.6302.2.1.2.9.0';
|
||||
my $oid_psBatteryVoltage = '.1.3.6.1.4.1.6302.2.1.2.5.1.0';
|
||||
my $oid_psTotalBatteryCurrent = '.1.3.6.1.4.1.6302.2.1.2.5.2.0';
|
||||
my $oid_psBatteryCapacity = '.1.3.6.1.4.1.6302.2.1.2.5.3.0';
|
||||
my $oid_psBatteryNominalCapacity = '.1.3.6.1.4.1.6302.2.1.2.5.4.0';
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_psStatusBatteryMode,
|
||||
$oid_psBatteryVoltage,
|
||||
$oid_psTotalBatteryCurrent,
|
||||
$oid_psBatteryCapacity,
|
||||
$oid_psBatteryNominalCapacity
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{battery} = {
|
||||
voltage => $snmp_result->{$oid_psBatteryVoltage} / 1000,
|
||||
current => $snmp_result->{$oid_psTotalBatteryCurrent} / 1000,
|
||||
capacity => $snmp_result->{$oid_psBatteryCapacity} / 1000,
|
||||
nominal_capacity => $snmp_result->{$oid_psBatteryNominalCapacity} / 1000,
|
||||
battery_mode => $map_battery_mode->{$snmp_result->{$oid_psStatusBatteryMode}},
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check battery.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds: voltage (V), current (A), capacity (%), nominal-capacity (Ah)
|
||||
|
||||
=item B<--unknown-battery-mode>
|
||||
|
||||
Define the conditions to match for the status to be UNKNOWN (default: '%{battery_mode} =~ /unknown/i').
|
||||
You can use the following variables: %{battery_mode}
|
||||
|
||||
=item B<--warning-battery-mode>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (default: '%{battery_mode} =~ /ShortTest|BoostChargingForTest|ManualTesting|PlanTesting|ManualBoostCharging|AutoBoostCharging|CyclicBoostCharging|MasterBoostCharging|MasterBateryTesting/i').
|
||||
You can use the following variables: %{battery_mode}
|
||||
|
||||
=item B<--critical-battery-mode>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{battery_mode} =~ /ACFailTesting|ACFail/i').
|
||||
You can use the following variables: %{battery_mode}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,114 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::input;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'input', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{input} = [
|
||||
{
|
||||
label => 'line-a', nlabel => 'lineA.input.voltage.volt',
|
||||
set => {
|
||||
key_values => [ { name => 'lineA' } ],
|
||||
output_template => 'line A voltage: %.2fV',
|
||||
perfdatas => [ { template => '%.2f', unit => 'V' } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'line-b', nlabel => 'lineB.input.voltage.volt',
|
||||
set => {
|
||||
key_values => [ { name => 'lineB' } ],
|
||||
output_template => 'line B voltage: %.2fV',
|
||||
perfdatas => [ { template => '%.2f', unit => 'V' } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'line-c', nlabel => 'lineC.input.voltage.volt',
|
||||
set => {
|
||||
key_values => [ { name => 'lineC' } ],
|
||||
output_template => 'line C voltage: %.2fV',
|
||||
perfdatas => [ { template => '%.2f', unit => 'V' } ]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_psInputLineAVoltage = '.1.3.6.1.4.1.6302.2.1.2.6.1.0';
|
||||
my $oid_psInputLineBVoltage = '.1.3.6.1.4.1.6302.2.1.2.6.2.0';
|
||||
my $oid_psInputLineCVoltage = '.1.3.6.1.4.1.6302.2.1.2.6.3.0';
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_psInputLineAVoltage,
|
||||
$oid_psInputLineBVoltage,
|
||||
$oid_psInputLineCVoltage,
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{input} = {
|
||||
lineA => $snmp_result->{$oid_psInputLineAVoltage} / 1000,
|
||||
lineB => $snmp_result->{$oid_psInputLineBVoltage} / 1000,
|
||||
lineC => $snmp_result->{$oid_psInputLineCVoltage} / 1000,
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check input lines.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Input thresholds in V
|
||||
|
||||
Thresholds: line-a, line-c, line-c.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,155 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::rectifier;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub rectifier_custom_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"installed: %d, communicating: %d, used capacity: %.2f%%",
|
||||
$self->{result_values}->{installed},
|
||||
$self->{result_values}->{communicating},
|
||||
$self->{result_values}->{used_capacity}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'rectifier', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{rectifier} = [
|
||||
{
|
||||
label => 'status',
|
||||
warning_default => '%{installed} != %{communicating}',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'used_capacity' },
|
||||
{ name => 'installed' },
|
||||
{ name => 'communicating' }
|
||||
],
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => sub {return 0;},
|
||||
closure_custom_output => $self->can('rectifier_custom_output')
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'used-capacity', display_ok => 0, nlabel => 'rectifier.capacity.used.percentage',
|
||||
set => {
|
||||
key_values => [ { name => 'used_capacity' } ],
|
||||
output_template => 'used capacity: %.2f%%',
|
||||
perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%' } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'installed', display_ok => 0, nlabel => 'rectifier.installed.count',
|
||||
set => {
|
||||
key_values => [ { name => 'installed' } ],
|
||||
output_template => 'installed: %d',
|
||||
perfdatas => [ { template => '%d', min => 0 } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'communicating', display_ok => 0, nlabel => 'rectifier.communicating.count',
|
||||
set => {
|
||||
key_values => [ { name => 'communicating' } ],
|
||||
output_template => 'communicating: %d',
|
||||
perfdatas => [ { template => '%d', 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;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_numberOfInstalledRectifiers = '.1.3.6.1.4.1.6302.2.1.2.11.1.0';
|
||||
my $oid_numberOfRectifiersCommunicating = '.1.3.6.1.4.1.6302.2.1.2.11.2.0';
|
||||
my $oid_rectifiersUsedCapacity = '.1.3.6.1.4.1.6302.2.1.2.11.3.0';
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_numberOfInstalledRectifiers,
|
||||
$oid_numberOfRectifiersCommunicating,
|
||||
$oid_rectifiersUsedCapacity
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{rectifier} = {
|
||||
installed => $snmp_result->{$oid_numberOfInstalledRectifiers},
|
||||
communicating => $snmp_result->{$oid_numberOfRectifiersCommunicating},
|
||||
used_capacity => $snmp_result->{$oid_rectifiersUsedCapacity}
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check rectifier.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--unknown-status>
|
||||
|
||||
Define the conditions to match for the status to be UNKNOWN.
|
||||
You can use the following variables: %{installed}, %{communicating}, %{used_capacity}
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (default: '%{installed} != %{communicating}').
|
||||
You can use the following variables: %{installed}, %{communicating}, %{used_capacity}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL.
|
||||
You can use the following variables: %{installed}, %{communicating}, %{used_capacity}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'used-capacity', 'installed', 'communicating'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,177 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::system;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
my $map_system_status = {
|
||||
1 => 'unknown',
|
||||
2 => 'normal',
|
||||
3 => 'warning',
|
||||
4 => 'minor',
|
||||
5 => 'major',
|
||||
6 => 'critical',
|
||||
7 => 'unmanaged',
|
||||
8 => 'restricted',
|
||||
9 => 'testing',
|
||||
10 => 'disabled'
|
||||
};
|
||||
|
||||
my $map_communication_status = {
|
||||
1 => 'unknown',
|
||||
2 => 'normal',
|
||||
3 => 'interrupt'
|
||||
};
|
||||
|
||||
sub status_custom_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"system status: '%s' - communication status: '%s'",
|
||||
$self->{result_values}->{system_status},
|
||||
$self->{result_values}->{communication_status}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'system', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{system} = [
|
||||
{
|
||||
label => 'status',
|
||||
unknown_default => '%{system_status} =~ /unknown|unmanaged|restricted|testing|disabled/i || %{communication_status} =~ /unknown/i',
|
||||
warning_default => '%{system_status} =~ /warning|minor/i',
|
||||
critical_default => '%{system_status} =~ /major|critical/i || %{communication_status} =~ /interrupt/i',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'system_status' },
|
||||
{ name => 'communication_status' }
|
||||
],
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => sub {return 0;},
|
||||
closure_custom_output => $self->can('status_custom_output')
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'voltage', nlabel => 'system.voltage.volt',
|
||||
set => {
|
||||
key_values => [ { name => 'voltage' } ],
|
||||
output_template => 'voltage: %.2fV',
|
||||
perfdatas => [ { template => '%.2f', unit => 'V' } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'current', nlabel => 'system.current.ampere',
|
||||
set => {
|
||||
key_values => [ { name => 'current' } ],
|
||||
output_template => 'current: %.2fA',
|
||||
perfdatas => [ { template => '%.2f', unit => 'A' } ]
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'used-capacity', nlabel => 'system.used.capacity.percentage',
|
||||
set => {
|
||||
key_values => [ { name => 'used_capacity' } ],
|
||||
output_template => 'used capacity: %.2f%%',
|
||||
perfdatas => [ { template => '%.2f', min => 0, max => 100, unit => '%' } ]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_systemStatus = '.1.3.6.1.4.1.6302.2.1.2.1.0';
|
||||
my $oid_systemVoltage = '.1.3.6.1.4.1.6302.2.1.2.2.0';
|
||||
my $oid_systemCurrent = '.1.3.6.1.4.1.6302.2.1.2.3.0';
|
||||
my $oid_systemUsedCapacity = '.1.3.6.1.4.1.6302.2.1.2.4.0';
|
||||
my $oid_psStatusCommunication = '.1.3.6.1.4.1.6302.2.1.2.8.0';
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_systemStatus,
|
||||
$oid_systemVoltage,
|
||||
$oid_systemCurrent,
|
||||
$oid_systemUsedCapacity,
|
||||
$oid_psStatusCommunication
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{system} = {
|
||||
system_status => $map_system_status->{$snmp_result->{$oid_systemStatus}},
|
||||
communication_status => $map_communication_status->{$snmp_result->{$oid_psStatusCommunication}},
|
||||
voltage => $snmp_result->{$oid_systemVoltage} / 1000,
|
||||
current => $snmp_result->{$oid_systemCurrent} / 1000,
|
||||
used_capacity => $snmp_result->{$oid_systemUsedCapacity}
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--unknown-status>
|
||||
|
||||
Define the conditions to match for the status to be UNKNOWN (default: '%{system_status} =~ /unknown|unmanaged|restricted|testing|disabled/i || %{communication_status} =~ /unknown/i').
|
||||
You can use the following variables: %{system_status}, %{communication_status}
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (default: '%{system_status} =~ /warning|minor/i').
|
||||
You can use the following variables: %{system_status}, %{communication_status}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{system_status} =~ /major|critical/i || %{communication_status} =~ /interrupt/i').
|
||||
You can use the following variables: %{system_status}, %{communication_status}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds: voltage (V), current (A), used-capacity (%)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,167 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::temperature;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub status_custom_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"alarm status %s [type: %s]",
|
||||
$self->{result_values}->{alarm_status},
|
||||
$self->{result_values}->{type}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_temperature_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Probe '" . $options{instance_value}->{name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'temperatures', type => 1, cb_prefix_output => 'prefix_temperature_output', message_multiple => 'All temperatures are ok', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{temperatures} = [
|
||||
{
|
||||
label => 'alarm-status',
|
||||
unknown_default => '%{alarm_status} =~ /fail/i',
|
||||
warning_default => '%{alarm_status} =~ /low/i',
|
||||
critical_default => '%{alarm_status} =~ /high/i',
|
||||
type => 2,
|
||||
set => {
|
||||
key_values => [
|
||||
{ name => 'alarm_status' }, { name => 'type' }, { name => 'name' }
|
||||
],
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => sub {return 0;},
|
||||
closure_custom_output => $self->can('status_custom_output')
|
||||
}
|
||||
},
|
||||
{
|
||||
label => 'temperature', nlabel => 'probe.temperature.celsius',
|
||||
set => {
|
||||
key_values => [ { name => 'temperature' }, { name => 'name' } ],
|
||||
output_template => 'temperature: %.2fC',
|
||||
perfdatas => [ { template => '%.2f', unit => 'C', label_extra_instance => 1, instance_use => 'name' } ]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $map_alarm_status = {
|
||||
0 => 'high',
|
||||
1 => 'low',
|
||||
2 => 'fail',
|
||||
3 => 'none'
|
||||
};
|
||||
|
||||
my $map_type = {
|
||||
0 => 'none',
|
||||
1 => 'ambient',
|
||||
2 => 'battery'
|
||||
};
|
||||
|
||||
my $mapping = {
|
||||
temperature => { oid => '.1.3.6.1.4.1.6302.2.1.2.7.3.1.2' },
|
||||
alarm_status => { oid => '.1.3.6.1.4.1.6302.2.1.2.7.3.1.5', map => $map_alarm_status },
|
||||
name => { oid => '.1.3.6.1.4.1.6302.2.1.2.7.3.1.3' },
|
||||
type => { oid => '.1.3.6.1.4.1.6302.2.1.2.7.3.1.4', map => $map_type }
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||
oids => [
|
||||
{ oid => $mapping->{temperature}->{oid} },
|
||||
{ oid => $mapping->{alarm_status}->{oid} },
|
||||
{ oid => $mapping->{name}->{oid} },
|
||||
{ oid => $mapping->{type}->{oid} }
|
||||
],
|
||||
return_type => 1,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{temperatures} = {};
|
||||
foreach my $oid (keys %{$snmp_result}) {
|
||||
next if ($oid !~ /^$mapping->{temperature}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $data = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
$self->{temperatures}->{$instance} = {
|
||||
temperature => $data->{temperature} / 1000,
|
||||
alarm_status => $data->{alarm_status},
|
||||
name => $data->{name},
|
||||
type => $data->{type}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check temperature.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--unknown-alarm-status>
|
||||
|
||||
Define the conditions to match for the status to be UNKNOWN (default: '%{alarm_status} =~ /fail/i').
|
||||
You can use the following variables: %{alarm_status}, %{type}, %{name}
|
||||
|
||||
=item B<--warning-alarm-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (default: '%{alarm_status} =~ /low/i').
|
||||
You can use the following variables: %{alarm_status}, %{type}, %{name}
|
||||
|
||||
=item B<--critical-alarm-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{alarm_status} =~ /high/i').
|
||||
You can use the following variables: %{alarm_status}, %{type}, %{name}
|
||||
|
||||
=item B<--warning-temperature> B<--critical-temperature>
|
||||
|
||||
Thresholds: temperature (C)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::snmp::mode::uptime;
|
||||
|
||||
use base qw(snmp_standard::mode::uptime);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system uptime.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-uptime>
|
||||
|
||||
Warning threshold.
|
||||
|
||||
=item B<--critical-uptime>
|
||||
|
||||
Critical threshold.
|
||||
|
||||
=item B<--add-sysdesc>
|
||||
|
||||
Display system description.
|
||||
|
||||
=item B<--force-oid>
|
||||
|
||||
Can choose your OID (numeric format only).
|
||||
|
||||
=item B<--check-overload>
|
||||
|
||||
Uptime counter limit is 4294967296 and overflow.
|
||||
With that option, we manage the counter going back. But there is a few chance we can miss a reboot.
|
||||
|
||||
=item B<--reboot-window>
|
||||
|
||||
To be used with check-overload option. Time in milliseconds (default: 5000)
|
||||
You increase the chance of not missing a reboot if you decrease that value.
|
||||
|
||||
=item B<--unit>
|
||||
|
||||
Select the unit for performance data and thresholds. May be 's' for seconds, 'm' for minutes,
|
||||
'h' for hours, 'd' for days, 'w' for weeks. Default is seconds
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# Copyright 2023 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 hardware::ups::ees::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->{modes} = {
|
||||
'system' => 'hardware::ups::ees::snmp::mode::system',
|
||||
'battery' => 'hardware::ups::ees::snmp::mode::battery',
|
||||
'input' => 'hardware::ups::ees::snmp::mode::input',
|
||||
'temperature' => 'hardware::ups::ees::snmp::mode::temperature',
|
||||
'rectifier' => 'hardware::ups::ees::snmp::mode::rectifier',
|
||||
'uptime' => 'hardware::ups::ees::snmp::mode::uptime'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Emerson Energy Systems (Vertiv) in SNMP.
|
||||
|
||||
=cut
|
|
@ -36,6 +36,7 @@ sub set_system {
|
|||
default => [
|
||||
['^ok$', 'OK'],
|
||||
['normal', 'OK'],
|
||||
['ready', 'OK'],
|
||||
['.*', 'CRITICAL']
|
||||
]
|
||||
};
|
||||
|
|
|
@ -49,9 +49,9 @@ sub set_counters {
|
|||
$self->{maps_counters_type} = [
|
||||
{ name => 'vdoms', type => 3, cb_prefix_output => 'prefix_vdom_output', cb_long_output => 'vdom_long_output', indent_long_output => ' ', message_multiple => 'All vdom systems are ok',
|
||||
group => [
|
||||
{ name => 'cpu', type => 0, display_short => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'memory', type => 0, display_short => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'session', type => 0, display_short => 0, skipped_code => { -10 => 1 } }
|
||||
{ name => 'cpu', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'memory', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'session', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
@ -110,6 +110,10 @@ sub manage_selection {
|
|||
get_param => ['global=1']
|
||||
);
|
||||
|
||||
if (ref($resources) ne 'ARRAY') {
|
||||
$resources = [$resources];
|
||||
}
|
||||
|
||||
$self->{vdoms} = {};
|
||||
foreach my $resource (@$resources) {
|
||||
next if (defined($self->{option_results}->{filter_vdom}) && $self->{option_results}->{filter_vdom} ne '' &&
|
||||
|
|
|
@ -24,8 +24,9 @@ use strict;
|
|||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'active',
|
||||
2 => 'inactive',
|
||||
0 => 'Fail',
|
||||
1 => 'Good',
|
||||
2 => 'Not installed',
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
|
|
|
@ -34,7 +34,8 @@ sub set_system {
|
|||
|
||||
$self->{thresholds} = {
|
||||
fan => [
|
||||
['active', 'OK'],
|
||||
['Good', 'OK'],
|
||||
['Not installed', 'OK'],
|
||||
['.*', 'CRITICAL'],
|
||||
],
|
||||
module => [
|
||||
|
|
Loading…
Reference in New Issue