Skip to content

Commit

Permalink
reorg directory layout
Browse files Browse the repository at this point in the history
  • Loading branch information
lausser committed Jul 10, 2015
1 parent 14847c1 commit a2a81bf
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 89 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ dist-hook:
if [ -f ../GLPlugin/lib/Monitoring/GLPlugin.pm ]; then cp -r ../GLPlugin/lib .; fi
rm -f t/var/tmp/*
rm -f t/var/adm/*
find $(distdir) -type f -exec $(DOS2UNIX) {} \;
find $(distdir) -type f -exec $(DOS2UNIX) {} >/dev/null 2>&1 \;
make

56 changes: 0 additions & 56 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -38,57 +38,6 @@ AC_SUBST(with_nagios_user)
AC_SUBST(with_nagios_group)
INSTALL_OPTS="-o $with_nagios_user -g $with_nagios_group"
AC_SUBST(INSTALL_OPTS)
AC_ARG_WITH(noinst_level,
ACX_HELP_STRING([--with-noinst-level=LEVEL],
[error level if nwc_health is not installed]),
with_noinst_level=$withval,
with_noinst_level=unknown)
AC_SUBST(NOINSTLEVEL, $with_noinst_level)
AC_ARG_WITH(degrees,
ACX_HELP_STRING([--with-degrees=UNIT],
[which temperature unit to use. (celsius or fahrenheit)]),
with_degrees=$withval,
with_degrees=unknown)
case "$with_degrees" in
fahrenheit)
AC_SUBST(CELSIUS, 0)
;;
*)
AC_SUBST(CELSIUS, 1)
;;
esac
AC_ARG_ENABLE([perfdata],
[ --enable-perfdata wether to output perfdata (default=no)], ,enable_perfdata=no)
if test x"$enable_perfdata" = xyes ; then
AC_SUBST(PERFDATA, 1)
else
AC_SUBST(PERFDATA, 0)
fi
AC_ARG_ENABLE([extendedinfo],
[ --enable-extendedinfo wether to output extended info (default=no)], ,enable_extendedinfo=no)
if test x"$enable_extendedinfo" = xyes ; then
AC_SUBST(EXTENDEDINFO, 1)
else
AC_SUBST(EXTENDEDINFO, 0)
fi
AC_ARG_ENABLE([hwinfo],
[ --disable-hwinfo wether to output model desc., serial no., bios version (default=yes)], ,enable_hwinfo=yes)

if test x"$enable_hwinfo" = xyes ; then
AC_SUBST(HWINFO, 1)
else
AC_SUBST(HWINFO, 0)
fi


case "$host_os" in
*hp*)
defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin:/usr/contrib/bin
;;
*)
defaulttrustedpath=/bin:/sbin:/usr/bin:/usr/sbin
;;
esac

EXTRAS=
dnl PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/etc:/usr/local/bin:/usr/local/sbin:$PATH
Expand Down Expand Up @@ -116,9 +65,4 @@ AC_OUTPUT(Makefile plugins-scripts/Makefile plugins-scripts/subst)
ACX_FEATURE([with],[perl])
ACX_FEATURE([with],[nagios-user])
ACX_FEATURE([with],[nagios-group])
ACX_FEATURE([with],[noinst-level])
ACX_FEATURE([with],[degrees])
ACX_FEATURE([enable],[perfdata])
ACX_FEATURE([enable],[extendedinfo])
ACX_FEATURE([enable],[hwinfo])
ACX_FEATURE([disable],[standalone], $disable_standalone)
File renamed without changes.
13 changes: 9 additions & 4 deletions lib/Monitoring/GLPlugin.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package Monitoring::GLPlugin;
# ABSTRACT: helper functions to build a upnp-based monitoring plugin

use strict;
use IO::File;
use File::Basename;
use Digest::MD5 qw(md5_hex);
use Errno;
#use AutoLoader;
our $AUTOLOAD;
our $VERSION = "1.0";

use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };

Expand Down Expand Up @@ -1011,9 +1013,12 @@ sub valdiff {
}
if ($mode eq "normal" || $mode eq "lookback" || $mode eq "lookback_freeze_chill") {
if ($self->{$_} =~ /^\d+$/) {
if ($self->opts->lookback) {
$last_values->{$_} = 0 if ! exists $last_values->{$_};
if ($self->{$_} >= $last_values->{$_}) {
$last_values->{$_} = 0 if ! exists $last_values->{$_};
if ($self->{$_} >= $last_values->{$_}) {
$self->{'delta_'.$_} = $self->{$_} - $last_values->{$_};
} else {
if ($mode =~ /lookback_freeze/) {
# hier koennen delta-werte auch negativ sein, wenn z.b. peers verschwinden
$self->{'delta_'.$_} = $self->{$_} - $last_values->{$_};
} else {
# vermutlich db restart und zaehler alle auf null
Expand Down
9 changes: 9 additions & 0 deletions lib/Monitoring/GLPlugin/SNMP.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package Monitoring::GLPlugin::SNMP;
our @ISA = qw(Monitoring::GLPlugin);
# ABSTRACT: helper functions to build a snmp-based monitoring plugin

use strict;
use File::Basename;
use Digest::MD5 qw(md5_hex);
use Data::Dumper;
use AutoLoader;
our $AUTOLOAD;
our $VERSION = "1.0";

use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };

Expand Down Expand Up @@ -146,6 +148,13 @@ sub add_snmp_args {
required => 0,
env => 'SNMPWALK',
);
$self->add_arg(
spec => 'servertype=s',
help => '--servertype
The type of the network device: cisco (default). Use it if auto-detection
is not possible',
required => 0,
);
$self->add_arg(
spec => 'oids=s',
help => '--oids
Expand Down
2 changes: 2 additions & 0 deletions lib/Monitoring/GLPlugin/UPNP.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package Monitoring::GLPlugin::UPNP;
our @ISA = qw(Monitoring::GLPlugin);
# ABSTRACT: helper functions to build a upnp-based monitoring plugin

use strict;
use File::Basename;
use Digest::MD5 qw(md5_hex);
use AutoLoader;
our $AUTOLOAD;
our $VERSION = "1.0";

use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };

Expand Down
36 changes: 18 additions & 18 deletions plugins-scripts/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
## Process this file with automake to produce Makefile.in

SED=/bin/sed
GREP=/bin/grep
CAT=/bin/cat
ECHO=/bin/echo
if DISABLE_STANDALONE
STANDALONE = no
else
STANDALONE = yes
endif

SUFFIXES = .pl .pm .sh

VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t

libexec_SCRIPTS=check_nwc_health
GL_MODULES=\
../lib/Monitoring/GLPlugin.pm \
Expand Down Expand Up @@ -206,7 +190,22 @@ EXTRA_MODULES=\
Classes/Lantronix/SLS.pm \
Classes/MibsAndOids.pm \
Classes/Device.pm
EXTRA_DIST=check_nwc_health.pl $(EXTRA_MODULES) $(GL_MODULES)

SED=/bin/sed
GREP=/bin/grep
CAT=/bin/cat
ECHO=/bin/echo
if DISABLE_STANDALONE
STANDALONE = no
else
STANDALONE = yes
endif

SUFFIXES = .pl .pm .sh

VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t

EXTRA_DIST=$(libexec_SCRIPTS).pl $(EXTRA_MODULES) $(GL_MODULES)

CLEANFILES=$(libexec_SCRIPTS)

Expand All @@ -225,6 +224,7 @@ AM_INSTALL_PROGRAM_FLAGS=@INSTALL_OPTS@
chmod +x $@

$(libexec_SCRIPTS) : $(EXTRA_DIST)
if [ -f ../../GLPlugin/lib/Monitoring/GLPlugin.pm ]; then cp -r ../../GLPlugin/lib ..; fi
$(ECHO) "#! #PERL# -w" | $(AWK) -f ./subst > $@
$(ECHO) "# nagios: -epn" >> $@
$(ECHO) >> $@
Expand All @@ -235,7 +235,7 @@ $(libexec_SCRIPTS) : $(EXTRA_DIST)
done \
fi
for m in ${EXTRA_MODULES}; do \
$(SED) -e 's/^1;//g' < $$m | $(SED) -e '/^__END__/,$$d' | $(AWK) -f ./subst | $(GREP) -v "use Nagios::Plugin" >> $@; \
$(SED) -e 's/^1;//g' < $$m | $(SED) -e '/^__END__/,$$d' | $(AWK) -f ./subst >> $@; \
done
$(ECHO) "package main;" >> $@
$(CAT) $(libexec_SCRIPTS).pl | $(AWK) -f ./subst >> $@
Expand Down
10 changes: 0 additions & 10 deletions plugins-scripts/check_nwc_health.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use strict;
no warnings qw(once);


eval {
if ( ! grep /AUTOLOAD/, keys %Monitoring::GLPlugin::) {
require "Monitoring::GLPlugin";
Expand Down Expand Up @@ -414,13 +413,6 @@
The role of this device in a hsrp group (active/standby/listen)",
required => 0,
);
$plugin->add_arg(
spec => 'servertype=s',
help => '--servertype
The type of the network device: cisco (default). Use it if auto-detection
is not possible',
required => 0,
);

$plugin->getopts();
$plugin->classify();
Expand All @@ -444,7 +436,5 @@
$plugin->check_messages(join => ', ', join_all => ', ');
$message .= sprintf "\n%s\n", $plugin->get_info("\n")
if $plugin->opts->verbose >= 1;
#printf "%s\n", Data::Dumper::Dumper($plugin);

$plugin->nagios_exit($code, $message);
printf "schluss\n";

0 comments on commit a2a81bf

Please sign in to comment.