nigig-org/nimanyatta/mon.sh
andodeki fd8b0632ca
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
Include nimanyatta as normal tree (not embedded git)
2026-09-26 09:29:36 +03:00

26 lines
No EOL
852 B
Bash
Executable file

#!/bin/bash
SERVER_PID=$(pgrep broadcast_server)
LOGFILE="server_monitor_$(date +%Y%m%d_%H%M%S).txt"
echo "Logging to: $LOGFILE"
echo "Press Ctrl+C to stop"
while true; do
{
echo "=== $(date) ==="
echo "--- Network ---"
echo "ESTABLISHED: $(netstat -an | grep 8080 | grep -c ESTABLISHED)"
echo "TIME_WAIT: $(netstat -an | grep 8080 | grep -c TIME_WAIT)"
echo "CLOSE_WAIT: $(netstat -an | grep 8080 | grep -c CLOSE_WAIT)"
echo "SYN_RCVD: $(netstat -an | grep 8080 | grep -c SYN_RCVD)"
echo "--- Process (PID: $SERVER_PID) ---"
FD_COUNT=$(lsof -p $SERVER_PID 2>/dev/null | wc -l)
echo "Open fds: $FD_COUNT / 65536"
echo "--- System ---"
echo "Ports in use: $(netstat -an | grep -c tcp)"
echo ""
} | tee -a "$LOGFILE"
sleep 1
done