-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnetmon_v2.sh
More file actions
64 lines (55 loc) · 1.65 KB
/
netmon_v2.sh
File metadata and controls
64 lines (55 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
echo "============================================================="
echo " NetMon: Simple Linux Network Monitoring Script"
echo "============================================================="
echo ""
# 1. Internet Connection Check
echo "[+] Checking Internet Connection..."
ping -c 2 8.8.8.8 > /dev/null 2>&1 && echo "✅ Internet is Working" || echo "❌ Internet NOT Working"
echo ""
# 2. IP, Gateway, DNS Details
echo "[+] Network Configuration:"
ip addr show | grep "inet " | grep -v "127.0.0.1"
echo ""
echo "Default Gateway: $(ip route | grep default | awk '{print $3}')"
echo "DNS Servers: "
cat /etc/resolv.conf | grep "nameserver"
echo ""
# 3. Active Connections
echo "[+] Active Network Connections (Top 5):"
ss -tunap | head -n 10
echo ""
# 4. Speed Test (Optional)
if command -v speedtest-cli &> /dev/null
then
echo "[+] Running Speed Test (May take few seconds)..."
speedtest-cli --simple
else
echo "[!] Speedtest-cli NOT installed. Run: sudo apt install speedtest-cli"
fi
echo ""
# 5. Packet Loss Summary (Ping Google)
echo "[+] Ping Packet Loss Summary:"
ping -c 10 8.8.8.8 | tail -2
echo ""
# 6. Live Bandwidth Usage (10 seconds)
echo "[+] Bandwidth Usage (10 sec sample):"
if command -v ifstat &> /dev/null
then
ifstat 1 10
else
echo "[!] ifstat NOT installed. Run: sudo apt install ifstat"
fi
echo ""
# 7. Top 5 Network Using Processes
echo "[+] Top 5 Network Using Processes:"
netstat -plant | grep ESTABLISHED | head -5
echo ""
# 8. Save Report
echo "[+] Saving Report to netmon_report.txt"
{
date
echo "Internet Check Done"
ip addr show | grep "inet " | grep -v "127.0.0.1"
} >> netmon_report.txt
echo "Done ✅"