Initial commit

This commit is contained in:
admin 2025-10-23 12:50:20 +07:00
commit 770833f110
4 changed files with 44 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# test_example
Effective Mobile

View File

@ -0,0 +1,10 @@
[Unit]
Description=Monitor Test Process
[Service]
Type=simple
ExecStart=/usr/local/bin/monitor_test.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=Run Monitor Test Process every minute
[Timer]
OnUnitActiveSec=1min
Unit=monitor_test.service
[Install]
WantedBy=timers.target

22
usr/local/bin/monitor_test.sh Executable file
View File

@ -0,0 +1,22 @@
#!/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