Home Directory

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Directory

bill_mcgonigle

Reviews(1)
bybill_mcgonigle, April 30, 2012
just a quick note: put something like this in your config file to enable the management interface:

management 127.0.0.1 2194 /etc/openvpn/management-password

and pass the relevant options in for this probe. (put your password in that named file and get your permissions right!).

I'm using OpenVPN 2.2.2 on CentOS 5 in 2012 and I needed to make a few small changes for a point-to-point link (plus a few warning message tweaks). Unified diff follows. Thank you Jamie - using the management interface is the right way to do this (my previous grep hacks were silly).

-------------

--- check_openvpn.pl-dist 2012-04-30 18:21:13.000000000 -0400
+++ check_openvpn.pl 2012-04-30 18:45:07.000000000 -0400
@@ -4,6 +4,9 @@
#
# Copyright (c) 2007 Jaime Gascon Romero
#
+# Modified 2012-04-30 Bill McGonigle
+# to handle OpenVPN 2 point-to-point connection checking.
+#
# License Information:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,7 +31,7 @@
use Net::Telnet ();
use Getopt::Long qw(:config no_ignore_case);
use vars qw($PROGNAME $VERSION);
-use lib "/usr/nagios/libexec";
+use lib "/usr/lib/nagios/plugins";
use utils qw(%ERRORS);

$PROGNAME = "check_openvpn";
@@ -85,7 +88,7 @@
$t->print($opt_P);
}
$t->waitfor('/^$/');
-@lines = $t->cmd("status 2");
+@lines = $t->cmd("state");
$t->close;
};

@@ -97,7 +100,7 @@

if (defined $opt_i || defined $opt_r) {
foreach (@lines) {
- if ($_ =~ /CLIENT_LIST,.*,(\d+\.\d+\.\d+\.\d+):\d+,/) {
+ if ($_ =~ /\d+,CONNECTED,SUCCESS,\d+\.\d+\.\d+\.\d+,(\d+\.\d+\.\d+\.\d+)/) {
push @clients_ip, $1;
}
}
@@ -107,10 +110,10 @@
} elsif (defined $opt_r) {
if ( ! grep /\b$opt_r\b/, @clients_ip) {
if (defined $opt_c) {
- print "OpenVPN CRITICAL: $opt_r don't found";
+ print "OpenVPN CRITICAL: $opt_r not found";
exit $ERRORS{'CRITICAL'};
} else {
- print "OpenVPN WARNING: $opt_r don't found";
+ print "OpenVPN WARNING: $opt_r not found";
exit $ERRORS{'WARNING'};
}
}
@@ -128,10 +131,10 @@
if (defined $opt_C) {
if ( ! grep /\b$opt_C\b/, @clients) {
if (defined $opt_c) {
- print "OpenVPN CRITICAL: $opt_C don't found";
+ print "OpenVPN CRITICAL: $opt_C not found";
exit $ERRORS{'CRITICAL'};
} else {
- print "OpenVPN WARNING: $opt_C don't found";
+ print "OpenVPN WARNING: $opt_C not found";
exit $ERRORS{'WARNING'};
}
}