23 lines
596 B
Bash
Executable File
23 lines
596 B
Bash
Executable File
#!/bin/bash
|
|
|
|
PROCESS_NAME="test"
|
|
LOG_FILE="/var/log/monitoring.log"
|
|
MONITOR_URL="https://test.com/monitoring/test/api"
|
|
|
|
log() {
|
|
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
|
|
}
|
|
|
|
if pgrep "$PROCESS_NAME" > /dev/null; then
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" "$MONITOR_URL")
|
|
if [[ "$RESPONSE" -ne 200 ]]; then
|
|
log "Сервер мониторинга недоступен, код ответа: $RESPONSE"
|
|
fi
|
|
else
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$(pgrep -c "$PROCESS_NAME")" -gt 1 ]; then
|
|
log "Процесс '$PROCESS_NAME' был перезапущен"
|
|
fi
|