forked from pool/monitoring-plugins-openvpn
osc copypac from project:server:monitoring package:nagios-plugins-openvpn revision:3
OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-openvpn?expand=0&rev=1
This commit is contained in:
commit
0301ebab55
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
## Default LFS
|
||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.osc
|
79
check_openvpn-add-perfdata.patch
Normal file
79
check_openvpn-add-perfdata.patch
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
--- check_openvpn.pl.org 2011-02-17 18:45:05.103601051 +0100
|
||||||
|
+++ check_openvpn.pl 2011-02-17 19:14:22.431762875 +0100
|
||||||
|
@@ -32,13 +32,13 @@
|
||||||
|
use utils qw(%ERRORS);
|
||||||
|
|
||||||
|
$PROGNAME = "check_openvpn";
|
||||||
|
-$VERSION = '$Revision: 1.0 $';
|
||||||
|
+$VERSION = '$Revision: 1.1 $';
|
||||||
|
|
||||||
|
$ENV{'PATH'}='';
|
||||||
|
$ENV{'BASH_ENV'}='';
|
||||||
|
$ENV{'ENV'}='';
|
||||||
|
|
||||||
|
-my ($opt_h, $opt_H, $opt_p, $opt_P, $opt_t, $opt_i, $opt_n, $opt_c, $opt_w, $opt_C, $opt_r);
|
||||||
|
+my ($opt_h, $opt_H, $opt_p, $opt_P, $opt_t, $opt_i, $opt_n, $opt_c, $opt_w, $opt_C, $opt_r, $opt_V);
|
||||||
|
|
||||||
|
sub print_help ();
|
||||||
|
sub print_usage ();
|
||||||
|
@@ -55,12 +55,16 @@
|
||||||
|
"w" => \$opt_w, "warning" => \$opt_w,
|
||||||
|
"C=s" => \$opt_C, "common_name=s" => \$opt_C,
|
||||||
|
"r=s" => \$opt_r, "remote_ip=s" => \$opt_r,
|
||||||
|
+ "V" => \$opt_V, "performance" => \$opt_V,
|
||||||
|
) or exit $ERRORS{'UNKNOWN'};
|
||||||
|
|
||||||
|
# default values
|
||||||
|
unless ( defined $opt_t ) {
|
||||||
|
$opt_t = 10;
|
||||||
|
}
|
||||||
|
+unless ( defined $opt_V){
|
||||||
|
+ $opt_V=0;
|
||||||
|
+}
|
||||||
|
|
||||||
|
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
|
||||||
|
|
||||||
|
@@ -102,7 +106,12 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defined $opt_i) {
|
||||||
|
+ @clients_ip=sort(@clients_ip);
|
||||||
|
print "OpenVPN OK: "."@clients_ip ";
|
||||||
|
+ if ( $opt_V ){
|
||||||
|
+ my $num=$#clients_ip+1;
|
||||||
|
+ print "| clients=".$num.";;;;";
|
||||||
|
+ }
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
} elsif (defined $opt_r) {
|
||||||
|
if ( ! grep /\b$opt_r\b/, @clients_ip) {
|
||||||
|
@@ -125,6 +134,8 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+@clients=sort(@clients);
|
||||||
|
+
|
||||||
|
if (defined $opt_C) {
|
||||||
|
if ( ! grep /\b$opt_C\b/, @clients) {
|
||||||
|
if (defined $opt_c) {
|
||||||
|
@@ -140,10 +151,12 @@
|
||||||
|
|
||||||
|
if (defined $opt_n) {
|
||||||
|
print "OpenVPN OK: ".@clients." connected clients.";
|
||||||
|
+print "| clients=".@clients.";;;;" if ($opt_V);
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
}
|
||||||
|
|
||||||
|
print "OpenVPN OK: "."@clients ";
|
||||||
|
+print "| clients=".@clients.";;;;" if ($opt_V);
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
@@ -186,6 +199,8 @@
|
||||||
|
-n | --numeric
|
||||||
|
Prints the number of clients connected to the openvpn server.
|
||||||
|
|
||||||
|
+-V | --performance
|
||||||
|
+ Prints the number of clients connected to the openvpn server as performance data.
|
||||||
|
|
||||||
|
Matching Parameters
|
||||||
|
===================
|
215
check_openvpn.pl
Normal file
215
check_openvpn.pl
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007 Jaime Gascon Romero <jgascon@gmail.com>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# the Free Software Foundation; either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# $Id: check_openvpn.pl,v 1.0 2007/07/15 16:07:20 jgr Exp jgr $
|
||||||
|
# $Revision: 1.0 $
|
||||||
|
# Home Site: http://emergeworld.blogspot.com/
|
||||||
|
# #####################################################################
|
||||||
|
|
||||||
|
use diagnostics;
|
||||||
|
use strict;
|
||||||
|
use Net::Telnet ();
|
||||||
|
use Getopt::Long qw(:config no_ignore_case);
|
||||||
|
use vars qw($PROGNAME $VERSION);
|
||||||
|
use lib "/usr/nagios/libexec";
|
||||||
|
use utils qw(%ERRORS);
|
||||||
|
|
||||||
|
$PROGNAME = "check_openvpn";
|
||||||
|
$VERSION = '$Revision: 1.0 $';
|
||||||
|
|
||||||
|
$ENV{'PATH'}='';
|
||||||
|
$ENV{'BASH_ENV'}='';
|
||||||
|
$ENV{'ENV'}='';
|
||||||
|
|
||||||
|
my ($opt_h, $opt_H, $opt_p, $opt_P, $opt_t, $opt_i, $opt_n, $opt_c, $opt_w, $opt_C, $opt_r);
|
||||||
|
|
||||||
|
sub print_help ();
|
||||||
|
sub print_usage ();
|
||||||
|
|
||||||
|
GetOptions
|
||||||
|
("h" => \$opt_h, "help" => \$opt_h,
|
||||||
|
"H=s" => \$opt_H, "host=s" => \$opt_H,
|
||||||
|
"p=i" => \$opt_p, "port=i" => \$opt_p,
|
||||||
|
"P=s" => \$opt_P, "password=s" => \$opt_P,
|
||||||
|
"t=i" => \$opt_t, "timeout=i" => \$opt_t,
|
||||||
|
"i" => \$opt_i, "ip" => \$opt_i,
|
||||||
|
"n" => \$opt_n, "numeric" => \$opt_n,
|
||||||
|
"c" => \$opt_c, "critical" => \$opt_c,
|
||||||
|
"w" => \$opt_w, "warning" => \$opt_w,
|
||||||
|
"C=s" => \$opt_C, "common_name=s" => \$opt_C,
|
||||||
|
"r=s" => \$opt_r, "remote_ip=s" => \$opt_r,
|
||||||
|
) or exit $ERRORS{'UNKNOWN'};
|
||||||
|
|
||||||
|
# default values
|
||||||
|
unless ( defined $opt_t ) {
|
||||||
|
$opt_t = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
|
||||||
|
|
||||||
|
if ( ! defined($opt_H) || ! defined($opt_p) ) {
|
||||||
|
print_usage();
|
||||||
|
exit $ERRORS{'UNKNOWN'}
|
||||||
|
}
|
||||||
|
|
||||||
|
my @lines;
|
||||||
|
my @clients;
|
||||||
|
my @clients_ip;
|
||||||
|
my $t;
|
||||||
|
|
||||||
|
eval {
|
||||||
|
$t = new Net::Telnet (Timeout => $opt_t,
|
||||||
|
Port => $opt_p,
|
||||||
|
Prompt => '/END$/'
|
||||||
|
);
|
||||||
|
$t->open($opt_H);
|
||||||
|
if ( defined $opt_P ) {
|
||||||
|
$t->waitfor('/ENTER PASSWORD:$/');
|
||||||
|
$t->print($opt_P);
|
||||||
|
}
|
||||||
|
$t->waitfor('/^$/');
|
||||||
|
@lines = $t->cmd("status 2");
|
||||||
|
$t->close;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($@) {
|
||||||
|
print "OpenVPN Critical: Can't connect to server\n";
|
||||||
|
exit $ERRORS{'CRITICAL'};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (defined $opt_i || defined $opt_r) {
|
||||||
|
foreach (@lines) {
|
||||||
|
if ($_ =~ /CLIENT_LIST,.*,(\d+\.\d+\.\d+\.\d+):\d+,/) {
|
||||||
|
push @clients_ip, $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defined $opt_i) {
|
||||||
|
print "OpenVPN OK: "."@clients_ip ";
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
} elsif (defined $opt_r) {
|
||||||
|
if ( ! grep /\b$opt_r\b/, @clients_ip) {
|
||||||
|
if (defined $opt_c) {
|
||||||
|
print "OpenVPN CRITICAL: $opt_r don't found";
|
||||||
|
exit $ERRORS{'CRITICAL'};
|
||||||
|
} else {
|
||||||
|
print "OpenVPN WARNING: $opt_r don't found";
|
||||||
|
exit $ERRORS{'WARNING'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "OpenVPN OK: "."@clients_ip ";
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (@lines) {
|
||||||
|
if ($_ =~ /CLIENT_LIST,(.*),\d+\.\d+\.\d+\.\d+:\d+,/) {
|
||||||
|
push @clients, $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined $opt_C) {
|
||||||
|
if ( ! grep /\b$opt_C\b/, @clients) {
|
||||||
|
if (defined $opt_c) {
|
||||||
|
print "OpenVPN CRITICAL: $opt_C don't found";
|
||||||
|
exit $ERRORS{'CRITICAL'};
|
||||||
|
} else {
|
||||||
|
print "OpenVPN WARNING: $opt_C don't found";
|
||||||
|
exit $ERRORS{'WARNING'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (defined $opt_n) {
|
||||||
|
print "OpenVPN OK: ".@clients." connected clients.";
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
}
|
||||||
|
|
||||||
|
print "OpenVPN OK: "."@clients ";
|
||||||
|
exit $ERRORS{'OK'};
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
###### Subroutines ####################################################
|
||||||
|
|
||||||
|
sub print_usage() {
|
||||||
|
print "Usage: $PROGNAME -H | --host <IP or hostname> -p | --port <port number> [-P | --password] <password> [-t | --timeout] <timeout in seconds>
|
||||||
|
[-i | --ip] [-n | --numeric] [-C | --common_name] <common_name> [-r | --remote_ip] <remote_ip> [-c | --critical] [-w | --warning]\n\n";
|
||||||
|
print " $PROGNAME [-h | --help]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub print_help() {
|
||||||
|
print "$PROGNAME $VERSION\n\n";
|
||||||
|
print "Copyright (c) 2007 Jaime Gascon Romero
|
||||||
|
|
||||||
|
Nagios plugin to check the clients connected to a openvpn server.
|
||||||
|
|
||||||
|
";
|
||||||
|
print_usage();
|
||||||
|
print "
|
||||||
|
-H | --host
|
||||||
|
IP address or hostname of the openvpn server.
|
||||||
|
|
||||||
|
-p | --port
|
||||||
|
Management port interface of the openvpn server.
|
||||||
|
|
||||||
|
-P | --password
|
||||||
|
Password for the management interface of the openvpn server.
|
||||||
|
|
||||||
|
-t | --timeout
|
||||||
|
Timeout for the connection attempt. Optional, default 10 seconds.
|
||||||
|
|
||||||
|
|
||||||
|
Optional parameters
|
||||||
|
===================
|
||||||
|
|
||||||
|
-i | --ip
|
||||||
|
Prints the IP address of the remote client instead of the common name.
|
||||||
|
|
||||||
|
-n | --numeric
|
||||||
|
Prints the number of clients connected to the openvpn server.
|
||||||
|
|
||||||
|
|
||||||
|
Matching Parameters
|
||||||
|
===================
|
||||||
|
|
||||||
|
-C | --common_name
|
||||||
|
The common name, as it is specified in the client certificate, who is wanted to check.
|
||||||
|
|
||||||
|
-r | --remote_ip
|
||||||
|
The client remote ip address who is wanted to check.
|
||||||
|
|
||||||
|
-c | --critical
|
||||||
|
Exits with CRITICAL status if the client specified by the common name or the remote ip address is not connected.
|
||||||
|
|
||||||
|
-w | --warning
|
||||||
|
Exits with WARNING status if the client specified by the common name or the remote ip address is not connected.
|
||||||
|
|
||||||
|
|
||||||
|
Other Parameters
|
||||||
|
================
|
||||||
|
|
||||||
|
-h | --help
|
||||||
|
Show this help.
|
||||||
|
";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim:sts=2:sw=2:ts=2:et
|
16
nagios-plugins-openvpn.changes
Normal file
16
nagios-plugins-openvpn.changes
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun May 6 01:17:42 UTC 2012 - lars@linux-schulserver.de
|
||||||
|
|
||||||
|
- use nagios-rpm-macros
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 17 18:17:55 UTC 2011 - lars@linux-schulserver.de
|
||||||
|
|
||||||
|
- add option to print out performance data and increase Version to
|
||||||
|
1.1 ( check_openvpn-add-perfdata.patch )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 17 17:37:25 UTC 2011 - lars@linux-schulserver.de
|
||||||
|
|
||||||
|
- initial version 1.0-
|
||||||
|
|
61
nagios-plugins-openvpn.spec
Normal file
61
nagios-plugins-openvpn.spec
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#
|
||||||
|
# All modifications and additions to the file contributed by third parties
|
||||||
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
# upon. The license for this file, and modifications and additions to the
|
||||||
|
# file, is the same license as for the pristine package itself (unless the
|
||||||
|
# license for the pristine package is not an Open Source License, in which
|
||||||
|
# case the license is the MIT License). An "Open Source License" is a
|
||||||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
|
Name: nagios-plugins-openvpn
|
||||||
|
Summary: Verify the state of the clients connected to a openvpn server
|
||||||
|
Version: 1.1
|
||||||
|
Release: 1
|
||||||
|
Url: https://www.monitoringexchange.org/inventory/Check-Plugins/Software/Misc/check_openvpn_pl
|
||||||
|
License: GPL-3.0
|
||||||
|
Group: System/Monitoring
|
||||||
|
Source0: check_openvpn.pl
|
||||||
|
Patch1: check_openvpn-add-perfdata.patch
|
||||||
|
BuildRequires: nagios-rpm-macros
|
||||||
|
Requires: perl(Net::Telnet)
|
||||||
|
Requires: perl
|
||||||
|
BuildArch: noarch
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
|
%description
|
||||||
|
The -H [IP or hostname of the openvpn server] and -p options [port of the
|
||||||
|
openvpn server] are always obligatory. If plugin can be connected with the
|
||||||
|
management interface it will show the common name (as it is specified in the
|
||||||
|
client certificate) of the connected clients. Otherwise, it will finish with
|
||||||
|
critical state. The -i option shows the remote IP address of the client instead
|
||||||
|
of their common name and the -n option shows the number of connected clients.
|
||||||
|
It is possible to be verified that a client in particular is connected using
|
||||||
|
one of these two options -C [common name] or -r [remote IP address]. If these
|
||||||
|
options are used, also the exit state is due to specify that will give back
|
||||||
|
plugin if it does not find the client through the -w [warning] -c [critical]
|
||||||
|
options.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q -T -c %name
|
||||||
|
install -m644 %{SOURCE0} .
|
||||||
|
%patch1 -p0
|
||||||
|
|
||||||
|
%build
|
||||||
|
|
||||||
|
%install
|
||||||
|
mkdir -p %buildroot/%{nagios_plugindir}
|
||||||
|
sed "s|/usr/nagios/libexec|%{nagios_plugindir}|g" check_openvpn.pl > %buildroot/%{nagios_plugindir}/check_openvpn
|
||||||
|
chmod +x %buildroot/%{nagios_plugindir}/check_openvpn
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf %buildroot
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root)
|
||||||
|
# avoid build dependecy of nagios - own the dirs
|
||||||
|
%dir %{nagios_libdir}
|
||||||
|
%dir %{nagios_plugindir}
|
||||||
|
%{nagios_plugindir}/check_openvpn
|
||||||
|
|
||||||
|
%changelog
|
Loading…
Reference in New Issue
Block a user