OpenVPN connected-disconnected users log
-
Hi everyone:
We have a roadwarrior openvpn service in our company. I need to report how long time the users are connected to the vpn. The hour of users connected and the hour the users disconnected. I have a rsyslog in other server, so I can read the openvpn log daily, and I cleaned the "trash info" with an excel macro and extract the info that I need, but how can I get a report of the connect-disconnect hours of the users in automatic mode like this?
User Connect Disconnect
ALONSO 08:00 10:45
ALONSO 12:33 18:42
MARIA 20:11 23:09Do you have any idea?
I hope you can help me.
Regards
-
Hallo, someone have solved your question? I've the same needed
-
done but with email ...
#!/usr/local/bin/php -q <?php require_once("/etc/inc/notices.inc"); $local_connect_value = " \n user_name: " . getenv('common_name') . " \n vpn_client_ip: " . getenv('ifconfig_pool_remote_ip') ." connected from " . getenv('trusted_ip') . " on " . date('F j, Y, g:i a'); if ( strrchr (__FILE__ , 'disconnect') ) { $local_connect_value .= ", \n duration : " . round(((getenv('time_duration'))/3600),2) . " hours, or " . round(((getenv('time_duration'))/60),2) . " minutes, or " . getenv('time_duration') . " seconds,\n upload from vpn-client (received) : " . round(((getenv('bytes_received'))/1048576),2) . " MB, \n download to vpn-client (send) : " . round(((getenv('bytes_sent'))/1048576),2) ." MB. \n DISCONNECTED."; } notify_all_remote($local_connect_value); ?>the script is called in openVPN server

output

see also here
https://forum.netgate.com/topic/151351/email-notification-openvpn-client-connect-common-name/26 -
let me know how do you twek the script
-
tks for reply! I will try and then I will post comment.
-
workin here like a charm ..
only problem i get mails for every client even for the trusted ones
so a tweak if ip (stored in txt file) is trusted do not send mail else send would be fine. -
OK, your script run very good!
thank you for all. -
@mfbart
do not forgett to upvote
-
@noplan said in OpenVPN connected-disconnected users log:
done but with email ...
#!/usr/local/bin/php -q <?php require_once("/etc/inc/notices.inc"); $local_connect_value = " \n user_name: " . getenv('common_name') . " \n vpn_client_ip: " . getenv('ifconfig_pool_remote_ip') ." connected from " . getenv('trusted_ip') . " on " . date('F j, Y, g:i a'); if ( strrchr (__FILE__ , 'disconnect') ) { $local_connect_value .= ", \n duration : " . round(((getenv('time_duration'))/3600),2) . " hours, or " . round(((getenv('time_duration'))/60),2) . " minutes, or " . getenv('time_duration') . " seconds,\n upload from vpn-client (received) : " . round(((getenv('bytes_received'))/1048576),2) . " MB, \n download to vpn-client (send) : " . round(((getenv('bytes_sent'))/1048576),2) ." MB. \n DISCONNECTED."; } notify_all_remote($local_connect_value); ?>the script is called in openVPN server

output

see also here
https://forum.netgate.com/topic/151351/email-notification-openvpn-client-connect-common-name/26very good works!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginPrivacy Policy · Cookie Policy