nagios-nrpe: add a NRPE check-local command with completion
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2781|5|2776|5|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/249//ansiblelint">Evolix » ansible-roles » unstable #249</a> Details
gitea/ansible-roles/pipeline/head This commit looks good Details

This commit is contained in:
William Hirigoyen 2023-05-12 12:35:49 +02:00
parent ad2d96d890
commit 6ab34517b6
5 changed files with 54 additions and 1 deletions

View File

@ -13,6 +13,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
### Added
* userlogrotate: rotate also php.log.
* nagios-nrpe: add a NRPE check-local command with completion.
### Changed
* evolinux-users: remove Stretch references in tasks that also apply to next Debian versions.

12
nagios-nrpe/files/check-local Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/bash
if ! test -f /usr/lib/nagios/plugins/check_nrpe; then
echo '/usr/lib/nagios/plugins/check_nrpe is missing, please install nagios-nrpe-plugin package.'
exit 1
fi
/usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_$1

View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
_check_local_dynamic_completion() {
local cur;
cur=${COMP_WORDS[COMP_CWORD]};
check_list=$(grep 'check_' /etc/nagios/nrpe.d/evolix.cfg | grep -vE '^[[:blank:]]*#' | awk -F'[\[\]=_]' '{print $3}')
COMPREPLY=();
COMPREPLY=( $( compgen -W '$(grep check_ /etc/nagios/nrpe.d/evolix.cfg | grep -vE "^[[:blank:]]*#" | awk -F"[\[\]=_]" "{print \$3}")' -- $cur ) );
}
complete -F _check_local_dynamic_completion check-local

View File

@ -0,0 +1,24 @@
---
# Install check-local utilitary
# This task is for Debian >= 10 only!
- name: Package nagios-nrpe-plugin is intalled
ansible.builtin.apt:
name: nagios-nrpe-plugin
when: ansible_distribution_major_version is version('10', '>=')
- name: Utilitary check-local is installed
ansible.builtin.copy:
src: check-local
dest: /usr/local/bin/check-local
mode: "0755"
when: ansible_distribution_major_version is version('10', '>=')
- name: Completion for utilitary check-local is installed
ansible.builtin.copy:
src: check-local_completion
dest: /etc/bash_completion.d/check-local
mode: "0755"
when: ansible_distribution_major_version is version('10', '>=')

View File

@ -84,4 +84,7 @@
tags:
- nagios-nrpe
- ansible.builtin.include_tasks: wrapper.yml
- ansible.builtin.include_tasks: wrapper.yml
- ansible.builtin.include_tasks: check-local.yml
when: ansible_distribution_major_version is version('10', '>=')