2

I have an OpenVPN server where I want to log how much bandwidth is used by client connections. I only need to know the bandwidth used in total by a client connection, at the end of the connection. OpenVPN has this information in the Bytes Received and Bytes Sent fields in its status file.

What is a practical way to get the value of these fields at the end of a client connection?

I know about the --status parameter, that lets OpenVPN write out its status periodically, but that seems inconvenient: the status file would have to be updated often, and it would need to be parsed just as often.

I've tried using the --client-disconnect option with a script that sends the USR2 signal to the openvpn process to dump the status, but unfortunately whenever that triggers the just-disconnected client is no longer present in the status output. So that's not working either.

I know I can log the bandwith by using iptables, as answered in How to log OpenVPN bandwidth used?, but I'm trying to find a solution that uses that data within OpenVPN itself.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.