mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-24 05:40:16 +00:00
Better client stats formatting
This commit is contained in:
parent
580e1b128e
commit
4466f1503c
2 changed files with 10 additions and 7 deletions
|
@ -698,9 +698,9 @@ askWhichVPN(){
|
||||||
|
|
||||||
installOpenVPN(){
|
installOpenVPN(){
|
||||||
echo "::: Installing OpenVPN from Debian package... "
|
echo "::: Installing OpenVPN from Debian package... "
|
||||||
# grepcidr is used to redact IPs in the debug log, whereas expect is used
|
# grepcidr is used to redact IPs in the debug log, expect is used to feed easy-rsa
|
||||||
# to feed easy-rsa with passwords
|
# with passwords, bsdmainutils provides column to format the terminal output
|
||||||
PIVPN_DEPS=(openvpn grepcidr expect)
|
PIVPN_DEPS=(openvpn grepcidr expect bsdmainutils)
|
||||||
installDependentPackages PIVPN_DEPS[@]
|
installDependentPackages PIVPN_DEPS[@]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,16 @@ printf ": NOTE : The output below is NOT real-time!\n"
|
||||||
printf ": : It may be off by a few minutes.\n"
|
printf ": : It may be off by a few minutes.\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "\e[1m::: Client Status List :::\e[0m\n"
|
printf "\e[1m::: Client Status List :::\e[0m\n"
|
||||||
printf "\t\t\t\t\t\t\t\tBytes\t\tBytes\t\n"
|
|
||||||
printf "\e[4mName\e[0m\t\t\t\e[4mRemote IP\e[0m\t\t\e[4mVirtual IP\e[0m\t\e[4mReceived\e[0m\t\e[4mSent\e[0m\t\t\e[4mConnected Since\e[0m \n"
|
{
|
||||||
|
printf "\e[4mName\e[0m \t \e[4mRemote IP\e[0m \t \e[4mVirtual IP\e[0m \t \e[4mBytes Received\e[0m \t \e[4mBytes Sent\e[0m \t \e[4mConnected Since\e[0m\n"
|
||||||
|
|
||||||
if grep -q "^CLIENT_LIST" "${STATUS_LOG}"; then
|
if grep -q "^CLIENT_LIST" "${STATUS_LOG}"; then
|
||||||
if [ -n "$(type -t numfmt)" ]; then
|
if [ -n "$(type -t numfmt)" ]; then
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
read -r -a array <<< $line
|
read -r -a array <<< $line
|
||||||
[[ ${array[0]} = CLIENT_LIST ]] || continue
|
[[ ${array[0]} = CLIENT_LIST ]] || continue
|
||||||
printf "%s\t\t%s\t%s\t%s\t\t%s\t\t%s %s %s - %s\n" ${array[1]} ${array[2]} ${array[3]} $(hr ${array[4]}) $(hr ${array[5]}) ${array[7]} ${array[8]} ${array[10]} ${array[9]}
|
printf "%s \t %s \t %s \t %s \t %s \t %s %s %s - %s\n" ${array[1]} ${array[2]} ${array[3]} $(hr ${array[4]}) $(hr ${array[5]}) ${array[7]} ${array[8]} ${array[10]} ${array[9]}
|
||||||
done <$STATUS_LOG
|
done <$STATUS_LOG
|
||||||
else
|
else
|
||||||
awk -F' ' -v s='CLIENT_LIST' '$1 == s {print $2"\t\t"$3"\t"$4"\t"$5"\t\t"$6"\t\t"$8" "$9" "$11" - "$10"\n"}' ${STATUS_LOG}
|
awk -F' ' -v s='CLIENT_LIST' '$1 == s {print $2"\t\t"$3"\t"$4"\t"$5"\t\t"$6"\t\t"$8" "$9" "$11" - "$10"\n"}' ${STATUS_LOG}
|
||||||
|
@ -33,3 +35,4 @@ else
|
||||||
printf "\nNo Clients Connected!\n"
|
printf "\nNo Clients Connected!\n"
|
||||||
fi
|
fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
} | column -t -s $'\t'
|
Loading…
Reference in a new issue