OpenVPN Traffic Counter

From NAT, 6 Years ago, written in Plain Text, viewed 591 times.
URL https://code.nat.moe/view/b2d8ee41 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. ## Mandatory variables
  4. sessionStart="UNSET"
  5. clientHostAddress="UNSET"
  6. clientUID="UNSET"
  7. sessionDuration="UNSET"
  8. txVolume="UNSET"
  9. rxVolume="UNSET"
  10.  
  11. ## Parse variables
  12.  
  13. if [ ! -z "$time_ascii" ]; then
  14.         sessionStart=$time_ascii
  15. fi
  16.  
  17. if [ ! -z "$trusted_ip" ]; then
  18.         clientHostAddress=$trusted_ip
  19. fi
  20.  
  21. if [ ! -z "$username" ]; then
  22.         clientUID=$username
  23. fi
  24.  
  25. if [ ! -z "$time_duration" ]; then
  26.         sessionDuration=$time_duration
  27. fi
  28.  
  29. if [ ! -z "$bytes_sent" ]; then
  30.         txVolume=$bytes_sent
  31. fi
  32.  
  33. if [ ! -z "$bytes_received" ]; then
  34.         rxVolume=$bytes_received
  35. fi
  36.  
  37. echo "$common_name ($clientHostAddress) Disconnect: Last for $sessionDuration seconds, TX: $txVolume bytes RX: $rxVolume bytes" >> /etc/openvpn/usage.log

Reply to "OpenVPN Traffic Counter"

Here you can reply to the paste above

captcha