|
@@ -6,7 +6,7 @@
|
|
# | | |___| | | | __/ (__| < | | | | . \ |
|
|
# | | |___| | | | __/ (__| < | | | | . \ |
|
|
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
|
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
|
|
# | |
|
|
# | |
|
|
-# | Copyright Jonas Nickl 2016 development@ichalsroot.de |
|
|
|
|
|
|
+# | Copyright Jonas Nickl 2021 development@ichalsroot.de |
|
|
# +------------------------------------------------------------------+
|
|
# +------------------------------------------------------------------+
|
|
#
|
|
#
|
|
# This file is an addon for Check_MK.
|
|
# This file is an addon for Check_MK.
|
|
@@ -26,16 +26,19 @@
|
|
HOSTNAME=`hostname`
|
|
HOSTNAME=`hostname`
|
|
MK_CONFDIR=/etc/check_mk
|
|
MK_CONFDIR=/etc/check_mk
|
|
|
|
|
|
|
|
+temp_file=$(mktemp)
|
|
|
|
+
|
|
## DEBUG Level (BOOL)
|
|
## DEBUG Level (BOOL)
|
|
if [ "$1" == "--debug" ] ; then DEBUG="1"; fi
|
|
if [ "$1" == "--debug" ] ; then DEBUG="1"; fi
|
|
-
|
|
|
|
|
|
+
|
|
be_done()
|
|
be_done()
|
|
{
|
|
{
|
|
|
|
+ rm ${temp_file}
|
|
echo "RC=$STATUS"
|
|
echo "RC=$STATUS"
|
|
## bad returncode if status nok
|
|
## bad returncode if status nok
|
|
if [ "$STATUS" != "OK" ]; then exit 1; fi
|
|
if [ "$STATUS" != "OK" ]; then exit 1; fi
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
validate()
|
|
validate()
|
|
## Verify config dir exists and that the config file exists
|
|
## Verify config dir exists and that the config file exists
|
|
{
|
|
{
|
|
@@ -59,19 +62,19 @@ validate()
|
|
echo "curl was not found in path, please install it."
|
|
echo "curl was not found in path, please install it."
|
|
exit 1
|
|
exit 1
|
|
fi
|
|
fi
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
get_result()
|
|
get_result()
|
|
{
|
|
{
|
|
## decode agent output with base64, remove line breaks and replace plus with html +
|
|
## decode agent output with base64, remove line breaks and replace plus with html +
|
|
- export DATA=$(check_mk_agent | base64 --wrap=0 | sed 's/+/%2b/g' )
|
|
|
|
|
|
+ export DATA=`check_mk_agent | base64 --wrap=0 | sed 's/+/%2b/g' > ${temp_file}`
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
send_result()
|
|
send_result()
|
|
{
|
|
{
|
|
- [ $DEBUG ] && echo "curl -X POST --silent --user $OMDUSER:$OMDPASS --data \"DATA=$DATA&HOSTNAME=$HOSTNAME&DEBUG=$DEBUG\" $OMDURL"
|
|
|
|
- STATUS=$(curl -X POST --silent --user $OMDUSER:$OMDPASS --data "DATA=$DATA&HOSTNAME=$HOSTNAME&DEBUG=$DEBUG" "$OMDURL")
|
|
|
|
|
|
+ [ $DEBUG ] && echo '$(echo "HOSTNAME=$HOSTNAME&DEBUG=$DEBUG&DATA=cat1 ${temp_file}" | curl -X POST --silent --user $OMDUSER:$OMDPASS --data @- $OMDURL'
|
|
|
|
+ STATUS=$(echo "HOSTNAME=${HOSTNAME}&DEBUG=${DEBUG}&DATA=`cat ${temp_file}`" | curl -X POST --silent --user ${OMDUSER}:${OMDPASS} --data @- ${OMDURL} )
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
if [ $? != 0 ]; then
|
|
echo "Failed to submit agent output via CURL"
|
|
echo "Failed to submit agent output via CURL"
|