Skip to content
Snippets Groups Projects
Unverified Commit 16e8c440 authored by Pavel Vyskočil's avatar Pavel Vyskočil
Browse files

Added rpc_status.sh

* Added script for check if Perun RPC is available
parent 046121c9
No related branches found
No related tags found
1 merge request!10Added rpc_status.sh
......@@ -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/
......
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment