37 lines
890 B
Bash
37 lines
890 B
Bash
#!/bin/bash
|
|
|
|
BASE_DIR="/opt/scripts/vpn-con-checker"
|
|
|
|
source "$BASE_DIR/config.conf"
|
|
source "$BASE_DIR/functions/logging.sh"
|
|
source "$BASE_DIR/functions/network_check.sh"
|
|
source "$BASE_DIR/functions/sql_check.sh"
|
|
source "$BASE_DIR/functions/restart_service.sh"
|
|
|
|
function is_within_business_hours() {
|
|
current_hour=$(date +%H)
|
|
current_hour=$((10#$current_hour))
|
|
if (( current_hour >= 7 && current_hour < 18 )); then
|
|
return 0 # True
|
|
else
|
|
return 1 # False
|
|
fi
|
|
}
|
|
|
|
function main() {
|
|
log_info "Starting VPN monitoring script."
|
|
|
|
if is_within_business_hours; then
|
|
log_info "Within business hours. Running network check."
|
|
check_network_traffic
|
|
else
|
|
log_info "Outside business hours. Running SQL activity check."
|
|
check_sql_activity
|
|
fi
|
|
|
|
log_info "VPN monitoring script completed successfully."
|
|
exit 0
|
|
}
|
|
|
|
main
|