Good day. There is a file /var/run/openvpn-status.log into which notifications about the connection fall, updated once a minute:

example: 192.168. . , user,. . . : *, Thu Nov 24 13:00:18 2016

help, please, write a script engine that would parse this file all the time and (for example, as in the user example) send a notification message (var / mail / user2) to mail users a few pieces.

my poor non-working example: tail -f /var/run/openvpn-status.log | grep user | echo "$ user connected" | mail -s "$ user connected" user2

1 answer 1

Maybe I don’t understand something, but why parse some kind of log when you can read the manual directly on the developer’s site?

From https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage

--client-connect cmd Run command cmd on client connection. cmd consists of a path to script (or executable program), optionally followed by arguments. It can be single or double escaped using a backslash and it can be separated by one or more spaces.

The IP address has been assigned to the public address of the environmental variables (see environmental variable section below). It has been established that it can be used to make it.

If you want to use the script

It can be legally used in a dynamically generated config file.

Note that the value of the script is significant. If the script returns a non-zero error status, it will cause it to be disconnected.

--client-disconnect cmd Like --client-connect but called on client instance shutdown. If you’ve signed it, it’sn’t been a script or plugins (if defined) for status returns. If you’re online, you’ll be able to connect, you’ll be able to do this. This is a list of client-connect functions.

The --client-disconnect command is the same path as the corresponding --client-connect command as its last argument. (after any arguments specified in cmd).

  • client configs can not edit, only on the server side - Alexander Alexandrovich
  • Well, it's in the server config - Sergey