4
2
I'm trying to check and display the status (connected/not connected) and the server's hostname/cn of an OpenVPN connection that should connect at every boot.
Now I've found out that in /var/log/syslog
the connection is logged, which I could use to determine if Initialization Sequence Completed
was logged and get the hostname/cn, 19 lines above from [brimstone] Peer Connection Initiated with [AF_INET]1.2.3.4:1234
.
Taken this log, I may check for the Initialization Sequence Completed
, which would mean that I am connected and the hostname, which I just want for a different script.
Now my problem is that I currently don't know if the connection is still alive and/or if I'm connected to another server. I could periodically check the log for changes but that seems a little extreme for a rather basic task.
How may I check the connection status of my OpenVPN and if connected get the Servers hostname/cn?