Commit b1bee835 authored by Tristan Cavelier's avatar Tristan Cavelier

stack/erp5: fix slowquery digest monitor promise

instance-mariadb.cfg.in:
  rename slowquerydex folder to slowquery_digest
mysql-querydigest.sh.in:
  exit 1 on error
  add date to the output file name of pt-query-digest to fit promise behavior
    https://lab.nexedi.com/nexedi/slapos.toolbox/blob/beb86eab2dee7178aa6e4795da0f56bb6cacaea1/slapos/promise/check_slow_queries_digest_result/__init__.py#L29
  review sh arguments handling
  end message: "ok" -> "Report generated successfully." or ..."failed with code $?"
parent ddccc802
......@@ -252,7 +252,7 @@ mariadb-ssl = ${:etc}/mariadb-ssl
var = ${buildout:directory}/var
log = ${:var}/log
run = ${:var}/run
slowquery = ${monitor-directory:private}/slowquerydex
slowquery = ${monitor-directory:private}/slowquery_digest
[{{ section('resiliency-exclude-file') }}]
# Generate rdiff exclude file in case of resiliency
......
......@@ -7,19 +7,20 @@ PT_QUERY_EXEC='{{pt_query_exec}}'
if [ ! -d "$OUTPUT_FOLDER" ]; then
echo "ERROR: output_folder don't exists"
exit 0
exit 1
fi
OUTPUT_FILE=${OUTPUT_FOLDER}/slowquery_digest.txt
TODAY=`date +%Y%m%d`
dashed_today=$(date +%Y-%m-%d)
today=$(date -d "$dashed_today" +%Y%m%d)
SLOW_LOG=$SLOW_QUERY_PATH-$TODAY
SLOW_LOG="$SLOW_QUERY_PATH-$today"
OUTPUT_FILE="$OUTPUT_FOLDER/slowquery_digest.txt-$dashed_today"
if [ ! -f "$SLOW_LOG" ]; then
echo "ERROR: cannot read mysql slow query log file $SLOW_LOG. Exiting."
exit 1
fi
$PT_QUERY_EXEC $SLOW_LOG > $OUTPUT_FILE
echo "ok"
"$PT_QUERY_EXEC" "$SLOW_LOG" > "$OUTPUT_FILE" && \
echo "Report generated successfully." || \
echo "Report failed with code $?"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment