HEX
Server: LiteSpeed
System: Linux s3604.bom1.stableserver.net 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User: dmstechonline (1480)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //proc/thread-self/root/lib64/nagios/plugins/check_a2_whmcs_th_network.sh
#!/bin/bash

# Define the URL you want to test and the expected word
url="https://mi3-thweb-1.a2hosting.com/ping"
expected_word="ok"

# Use the 'time' command to measure the response time
response_time=$( (time -p timeout 5 curl -s "$url" -o /dev/null) 2>&1 | awk '/real/ {print $2}' )

# Use 'curl' to fetch the content and search for the expected word
response=$(curl -s "$url")


if (( $(echo "${response_time} > 1" | bc -l) )); then
  echo "check_a2_whmcs_th_network - Unable to connect! Response time: ${response_time}"
  exit 2
fi

if [[ $response == *"${expected_word}"* ]]; then
  echo "check_a2_whmcs_th_network - Response time: ${response_time}"
  exit 0
else
  echo "check_a2_whmcs_th_network.sh - Unexpected output! Response time: ${response_time}"
  exit 2
fi