diff --git a/README.md b/README.md index c643b0102c1507ddef333d6ff4b1f7f92e7c828e..c075345c71e444aa90d6e3053d88b6af0c2c7fb1 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,32 @@ This script checks if the LDAP servers are accessible hostnames="" </pre> +### rpc_status.sh +This script checks if the RPC server is accessible and if RPC returns valid user + +* Requirements: + * library *bc* + <pre> + apt-get install bc + </pre> +* Attributes to be filled: + <pre> + # RPC username + USER="" + + # RPC password + PASSWORD="" + + # RPC domain with authentication method + # Example: "perun.cesnet.cz/krb" + DOMAIN="" + + # Valid userId - This id will be used in getUserById call + USER_ID="" + </pre> + + + ## List of plugins Plugins are located in /usr/lib/check_mk/plugins/ diff --git a/rpc_status.sh b/rpc_status.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f1a851c1636b6b2f942f52839ff97b166165a8e --- /dev/null +++ b/rpc_status.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# RPC username +USER="" + +# RPC password +PASSWORD="" + +# RPC domain with authentication method +# Example: "perun.cesnet.cz/krb" +DOMAIN="" + +# Valid userId - This id will be used in getUserById call +USER_ID="" + +URL="https://${DOMAIN}/rpc/json/usersManager/getUserById?id=${USER_ID}" + +START_TIME=$(date +%s%N) +RPC_RESULT=$(timeout 10 curl --user ${USER}:${PASSWORD} ${URL} 2>&1) +END_TIME=$(date +%s%N) +TOTAL_TIME=$(echo "scale=4;$(expr ${END_TIME} - ${START_TIME}) / 1000000000" | bc -l) +if [[ $RPC_RESULT == *\"id\":${USER_ID}* ]]; then + echo "0 rpc_status total_time=${TOTAL_TIME} OK" +else + echo "2 rpc_status total_time=${TOTAL_TIME} ${RPC_RESULT}" +fi