Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Floaty self-test nagios check script #92

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ nfpms:
- deb
- rpm
- apk
contents:
- src: floaty-self-test.sh
dst: /usr/lib/nagios/plugins/floaty-self-test
file_info:
mode: 0755

release:
prerelease: auto
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ Keepalived.
/bin/floaty --json-log --verbose --test /etc/floaty.yml
```

The Debian, RPM and Alpine packages generated by `goreleaser` include script `floaty-self-test.sh` as `/usr/lib/nagios/plugins/floaty-self-test`.
This script runs Floaty in test mode and expects a config file as its only argument.
The script is intended to be used as a check script for an Icinga2 check.

### FIFO mode

Floaty can run in FIFO mode allowing it to process notification events through a FIFO instead of using notify scrips
Expand Down
31 changes: 31 additions & 0 deletions floaty-self-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -u -o pipefail

if [ $# -eq 0 ]; then
echo "Usage: $0 /path/to/floaty-config.yaml"
exit 3
elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "Usage: $0 /path/to/floaty-config.yaml"
exit 3
fi

floaty_bin=/usr/bin/floaty
config_file="$1"

if [ ! -f "$config_file" ]; then
echo "Floaty config file doesn't exist: ${config_file}"
exit 3
fi

self_test_output=$("$floaty_bin" -T "$config_file" 2>&1)
self_test_exit=$?

if [ $self_test_exit -eq 0 ]; then
echo "Floaty self-test passed"
exit 0
else
echo -e "Floaty self-test failed\n"
echo -e "${self_test_output}"
exit 2
fi
Loading