Skip to content
Snippets Groups Projects
Commit a74306cb authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add check "httpd"

parent 1c44ff54
No related branches found
No related tags found
1 merge request!1536588 add couchdb check
...@@ -19,11 +19,12 @@ ...@@ -19,11 +19,12 @@
# 2023-08-28 v0.4 <axel.hahn@unibe.ch> add check "pending" # 2023-08-28 v0.4 <axel.hahn@unibe.ch> add check "pending"
# 2023-08-28 v0.5 <axel.hahn@unibe.ch> add checks "open_databases" + "open_os_files" # 2023-08-28 v0.5 <axel.hahn@unibe.ch> add checks "open_databases" + "open_os_files"
# 2023-08-28 v0.6 <axel.hahn@unibe.ch> add check "httpd_methods" # 2023-08-28 v0.6 <axel.hahn@unibe.ch> add check "httpd_methods"
# 2023-08-29 v0.7 <axel.hahn@unibe.ch> add check "httpd"
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
export self_APPVERSION=0.6 export self_APPVERSION=0.7
cfgfile=/etc/icingaclient/.couchdb cfgfile=/etc/icingaclient/.couchdb
export RESPONSE export RESPONSE
...@@ -51,17 +52,25 @@ OPTIONS: ...@@ -51,17 +52,25 @@ OPTIONS:
response will be shown response will be shown
MODE is one of MODE is one of
up show general couchdb status httpd Show counters for http request types
replication show last replication status httpd_methods Show counters for http request methods
pending show count of pending updates for nodes, dbs and users
open_databases show number of open databases open_databases show number of open databases
open_os_files show number of file descriptors CouchDB has open open_os_files show number of file descriptors CouchDB has open
httpd_methods Show counters for http request methods replication show last replication status
pending show count of pending updates for nodes, dbs and users
replication show last replication status
up show general couchdb health status
EXAMPLE: EXAMPLE:
$_self -m up $_self -m up
Check if couchdb is up and running Check if couchdb is up and running
$_self -m httpd_methods
Show counters and change rate per sec of GET, POST, and other methods
$_self -c /opt/couchdb/myconfig.sh -m up
Source another config to define COUCH_URL
EOF EOF
} }
...@@ -118,35 +127,74 @@ fi ...@@ -118,35 +127,74 @@ fi
case "${sMode}" in case "${sMode}" in
# ............................................................ # ............................................................
"up") "httpd")
REQ=/_up REQ=/_node/_local/_stats/couchdb/httpd
abortOnWrongResponse "${REQ}" '"status":"' abortOnWrongResponse "${REQ}" '"value":'
_status=$( jq '.status' <<< "${RESPONSE}" | tr -d '"') typeset -i _iValue
if ! echo "$_status" | grep "ok" >/dev/null; then typeset -i _iDelta
ph.setStatus critical
fi _status=$( jq 'with_entries(.value |= .value)' <<< "${RESPONSE}" | grep '^ "' | grep -v '\{' | sed 's#[", ]##g' )
ph.status "Couchdb :: health status (value 'status' in ${REQ} is '$_status')" # this returns:
echo "Reponse of ${REQ}: "; # aborted_requests:0
echo "${RESPONSE}" | jq # bulk_requests:0
# requests:185531
# ...
ph.status "Couchdb :: Http request methods"
printf "%30s %10s %10s\n" "Property" "Counter" "Delta" | tr ' ' '_'
for myVar in $( grep "[a-z\_]" <<< "$_status" | cut -f 1 -d ':' )
do
_iValue=$( grep "^${myVar}:" <<< "$_status" | cut -f 2 -d ':' )
_label="couchdb-${myVar//_/-}" # underscrore to minus
_iDelta=$( ph.perfdeltaspeed "${_label}" $_iValue )
printf "%30s %10s %10s per sec\n" "$myVar" $_iValue $_iDelta
ph.perfadd "${myVar}" "$_iDelta" "" ""
done
echo
;; ;;
# ............................................................ # ............................................................
"replication") "httpd_methods")
REQ=/_up REQ=/_node/_local/_stats/couchdb/httpd_request_methods
abortOnWrongResponse "${REQ}" '"status":"' abortOnWrongResponse "${REQ}" '"value":'
_status=$( jq '.seeds[] | .last_replication_status' <<< "${RESPONSE}" | grep -v "null" | tr -d '"') typeset -i _iValue
typeset -i _iDelta
# there can be multiple sections "seeds" and multiple line responses. _status=$( jq 'with_entries(.value |= .value)' <<< "${RESPONSE}" | sed 's#[", ]##g' | grep '^[A-Z]' )
# remove all lines with "ok" and check if there is any "bad content" left # this returns:
_nonok=$( echo "$_status" | grep -v "ok" ) # COPY:0
if [ -n "$_nonok" ]; then # DELETE:1
ph.setStatus critical # GET:188183
fi # HEAD:0
# ...
ph.status "Couchdb :: replication (values 'last_replication_status' in ${REQ} are '$_status')" ph.status "Couchdb :: Http request methods"
echo "Reponse: of ${REQ}"; printf "%10s %10s %10s\n" "Method" "Counter" "Delta" | tr ' ' '_'
echo "${RESPONSE}" | jq for myVar in $( grep "[A-Z]" <<< "$_status" | cut -f 1 -d ':' )
do
_iValue=$( grep "$myVar" <<< "$_status" | cut -f 2 -d ':' )
_iDelta=$( ph.perfdeltaspeed "couchdb-method-${myVar}" $_iValue)
printf "%10s %10s %10s per sec\n" "$myVar" $_iValue $_iDelta
ph.perfadd "${myVar}" "$_iDelta" "" ""
done
# echo "${_status}" | jq
;;
# ............................................................
"open_databases"|"open_os_files")
REQ=/_node/_local/_stats/couchdb/${sMode}
abortOnWrongResponse "${REQ}" '"value":'
typeset -i _iValue
# descr=$( jq '.desc' <<< "${RESPONSE}" | tr -d '"')
_iValue=$( jq '.value' <<< "${RESPONSE}" )
ph.perfadd "${sMode}" "$_iValue" "" ""
ph.status "Couchdb :: ${sMode} = $_iValue"
# echo "$descr"
# echo "Reponse: of ${REQ}";
# echo "${RESPONSE}" | jq
;; ;;
# ............................................................ # ............................................................
"pending") "pending")
...@@ -176,40 +224,38 @@ case "${sMode}" in ...@@ -176,40 +224,38 @@ case "${sMode}" in
echo "${RESPONSE}" | jq echo "${RESPONSE}" | jq
;; ;;
# ............................................................ # ............................................................
"open_databases"|"open_os_files") "replication")
REQ=/_node/_local/_stats/couchdb/${sMode} REQ=/_up
abortOnWrongResponse "${REQ}" '"value":' abortOnWrongResponse "${REQ}" '"status":"'
# descr=$( jq '.desc' <<< "${RESPONSE}" | tr -d '"') _status=$( jq '.seeds[] | .last_replication_status' <<< "${RESPONSE}" | grep -v "null" | tr -d '"')
value=$( jq '.value' <<< "${RESPONSE}" )
ph.perfadd "${sMode}" "$value" "" "" # there can be multiple sections "seeds" and multiple line responses.
ph.status "Couchdb :: ${sMode} = $value" # remove all lines with "ok" and check if there is any "bad content" left
# echo "$descr" _nonok=$( echo "$_status" | grep -v "ok" )
if [ -n "$_nonok" ]; then
ph.setStatus critical
fi
ph.status "Couchdb :: replication (values 'last_replication_status' in ${REQ} are '$_status')"
echo "Reponse: of ${REQ}"; echo "Reponse: of ${REQ}";
echo "${RESPONSE}" | jq echo "${RESPONSE}" | jq
;; ;;
# ............................................................ # ............................................................
"httpd_methods") "up")
REQ=/_node/_local/_stats/couchdb/httpd_request_methods REQ=/_up
abortOnWrongResponse "${REQ}" '"value":' abortOnWrongResponse "${REQ}" '"status":"'
_status=$( jq 'with_entries(.value |= .value)' <<< "${RESPONSE}" )
typeset -i _iValue
typeset -i _iDelta
ph.status "Couchdb :: Http request methods" _status=$( jq '.status' <<< "${RESPONSE}" | tr -d '"')
echo " Method Counter Delta" if ! echo "$_status" | grep "ok" >/dev/null; then
for myMethod in $( grep "[A-Z]" <<< "$_status" | cut -f 1 -d ':' | tr -d ' ' | tr -d '"') ph.setStatus critical
do fi
ph.status "Couchdb :: health status"
echo "Reponse of ${REQ}: ";
echo "${RESPONSE}" | jq
;;
_iValue=$( grep "$myMethod" <<< "$_status" | cut -f 2 -d ':' | tr -d ',' )
_iDelta=$( ph.perfdeltaspeed "couchdb-method-${myMethod}" $_iValue)
printf "%10s %10s %10s per sec\n" "$myMethod" $_iValue $_iDelta
ph.perfadd "${myMethod}" "$_iDelta" "" ""
done
# echo "${_status}" | jq
;;
# ............................................................ # ............................................................
*) *)
echo "ERRROR: [${sMode}] is an INVALID mode" echo "ERRROR: [${sMode}] is an INVALID mode"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment