diff --git a/docker/auth-bench/run-ab.sh b/docker/auth-bench/run-ab.sh deleted file mode 100644 index 7468363..0000000 --- a/docker/auth-bench/run-ab.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/bash - -function fetch_auth_cookie { - local cms_type=${CMS_TYPE} - local cookie_file="/tmp/cookie.txt" # Ensure this path matches across all functions - - case $cms_type in - "Concrete5") - local login_url="https://bishopairport.org/login/concrete/authenticate" - local login_data="uName=$USERNAME&uPassword=$PASSWORD" - - # Fetch and store the cookie for Concrete5, with verbose output for debugging - curl -c "$cookie_file" -d "$login_data" -X POST "$login_url" -v > /tmp/curl_response_concrete5.txt 2>&1 - - if [ ! -s "$cookie_file" ]; then - echo "Failed to fetch cookie for Concrete5. Check /tmp/curl_response_concrete5.txt for details." - exit 1 - fi - ;; - - "WordPress") - echo "WordPress authentication: To be developed" - ;; - - *) - echo "Unsupported CMS type: $cms_type" - exit 1 - ;; - esac -} - - - - -function prepare_log_file { - local log_file="/logs/authenticated.csv" - > "$log_file" - mkdir -p $(dirname "$log_file") - touch "$log_file" -} - -function run_apache_bench_and_check_ttfb { - local urls=(${URLS//,/ }) - local requests=$REQUESTS - local concurrency=$CONCURRENCY - local log_file="/logs/authenticated.csv" - local cookie_file="/tmp/cookie.txt" - - echo "URL,HTTP Code,Average TTFB (ms),AB Mean Time per Request (ms)" | tee "$log_file" - - for url in "${urls[@]}"; do - local total_ttfb=0 - local ttfb=0 - local http_code=$(curl -o /dev/null -s -w "%{http_code}" -b "$cookie_file" "$url") - - # Apache Bench with cookie - local ab_summary=$(ab -n "$requests" -c "$concurrency" -C "$(cat $cookie_file)" "$url" 2>&1 | grep "Time per request" | head -1) - local ab_mean_time_per_request=$(echo "$ab_summary" | awk '{print $4}' | awk '{printf "%.3f", $1}') - - # TTFB with cookie - for i in {1..5}; do - ttfb=$(curl -o /dev/null -s -w "%{time_starttransfer}\n" -b "$cookie_file" "$url") - total_ttfb=$(echo "$total_ttfb + $ttfb" | bc -l) - done - local mean_ttfb=$(echo "scale=3; ($total_ttfb / 5) * 1000" | bc) - - echo "$url,$http_code,${mean_ttfb},${ab_mean_time_per_request}" | tee -a "$log_file" - done -} - - -function upload_to_hastebin_and_notify { - local log_file="/logs/authenticated.csv" - local response=$(curl -X POST -s --data-binary @"${log_file}" https://haste.nixc.us/documents) - local key=$(echo $response | awk -F '"' '{print $4}') - - if [ ! -z "$key" ]; then - local haste_url="https://haste.nixc.us/$key" - echo "Logs uploaded to: $haste_url" - # Send notification with the Haste URL, including the authentication token - curl -X POST -H "Authorization: Bearer tk_2wyr6054606hy17emk6ivdjqt6m5k" -d "$haste_url" https://admin:tiZcgc8Waf9mg5A4n2aJ4Qk2RyYnwEHDT@ntfy.nixc.us/bnHobG80sO5ZF4SB - else - echo "Failed to upload logs to Hastebin." - fi -} - - -prepare_log_file -fetch_auth_cookie -run_apache_bench_and_check_ttfb -upload_to_hastebin_and_notify