cek-ws.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- icanhazip.com);
  6. echo "Checking VPS"
  7. clear
  8. echo -n > /tmp/other.txt
  9. data=( `cat /etc/v2ray/config.json | grep '^###' | cut -d ' ' -f 2`);
  10. echo "-------------------------------";
  11. echo "-----=[ Vmess User Login ]=-----";
  12. echo "-------------------------------";
  13. for akun in "${data[@]}"
  14. do
  15. if [[ -z "$akun" ]]; then
  16. akun="tidakada"
  17. fi
  18. echo -n > /tmp/ipvmess.txt
  19. data2=( `netstat -anp | grep ESTABLISHED | grep tcp6 | grep v2ray | awk '{print $5}' | cut -d: -f1 | sort | uniq`);
  20. for ip in "${data2[@]}"
  21. do
  22. jum=$(cat /var/log/v2ray/access.log | grep -w $akun | awk '{print $3}' | cut -d: -f1 | grep -w $ip | sort | uniq)
  23. if [[ "$jum" = "$ip" ]]; then
  24. echo "$jum" >> /tmp/ipvmess.txt
  25. else
  26. echo "$ip" >> /tmp/other.txt
  27. fi
  28. jum2=$(cat /tmp/ipvmess.txt)
  29. sed -i "/$jum2/d" /tmp/other.txt > /dev/null 2>&1
  30. done
  31. jum=$(cat /tmp/ipvmess.txt)
  32. if [[ -z "$jum" ]]; then
  33. echo > /dev/null
  34. else
  35. jum2=$(cat /tmp/ipvmess.txt | nl)
  36. echo "user : $akun";
  37. echo "$jum2";
  38. echo "-------------------------------"
  39. fi
  40. rm -rf /tmp/ipvmess.txt
  41. done
  42. oth=$(cat /tmp/other.txt | sort | uniq | nl)
  43. echo "other";
  44. echo "$oth";
  45. echo "-------------------------------"
  46. rm -rf /tmp/other.txt