OpenVPN connections
Moderators: Developers, Moderators
OpenVPN connections
Hi all,
after searching for some hours I've come to ask here for your help. I'd need a template to monitor the number of open/active OpenVPN connections.
Is there a known way to do this with cacti? Has anyone already a solution for this issue?
I do not even know how to "count the open connections" on the commandline, so any kind of help or suggestions are welcome
Many thanks in advance
Daniel
PS: Best of all solutions would be a way to provide the stats through snmp, e.g. as we do this with exim-stats or pfoftp-stats.
after searching for some hours I've come to ask here for your help. I'd need a template to monitor the number of open/active OpenVPN connections.
Is there a known way to do this with cacti? Has anyone already a solution for this issue?
I do not even know how to "count the open connections" on the commandline, so any kind of help or suggestions are welcome
Many thanks in advance
Daniel
PS: Best of all solutions would be a way to provide the stats through snmp, e.g. as we do this with exim-stats or pfoftp-stats.
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
- streaker69
- Cacti Pro User
- Posts: 712
- Joined: Mon Mar 27, 2006 10:35 am
- Location: Psychic Amish Network Administrator
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Re: OpenVPN connections
That's the real problem. You may want to ask for this on an opneVPN forum/mailing list. If you have the command, if have the walkthrough (at the first link of my signature)dk10tlx wrote:I do not even know how to "count the open connections" on the commandline, so any kind of help or suggestions are welcome
Reinhard
The VPN connections are created on a Linux-box with openvpn-server installed. Therefor I use Debian GNU/Linux with the openvpn-2.0.9-8 package. The used IP ranges are 10.0.10.2 to 10.0.10.200 for the clients. The server itself uses 10.0.10.1 an 10.0.10.2 as the tunnel endpoint/router address.
It seems really to be the most important part to find out how to track the connection with openvpn. Maybe there's someone on the forums who has already had this situation and knows a solution?
At the moment I'm searching around (google etc) for a method to track the connections under linux. I'll post anything I'll find accordingly.
It seems really to be the most important part to find out how to track the connection with openvpn. Maybe there's someone on the forums who has already had this situation and knows a solution?
At the moment I'm searching around (google etc) for a method to track the connections under linux. I'll post anything I'll find accordingly.
regards
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Daniel
[size=67]
[b]cacti [color=red]0.8.6j[/color] - cactid [color=red]0.8.6i[/color]
Debian GNU/Linux lenny/sid[/b]
Apache2 - PHP5 - MySQL5[/size]
Better to use the management port.matias wrote:You can grep this from your openvpn status log.
<conf>
management localhost 7505
</>
# telnet localhost 7505
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
>INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info
status
OpenVPN CLIENT LIST
Updated,Thu Jan 10 10:59:34 2008
Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
client1,client.public.ip.here:1045,1287132,13668445,Thu Jan 10 08:23:06 2008
client1,client.public.ip.here:4739,905971,964649,Wed Jan 9 01:53:45 2008
-
- Posts: 1
- Joined: Wed Mar 12, 2008 9:51 am
Solution
Hi. I created this python script which telnets the OpenVpn management interface. Hope it will help you.
import getpass
import sys
import telnetlib
import string
import re
counter = 0
def getInfo():
HOST = "OpenVPN_SERVER_IP"
tn = telnetlib.Telnet(HOST , 7505)
tn.read_until("info")
tn.write("status" + "\n")
string = tn.read_until("END")
tn.write("exit" + "\n")
return string
# parse the output
regex = re.compile("[a-zA-Z0-9]*\,[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}").match
lines = string.split(getInfo(),"\n")
# regex matching for each line, set the total number of occurrences
for line in lines:
if regex(line):
counter += 1
print counter
import getpass
import sys
import telnetlib
import string
import re
counter = 0
def getInfo():
HOST = "OpenVPN_SERVER_IP"
tn = telnetlib.Telnet(HOST , 7505)
tn.read_until("info")
tn.write("status" + "\n")
string = tn.read_until("END")
tn.write("exit" + "\n")
return string
# parse the output
regex = re.compile("[a-zA-Z0-9]*\,[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}").match
lines = string.split(getInfo(),"\n")
# regex matching for each line, set the total number of occurrences
for line in lines:
if regex(line):
counter += 1
print counter
Re: OpenVPN connections
Here is the perl script
2 extremoburo: you have forgotten ^ in your regexp
Code: Select all
#!/usr/bin/perl
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,
Port=>7505,
Errmode=>'die');
$telnet->open('localhost');
$telnet->waitfor('/>INFO:OpenVPN Management Interface.*$/i');
$telnet->print('status');
($prematch) = $telnet->waitfor('/END$/');
@str = split /\n/, $prematch;
foreach $s (@str) {
$users++ if $s =~ m/^[a-zA-Z0-9_.-]*\,([0-9]{1,3}\.){3}[0-9]{1,3}:/;
}
print "$users";
Who is online
Users browsing this forum: No registered users and 20 guests