Collection of CheckMK checks (see https://checkmk.com/). All checks and plugins are provided as is. Absolutely no warranty. Send any comments to thl-cmk[at]outlook[dot]com

Skip to content
Snippets Groups Projects
Commit 62c7312f authored by thl-cmk's avatar thl-cmk :flag_na:
Browse files

Delete curl.cmd

parent 03f49a39
No related branches found
No related tags found
No related merge requests found
@echo off
:: License: GNU General Public License v2
:: Author: thl-cmk[at]outlook[dot]com
:: URL : https://thl-cmk.hopto.org
:: Date : 2022-02-10
:: based on the work by Christian Wirtz doc[at]snowheaven[dot]de and
:: Wrapper around: https://curl.se/
:: 2022-02-10: rewritten by thl-cmk[at]outlook.com to output json string
:: 2022-02-16: added file checks for CURL_EXECUTABLE and CURL_FORMAT
:: 2022-02-17: added ERRORLEVEL
:: 2022-02-21: added curl_option to the output
:: 2022-02-22: fixed search for curl.exe
:: 2022-02-23: fixed handling of options from curl.cfg
:: 2022-02-24: removed curl.format, replaced by -w %{json}
:: 2022-02-25: removed separate url and error_level from output
echo | set /p="<<<curl:sep(0)>>>"
echo.
SETLOCAL ENABLEDELAYEDEXPANSION
set CURL_FORMAT=C:\ProgramData\checkmk\agent\plugins\curl.format
set CURL_CONFIG=C:\ProgramData\checkmk\agent\config\curl.cfg
:: 4x% escapes the single % (don't know why/how)
set CURL_OPTIONS=-q -w %%%%{json} -s
set CURL_RUN="FIRST"
If Not Exist "%CURL_CONFIG%" (
echo {"ERROR":"config file %CURL_CONFIG% does not exist"}
exit
)
:: first check for curl.exe in cmk agent directory
if exist "C:\ProgramData\checkmk\agent\bin\curl.exe" (
set CURL_EXECUTABLE=C:\ProgramData\checkmk\agent\bin\curl.exe
) else (
:: if not found look for system provided file
if exist "C:\Windows\System32\curl.exe" (
set CURL_EXECUTABLE=C:\Windows\System32\curl.exe
) else (
echo {"ERROR":"executable file curl.exe not found"}
)
)
echo | set /p={
FOR /F "tokens=1,2,3 delims=|" %%a IN ('Type "%CURL_CONFIG%"') DO @call :GET_URL %%a %%b %%c
echo }
exit 0
:GET_URL
set OPTIONS=%3
:: trim "options" to options
set STRIP_OPTIONS=%OPTIONS:~1,-1%
if "%CURL_RUN%"=="SECOND" (
echo | set /p=,
) else (
set "CURL_RUN=SECOND"
)
echo | set /p=""%1":{"data""
echo | set /p=:
call "%CURL_EXECUTABLE%" %CURL_OPTIONS% --url %2 %STRIP_OPTIONS%
echo | set /p=,"curl_options":"%CURL_OPTIONS% %STRIP_OPTIONS%"
echo | set /p=}
goto :EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment