Skip to content

Commit

Permalink
Fixed error when no history logs are found
Browse files Browse the repository at this point in the history
  • Loading branch information
catttam committed Sep 13, 2024
1 parent 339c92e commit ca13781
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion create_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="mt-48 page-full-wrap relative ">
<input type="hidden" value="creator-page" id="page-type">
<img class="display-image m-auto" data-src="{assets_base_url}/images/logo.png" src="{assets_base_url}/images/logo.png" alt="OSCAR metrics"/>
<h2 class="page-title page-text-color page-text-font mt-24 text-center text-fs-18">OSCAR-ai4eosc metrics index</h2>
<h2 class="page-title page-text-color page-text-font mt-24 text-center text-fs-18">OSCAR-{cluster_id}" metrics index</h2>
<div class="mt-24">
"""
Expand Down
20 changes: 10 additions & 10 deletions extract_goaccess_metrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CLUSTER_LOGS_DIR="/var/log/clusterlogs"
LOCAL_LOGS_DIR="/var/log/ingresslogs"
OSCAR_LOGS_DIR="$LOCAL_LOGS_DIR/oscar"

FULL_LOGS="$OSCAR_LOGS_DIR/oscar.log"
HISTORY_LOGS="$OSCAR_LOGS_DIR/oscar.log"
LATEST_LOGS="$OSCAR_LOGS_DIR/latest_oscar.log"
mkdir -p $OSCAR_LOGS_DIR

Expand All @@ -16,7 +16,7 @@ LOG_FORMAT='%^ %^ %^ %h - - [%d:%t] %~ %m %U %^ %s %^ %R %^ %^'

addLog(){
ingress_logfile=$1
cat $ingress_logfile | grep -a 'oscar-oscar' | grep -a '/job\|/run' | tee -a $FULL_LOGS >/dev/null
cat $ingress_logfile | grep -a 'oscar-oscar' | grep -a '/job\|/run' | tee -a $HISTORY_LOGS >/dev/null
}

metrics(){
Expand Down Expand Up @@ -75,6 +75,7 @@ for logfile in "$LOCAL_LOGS_DIR/$log/controller/"*;
do
if [[ $logfile == *".log"* ]]; then
if [[ $logfile == *".log" ]]; then
aws s3 cp $logfile s3://metrics.oscar.grycap.net/"${CLUSTER_ID}"/ingresslogs/
cat $logfile | grep -a 'oscar-oscar' | grep -a '/job\|/run' | tee -a $LATEST_LOGS >/dev/null
metrics $LATEST_LOGS
else
Expand All @@ -84,12 +85,11 @@ do
done

# Generate the html file
if [ ! -f "${FULL_LOGS}" ] || [ ! -s "${FULL_LOGS}" ]; then
echo "Error: Failed to create html report."
exit 1
fi

metrics $FULL_LOGS
if [ ! -f "${HISTORY_LOGS}" ] || [ ! -s "${HISTORY_LOGS}" ]; then
goaccess "${LATEST_LOGS}" --log-format="${LOG_FORMAT}" -o "/app/metrics/dashboard.html"
else
metrics $HISTORY_LOGS

cat $LATEST_LOGS | tee -a $FULL_LOGS >/dev/null
goaccess "${FULL_LOGS}" --log-format="${LOG_FORMAT}" -o "/app/metrics/dashboard.html"
cat $LATEST_LOGS | tee -a $HISTORY_LOGS >/dev/null
goaccess "${HISTORY_LOGS}" --log-format="${LOG_FORMAT}" -o "/app/metrics/dashboard.html"
fi

0 comments on commit ca13781

Please sign in to comment.