summaryrefslogtreecommitdiffstats
path: root/libexec/plugins-hook
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/plugins-hook')
-rwxr-xr-xlibexec/plugins-hook37
1 files changed, 37 insertions, 0 deletions
diff --git a/libexec/plugins-hook b/libexec/plugins-hook
new file mode 100755
index 0000000..c2cce60
--- /dev/null
+++ b/libexec/plugins-hook
@@ -0,0 +1,37 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -u
16
17export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
18
19hook_name=${0##*/}
20hook_directory="/home/plugins/libexec/$hook_name.d"
21
22if [ -d "$hook_directory" ]
23then
24 stdin_file=$(mktemp "/tmp/.$hook_name.XXXXXX")
25 trap 'rm -f "$stdin_file"' EXIT
26 test "${hook_name##*-}" = 'receive' && cat > "$stdin_file"
27
28 for file in $(find -L "$hook_directory/." ! -name '.' -prune \
29 -type 'f' -perm -'+x' | sort)
30 do
31 "$file" "$@" < "$stdin_file"
32 status=$?
33 test "$status" -ne 0 && return_value=$status
34 done
35fi
36
37exit ${return_value:-0}