Page 1 of 1
HOWTO - use Monit to monitor VPN
Posted: Sun Jan 02, 2022 7:47 pm
by pm13
Hi,
I used OpenVPN at home on an OPNSense firewall & since this is a home LAN the use of VPN is minimal and and have limited users.
My request:
At the time of a VPN user logging in, is there a way to execute a custom shell script on OpenVPN server? If so where do I need to add the script - config file or its location?
The idea is that as soon a VPN user logs in, the script will execute on server and send me a text "User-X has logged-on/logged-off at xx:yy:zz".
Any pointers will be appreciated!
Re: Newbie question around custom shell script
Posted: Sun Jan 02, 2022 9:46 pm
by TinCanTech
Re: Newbie question around custom shell script
Posted: Sun Jan 02, 2022 10:24 pm
by pm13
Thanks for the pointers, I've become little bold experimenting stuff on OPNSense and just need to follow one rule i.e make a backup of configuration. The experiments mostly end badly but system restoration is a breeze once I am done messing around!
Re: Newbie question around custom shell script
Posted: Sun Jan 02, 2022 11:23 pm
by pm13
If I want to access an environment variable say "ifconfig_remote" from command line of the OS running OpenVPN Server then how do I get the output. I have tried "echo $ifconfig_remote", tried exporting it from a bash script using "--client-connected" option but each time I get "undefined_variable" as output.
Re: Newbie question around custom shell script
Posted: Sun Jan 02, 2022 11:53 pm
by TinCanTech
pm13 wrote: ↑Sun Jan 02, 2022 11:23 pm
If I want to access an environment variable say "ifconfig_remote" from command line of the OS running OpenVPN Server then how do I get the output. I have tried "echo $ifconfig_remote",
Imagine if you have 50 clients connected to your server, which
ifconfig_remote, for which client, do you require ?
pm13 wrote: ↑Sun Jan 02, 2022 11:23 pm
tried exporting it from a bash script using "--client-connected" option but each time I get "undefined_variable" as output
That is not how your server OS works. And teaching you how your OS works is way beyond the scope of this Forum.
The variables are
only available to a script which was started by openvpn.
Re: Newbie question around custom shell script [Solved]
Posted: Mon Jan 03, 2022 10:40 pm
by pm13
I finally got OpenVPN and Monit to work together & the solution actually worked out to be lot simpler than I originally thought -
https://forum.opnsense.org/index.php?topic=26221.0
@TinCanTech - thanks for your inputs!
Re: HOWTO - use Monit to monitor VPN
Posted: Mon Jan 03, 2022 11:46 pm
by TinCanTech
Edited for visibility.
No idea of the quality.
Imagine, if you had 5,000 clients and ..