Skip to content
Open
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
sysmonitor:
build:
context: .
image: linux-sysmonitor:v2
volumes:
- sysmonitor_logs:/app/logs
environment:
- LOG_LEVEL=INFO
- CHECK_INTERVAL=60
- TARGET_HOST=webserver
depends_on:
- webserver
# restart: unless-stopped
# Enable this after health-check.sh is converted to a long-running monitoring service.
webserver:
image: nginx:alpine

volumes:
sysmonitor_logs:
6 changes: 3 additions & 3 deletions linux-sysmonitor/health-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set -uo pipefail
LOGFILE="logs/$(date +"%Y-%m-%d-%H-%M").log"

TARGET_HOST="${TARGET_HOST:-8.8.8.8}"

if [ -d logs ]; then
:
Expand Down Expand Up @@ -91,7 +91,7 @@ check_top_processes() {
check_top_processes

check_network () {
NETWORK_CHECK=$(ping -c 4 8.8.8.8)
NETWORK_CHECK=$(ping -c 4 "$TARGET_HOST")
PING_STATUS=$?
PING_LATENCY=$(echo "$NETWORK_CHECK"| grep "rtt" | awk '{print $4}' | awk -F'/' '{print $2}')
if [ $PING_STATUS -eq 0 ] ; then
Expand All @@ -100,7 +100,7 @@ check_network () {
write_log "CRITICAL" "No network connectivity"
fi
}
#check_network
check_network

check_ports (){
PORTS=$(ss -tlnp | awk '{print $4}'| awk -F':' '{print $2}' | paste -sd ' ' -)
Expand Down