Skip to content
Snippets Groups Projects
Commit 248ec8ac authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check pipes in output and performance data

parent 62269723
Branches
No related tags found
1 merge request!12check pipes in output and performance data
```text
_______ __
|_ _|.----.|__|.-----.-----.---.-.
_| |_ | __|| || | _ | _ |
|_______||____||__||__|__|___ |___._|
|_____|
______ __ ______ _____ __ __
| __ \.---.-.-----.-----.|__|.--.--.-----. | | |_|__|.-----.-----.| |_
| __/| _ |__ --|__ --|| || | | -__| | ---| | || -__| || _|
|___| |___._|_____|_____||__| \___/|_____| |______|_______|__||_____|__|__||____|
```
A set of shell scripts (Bash) for an icinga client.
With a director script you can create Hosts and service checks with Icingaweb2 director API.
With an Icinga2 script you can run checks and post its results to the Icinga2 API.
Licencse: GNU GPL 3.0
IML * Institute For Medical Education; University of Bern
## Requirements
Icinga:
* In Icingaweb2 the module "director" must be enabled and the API access to it
* An existing Icinga 2 instance with enabled API access
On clients:
* Linux with Bash
## Basic Installation
As root...
* Create a non privileged user "icingaclient".
* Create a directory `mkdir -p /opt/imlmonitor/ && cd /opt/imlmonitor/`
* Run a git clone: `git clone https://git-repo.iml.unibe.ch/open-source/icinga-passive-client.git client`
* Set owner: `chown -R icingaclient. client`
## Setup client
* go to the "client" directory `cd /opt/imlmonitor/client` and copy _etc directory to /etc: `cp -r _etc /etc/icingaclient`
## Setup Icingaweb2 director access
TBD
## Setup Icinga2 access
TBD
......@@ -15,11 +15,12 @@
# 2022-02-16 v0.8 ah add --cfg param
# 2022-03-04 v0.9 ah abort on http 5xx error
# 2022-03-14 v0.10 ah less output and add _elog to run as a service
# 2022-07-08 v0.11 ah check pipes in output and performance data
# ======================================================================
_product="ICINGA PASSIVE CLIENT"
_version="0.10"
_version="0.11"
_license="GNU GPL 3.0"
_copyright='(c) 2020 Institute for Medical Education * University of Bern'
......@@ -294,6 +295,7 @@ function processCheck(){
local _myconfig=$1
local _force=$2
typeset -i local iPipes
typeset -i local iCheckStart
iCheckStart=$(_getUnixTs)
......@@ -350,16 +352,27 @@ function processCheck(){
_elog "${_logPrefix} $( ls -ld ${dir_data} $_outfile )"
exit 1
fi
iPipes=$( sed 's#[^|]##g' "$_outfile" | grep "." | wc -L )
_echo "Pipe chars: $iPipes"
if [[ $iPipes -gt 1 ]]; then
_elog "ABORT - pipes were found in plugin output"
exit 1
fi
typeset -i local iTsEnd=`date +%s`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
outPerfdata=`grep '|' $_outfile | rev | cut -f 1 -d '|' | rev`
_echo
_echo -------- check output:
_echo $( cat $_outfile )
_echo $( cat "$_outfile" )
_echo
# echo -------- extracted performance data:
# echo $outPerfdata
# echo
if ! echo "$outPerfdata" | grep "=[0-9\.]*;[0-9\.]*;[0-9\.]*;[0-9\.]*;" >/dev/null; then
_elog "ABORT - this does not look like performance data: $outPerfdata"
exit 1
fi
_log "${_logPrefix} check command finished with returncode $rc"
_rc=$_rc+$rc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment