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

ceph_io: add test

parent a288b19f
No related branches found
No related tags found
1 merge request!80ceph_io: add test
...@@ -16,14 +16,16 @@ ...@@ -16,14 +16,16 @@
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2023-05-09 v1.0 <axel.hahn@unibe.ch> # 2023-05-09 v1.0 <axel.hahn@unibe.ch>
# 2023-05-10 v1.1 <axel.hahn@unibe.ch> fix for small transfer rates in B/s # 2023-05-10 v1.1 <axel.hahn@unibe.ch> fix for small transfer rates in B/s
# 2023-05-10 v1.2 <axel.hahn@unibe.ch> add tests
# ====================================================================== # ======================================================================
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.1 self_APPVERSION=1.2
function showHelp(){ function showHelp(){
_self=$(basename $0)
cat <<EOF cat <<EOF
______________________________________________________________________ ______________________________________________________________________
...@@ -38,10 +40,22 @@ Show cheph IO as read and written bytes per second. ...@@ -38,10 +40,22 @@ Show cheph IO as read and written bytes per second.
This check sends performance data. This check sends performance data.
SYNTAX: SYNTAX:
$(basename $0) $_self
OPTIONS: OPTIONS:
-h or --help show this help. -h or --help show this help.
-t [STRING] test a value; for debugging purposes
Without a string internally stored values will be tested
EXAMPLE:
$_self
no parameters; normal usage to get the ceph io data
$_self -t
Run a few builtin tests
$_self -t " client: 255 B/s rd, 0 op/s rd, 0 op/s wr"
Test a given string
EOF EOF
} }
...@@ -55,12 +69,29 @@ case "$1" in ...@@ -55,12 +69,29 @@ case "$1" in
*) *)
esac esac
# --- check required tools if [ "$1" = "-t" ]; then
ph.require ceph # Snippets for testing:
# TEST: client: 13 KiB/s rd, 1.1 MiB/s wr, 130 op/s rd, 137 op/s wr
CEPHIO=$( sudo ceph status 2>/dev/null | grep "client:.* rd,.* wr," | cut -f 2 -d ":" ) # TEST: client: 8.9 KiB/s rd, 887 KiB/s wr, 138 op/s rd, 140 op/s wr
# CEPHIO="8.9 KiB/s rd, 887 KiB/s wr, 138 op/s rd, 140 op/s wr" # TEST: client: 255 B/s rd, 85 B/s wr, 0 op/s rd, 0 op/s
# CEPHIO="255 B/s rd, 85 B/s wr, 0 op/s rd, 0 op/s" # TEST: client: 255 B/s rd, 0 op/s rd, 0 op/s wr
if [ -z "$2" ]; then
echo; echo ">>>>>>>>>> TESTS"; echo
grep '# TEST: ' $0 | grep -v grep | cut -f 2- -d ':' | while read -r teststring
do
echo "--- test string [$teststring]"
$0 -t "$teststring"
echo; echo; echo
done
exit 0
else
CEPHIO="$2"
fi
else
# --- check required tools
ph.require ceph
CEPHIO=$( sudo ceph status 2>/dev/null | grep "client:")
fi
if [ -z "${CEPHIO}" ]; then if [ -z "${CEPHIO}" ]; then
...@@ -70,19 +101,22 @@ if [ -z "${CEPHIO}" ]; then ...@@ -70,19 +101,22 @@ if [ -z "${CEPHIO}" ]; then
echo "No ceph here or no sudo permissions on ceph command?" echo "No ceph here or no sudo permissions on ceph command?"
else else
CEPHDATA=$( echo "${CEPHIO}" | cut -f 2 -d ':' )
SEG_R=$( echo "${CEPHDATA}" | cut -f 1 -d "," | grep "rd" | awk '{ print $1 " " $2 }')
SEG_W=$( echo "${CEPHDATA}" | cut -f 2 -d "," | grep "wr" | awk '{ print $1 " " $2 }')
# remark: # remark:
# - the sed transforms "NN KiB/s" --> "NN KB" (cut "i") # - the sed transforms "NN KiB/s" --> "NN KB" (cut "i")
# - the tr is for small values "NN B/s" and removes "s" # - the tr is for small values "NN B/s" and removes "s"
IO_READ=$( echo ${CEPHIO} | cut -f 1,2 -d " " | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's' ) IO_READ=$( echo "${SEG_R}" | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's')
IO_WRITE=$( echo ${CEPHIO} | cut -f 4,5 -d " " | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's' ) IO_WRITE=$( echo "${SEG_W}" | sed -E "s#([0-9]*) (.).(.).*#\1\2\3#g" | tr -d 's')
ph.status "$CEPHIO"
# echo "read: $IO_READ" test -z "$IO_READ" && IO_READ="0"
# echo "write: $IO_WRITE" test -z "$IO_WRITE" && IO_WRITE="0"
ph.status "$( echo "${CEPHIO}" | cut -f 2 -d ":" )"
ph.perfadd "cephio-read" "$IO_READ" "" "" ph.perfadd "cephio-read" "$IO_READ" "" ""
ph.perfadd "cephio-write" "$IO_WRITE" "" "" ph.perfadd "cephio-write" "$IO_WRITE" "" ""
fi fi
ph.exit ph.exit
\ No newline at end of file
...@@ -11,12 +11,11 @@ It returns a single line for the status and performance data. ...@@ -11,12 +11,11 @@ It returns a single line for the status and performance data.
## Syntax ## Syntax
``` ```txt
$ check_ceph_io --help
______________________________________________________________________ ______________________________________________________________________
CHECK_CEPH_IO CHECK_CEPH_IO
v1.0 v1.2
(c) Institute for Medical Education - University of Bern (c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3 Licence: GNU GPL 3
...@@ -30,6 +29,19 @@ check_ceph_io ...@@ -30,6 +29,19 @@ check_ceph_io
OPTIONS: OPTIONS:
-h or --help show this help. -h or --help show this help.
-t [STRING] test a value; for debugging purposes
Without a string internally stored values will be tested
EXAMPLE:
check_ceph_io
no parameters; normal usage to get the ceph io data
check_ceph_io -t
Run a few builtin tests
check_ceph_io -t " client: 255 B/s rd, 0 op/s rd, 0 op/s wr"
Test a given string
``` ```
### Parameters ### Parameters
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment