Verschiebe in Root
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
function check_sql_activity() {
|
||||
last_order_time=$(mysql -u $DB_USER -p$DB_PASSWORD -D $DB_NAME -sse \
|
||||
"SELECT MAX(create_time) FROM otrs_ticket WHERE create_user = 'LIDLWebservice';")
|
||||
|
||||
last_bsi_log_time=$(mysql -u $DB_USER -p$DB_PASSWORD -D $DB_NAME -sse \
|
||||
"SELECT MAX(log_time) FROM bsi_logs WHERE service = 'ITNovumBSIConnector';")
|
||||
|
||||
if [[ -z "$last_order_time" || -z "$last_bsi_log_time" ]]; then
|
||||
log_error "SQL query failed or returned no data."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
now=$(date +%s)
|
||||
last_order_epoch=$(date -d "$last_order_time" +%s)
|
||||
last_bsi_epoch=$(date -d "$last_bsi_log_time" +%s)
|
||||
|
||||
if (( (now - last_order_epoch) > 3600 && (now - last_bsi_epoch) > 7200 )); then
|
||||
log_critical "SQL activity check failed. No activity in expected timeframes."
|
||||
restart_service
|
||||
else
|
||||
log_info "SQL activity is within acceptable limits."
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user