Imported Upstream version 1.4.5

This commit is contained in:
Jan Wagner 2013-11-26 23:53:19 +01:00
parent 62d1e7d5fe
commit 6a280f6f24
412 changed files with 168642 additions and 0 deletions

View file

@ -0,0 +1,33 @@
## Process this file with automake to produce Makefile.in
SUFFIXES = .pl .sh
VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t
libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
check_log check_oracle check_rpc check_sensors check_wave \
check_ifstatus check_ifoperstatus check_mailq check_file_age \
utils.sh utils.pm
EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
utils.sh.in utils.pm.in t
TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir)
TESTS = @SCRIPT_TEST@
test:
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test
CLEANFILES=$(libexec_SCRIPTS)
.pl :
$(AWK) -f ./subst $< > $@
chmod +x $@
.sh :
$(AWK) -f ./subst $< > $@
chmod +x $@

542
plugins-scripts/Makefile.in Normal file
View file

@ -0,0 +1,542 @@
# Makefile.in generated by automake 1.9.4 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = plugins-scripts
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/subst.in $(srcdir)/utils.pm.in $(srcdir)/utils.sh.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/afs.m4 \
$(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/basename.m4 \
$(top_srcdir)/m4/c-strtod.m4 $(top_srcdir)/m4/codeset.m4 \
$(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/exitfail.m4 \
$(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
$(top_srcdir)/m4/fstypename.m4 $(top_srcdir)/m4/fsusage.m4 \
$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/inttypes_h.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/ls-mntd-fs.m4 \
$(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/np_coreutils.m4 $(top_srcdir)/m4/np_curl.m4 \
$(top_srcdir)/m4/onceonly_2_57.m4 $(top_srcdir)/m4/po.m4 \
$(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/regex.m4 \
$(top_srcdir)/m4/restrict.m4 $(top_srcdir)/m4/stdbool.m4 \
$(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \
$(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/m4/unistd-safer.m4 \
$(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/xalloc.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = subst utils.pm utils.sh
am__installdirs = "$(DESTDIR)$(libexecdir)"
libexecSCRIPT_INSTALL = $(INSTALL_SCRIPT)
SCRIPTS = $(libexec_SCRIPTS)
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
VPATH = $(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/t
INSTALL = @INSTALL@
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
ALLOCA_H = @ALLOCA_H@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BASENAME = @BASENAME@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPLIBS = @DEPLIBS@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXTRAS = @EXTRAS@
EXTRAS_ROOT = @EXTRAS_ROOT@
EXTRA_NETOBJS = @EXTRA_NETOBJS@
EXTRA_TEST = @EXTRA_TEST@
F77 = @F77@
FFLAGS = @FFLAGS@
GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
GETOPT_H = @GETOPT_H@
GMSGFMT = @GMSGFMT@
HAVE__BOOL = @HAVE__BOOL@
HOSTNAME = @HOSTNAME@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
KMEM_GROUP = @KMEM_GROUP@
KRBINCLUDE = @KRBINCLUDE@
LDAPINCLUDE = @LDAPINCLUDE@
LDAPLIBS = @LDAPLIBS@
LDFLAGS = @LDFLAGS@
LIBGNUTLS_CONFIG = @LIBGNUTLS_CONFIG@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
MATHLIBS = @MATHLIBS@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
MYSQLCFLAGS = @MYSQLCFLAGS@
MYSQLCONFIG = @MYSQLCONFIG@
MYSQLINCLUDE = @MYSQLINCLUDE@
MYSQLLIBS = @MYSQLLIBS@
NEED_SETGID = @NEED_SETGID@
NEED_VA_LIST = @NEED_VA_LIST@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PATH_TO_APTGET = @PATH_TO_APTGET@
PATH_TO_DIG = @PATH_TO_DIG@
PATH_TO_FPING = @PATH_TO_FPING@
PATH_TO_LMSTAT = @PATH_TO_LMSTAT@
PATH_TO_LSPS = @PATH_TO_LSPS@
PATH_TO_MAILQ = @PATH_TO_MAILQ@
PATH_TO_NSLOOKUP = @PATH_TO_NSLOOKUP@
PATH_TO_PING = @PATH_TO_PING@
PATH_TO_PING6 = @PATH_TO_PING6@
PATH_TO_PS = @PATH_TO_PS@
PATH_TO_QMAIL_QSTAT = @PATH_TO_QMAIL_QSTAT@
PATH_TO_QSTAT = @PATH_TO_QSTAT@
PATH_TO_QUAKESTAT = @PATH_TO_QUAKESTAT@
PATH_TO_RPCINFO = @PATH_TO_RPCINFO@
PATH_TO_SMBCLIENT = @PATH_TO_SMBCLIENT@
PATH_TO_SNMPGET = @PATH_TO_SNMPGET@
PATH_TO_SNMPGETNEXT = @PATH_TO_SNMPGETNEXT@
PATH_TO_SSH = @PATH_TO_SSH@
PATH_TO_SWAP = @PATH_TO_SWAP@
PATH_TO_SWAPINFO = @PATH_TO_SWAPINFO@
PATH_TO_UPTIME = @PATH_TO_UPTIME@
PATH_TO_WHO = @PATH_TO_WHO@
PERL = @PERL@
PGINCLUDE = @PGINCLUDE@
PGLIBS = @PGLIBS@
PKG_ARCH = @PKG_ARCH@
PLUGIN_TEST = @PLUGIN_TEST@
POSUB = @POSUB@
POW_LIB = @POW_LIB@
PYTHON = @PYTHON@
RADIUSLIBS = @RADIUSLIBS@
RANLIB = @RANLIB@
RELEASE = @RELEASE@
REV_DATESTAMP = @REV_DATESTAMP@
REV_TIMESTAMP = @REV_TIMESTAMP@
SCRIPT_TEST = @SCRIPT_TEST@
SET_MAKE = @SET_MAKE@
SH = @SH@
SHELL = @SHELL@
SOCKETLIBS = @SOCKETLIBS@
SSLINCLUDE = @SSLINCLUDE@
SSLLIBS = @SSLLIBS@
STDBOOL_H = @STDBOOL_H@
STRIP = @STRIP@
SUPPORT = @SUPPORT@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARRANTY = @WARRANTY@
XGETTEXT = @XGETTEXT@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
check_tcp_ssl = @check_tcp_ssl@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
with_trusted_path = @with_trusted_path@
SUFFIXES = .pl .sh
libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
check_log check_oracle check_rpc check_sensors check_wave \
check_ifstatus check_ifoperstatus check_mailq check_file_age \
utils.sh utils.pm
EXTRA_DIST = check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
utils.sh.in utils.pm.in t
TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
TESTS = @SCRIPT_TEST@
CLEANFILES = $(libexec_SCRIPTS)
all: all-am
.SUFFIXES:
.SUFFIXES: .pl .sh
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins-scripts/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu plugins-scripts/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
subst: $(top_builddir)/config.status $(srcdir)/subst.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
utils.pm: $(top_builddir)/config.status $(srcdir)/utils.pm.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
utils.sh: $(top_builddir)/config.status $(srcdir)/utils.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
install-libexecSCRIPTS: $(libexec_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(libexecdir)" || $(mkdir_p) "$(DESTDIR)$(libexecdir)"
@list='$(libexec_SCRIPTS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f $$d$$p; then \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " $(libexecSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(libexecdir)/$$f'"; \
$(libexecSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(libexecdir)/$$f"; \
else :; fi; \
done
uninstall-libexecSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(libexec_SCRIPTS)'; for p in $$list; do \
f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
echo " rm -f '$(DESTDIR)$(libexecdir)/$$f'"; \
rm -f "$(DESTDIR)$(libexecdir)/$$f"; \
done
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
check-TESTS: $(TESTS)
@failed=0; all=0; xfail=0; xpass=0; skip=0; \
srcdir=$(srcdir); export srcdir; \
list='$(TESTS)'; \
if test -n "$$list"; then \
for tst in $$list; do \
if test -f ./$$tst; then dir=./; \
elif test -f $$tst; then dir=; \
else dir="$(srcdir)/"; fi; \
if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xpass=`expr $$xpass + 1`; \
failed=`expr $$failed + 1`; \
echo "XPASS: $$tst"; \
;; \
*) \
echo "PASS: $$tst"; \
;; \
esac; \
elif test $$? -ne 77; then \
all=`expr $$all + 1`; \
case " $(XFAIL_TESTS) " in \
*" $$tst "*) \
xfail=`expr $$xfail + 1`; \
echo "XFAIL: $$tst"; \
;; \
*) \
failed=`expr $$failed + 1`; \
echo "FAIL: $$tst"; \
;; \
esac; \
else \
skip=`expr $$skip + 1`; \
echo "SKIP: $$tst"; \
fi; \
done; \
if test "$$failed" -eq 0; then \
if test "$$xfail" -eq 0; then \
banner="All $$all tests passed"; \
else \
banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
fi; \
else \
if test "$$xpass" -eq 0; then \
banner="$$failed of $$all tests failed"; \
else \
banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
fi; \
fi; \
dashes="$$banner"; \
skipped=""; \
if test "$$skip" -ne 0; then \
skipped="($$skip tests were not run)"; \
test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
dashes="$$skipped"; \
fi; \
report=""; \
if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
report="Please report to $(PACKAGE_BUGREPORT)"; \
test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
dashes="$$report"; \
fi; \
dashes=`echo "$$dashes" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
test -z "$$skipped" || echo "$$skipped"; \
test -z "$$report" || echo "$$report"; \
echo "$$dashes"; \
test "$$failed" -eq 0; \
else :; fi
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
all-am: Makefile $(SCRIPTS)
installdirs:
for dir in "$(DESTDIR)$(libexecdir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am: install-libexecSCRIPTS
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libexecSCRIPTS
.PHONY: all all-am check check-TESTS check-am clean clean-generic \
clean-libtool distclean distclean-generic distclean-libtool \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am \
install-libexecSCRIPTS install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am uninstall-libexecSCRIPTS
test:
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl t/utils.t # utils.t is excluded from above, so manually ask to test
.pl :
$(AWK) -f ./subst $< > $@
chmod +x $@
.sh :
$(AWK) -f ./subst $< > $@
chmod +x $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

87
plugins-scripts/check_breeze.pl Executable file
View file

@ -0,0 +1,87 @@
#!/usr/bin/perl -wT
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
use lib utils.pm ;
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME = "check_breeze";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"C=s" => \$opt_C, "community=s" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.5 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
($opt_H) || usage("Host name/address not specified\n");
my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($host) || usage("Invalid host: $opt_H\n");
($opt_w) || usage("Warning threshold not specified\n");
my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/);
($warning) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || usage("Critical threshold not specified\n");
my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/);
($critical) || usage("Invalid critical threshold: $opt_c\n");
($opt_C) || ($opt_C = "public") ;
my $sig=0;
$sig = `/usr/bin/snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`;
my @test=split(/ /,$sig);
$sig=$test[2];
$sig=int($sig);
if ($sig>100){$sig=100}
print "Signal Strength at: $sig%\n";
exit $ERRORS{'CRITICAL'} if ($sig<$critical);
exit $ERRORS{'WARNING'} if ($sig<$warning);
exit $ERRORS{'OK'};
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-C community] -w <warn> -c <crit>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.5 $');
print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop
This plugin reports the signal strength of a Breezecom wireless equipment
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-C, --community=community
SNMPv1 community (default public)
-w, --warning=INTEGER
Percentage strength below which a WARNING status will result
-c, --critical=INTEGER
Percentage strength below which a CRITICAL status will result
";
support();
}

280
plugins-scripts/check_disk_smb.pl Executable file
View file

@ -0,0 +1,280 @@
#!/usr/bin/perl -w
#
#
# check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port]
#
# Nagios host script to get the disk usage from a SMB share
#
# Changes and Modifications
# =========================
# 7-Aug-1999 - Michael Anthon
# Created from check_disk.pl script provided with netsaint_statd (basically
# cause I was too lazy (or is that smart?) to write it from scratch)
# 8-Aug-1999 - Michael Anthon
# Modified [warn] and [critical] parameters to accept format of nnn[M|G] to
# allow setting of limits in MBytes or GBytes. Percentage settings for large
# drives is a pain in the butt
# 2-May-2002 - SGhosh fix for embedded perl
#
# $Id: check_disk_smb.pl,v 1.13 2005/10/13 10:14:33 seanius Exp $
#
require 5.004;
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $verbose);
use vars qw($PROGNAME);
use lib utils.pm ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
sub print_usage ();
$PROGNAME = "check_disk_smb";
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("v" => \$verbose, "verbose" => \$verbose,
"P=s" => \$opt_P, "port=s" => \$opt_P,
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"p=s" => \$opt_p, "password=s" => \$opt_p,
"u=s" => \$opt_u, "username=s" => \$opt_u,
"s=s" => \$opt_s, "share=s" => \$opt_s,
"W=s" => \$opt_W, "workgroup=s" => \$opt_W,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.13 $'); #'
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
my $smbclient= "$utils::PATH_TO_SMBCLIENT " ;
my $smbclientoptions= $opt_P ? "-p $opt_P " : "";
# Options checking
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/);
($host) || usage("Invalid host: $opt_H\n");
($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
my $share = $1 if ($opt_s =~ /^([-_.A-Za-z0-9]+\$?)$/);
($share) || usage("Invalid share: $opt_s\n");
($opt_u) || ($opt_u = shift) || ($opt_u = "guest");
my $user = $1 if ($opt_u =~ /^([-_.A-Za-z0-9\\]+)$/);
($user) || usage("Invalid user: $opt_u\n");
($opt_p) || ($opt_p = shift) || ($opt_p = "");
my $pass = $1 if ($opt_p =~ /(.*)/);
($opt_w) || ($opt_w = shift) || ($opt_w = 85);
my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($warn) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift) || ($opt_c = 95);
my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
# split the type from the unit value
#Check $warn and $crit for type (%/M/G) and set up for tests
#P = Percent, K = KBytes
my $warn_type;
my $crit_type;
if ($opt_w =~ /^([0-9]+)\%?$/) {
$warn = "$1";
$warn_type = "P";
} elsif ($opt_w =~ /^([0-9]+)k$/) {
$warn_type = "K";
$warn = $1;
} elsif ($opt_w =~ /^([0-9]+)M$/) {
$warn_type = "K";
$warn = $1 * 1024;
} elsif ($opt_w =~ /^([0-9]+)G$/) {
$warn_type = "K";
$warn = $1 * 1048576;
}
if ($opt_c =~ /^([0-9]+)\%?$/) {
$crit = "$1";
$crit_type = "P";
} elsif ($opt_c =~ /^([0-9]+)k$/) {
$crit_type = "K";
$crit = $1;
} elsif ($opt_c =~ /^([0-9]+)M$/) {
$crit_type = "K";
$crit = $1 * 1024;
} elsif ($opt_c =~ /^([0-9]+)G$/) {
$crit_type = "K";
$crit = $1 * 1048576;
}
# check if both warning and critical are percentage or size
unless( ( $warn_type eq "P" && $crit_type eq "P" ) || ( $warn_type ne "P" && $crit_type ne "P" ) ){
$opt_w =~ s/\%/\%\%/g;
$opt_c =~ s/\%/\%\%/g;
usage("Both warning and critical should be same type- warning: $opt_w critical: $opt_c \n");
}
# verify warning is less than critical
if ( $warn_type eq "K") {
unless ( $warn > $crit) {
usage("Disk size: warning ($opt_w) should be greater than critical ($opt_c) \n");
}
}else{
unless ( $warn < $crit) {
$opt_w =~ s/\%/\%\%/g;
$opt_c =~ s/\%/\%\%/g;
usage("Percentage: warning ($opt_w) should be less than critical ($opt_c) \n");
}
}
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
# end of options checking
my $state = "OK";
my $answer = undef;
my $res = undef;
my @lines = undef;
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print "No Answer from Client\n";
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
# Execute an "ls" on the share using smbclient program
# get the results into $res
if (defined($workgroup)) {
$res = qx/$smbclient \/\/$host\/$share -W $workgroup -U $user%$pass $smbclientoptions -c ls/;
} else {
print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
$res = qx/$smbclient \/\/$host\/$share -U $user%$pass $smbclientoptions -c ls/;
}
#Turn off alarm
alarm(0);
#Split $res into an array of lines
@lines = split /\n/, $res;
#Get the last line into $_
$_ = $lines[$#lines];
#print "$_\n";
#Process the last line to get free space.
#If line does not match required regexp, return an UNKNOWN error
if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
my ($avail) = ($3*$2)/1024;
my ($avail_bytes) = $avail;
my ($capper) = int(($3/$1)*100);
my ($mountpt) = "\\\\$host\\$share";
if (int($avail / 1024) > 0) {
$avail = int($avail / 1024);
if (int($avail /1024) > 0) {
$avail = (int(($avail / 1024)*100))/100;
$avail = $avail ."G";
} else {
$avail = $avail ."M";
}
} else {
$avail = $avail ."K";
}
#print ":$warn:$warn_type:\n";
#print ":$crit:$crit_type:\n";
#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) {
$answer = "Disk ok - $avail ($capper%) free on $mountpt\n";
} elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) {
$state = "WARNING";
$answer = "WARNING: Only $avail ($capper%) free on $mountpt\n";
} else {
$state = "CRITICAL";
$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
}
} else {
$answer = "Result from smbclient not suitable\n";
$state = "UNKNOWN";
foreach (@lines) {
if (/(Access denied|NT_STATUS_LOGON_FAILURE)/) {
$answer = "Access Denied\n";
$state = "CRITICAL";
last;
}
if (/(Unknown host \w*|Connection.*failed)/) {
$answer = "$1\n";
$state = "CRITICAL";
last;
}
if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
$answer = "Invalid share name \\\\$host\\$share\n";
$state = "CRITICAL";
last;
}
}
}
print $answer;
print "$state\n" if ($verbose);
exit $ERRORS{$state};
sub print_usage () {
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
-w <warn> -c <crit> [-W <workgroup>] [-P <port>]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.13 $');
print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop
Perl Check SMB Disk plugin for Nagios
";
print_usage();
print "
-H, --hostname=HOST
NetBIOS name of the server
-s, --share=STRING
Share name to be tested
-W, --workgroup=STRING
Workgroup or Domain used (Defaults to \"WORKGROUP\")
-u, --user=STRING
Username to log in to server. (Defaults to \"guest\")
-p, --password=STRING
Password to log in to server. (Defaults to an empty password)
-w, --warning=INTEGER or INTEGER[kMG]
Percent of used space at which a warning will be generated (Default: 85%)
-c, --critical=INTEGER or INTEGER[kMG]
Percent of used space at which a critical will be generated (Defaults: 95%)
-P, --port=INTEGER
Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
If thresholds are followed by either a k, M, or G then check to see if that
much disk space is available (kilobytes, Megabytes, Gigabytes)
Warning percentage should be less than critical
Warning (remaining) disk space should be greater than critical.
";
support();
}

113
plugins-scripts/check_file_age.pl Executable file
View file

@ -0,0 +1,113 @@
#!/bin/perl -w
# $Id: check_file_age.pl,v 1.3 2005/12/15 15:17:49 tonvoon Exp $
# check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com>
#
# Checks a file's size and modification time to make sure it's not empty
# and that it's sufficiently recent.
#
#
# 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 2
# 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 (or with Nagios); if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA
use strict;
use English;
use Getopt::Long;
use File::stat;
use vars qw($PROGNAME);
use lib ".";
use utils qw (%ERRORS &print_revision &support);
sub print_help ();
sub print_usage ();
my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V);
my ($result, $message, $age, $size, $st);
$PROGNAME="check_file_age";
$opt_w = 240;
$opt_c = 600;
$opt_W = 0;
$opt_C = 0;
$opt_f = "";
Getopt::Long::Configure('bundling');
GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"f=s" => \$opt_f, "file" => \$opt_f,
"w=f" => \$opt_w, "warning-age=f" => \$opt_w,
"W=f" => \$opt_W, "warning-size=f" => \$opt_W,
"c=f" => \$opt_c, "critical-age=f" => \$opt_c,
"C=f" => \$opt_C, "critical-size=f" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME, '$Id: check_file_age.pl,v 1.3 2005/12/15 15:17:49 tonvoon Exp $');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
$opt_f = shift unless ($opt_f);
if (! $opt_f) {
print "FILE_AGE UNKNOWN: No file specified\n";
exit $ERRORS{'UNKNOWN'};
}
# Check that file exists (can be directory or link)
unless (-e $opt_f) {
print "FILE_AGE CRITICAL: File not found - $opt_f\n";
exit $ERRORS{'CRITICAL'};
}
$st = File::stat::stat($opt_f);
$age = time - $st->mtime;
$size = $st->size;
$result = 'OK';
if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) {
$result = 'CRITICAL';
}
elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) {
$result = 'WARNING';
}
print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n";
exit $ERRORS{$result};
sub print_usage () {
print "Usage:\n";
print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";
}
sub print_help () {
print_revision($PROGNAME, '$Id: check_file_age.pl,v 1.3 2005/12/15 15:17:49 tonvoon Exp $');
print "Copyright (c) 2003 Steven Grimm\n\n";
print_usage();
print "\n";
print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n";
print "\n";
support();
}

245
plugins-scripts/check_flexlm.pl Executable file
View file

@ -0,0 +1,245 @@
#!/usr/bin/perl -w
#
# usage:
# check_flexlm.pl license_file
#
# Check available flexlm license managers.
# Use lmstat to check the status of the license server
# described by the license file given as argument.
# Check and interpret the output of lmstat
# and create returncodes and output.
#
# Contrary to the nagios concept, this script takes
# a file, not a hostname as an argument and returns
# the status of hosts and services described in that
# file. Use these hosts.cfg entries as an example
#
#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1;
#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic
#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic
#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$
#
# Notes:
# - you need the lmstat utility which comes with flexlm.
# - set the correct path in the variable $lmstat.
#
# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com
#
# License: GPL
# $Id: check_flexlm.pl,v 1.6 2003/02/04 06:16:16 sghosh Exp $
#
# lmstat output patches from Steve Rigler/Cliff Rice 13-Apr-2002
# srigler@marathonoil.com,cerice@marathonoil.com
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
use lib utils.pm;
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME="check_flexlm";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose, "verbose" => \$verbose,
"F=s" => \$opt_F, "filename=s" => \$opt_F,
"t=i" => \$opt_t, "timeout=i" => \$opt_t);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.6 $');
exit $ERRORS{'OK'};
}
unless (defined $opt_t) {
$opt_t = $utils::TIMEOUT ; # default timeout
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
unless (defined $opt_F) {
print "Missing license.dat file\n";
print_usage();
exit $ERRORS{'UNKNOWN'};
}
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print "Timeout: No Answer from Client\n";
exit $ERRORS{'UNKNOWN'};
};
alarm($opt_t);
my $lmstat = $utils::PATH_TO_LMSTAT ;
unless (-x $lmstat ) {
print "Cannot find \"lmstat\"\n";
exit $ERRORS{'UNKNOWN'};
}
($opt_F) || ($opt_F = shift) || usage("License file not specified\n");
my $licfile = $1 if ($opt_F =~ /^(.*)$/);
($licfile) || usage("Invalid filename: $opt_F\n");
print "$licfile\n" if $verbose;
if ( ! open(CMD,"$lmstat -c $licfile |") ) {
print "ERROR: Could not open \"$lmstat -c $licfile\" ($!)\n";
exit exit $ERRORS{'UNKNOWN'};
}
my $serverup = 0;
my @upsrv;
my @downsrv; # list of servers up and down
#my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers);
# key off of the term "license server" and
# grab the status. Keep going until "Vendor" is found
#
#
# Collect list of license servers by their status
# Vendor daemon status is ignored for the moment.
while ( <CMD> ) {
next if (/^lmstat/); # ignore 1st line - copyright
next if (/^Flexible/); # ignore 2nd line - timestamp
(/^Vendor/) && last; # ignore Vendor daemon status
print $_ if $verbose;
if ($_ =~ /license server /) { # matched 1 (of possibly 3) license server
s/^\s*//; #some servers start at col 1, other have whitespace
# strip staring whitespace if any
if ( $_ =~ /UP/) {
$_ =~ /^(.*):/ ;
push(@upsrv, $1);
print "up:$1:\n" if $verbose;
} else {
$_ =~ /^(.*):/;
push(@downsrv, $1);
print "down:$1:\n" if $verbose;
}
}
# if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) {
# $ls1 = $1;
# $ls2 = $2;
# $ls3 = $3;
# $lf1 = $lf2 = $lf3 = 0;
# $servers = 3;
# } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) {
# $ls1 = $1;
# $ls2 = $ls3 = "";
# $lf1 = $lf2 = $lf3 = 0;
# $servers = 1;
# } elsif ( / *$ls1: license server UP/ ) {
# print "$ls1 UP, ";
# $lf1 = 1
# } elsif ( / *$ls2: license server UP/ ) {
# print "$ls2 UP, ";
# $lf2 = 1
# } elsif ( / *$ls3: license server UP/ ) {
# print "$ls3 UP, ";
# $lf3 = 1
# } elsif ( / *([^:]*: UP .*)/ ) {
# print " license server for $1\n";
# $serverup = 1;
# }
}
#if ( $serverup == 0 ) {
# print " license server not running\n";
# exit 2;
#}
close CMD;
if ($verbose) {
print "License Servers running: ".scalar(@upsrv) ."\n";
foreach my $upserver (@upsrv) {
print "$upserver\n";
}
print "License servers not running: ".scalar(@downsrv)."\n";
foreach my $downserver (@downsrv) {
print "$downserver\n";
}
}
#
# print list of servers which are up.
#
if (scalar(@upsrv) > 0) {
print "License Servers running:";
foreach my $upserver (@upsrv) {
print "$upserver,";
}
}
#
# Ditto for those which are down.
#
if (scalar(@downsrv) > 0) {
print "License servers NOT running:";
foreach my $downserver (@downsrv) {
print "$downserver,";
}
}
# perfdata
print "\n|flexlm::up:".scalar(@upsrv).";down:".scalar(@downsrv)."\n";
exit $ERRORS{'OK'} if ( scalar(@downsrv) == 0 );
exit $ERRORS{'WARNING'} if ( (scalar(@upsrv) > 0) && (scalar(@downsrv) > 0));
#exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 );
#exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
exit $ERRORS{'CRITICAL'};
sub print_usage () {
print "Usage:
$PROGNAME -F <filename> [-v] [-t] [-V] [-h]
$PROGNAME --help
$PROGNAME --version
";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.6 $');
print "Copyright (c) 2000 Ernst-Dieter Martin/Karl DeBisschop
Check available flexlm license managers
";
print_usage();
print "
-F, --filename=FILE
Name of license file (usually \"license.dat\")
-v, --verbose
Print some extra debugging information (not advised for normal operation)
-t, --timeout
Plugin time out in seconds (default = $utils::TIMEOUT )
-V, --version
Show version and license information
-h, --help
Show this help screen
Flexlm license managers usually run as a single server or three servers and a
quorum is needed. The plugin return OK if 1 (single) or 3 (triple) servers
are running, CRITICAL if 1(single) or 3 (triple) servers are down, and WARNING
if 1 or 2 of 3 servers are running\n
";
support();
}

View file

@ -0,0 +1,505 @@
#!/usr/local/bin/perl -w
#
# check_ifoperstatus.pl - nagios plugin
#
# Copyright (C) 2000 Christoph Kron,
# Modified 5/2002 to conform to updated Nagios Plugin Guidelines
# Added support for named interfaces per Valdimir Ivaschenko (S. Ghosh)
# Added SNMPv3 support (10/2003)
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Report bugs to: nagiosplug-help@lists.sourceforge.net
#
# 11.01.2000 Version 1.0
# $Id: check_ifoperstatus.pl,v 1.6 2004/12/07 03:13:14 mattkent Exp $
#
# Patches from Guy Van Den Bergh to warn on ifadminstatus down interfaces
# instead of critical.
#
# Primary MIB reference - RFC 2863
use POSIX;
use strict;
use lib utils.pm ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('bundling');
my $PROGNAME = "check_ifoperstatus";
sub print_help ();
sub usage ();
sub process_arguments ();
my $timeout;
my $status;
my %ifOperStatus = ('1','up',
'2','down',
'3','testing',
'4','unknown',
'5','dormant',
'6','notPresent',
'7','lowerLayerDown'); # down due to the state of lower layer interface(s)
my $state = "UNKNOWN";
my $answer = "";
my $snmpkey = 0;
my $community = "public";
my $maxmsgsize = 1472 ; # Net::SNMP default is 1472
my ($seclevel, $authproto, $secname, $authpass, $privpass, $auth, $priv, $context);
my $port = 161;
my @snmpoids;
my $sysUptime = '1.3.6.1.2.1.1.3.0';
my $snmpIfDescr = '1.3.6.1.2.1.2.2.1.2';
my $snmpIfAdminStatus = '1.3.6.1.2.1.2.2.1.7';
my $snmpIfOperStatus = '1.3.6.1.2.1.2.2.1.8';
my $snmpIfName = '1.3.6.1.2.1.31.1.1.1.1';
my $snmpIfLastChange = '1.3.6.1.2.1.2.2.1.9';
my $snmpIfAlias = '1.3.6.1.2.1.31.1.1.1.18';
my $snmpLocIfDescr = '1.3.6.1.4.1.9.2.2.1.1.28';
my $hostname;
my $ifName;
my $session;
my $error;
my $response;
my $snmp_version = 1 ;
my $ifXTable;
my $opt_h ;
my $opt_V ;
my $ifdescr;
my $key;
my $lastc;
my $dormantWarn;
my $adminWarn;
my $name;
### Validate Arguments
$status = process_arguments();
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: No snmp response from $hostname (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($timeout);
## map ifdescr to ifindex - should look at being able to cache this value
if (defined $ifdescr) {
# escape "/" in ifdescr - very common in the Cisco world
$ifdescr =~ s/\//\\\//g;
$status=fetch_ifdescr(); # if using on device with large number of interfaces
# recommend use of SNMP v2 (get-bulk)
if ($status==0) {
$state = "UNKNOWN";
printf "$state: could not retrive ifdescr snmpkey - $status-$snmpkey\n";
$session->close;
exit $ERRORS{$state};
}
}
## Main function
$snmpIfAdminStatus = $snmpIfAdminStatus . "." . $snmpkey;
$snmpIfOperStatus = $snmpIfOperStatus . "." . $snmpkey;
$snmpIfDescr = $snmpIfDescr . "." . $snmpkey;
$snmpIfName = $snmpIfName . "." . $snmpkey ;
$snmpIfAlias = $snmpIfAlias . "." . $snmpkey ;
push(@snmpoids,$snmpIfAdminStatus);
push(@snmpoids,$snmpIfOperStatus);
push(@snmpoids,$snmpIfDescr);
push(@snmpoids,$snmpIfName) if (defined $ifXTable) ;
push(@snmpoids,$snmpIfAlias) if (defined $ifXTable) ;
if (!defined($response = $session->get_request(@snmpoids))) {
$answer=$session->error;
$session->close;
$state = 'WARNING';
print ("$state: SNMP error: $answer\n");
exit $ERRORS{$state};
}
$answer = sprintf("host '%s', %s(%s) is %s\n",
$hostname,
$response->{$snmpIfDescr},
$snmpkey,
$ifOperStatus{$response->{$snmpIfOperStatus}}
);
## Check to see if ifName match is requested and it matches - exit if no match
## not the interface we want to monitor
if ( defined $name && not ($response->{$snmpIfName} eq $name) ) {
$state = 'UNKNOWN';
$answer = "Interface name ($name) doesn't match snmp value ($response->{$snmpIfName}) (index $snmpkey)";
print ("$state: $answer");
exit $ERRORS{$state};
}
## define the interface name
if (defined $ifXTable) {
$name = $response->{$snmpIfName} ." - " .$response->{$snmpIfAlias} ;
}else{
$name = $response->{$snmpIfDescr} ;
}
## if AdminStatus is down - some one made a consious effort to change config
##
if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
$answer = "Interface $name (index $snmpkey) is administratively down.";
if ( not defined $adminWarn or $adminWarn eq "w" ) {
$state = 'WARNING';
} elsif ( $adminWarn eq "i" ) {
$state = 'OK';
} elsif ( $adminWarn eq "c" ) {
$state = 'CRITICAL';
} else { # If wrong value for -a, say warning
$state = 'WARNING';
}
}
## Check operational status
elsif ( $response->{$snmpIfOperStatus} == 2 ) {
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) is down.";
} elsif ( $response->{$snmpIfOperStatus} == 5 ) {
if (defined $dormantWarn ) {
if ($dormantWarn eq "w") {
$state = 'WARNING';
$answer = "Interface $name (index $snmpkey) is dormant.";
}elsif($dormantWarn eq "c") {
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) is dormant.";
}elsif($dormantWarn eq "i") {
$state = 'OK';
$answer = "Interface $name (index $snmpkey) is dormant.";
}
}else{
# dormant interface - but warning/critical/ignore not requested
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) is dormant.";
}
} elsif ( $response->{$snmpIfOperStatus} == 6 ) {
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) notPresent - possible hotswap in progress.";
} elsif ( $response->{$snmpIfOperStatus} == 7 ) {
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) down due to lower layer being down.";
} elsif ( $response->{$snmpIfOperStatus} == 3 || $response->{$snmpIfOperStatus} == 4 ) {
$state = 'CRITICAL';
$answer = "Interface $name (index $snmpkey) down (testing/unknown).";
} else {
$state = 'OK';
$answer = "Interface $name (index $snmpkey) is up.";
}
print ("$state: $answer");
exit $ERRORS{$state};
### subroutines
sub fetch_ifdescr {
if (!defined ($response = $session->get_table($snmpIfDescr))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
printf ("$state: SNMP error with snmp version $snmp_version ($answer)\n");
$session->close;
exit $ERRORS{$state};
}
foreach $key ( keys %{$response}) {
if ($response->{$key} =~ /^$ifdescr$/) {
$key =~ /.*\.(\d+)$/;
$snmpkey = $1;
#print "$ifdescr = $key / $snmpkey \n"; #debug
}
}
unless (defined $snmpkey) {
$session->close;
$state = 'CRITICAL';
printf "$state: Could not match $ifdescr on $hostname\n";
exit $ERRORS{$state};
}
return $snmpkey;
}
sub usage() {
printf "\nMissing arguments!\n";
printf "\n";
printf "usage: \n";
printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n";
printf "This programm is licensed under the terms of the ";
printf "GNU General Public License\n(check source code for details)\n";
printf "\n\n";
exit $ERRORS{"UNKNOWN"};
}
sub print_help() {
printf "check_ifoperstatus plugin for Nagios monitors operational \n";
printf "status of a particular network interface on the target host\n";
printf "\nUsage:\n";
printf " -H (--hostname) Hostname to query - (required)\n";
printf " -C (--community) SNMP read community (defaults to public,\n";
printf " used with SNMP v1 and v2c\n";
printf " -v (--snmp_version) 1 for SNMP v1 (default)\n";
printf " 2 for SNMP v2c\n";
printf " SNMP v2c will use get_bulk for less overhead\n";
printf " if monitoring with -d\n";
printf " -L (--seclevel) choice of \"noAuthNoPriv\", \"authNoPriv\", or \"authPriv\"\n";
printf " -U (--secname) username for SNMPv3 context\n";
printf " -c (--context) SNMPv3 context name (default is empty string)";
printf " -A (--authpass) authentication password (cleartext ascii or localized key\n";
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " auth password and authEngineID\n";
printf " -a (--authproto) Authentication protocol ( MD5 or SHA1)\n";
printf " -X (--privpass) privacy password (cleartext ascii or localized key\n";
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " privacy password and authEngineID\n";
printf " -k (--key) SNMP IfIndex value\n";
printf " -d (--descr) SNMP ifDescr value\n";
printf " -p (--port) SNMP port (default 161)\n";
printf " -I (--ifmib) Agent supports IFMIB ifXTable. Do not use if\n";
printf " you don't know what this is. \n";
printf " -n (--name) the value should match the returned ifName\n";
printf " (Implies the use of -I)\n";
printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
printf " -k or -d must be specified\n\n";
printf "Note: either -k or -d must be specified and -d is much more network \n";
printf "intensive. Use it sparingly or not at all. -n is used to match against\n";
printf "a much more descriptive ifName value in the IfXTable to verify that the\n";
printf "snmpkey has not changed to some other network interface after a reboot.\n\n";
print_revision($PROGNAME, '$Revision: 1.6 $');
}
sub process_arguments() {
$status = GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version,
"C=s" => \$community, "community=s" => \$community,
"L=s" => \$seclevel, "seclevel=s" => \$seclevel,
"a=s" => \$authproto, "authproto=s" => \$authproto,
"U=s" => \$secname, "secname=s" => \$secname,
"A=s" => \$authpass, "authpass=s" => \$authpass,
"X=s" => \$privpass, "privpass=s" => \$privpass,
"c=s" => \$context, "context=s" => \$context,
"k=i" => \$snmpkey, "key=i",\$snmpkey,
"d=s" => \$ifdescr, "descr=s" => \$ifdescr,
"l=s" => \$lastc, "lastchange=s" => \$lastc,
"p=i" => \$port, "port=i" =>\$port,
"H=s" => \$hostname, "hostname=s" => \$hostname,
"I" => \$ifXTable, "ifmib" => \$ifXTable,
"n=s" => \$ifName, "name=s" => \$ifName,
"w=s" => \$dormantWarn, "warn=s" => \$dormantWarn,
"D=s" => \$adminWarn, "admin-down=s" => \$adminWarn,
"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
"t=i" => \$timeout, "timeout=i" => \$timeout,
);
if ($status == 0){
print_help();
exit $ERRORS{'OK'};
}
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.6 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if (! utils::is_hostname($hostname)){
usage();
exit $ERRORS{"UNKNOWN"};
}
unless ($snmpkey > 0 || defined $ifdescr){
printf "Either a valid snmpkey key (-k) or a ifDescr (-d) must be provided)\n";
usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined $name) {
$ifXTable=1;
}
if (defined $dormantWarn) {
unless ($dormantWarn =~ /^(w|c|i)$/ ) {
printf "Dormant alerts must be one of w|c|i \n";
exit $ERRORS{'UNKNOWN'};
}
}
unless (defined $timeout) {
$timeout = $TIMEOUT;
}
if ($snmp_version =~ /3/ ) {
# Must define a security level even though default is noAuthNoPriv
# v3 requires a security username
if (defined $seclevel && defined $secname) {
# Must define a security level even though defualt is noAuthNoPriv
unless ($seclevel eq ('noAuthNoPriv' || 'authNoPriv' || 'authPriv' ) ) {
usage();
exit $ERRORS{"UNKNOWN"};
}
# Authentication wanted
if ($seclevel eq ('authNoPriv' || 'authPriv') ) {
unless ($authproto eq ('MD5' || 'SHA1') ) {
usage();
exit $ERRORS{"UNKNOWN"};
}
if ( !defined $authpass) {
usage();
exit $ERRORS{"UNKNOWN"};
}else{
if ($authpass =~ /^0x/ ) {
$auth = "-authkey => $authpass" ;
}else{
$auth = "-authpassword => $authpass";
}
}
}
# Privacy (DES encryption) wanted
if ($seclevel eq 'authPriv' ) {
if (! defined $privpass) {
usage();
exit $ERRORS{"UNKNOWN"};
}else{
if ($privpass =~ /^0x/){
$priv = "-privkey => $privpass";
}else{
$priv = "-privpassword => $privpass";
}
}
}
# Context name defined or default
unless ( defined $context) {
$context = "";
}
}else {
usage();
exit $ERRORS{'UNKNOWN'}; ;
}
} # end snmpv3
if ( $snmp_version =~ /[12]/ ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port,
-version => $snmp_version,
-maxmsgsize => $maxmsgsize
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
}elsif ( $snmp_version =~ /3/ ) {
if ($seclevel eq 'noAuthNoPriv') {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
);
}elsif ( $seclevel eq 'authNoPriv' ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
$auth,
-authprotocol => $authproto,
);
}elsif ($seclevel eq 'authPriv' ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
$auth,
-authprotocol => $authproto,
$priv
);
}
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
}else{
$state='UNKNOWN';
print ("$state: No support for SNMP v$snmp_version yet\n");
exit $ERRORS{$state};
}
}
## End validation

459
plugins-scripts/check_ifstatus.pl Executable file
View file

@ -0,0 +1,459 @@
#!/usr/local/bin/perl -w
#
# check_ifstatus.pl - nagios plugin
#
#
# Copyright (C) 2000 Christoph Kron
# Modified 5/2002 to conform to updated Nagios Plugin Guidelines (S. Ghosh)
# Added -x option (4/2003)
# Added -u option (4/2003)
# Added -M option (10/2003)
# Added SNMPv3 support (10/2003)
#
# 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 2
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# Report bugs to: ck@zet.net, nagiosplug-help@lists.sf.net
#
# 11.01.2000 Version 1.0
#
# $Id: check_ifstatus.pl,v 1.9 2004/08/18 19:51:35 tonvoon Exp $
use POSIX;
use strict;
use lib utils.pm ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
use Getopt::Long;
Getopt::Long::Configure('bundling');
my $PROGNAME = "check_ifstatus";
sub print_help ();
sub usage ();
sub process_arguments ();
my $status;
my %ifOperStatus = ('1','up',
'2','down',
'3','testing',
'4','unknown',
'5','dormant',
'6','notPresent',
'7','lowerLayerDown'); # down due to the state of lower layer interface(s));
my $timeout ;
my $state = "UNKNOWN";
my $answer = "";
my $snmpkey=0;
my $snmpoid=0;
my $key=0;
my $community = "public";
my $maxmsgsize = 1472 ; # Net::SNMP default is 1472
my ($seclevel, $authproto, $secname, $authpass, $privpass, $auth, $priv, $context);
my $port = 161;
my @snmpoids;
my $snmpIfAdminStatus = '1.3.6.1.2.1.2.2.1.7';
my $snmpIfDescr = '1.3.6.1.2.1.2.2.1.2';
my $snmpIfOperStatus = '1.3.6.1.2.1.2.2.1.8';
my $snmpIfName = '1.3.6.1.2.1.31.1.1.1.1';
my $snmpIfAlias = '1.3.6.1.2.1.31.1.1.1.18';
my $snmpLocIfDescr = '1.3.6.1.4.1.9.2.2.1.1.28';
my $snmpIfType = '1.3.6.1.2.1.2.2.1.3';
my $hostname;
my $session;
my $error;
my $response;
my %ifStatus;
my $ifup =0 ;
my $ifdown =0;
my $ifdormant = 0;
my $ifexclude = 0 ;
my $ifunused = 0;
my $ifmessage = "";
my $snmp_version = 1;
my $ifXTable;
my $opt_h ;
my $opt_V ;
my $opt_u;
my $opt_x ;
my %excluded ;
my @unused_ports ;
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: No snmp response from $hostname (alarm timeout)\n");
exit $ERRORS{"UNKNOWN"};
};
#Option checking
$status = process_arguments();
if ($status != 0)
{
print_help() ;
exit $ERRORS{'OK'};
}
alarm($timeout);
push(@snmpoids,$snmpIfOperStatus);
push(@snmpoids,$snmpIfAdminStatus);
push(@snmpoids,$snmpIfDescr);
push(@snmpoids,$snmpIfType);
push(@snmpoids,$snmpIfName) if ( defined $ifXTable);
push(@snmpoids,$snmpIfAlias) if ( defined $ifXTable);
foreach $snmpoid (@snmpoids) {
if (!defined($response = $session->get_table($snmpoid))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
if ( ( $snmpoid =~ $snmpIfName ) && defined $ifXTable ) {
print ("$state: Device does not support ifTable - try without -I option\n");
}else{
print ("$state: $answer for $snmpoid with snmp version $snmp_version\n");
}
exit $ERRORS{$state};
}
foreach $snmpkey (keys %{$response}) {
$snmpkey =~ /.*\.(\d+)$/;
$key = $1;
$ifStatus{$key}{$snmpoid} = $response->{$snmpkey};
}
}
$session->close;
alarm(0);
foreach $key (keys %ifStatus) {
# skip unused interfaces
if (!defined($ifStatus{$key}{'notInUse'})) {
# check only if interface is administratively up
if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
# check only if interface type is not listed in %excluded
if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ;}
if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
$ifdown++ ;
if (defined $ifXTable) {
$ifmessage .= sprintf("%s: down -> %s<BR>",
$ifStatus{$key}{$snmpIfName},
$ifStatus{$key}{$snmpIfAlias});
}else{
$ifmessage .= sprintf("%s: down <BR>",
$ifStatus{$key}{$snmpIfDescr});
}
}
if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
}else{
$ifexclude++;
}
}
}else{
$ifunused++;
}
}
if ($ifdown > 0) {
$state = 'CRITICAL';
$answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d<BR>",
$hostname,
$ifup,
$ifdown,
$ifdormant,
$ifexclude,
$ifunused);
$answer = $answer . $ifmessage . "\n";
}
else {
$state = 'OK';
$answer = sprintf("host '%s', interfaces up: %d, down: %d, dormant: %d, excluded: %d, unused: %d",
$hostname,
$ifup,
$ifdown,
$ifdormant,
$ifexclude,
$ifunused);
}
my $perfdata = sprintf("up=%d,down=%d,dormant=%d,excluded=%d,unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
print ("$state: $answer |$perfdata\n");
exit $ERRORS{$state};
sub usage (){
printf "\nMissing arguments!\n";
printf "\n";
printf "check_ifstatus -C <READCOMMUNITY> -p <PORT> -H <HOSTNAME>\n";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "Updates 5/2002 Subhendu Ghosh\n";
printf "\n\n";
support();
exit $ERRORS{"UNKNOWN"};
}
sub print_help (){
printf "check_ifstatus plugin for Nagios monitors operational \n";
printf "status of each network interface on the target host\n";
printf "\nUsage:\n";
printf " -H (--hostname) Hostname to query - (required)\n";
printf " -C (--community) SNMP read community (defaults to public,\n";
printf " used with SNMP v1 and v2c\n";
printf " -v (--snmp_version) 1 for SNMP v1 (default)\n";
printf " 2 for SNMP v2c\n";
printf " SNMP v2c will use get_bulk for less overhead\n";
printf " 3 for SNMPv3 (requires -U option)";
printf " -p (--port) SNMP port (default 161)\n";
printf " -I (--ifmib) Agent supports IFMIB ifXTable. For Cisco - this will provide\n";
printf " the descriptive name. Do not use if you don't know what this is. \n";
printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n";
printf " from the report (default for an empty list is PPP(23).\n";
printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n";
printf " from the report (default is an empty exclusion list).\n";
printf " See the IANAifType-MIB for a list of interface types.\n";
printf " -L (--seclevel) choice of \"noAuthNoPriv\", \"authNoPriv\", or \"authPriv\"\n";
printf " -U (--secname) username for SNMPv3 context\n";
printf " -c (--context) SNMPv3 context name (default is empty string)";
printf " -A (--authpass) authentication password (cleartext ascii or localized key\n";
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " auth password and authEngineID\n";
printf " -a (--authproto) Authentication protocol ( MD5 or SHA1)\n";
printf " -X (--privpass) privacy password (cleartext ascii or localized key\n";
printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
printf " privacy password and authEngineID\n";
printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
printf " -V (--version) Plugin version\n";
printf " -h (--help) usage help \n\n";
print_revision($PROGNAME, '$Revision: 1.9 $');
}
sub process_arguments() {
$status = GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version,
"C=s" => \$community,"community=s" => \$community,
"L=s" => \$seclevel, "seclevel=s" => \$seclevel,
"a=s" => \$authproto, "authproto=s" => \$authproto,
"U=s" => \$secname, "secname=s" => \$secname,
"A=s" => \$authpass, "authpass=s" => \$authpass,
"X=s" => \$privpass, "privpass=s" => \$privpass,
"c=s" => \$context, "context=s" => \$context,
"p=i" =>\$port, "port=i" => \$port,
"H=s" => \$hostname, "hostname=s" => \$hostname,
"I" => \$ifXTable, "ifmib" => \$ifXTable,
"x:s" => \$opt_x, "exclude:s" => \$opt_x,
"u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
"t=i" => \$timeout, "timeout=i" => \$timeout,
);
if ($status == 0){
print_help() ;
exit $ERRORS{'OK'};
}
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.9 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
unless (defined $timeout) {
$timeout = $TIMEOUT;
}
if ($snmp_version =~ /3/ ) {
# Must define a security level even though default is noAuthNoPriv
# v3 requires a security username
if (defined $seclevel && defined $secname) {
# Must define a security level even though defualt is noAuthNoPriv
unless ($seclevel eq ('noAuthNoPriv' || 'authNoPriv' || 'authPriv' ) ) {
usage();
exit $ERRORS{"UNKNOWN"};
}
# Authentication wanted
if ($seclevel eq ('authNoPriv' || 'authPriv') ) {
unless ($authproto eq ('MD5' || 'SHA1') ) {
usage();
exit $ERRORS{"UNKNOWN"};
}
if ( !defined $authpass) {
usage();
exit $ERRORS{"UNKNOWN"};
}else{
if ($authpass =~ /^0x/ ) {
$auth = "-authkey => $authpass" ;
}else{
$auth = "-authpassword => $authpass";
}
}
}
# Privacy (DES encryption) wanted
if ($seclevel eq 'authPriv' ) {
if (! defined $privpass) {
usage();
exit $ERRORS{"UNKNOWN"};
}else{
if ($privpass =~ /^0x/){
$priv = "-privkey => $privpass";
}else{
$priv = "-privpassword => $privpass";
}
}
}
# Context name defined or default
unless ( defined $context) {
$context = "";
}
}else {
usage();
exit $ERRORS{'UNKNOWN'}; ;
}
} # end snmpv3
# for snmp v1 & v2c we default to community = "public"
# Excluded interfaces types (ifType) (backup interfaces, dial-on demand interfaces, PPP interfaces
if (defined $opt_x) {
my @x = split(/,/, $opt_x);
if ( @x) {
foreach $key (@x){
$excluded{$key} = 1;
}
}else{
$excluded{23} = 1; # default PPP(23) if empty list - note (AIX seems to think PPP is 22 according to a post)
}
}
# Excluded interface ports (ifIndex) - management reasons
if ($opt_u) {
@unused_ports = split(/,/,$opt_u);
foreach $key (@unused_ports) {
$ifStatus{$key}{'notInUse'}++ ;
}
}
if (! utils::is_hostname($hostname)){
usage();
exit $ERRORS{"UNKNOWN"};
}
# create SNMP session handle based on options passed.
if ( ! $snmp_version ) {
$snmp_version =1 ;
}else{
if ( $snmp_version =~ /[12]/ ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port,
-version => $snmp_version,
-maxmsgsize => $maxmsgsize
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
}elsif ( $snmp_version =~ /3/ ) {
if ($seclevel eq 'noAuthNoPriv') {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
);
}elsif ( $seclevel eq 'authNoPriv' ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
-authprotocol => $authproto,
$auth
);
}elsif ($seclevel eq 'authPriv' ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-port => $port,
-version => $snmp_version,
-username => $secname,
-authprotocol => $authproto,
$auth,
$priv
);
}
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
}else{
$state='UNKNOWN';
print ("$state: No support for SNMP v$snmp_version yet\n");
exit $ERRORS{$state};
}
}
return $ERRORS{"OK"};
}

251
plugins-scripts/check_ircd.pl Executable file
View file

@ -0,0 +1,251 @@
#!/usr/bin/perl -wT
# -----------------------------------------------------------------------------
# File Name: check_ircd.pl
#
# Author: Richard Mayhew - South Africa
#
# Date: 1999/09/20
#
# $Id: check_ircd.pl,v 1.3 2002/05/07 05:35:49 sghosh Exp $
#
# Description: This script will check to see if an IRCD is running
# about how many users it has
#
# Email: netsaint@splash.co.za
#
# -----------------------------------------------------------------------------
# Copyright 1999 (c) Richard Mayhew
#
# Credits go to Ethan Galstad for coding Nagios
#
# If any changes are made to this script, please mail me a copy of the
# changes :)
#
# Some code taken from Charlie Cook (check_disk.pl)
#
# License GPL
#
# -----------------------------------------------------------------------------
# Date Author Reason
# ---- ------ ------
#
# 1999/09/20 RM Creation
#
# 1999/09/20 TP Changed script to use strict, more secure by
# specifying $ENV variables. The bind command is
# still insecure through. Did most of my work
# with perl -wT and 'use strict'
#
# test using check_ircd.pl (irc-2.mit.edu|irc.erols.com|irc.core.com)
# 2002/05/02 SG Fixed for Embedded Perl
#
# ----------------------------------------------------------------[ Require ]--
require 5.004;
# -------------------------------------------------------------------[ Uses ]--
use Socket;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
use vars qw($PROGNAME);
use lib utils.pm;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# ----------------------------------------------------[ Function Prototypes ]--
sub print_help ();
sub print_usage ();
sub connection ($$$$);
sub bindRemote ($$$);
# -------------------------------------------------------------[ Enviroment ]--
$ENV{PATH} = "";
$ENV{ENV} = "";
$ENV{BASH_ENV} = "";
# -----------------------------------------------------------------[ Global ]--
$PROGNAME = "check_ircd";
my $NICK="ircd$$";
my $USER_INFO="monitor localhost localhost : ";
# -------------------------------------------------------------[ connection ]--
sub connection ($$$$)
{
my ($in_remotehost,$in_users,$in_warn,$in_crit) = @_;
my $state;
my $answer;
print "connection(debug): users = $in_users\n" if $verbose;
$in_users =~ s/\ //g;
if ($in_users >= 0) {
if ($in_users > $in_crit) {
$state = "CRITICAL";
$answer = "Critical Number Of Clients Connected : $in_users (Limit = $in_crit)\n";
} elsif ($in_users > $in_warn) {
$state = "WARNING";
$answer = "Warning Number Of Clients Connected : $in_users (Limit = $in_warn)\n";
} else {
$state = "OK";
$answer = "IRCD ok - Current Local Users: $in_users\n";
}
} else {
$state = "UNKNOWN";
$answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n";
}
print ClientSocket "quit\n";
print $answer;
exit $ERRORS{$state};
}
# ------------------------------------------------------------[ print_usage ]--
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>]\n";
}
# -------------------------------------------------------------[ print_help ]--
sub print_help ()
{
print_revision($PROGNAME,'$Revision: 1.3 $ ');
print "Copyright (c) 2000 Richard Mayhew/Karl DeBisschop
Perl Check IRCD plugin for Nagios
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-w, --warning=INTEGER
Number of connected users which generates a warning state (Default: 50)
-c, --critical=INTEGER
Number of connected users which generates a critical state (Default: 100)
-p, --port=INTEGER
Port that the ircd daemon is running on <host> (Default: 6667)
-v, --verbose
Print extra debugging information
";
}
# -------------------------------------------------------------[ bindRemote ]--
sub bindRemote ($$$)
{
my ($in_remotehost, $in_remoteport, $in_hostname) = @_;
my $proto = getprotobyname('tcp');
my $sockaddr;
my $this;
my $thisaddr = gethostbyname($in_hostname);
my $that;
my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
# ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname);
if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) {
print "IRCD UNKNOWN: Could not start socket ($!)\n";
exit $ERRORS{"UNKNOWN"};
}
$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr);
if (!bind(ClientSocket, $this)) {
print "IRCD UNKNOWN: Could not bind socket ($!)\n";
exit $ERRORS{"UNKNOWN"};
}
if (!connect(ClientSocket, $that)) {
print "IRCD UNKNOWN: Could not connect socket ($!)\n";
exit $ERRORS{"UNKNOWN"};
}
select(ClientSocket); $| = 1; select(STDOUT);
return \*ClientSocket;
}
# ===================================================================[ MAIN ]==
MAIN:
{
my $hostname;
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose,"verbose" => \$verbose,
"t=i" => \$opt_t, "timeout=i" => \$opt_t,
"w=i" => \$opt_w, "warning=i" => \$opt_w,
"c=i" => \$opt_c, "critical=i" => \$opt_c,
"p=i" => \$opt_p, "port=i" => \$opt_p,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.3 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n");
my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($remotehost) || usage("Invalid host: $opt_H\n");
($opt_w) || ($opt_w = shift) || ($opt_w = 50);
my $warn = $1 if ($opt_w =~ /^([0-9]+)$/);
($warn) || usage("Invalid warning threshold: $opt_w\n");
($opt_c) || ($opt_c = shift) || ($opt_c = 100);
my $crit = $1 if ($opt_c =~ /^([0-9]+)$/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
($opt_p) || ($opt_p = shift) || ($opt_p = 6667);
my $remoteport = $1 if ($opt_p =~ /^([0-9]+)$/);
($remoteport) || usage("Invalid port: $opt_p\n");
if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; }
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
chomp($hostname = `/bin/hostname`);
$hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/);
my ($name, $alias, $proto) = getprotobyname('tcp');
print "MAIN(debug): hostname = $hostname\n" if $verbose;
print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose;
my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname);
print ClientSocket "NICK $NICK\nUSER $USER_INFO\n";
while (<ClientSocket>) {
print "MAIN(debug): default var = $_\n" if $verbose;
# DALnet,LagNet,UnderNet etc. Require this!
# Replies with a PONG when presented with a PING query.
# If a server doesn't require it, it will be ignored.
if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";}
alarm(0);
# Look for pattern in IRCD Output to gather Client Connections total.
connection($remotehost,$1,$warn,$crit) if (m/:I have\s+(\d+)/);
}
print "IRCD UNKNOWN: Unknown error - maybe could not authenticate\n";
exit $ERRORS{"UNKNOWN"};
}

219
plugins-scripts/check_log.sh Executable file
View file

@ -0,0 +1,219 @@
#!/bin/sh
#
# Log file pattern detector plugin for Nagios
# Written by Ethan Galstad (nagios@nagios.org)
# Last Modified: 07-31-1999
#
# Usage: ./check_log <log_file> <old_log_file> <pattern>
#
# Description:
#
# This plugin will scan a log file (specified by the <log_file> option)
# for a specific pattern (specified by the <pattern> option). Successive
# calls to the plugin script will only report *new* pattern matches in the
# log file, since an copy of the log file from the previous run is saved
# to <old_log_file>.
#
# Output:
#
# On the first run of the plugin, it will return an OK state with a message
# of "Log check data initialized". On successive runs, it will return an OK
# state if *no* pattern matches have been found in the *difference* between the
# log file and the older copy of the log file. If the plugin detects any
# pattern matches in the log diff, it will return a CRITICAL state and print
# out a message is the following format: "(x) last_match", where "x" is the
# total number of pattern matches found in the file and "last_match" is the
# last entry in the log file which matches the pattern.
#
# Notes:
#
# If you use this plugin make sure to keep the following in mind:
#
# 1. The "max_attempts" value for the service should be 1, as this
# will prevent Nagios from retrying the service check (the
# next time the check is run it will not produce the same results).
#
# 2. The "notify_recovery" value for the service should be 0, so that
# Nagios does not notify you of "recoveries" for the check. Since
# pattern matches in the log file will only be reported once and not
# the next time, there will always be "recoveries" for the service, even
# though recoveries really don't apply to this type of check.
#
# 3. You *must* supply a different <old_file_log> for each service that
# you define to use this plugin script - even if the different services
# check the same <log_file> for pattern matches. This is necessary
# because of the way the script operates.
#
# Examples:
#
# Check for login failures in the syslog...
#
# check_log /var/log/messages ./check_log.badlogins.old "LOGIN FAILURE"
#
# Check for port scan alerts generated by Psionic's PortSentry software...
#
# check_log /var/log/message ./check_log.portscan.old "attackalert"
#
# Paths to commands used in this script. These
# may have to be modified to match your system setup.
# TV: removed PATH restriction. Need to think more about what this means overall
#PATH=""
ECHO="/bin/echo"
GREP="/bin/egrep"
DIFF="/bin/diff"
TAIL="/bin/tail"
CAT="/bin/cat"
RM="/bin/rm"
CHMOD="/bin/chmod"
TOUCH="/bin/touch"
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.7 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "Log file pattern detector plugin for Nagios"
echo ""
support
}
# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 1 ]; then
print_usage
exit $STATE_UNKNOWN
fi
# Grab the command line arguments
#logfile=$1
#oldlog=$2
#query=$3
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $VERSION
exit $STATE_OK
;;
--filename)
logfile=$2
shift
;;
-F)
logfile=$2
shift
;;
--oldlog)
oldlog=$2
shift
;;
-O)
oldlog=$2
shift
;;
--query)
query=$2
shift
;;
-q)
query=$2
shift
;;
-x)
exitstatus=$2
shift
;;
--exitstatus)
exitstatus=$2
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
# If the source log file doesn't exist, exit
if [ ! -e $logfile ]; then
$ECHO "Log check error: Log file $logfile does not exist!\n"
exit $STATE_UNKNOWN
elif [ ! -r $logfile ] ; then
$ECHO "Log check error: Log file $logfile is not readable!\n"
exit $STATE_UNKNOWN
fi
# If the old log file doesn't exist, this must be the first time
# we're running this test, so copy the original log file over to
# the old diff file and exit
if [ ! -e $oldlog ]; then
$CAT $logfile > $oldlog
$ECHO "Log check data initialized...\n"
exit $STATE_OK
fi
# The old log file exists, so compare it to the original log now
# The temporary file that the script should use while
# processing the log file.
if [ -x /bin/mktemp ]; then
tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX`
else
tempdiff=`/bin/date '+%H%M%S'`
tempdiff="/tmp/check_log.${tempdiff}"
$TOUCH $tempdiff
$CHMOD 600 $tempdiff
fi
$DIFF $logfile $oldlog > $tempdiff
# Count the number of matching log entries we have
count=`$GREP -c "$query" $tempdiff`
# Get the last matching entry in the diff file
lastentry=`$GREP "$query" $tempdiff | $TAIL -1`
$RM -f $tempdiff
$CAT $logfile > $oldlog
if [ "$count" = "0" ]; then # no matches, exit with no error
$ECHO "Log check ok - 0 pattern matches found\n"
exitstatus=$STATE_OK
else # Print total matche count and the last entry we found
$ECHO "($count) $lastentry"
exitstatus=$STATE_CRITICAL
fi
exit $exitstatus

609
plugins-scripts/check_mailq.pl Executable file
View file

@ -0,0 +1,609 @@
#!/usr/local/bin/perl -w
# check_mailq - check to see how many messages are in the smtp queue awating
# transmittal.
#
# Initial version support sendmail's mailq command
# Support for mutiple sendmail queues (Carlos Canau)
# Support for qmail (Benjamin Schmid)
# 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 2 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, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: check_mailq.pl,v 1.7 2006/07/05 13:45:57 tonvoon Exp $
#
############################################################################
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t
$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines
%srcdomains %dstdomains);
use lib utils.pm;
use utils qw(%ERRORS &print_revision &support &usage );
sub print_help ();
sub print_usage ();
sub process_arguments ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$PROGNAME = "check_mailq";
$mailq = 'sendmail'; # default
$msg_q = 0 ;
$msg_p = 0 ;
$state = $ERRORS{'UNKNOWN'};
Getopt::Long::Configure('bundling');
$status = process_arguments();
if ($status){
print "ERROR: processing arguments\n";
exit $ERRORS{"UNKNOWN"};
}
$SIG{'ALRM'} = sub {
print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
exit $ERRORS{"WARNING"};
};
alarm($opt_t);
# switch based on MTA
if ($mailq eq "sendmail") {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
}elsif( defined $utils::PATH_TO_MAILQ){
unless (-x $utils::PATH_TO_MAILQ) {
print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
exit $ERRORS{'UNKNOWN'};
}
} else {
print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
exit $ERRORS{'UNKNOWN'};
}
# single queue empty
##/var/spool/mqueue is empty
# single queue: 1
## /var/spool/mqueue (1 request)
##----Q-ID---- --Size-- -----Q-Time----- ------------Sender/Recipient------------
##h32E30p01763 2782 Wed Apr 2 15:03 <silvaATkpnqwest.pt>
## 8BITMIME
## <silvaATeunet.pt>
# multi queue empty
##/var/spool/mqueue/q0/df is empty
##/var/spool/mqueue/q1/df is empty
##/var/spool/mqueue/q2/df is empty
##/var/spool/mqueue/q3/df is empty
##/var/spool/mqueue/q4/df is empty
##/var/spool/mqueue/q5/df is empty
##/var/spool/mqueue/q6/df is empty
##/var/spool/mqueue/q7/df is empty
##/var/spool/mqueue/q8/df is empty
##/var/spool/mqueue/q9/df is empty
##/var/spool/mqueue/qA/df is empty
##/var/spool/mqueue/qB/df is empty
##/var/spool/mqueue/qC/df is empty
##/var/spool/mqueue/qD/df is empty
##/var/spool/mqueue/qE/df is empty
##/var/spool/mqueue/qF/df is empty
## Total Requests: 0
# multi queue: 1
##/var/spool/mqueue/q0/df is empty
##/var/spool/mqueue/q1/df is empty
##/var/spool/mqueue/q2/df is empty
## /var/spool/mqueue/q3/df (1 request)
##----Q-ID---- --Size-- -----Q-Time----- ------------Sender/Recipient------------
##h32De2f23534* 48 Wed Apr 2 14:40 nocol
## nouserATEUnet.pt
## canau
##/var/spool/mqueue/q4/df is empty
##/var/spool/mqueue/q5/df is empty
##/var/spool/mqueue/q6/df is empty
##/var/spool/mqueue/q7/df is empty
##/var/spool/mqueue/q8/df is empty
##/var/spool/mqueue/q9/df is empty
##/var/spool/mqueue/qA/df is empty
##/var/spool/mqueue/qB/df is empty
##/var/spool/mqueue/qC/df is empty
##/var/spool/mqueue/qD/df is empty
##/var/spool/mqueue/qE/df is empty
##/var/spool/mqueue/qF/df is empty
## Total Requests: 1
while (<MAILQ>) {
# match email addr on queue listing
if ( (/<.*@.*\.(\w+\.\w+)>/) || (/<.*@(\w+\.\w+)>/) ) {
my $domain = $1;
if (/^\w+/) {
print "$utils::PATH_TO_MAILQ = srcdomain = $domain \n" if $verbose ;
$srcdomains{$domain} ++;
}
next;
}
#
# ...
# sendmail considers a message with more than one destiny, say N, to the same MX
# to have N messages in queue.
# we will only consider one in this code
if (( /\s\(reply:\sread\serror\sfrom\s.*\.(\w+\.\w+)\.$/ ) || ( /\s\(reply:\sread\serror\sfrom\s(\w+\.\w+)\.$/ ) ||
( /\s\(timeout\swriting\smessage\sto\s.*\.(\w+\.\w+)\.:/ ) || ( /\s\(timeout\swriting\smessage\sto\s(\w+\.\w+)\.:/ ) ||
( /\s\(host\smap:\slookup\s\(.*\.(\w+\.\w+)\):/ ) || ( /\s\(host\smap:\slookup\s\((\w+\.\w+)\):/ ) ||
( /\s\(Deferred:\s.*\s.*\.(\w+\.\w+)\.\)/ ) || ( /\s\(Deferred:\s.*\s(\w+\.\w+)\.\)/ ) ) {
print "$utils::PATH_TO_MAILQ = dstdomain = $1 \n" if $verbose ;
$dstdomains{$1} ++;
}
if (/\s+\(I\/O\serror\)/) {
print "$utils::PATH_TO_MAILQ = dstdomain = UNKNOWN \n" if $verbose ;
$dstdomains{'UNKNOWN'} ++;
}
# Finally look at the overall queue length
#
if (/mqueue/) {
print "$utils::PATH_TO_MAILQ = $_ "if $verbose ;
if (/ \((\d+) request/) {
#
# single queue: first line
# multi queue: one for each queue. overwrite on multi queue below
$msg_q = $1 ;
}
} elsif (/^\s+Total\sRequests:\s(\d+)$/i) {
print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
#
# multi queue: last line
$msg_q = $1 ;
}
}
## close mailq
close (MAILQ);
if ( $? ) {
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
exit $ERRORS{CRITICAL};
}
## shut off the alarm
alarm(0);
## now check the queue length(s)
if ($msg_q == 0) {
$msg = "OK: mailq is empty";
$state = $ERRORS{'OK'};
} else {
print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
# overall queue length
if ($msg_q < $opt_w) {
$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
# check for domain specific queue lengths if requested
if (defined $opt_W) {
# Apply threshold to queue lengths FROM domain
my @srckeys = sort { $srcdomains{$b} <=> $srcdomains{$a} } keys %srcdomains;
my $srcmaxkey = $srckeys[0];
print "src max is $srcmaxkey with $srcdomains{$srcmaxkey} messages\n" if $verbose;
if ($srcdomains{$srcmaxkey} >= $opt_W && $srcdomains{$srcmaxkey} < $opt_C) {
if ($state == $ERRORS{'OK'}) {
$msg = "WARNING: $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'WARNING'};
} elsif (($state == $ERRORS{'WARNING'}) || ($state == $ERRORS{'CRITICAL'})){
$msg .= " -and- $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold W = $opt_W)";
} else {
$msg = "WARNING: $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'WARNING'};
}
} elsif ($srcdomains{$srcmaxkey} >= $opt_C) {
if ($state == $ERRORS{'OK'}) {
$msg = "CRITICAL: $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold C = $opt_C)";
$state = $ERRORS{'CRITICAL'};
} elsif ($state == $ERRORS{'WARNING'}) {
$msg = "CRITICAL: $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold C = $opt_C) -and- " . $msg;
$msg =~ s/WARNING: //;
} elsif ($state == $ERRORS{'CRITICAL'}) {
$msg .= " -and- $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold W = $opt_W)";
} else {
$msg = "CRITICAL: $srcdomains{$srcmaxkey} messages in queue FROM $srcmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'CRITICAL'};
}
} else {
if ($srcdomains{$srcmaxkey} > 0) {
$msg .= " $srcdomains{$srcmaxkey} msgs. FROM $srcmaxkey is below threshold ($opt_W/$opt_C)";
}
}
# Apply threshold to queue lengths TO domain
my @dstkeys = sort { $dstdomains{$b} <=> $dstdomains{$a} } keys %dstdomains;
my $dstmaxkey = $dstkeys[0];
print "dst max is $dstmaxkey with $dstdomains{$dstmaxkey} messages\n" if $verbose;
if ($dstdomains{$dstmaxkey} >= $opt_W && $dstdomains{$dstmaxkey} < $opt_C) {
if ($state == $ERRORS{'OK'}) {
$msg = "WARNING: $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'WARNING'};
} elsif (($state == $ERRORS{'WARNING'}) || ($state == $ERRORS{'CRITICAL'})){
$msg .= " -and- $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold W = $opt_W)";
} else {
$msg = "WARNING: $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'WARNING'};
}
} elsif ($dstdomains{$dstmaxkey} >= $opt_C) {
if ($state == $ERRORS{'OK'}) {
$msg = "CRITICAL: $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold C = $opt_C)";
$state = $ERRORS{'CRITICAL'};
} elsif ($state == $ERRORS{'WARNING'}) {
$msg = "CRITICAL: $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold C = $opt_C) -and- " . $msg;
$msg =~ s/WARNING: //;
} elsif ($state == $ERRORS{'CRITICAL'}) {
$msg .= " -and- $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold W = $opt_W)";
} else {
$msg = "CRITICAL: $dstdomains{$dstmaxkey} messages in queue TO $dstmaxkey (threshold W = $opt_W)";
$state = $ERRORS{'CRITICAL'};
}
} else {
if ($dstdomains{$dstmaxkey} > 0) {
$msg .= " $dstdomains{$dstmaxkey} msgs. TO $dstmaxkey is below threshold ($opt_W/$opt_C)";
}
}
} # End of queue length thresholds
}
} # end of ($mailq eq "sendmail")
elsif ( $mailq eq "postfix" ) {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
}elsif( defined $utils::PATH_TO_MAILQ){
unless (-x $utils::PATH_TO_MAILQ) {
print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
exit $ERRORS{'UNKNOWN'};
}
} else {
print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
exit $ERRORS{'UNKNOWN'};
}
@lines = reverse <MAILQ>;
# close qmail-qstat
close MAILQ;
if ( $? ) {
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
exit $ERRORS{CRITICAL};
}
## shut off the alarm
alarm(0);
# check queue length
if ($lines[0]=~/Kbytes in (\d+)/) {
$msg_q = $1 ;
}elsif ($lines[0]=~/Mail queue is empty/) {
$msg_q = 0;
}else{
print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
exit $ERRORS{'UNKNOWN'};
}
# check messages not processed
#if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
# my $msg_p = $1;
#}else{
# print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
# exit $ERRORS{'UNKNOWN'};
#}
# check queue length(s)
if ($msg_q == 0){
$msg = "OK: mailq reports queue is empty";
$state = $ERRORS{'OK'};
} else {
print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
# overall queue length
if ($msg_q < $opt_w) {
$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
# check messages not yet preprocessed (only compare is $opt_W and $opt_C
# are defined)
#if (defined $opt_W) {
# $msg .= "[Preprocessed = $msg_p]";
# if ($msg_p >= $opt_W && $msg_p < $opt_C ) {
# $state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"} ;
# }elsif ($msg_p >= $opt_C ) {
# $state = $ERRORS{"CRITICAL"} ;
# }
#}
}
} # end of ($mailq eq "postfixl")
elsif ( $mailq eq "qmail" ) {
# open qmail-qstat
if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) {
if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) {
print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n";
exit $ERRORS{'UNKNOWN'};
}
}elsif( defined $utils::PATH_TO_QMAIL_QSTAT){
unless (-x $utils::PATH_TO_QMAIL_QSTAT) {
print "ERROR: $utils::PATH_TO_QMAIL_QSTAT is not executable by (uid $>:gid($)))\n";
exit $ERRORS{'UNKNOWN'};
}
} else {
print "ERROR: \$utils::PATH_TO_QMAIL_QSTAT is not defined\n";
exit $ERRORS{'UNKNOWN'};
}
@lines = <MAILQ>;
# close qmail-qstat
close MAILQ;
if ( $? ) {
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
exit $ERRORS{CRITICAL};
}
## shut off the alarm
alarm(0);
# check queue length
if ($lines[0]=~/^messages in queue: (\d+)/) {
$msg_q = $1 ;
}else{
print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
exit $ERRORS{'UNKNOWN'};
}
# check messages not processed
if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
my $msg_p = $1;
}else{
print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n";
exit $ERRORS{'UNKNOWN'};
}
# check queue length(s)
if ($msg_q == 0){
$msg = "OK: qmail-qstat reports queue is empty";
$state = $ERRORS{'OK'};
} else {
print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
# overall queue length
if ($msg_q < $opt_w) {
$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
# check messages not yet preprocessed (only compare is $opt_W and $opt_C
# are defined)
if (defined $opt_W) {
$msg .= "[Preprocessed = $msg_p]";
if ($msg_p >= $opt_W && $msg_p < $opt_C ) {
$state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"} ;
}elsif ($msg_p >= $opt_C ) {
$state = $ERRORS{"CRITICAL"} ;
}
}
}
} # end of ($mailq eq "qmail")
elsif ( $mailq eq "exim" ) {
## open mailq
if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
exit $ERRORS{'UNKNOWN'};
}
}elsif( defined $utils::PATH_TO_MAILQ){
unless (-x $utils::PATH_TO_MAILQ) {
print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
exit $ERRORS{'UNKNOWN'};
}
} else {
print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
exit $ERRORS{'UNKNOWN'};
}
while (<MAILQ>) {
#22m 1.7K 19aEEr-0007hx-Dy <> *** frozen ***
#root@exlixams.glups.fr
if (/\s[\w\d]{6}-[\w\d]{6}-[\w\d]{2}\s/) { # message id 19aEEr-0007hx-Dy
$msg_q++ ;
}
}
close(MAILQ) ;
if ( $? ) {
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
exit $ERRORS{CRITICAL};
}
if ($msg_q < $opt_w) {
$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
$msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
$msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
} # end of ($mailq eq "exim")
# Perfdata support
print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n";
exit $state;
#####################################
#### subs
sub process_arguments(){
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"v" => \$opt_v, "verbose" => \$opt_v,
"h" => \$opt_h, "help" => \$opt_h,
"M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail)
"w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
"c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
"t=i" => \$opt_t, "timeout=i" => \$opt_t
);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.7 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if (defined $opt_v ){
$verbose = $opt_v;
}
unless (defined $opt_t) {
$opt_t = $utils::TIMEOUT ; # default timeout
}
unless ( defined $opt_w && defined $opt_c ) {
print_usage();
exit $ERRORS{'UNKNOWN'};
}
if ( $opt_w >= $opt_c) {
print "Warning (-w) cannot be greater than Critical (-c)!\n";
exit $ERRORS{'UNKNOWN'};
}
if (defined $opt_W && ! defined !$opt_C) {
print "Need -C if using -W\n";
exit $ERRORS{'UNKNOWN'};
}elsif(defined $opt_W && defined $opt_C) {
if ($opt_W >= $opt_C) {
print "Warning (-W) cannot be greater than Critical (-C)!\n";
exit $ERRORS{'UNKNOWN'};
}
}
if (defined $opt_M) {
if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) {
$mailq = $opt_M ;
}elsif( $opt_M eq ''){
$mailq = 'sendmail';
}else{
print "-M: $opt_M is not supported\n";
exit $ERRORS{'UNKNOWN'};
}
}else{
$mailq = 'sendmail' ;
}
return $ERRORS{'OK'};
}
sub print_usage () {
print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.7 $');
print "Copyright (c) 2002 Subhendu Ghosh/Carlos Canau/Benjamin Schmid\n";
print "\n";
print_usage();
print "\n";
print " Checks the number of messages in the mail queue (supports multiple sendmail queues, qmail)\n";
print " Feedback/patches to support non-sendmail mailqueue welcome\n\n";
print "-w (--warning) = Min. number of messages in queue to generate warning\n";
print "-c (--critical) = Min. number of messages in queu to generate critical alert ( w < c )\n";
print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n";
print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n";
print "-h (--help)\n";
print "-V (--version)\n";
print "-v (--verbose) = debugging output\n";
print "\n\n";
print "Note: -w and -c are required arguments. -W and -C are optional.\n";
print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
print " -W and -C are applied message not yet preproccessed. (qmail)\n";
print " This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)\n";
print " to look at the queues. Mailq can usually only be accessed by root or \n";
print " a TrustedUser. You will have to set appropriate permissions for the plugin to work.\n";
print "";
print "\n\n";
support();
}

472
plugins-scripts/check_ntp.pl Executable file
View file

@ -0,0 +1,472 @@
#!/usr/bin/perl -w
#
# (c)1999 Ian Cass, Knowledge Matters Ltd.
# Read the GNU copyright stuff for all the legalese
#
# Check NTP time servers plugin. This plugin requires the ntpdate utility to
# be installed on the system, however since it's part of the ntp suite, you
# should already have it installed.
#
# $Id: check_ntp.pl,v 1.31 2005/11/30 00:49:47 harpermann Exp $
#
# Nothing clever done in this program - its a very simple bare basics hack to
# get the job done.
#
# Things to do...
# check @words[9] for time differences greater than +/- x secs & return a
# warning.
#
# (c) 1999 Mark Jewiss, Knowledge Matters Limited
# 22-9-1999, 12:45
#
# Modified script to accept 2 parameters or set defaults.
# Now issues warning or critical alert is time difference is greater than the
# time passed.
#
# These changes have not been tested completely due to the unavailability of a
# server with the incorrect time.
#
# (c) 1999 Bo Kersey, VirCIO - Managed Server Solutions <bo@vircio.com>
# 22-10-99, 12:17
#
# Modified the script to give useage if no parameters are input.
#
# Modified the script to check for negative as well as positive
# time differences.
#
# Modified the script to work with ntpdate 3-5.93e Wed Apr 14 20:23:03 EDT 1999
#
# Modified the script to work with ntpdate's that return adjust or offset...
#
#
# Script modified 2000 June 01 by William Pietri <william@bianca.com>
#
# Modified script to handle weird cases:
# o NTP server doesn't respond (e.g., has died)
# o Server has correct time but isn't suitable synchronization
# source. This happens while starting up and if contact
# with master has been lost.
#
# Modifed to run under Embedded Perl (sghosh@users.sf.net)
# - combined logic some blocks together..
#
# Added ntpdate check for stratum 16 desynch peer (James Fidell) Feb 03, 2003
#
# ntpdate - offset is in seconds
# changed ntpdc to ntpq - jitter/dispersion is in milliseconds
#
# Patch for for regex for stratum1 refid.
require 5.004;
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_H $opt_t $opt_w $opt_c $opt_O $opt_j $opt_k $verbose $PROGNAME $def_jitter $ipv4 $ipv6);
use lib utils.pm;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
$PROGNAME="check_ntp";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
# defaults in sec
my $DEFAULT_OFFSET_WARN = 60; # 1 minute
my $DEFAULT_OFFSET_CRIT = 120; # 2 minutes
# default in millisec
my $DEFAULT_JITTER_WARN = 5000; # 5 sec
my $DEFAULT_JITTER_CRIT = 10000; # 10 sec
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose, "verbose" => \$verbose,
"4" => \$ipv4, "use-ipv4" => \$ipv4,
"6" => \$ipv6, "use-ipv6" => \$ipv6,
"w=f" => \$opt_w, "warning=f" => \$opt_w, # offset|adjust warning if above this number
"c=f" => \$opt_c, "critical=f" => \$opt_c, # offset|adjust critical if above this number
"O" => \$opt_O, "zero-offset" => \$opt_O, # zero-offset bad
"j=s" => \$opt_j, "jwarn=i" => \$opt_j, # jitter warning if above this number
"k=s" => \$opt_k, "jcrit=i" => \$opt_k, # jitter critical if above this number
"t=s" => \$opt_t, "timeout=i" => \$opt_t,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.31 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
# jitter test params specified
if (defined $opt_j || defined $opt_k ) {
$def_jitter = 1;
}
$opt_H = shift unless ($opt_H);
my $host = $1 if ($opt_H && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/);
unless ($host) {
print "No target host specified\n";
print_usage();
exit $ERRORS{'UNKNOWN'};
}
my ($timeout, $owarn, $ocrit, $jwarn, $jcrit);
$timeout = $TIMEOUT;
($opt_t) && ($opt_t =~ /^([0-9]+)$/) && ($timeout = $1);
$owarn = $DEFAULT_OFFSET_WARN;
($opt_w) && ($opt_w =~ /^([0-9.]+)$/) && ($owarn = $1);
$ocrit = $DEFAULT_OFFSET_CRIT;
($opt_c) && ($opt_c =~ /^([0-9.]+)$/) && ($ocrit = $1);
$jwarn = $DEFAULT_JITTER_WARN;
($opt_j) && ($opt_j =~ /^([0-9]+)$/) && ($jwarn = $1);
$jcrit = $DEFAULT_JITTER_CRIT;
($opt_k) && ($opt_k =~ /^([0-9]+)$/) && ($jcrit = $1);
if ($ocrit < $owarn ) {
print "Critical offset should be larger than warning offset\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($def_jitter) {
if ($opt_k < $opt_j) {
print "Critical jitter should be larger than warning jitter\n";
print_usage();
exit $ERRORS{'UNKNOWN'};
}
}
my $stratum = -1;
my $ignoreret = 0;
my $answer = undef;
my $offset = undef;
my $jitter = undef;
my $syspeer = undef;
my $candidate = 0;
my @candidates;
my $msg; # first line of output to print if format is invalid
my $state = $ERRORS{'UNKNOWN'};
my $ntpdate_error = $ERRORS{'UNKNOWN'};
my $jitter_error = $ERRORS{'UNKNOWN'};
# some systems don't have a proper ntpq (migrated from ntpdc)
my $have_ntpq = undef;
if ($utils::PATH_TO_NTPQ && -x $utils::PATH_TO_NTPQ ) {
$have_ntpq = 1;
}else{
$have_ntpq = 0;
}
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: No response from ntp server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($timeout);
# Determine protocol to be used for ntpdate and ntpq
my $ntpdate = $utils::PATH_TO_NTPDATE;
my $ntpq = $utils::PATH_TO_NTPQ;
if ($ipv4) {
$ntpdate .= " -4";
$ntpq .= " -4";
}
elsif ($ipv6) {
$ntpdate .= " -6";
$ntpq .= " -6";
}
# else don't use any flags
###
###
### First, check ntpdate
###
###
if (!open (NTPDATE, $ntpdate . " -q $host 2>&1 |")) {
print "Could not open $ntpdate: $!\n";
exit $ERRORS{"UNKNOWN"};
}
my $out;
while (<NTPDATE>) {
#print if ($verbose); # noop
$msg = $_ unless ($msg);
$out .= "$_ ";
if (/stratum\s(\d+)/) {
$stratum = $1;
}
if (/(offset|adjust)\s+([-.\d]+)/i) {
$offset = $2;
# An offset of 0.000000 with an error is probably bogus. Actually,
# it's probably always bogus, but let's be paranoid here.
# Has been reported that 0.0000 happens in a production environment
# on Solaris 8 so this check should be taken out - SF tracker 1150777
if (defined $opt_O ) {
if ($offset == 0) { undef $offset;}
}
$ntpdate_error = defined ($offset) ? $ERRORS{"OK"} : $ERRORS{"CRITICAL"};
print "ntperr = $ntpdate_error \n" if $verbose;
}
if (/no server suitable for synchronization found/) {
if ($stratum == 16) {
$ntpdate_error = $ERRORS{"WARNING"};
$msg = "Desynchronized peer server found";
$ignoreret=1;
}
else {
$ntpdate_error = $ERRORS{"CRITICAL"};
$msg = "No suitable peer server found - ";
}
}
}
$out =~ s/\n//g;
close (NTPDATE) ||
die $! ? "$out - Error closing $ntpdate pipe: $!"
: "$out - Exit status: $? from $ntpdate\n";
# declare an error if we also get a non-zero return code from ntpdate
# unless already set to critical
if ( $? && !$ignoreret ) {
print "stderr = $? : $! \n" if $verbose;
$ntpdate_error = $ntpdate_error == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"UNKNOWN"} ;
print "ntperr = $ntpdate_error : $!\n" if $verbose;
}
###
###
### Then scan xntpq/ntpq if it exists
### and look in the 11th column for jitter
###
# Field 1: Tally Code ( Space, 'x','.','-','+','#','*','o')
# Only match for '*' which implies sys.peer
# or 'o' which implies pps.peer
# If both exist, the last one is picked.
# Field 2: address of the remote peer
# Field 3: Refid of the clock (0.0.0.0 if unknown, WWWV/PPS/GPS/ACTS/USNO/PCS/... if Stratum1)
# Field 4: stratum (0-15)
# Field 5: Type of the peer: local (l), unicast (u), multicast (m)
# broadcast (b); not sure about multicast/broadcast
# Field 6: last packet receive (in seconds)
# Field 7: polling interval
# Field 8: reachability resgister (octal)
# Field 9: delay
# Field 10: offset
# Field 11: dispersion/jitter
#
# According to bug 773588 Some solaris xntpd implementations seemto match on
# "#" even though the docs say it exceeds maximum distance. Providing patch
# here which will generate a warining.
if ($have_ntpq) {
if ( open(NTPQ, $ntpq . " -np $host 2>&1 |") ) {
while (<NTPQ>) {
print $_ if ($verbose);
if ( /timed out/ ){
$have_ntpq = 0 ;
last ;
}
# number of candidates on <host> for sys.peer
if (/^(\*|\+|\#|o])/) {
++$candidate;
push (@candidates, $_);
print "Candidate count= $candidate\n" if ($verbose);
}
# match sys.peer or pps.peer
if (/^(\*|o)(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) {
$syspeer = $2;
$stratum = $4;
$jitter = $11;
print "match $_ \n" if $verbose;
if ($jitter > $jcrit) {
print "Jitter_crit = $11 :$jcrit\n" if ($verbose);
$jitter_error = $ERRORS{'CRITICAL'};
} elsif ($jitter > $jwarn ) {
print "Jitter_warn = $11 :$jwarn\n" if ($verbose);
$jitter_error = $ERRORS{'WARNING'};
} else {
$jitter_error = $ERRORS{'OK'};
}
} else {
print "No match!\n" if $verbose;
$jitter = '(not parsed)';
}
}
close NTPQ ||
die $! ? "Error closing $ntpq pipe: $!"
: "Exit status: $? from $ntpq\n";
# if we did not match sys.peer or pps.peer but matched # candidates only
# generate a warning
# based on bug id 773588
unless (defined $syspeer) {
if ($#candidates >=0) {
foreach my $c (@candidates) {
$c =~ /^(#)([-0-9.\s]+)\s+([-0-9A-Za-z_().]+)\s+([-0-9.]+)\s+([lumb-]+)\s+([-0-9m.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)\s+([-0-9.]+)/;
$syspeer = $2;
$stratum = $4;
$jitter = $11;
print "candidate match $c \n" if $verbose;
if ($jitter > $jcrit) {
print "Candidate match - Jitter_crit = $11 :$jcrit\n" if ($verbose);
$jitter_error = $ERRORS{'CRITICAL'};
}elsif ($jitter > $jwarn ) {
print "Candidate match - Jitter_warn = $11 :$jwarn \n" if ($verbose);
$jitter_error = $ERRORS{'WARNING'};
} else {
$jitter_error = $ERRORS{'WARNING'};
}
}
}
}
}
}
if ($ntpdate_error != $ERRORS{'OK'}) {
$state = $ntpdate_error;
if ($ntpdate_error == $ERRORS{'WARNING'} ) {
$answer = $msg;
}
else {
$answer = $msg . "Server for ntp probably down";
}
if (defined($offset) && abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
$answer = "Server Error and offset $offset sec > +/- $ocrit sec";
} elsif (defined($offset) && abs($offset) > $owarn) {
$answer = "Server error and offset $offset sec > +/- $owarn sec";
} elsif (defined($jitter) && abs($jitter) > $jcrit) {
$answer = "Server error and jitter $jitter msec > +/- $jcrit msec";
} elsif (defined($jitter) && abs($jitter) > $jwarn) {
$answer = "Server error and jitter $jitter msec > +/- $jwarn msec";
}
} elsif ($have_ntpq && $jitter_error != $ERRORS{'OK'}) {
$state = $jitter_error;
$answer = "Jitter $jitter too high";
if (defined($offset) && abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
$answer = "Jitter error and offset $offset sec > +/- $ocrit sec";
} elsif (defined($offset) && abs($offset) > $owarn) {
$answer = "Jitter error and offset $offset sec > +/- $owarn sec";
} elsif (defined($jitter) && abs($jitter) > $jcrit) {
$answer = "Jitter error and jitter $jitter msec > +/- $jcrit msec";
} elsif (defined($jitter) && abs($jitter) > $jwarn) {
$answer = "Jitter error and jitter $jitter msec > +/- $jwarn msec";
}
} elsif( !$have_ntpq ) { # no errors from ntpdate and no ntpq or ntpq timed out
if (abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
$answer = "Offset $offset sec > +/- $ocrit sec";
} elsif (abs($offset) > $owarn) {
$state = $ERRORS{'WARNING'};
$answer = "Offset $offset sec > +/- $owarn sec";
} elsif (( abs($offset) > $owarn) && $def_jitter ) {
$state = $ERRORS{'WARNING'};
$answer = "Offset $offset sec > +/- $owarn sec, ntpq timed out";
} elsif ( $def_jitter ) {
$state = $ERRORS{'WARNING'};
$answer = "Offset $offset secs, ntpq timed out";
} else{
$state = $ERRORS{'OK'};
$answer = "Offset $offset secs";
}
} else { # no errors from ntpdate or ntpq
if (abs($offset) > $ocrit) {
$state = $ERRORS{'CRITICAL'};
$answer = "Offset $offset sec > +/- $ocrit sec, jitter $jitter msec";
} elsif (abs($jitter) > $jcrit ) {
$state = $ERRORS{'CRITICAL'};
$answer = "Jitter $jitter msec> +/- $jcrit msec, offset $offset sec";
} elsif (abs($offset) > $owarn) {
$state = $ERRORS{'WARNING'};
$answer = "Offset $offset sec > +/- $owarn sec, jitter $jitter msec";
} elsif (abs($jitter) > $jwarn ) {
$state = $ERRORS{'WARNING'};
$answer = "Jitter $jitter msec> +/- $jwarn msec, offset $offset sec";
} else {
$state = $ERRORS{'OK'};
$answer = "Offset $offset secs, jitter $jitter msec, peer is stratum $stratum";
}
}
foreach my $key (keys %ERRORS) {
if ($state==$ERRORS{$key}) {
# print ("NTP $key: $answer");
print ("NTP $key: $answer|offset=$offset, jitter=" . $jitter/1000 . ",peer_stratum=$stratum\n");
last;
}
}
exit $state;
####
#### subs
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-46] [-O] [-w <warn>] [-c <crit>] [-j <warn>] [-k <crit>] [-v verbose]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.31 $');
print "Copyright (c) 2003 Bo Kersey/Karl DeBisschop\n";
print "\n";
print_usage();
print "
Checks the local timestamp offset versus <host> with ntpdate
Checks the jitter/dispersion of clock signal between <host> and its sys.peer with ntpq\n
-O (--zero-offset)
A zero offset on \"ntpdate\" will generate a CRITICAL.\n
-w (--warning)
Clock offset in seconds at which a warning message will be generated.\n Defaults to $DEFAULT_OFFSET_WARN.
-c (--critical)
Clock offset in seconds at which a critical message will be generated.\n Defaults to $DEFAULT_OFFSET_CRIT.
-j (--jwarn)
Clock jitter in milliseconds at which a warning message will be generated.\n Defaults to $DEFAULT_JITTER_WARN.
-k (--jcrit)
Clock jitter in milliseconds at which a critical message will be generated.\n Defaults to $DEFAULT_JITTER_CRIT.
If jitter/dispersion is specified with -j or -k and ntpq times out, then a
warning is returned.\n
-4 (--use-ipv4)
Use IPv4 connection
-6 (--use-ipv6)
Use IPv6 connection
\n";
support();
}

285
plugins-scripts/check_oracle.sh Executable file
View file

@ -0,0 +1,285 @@
#!/bin/sh
#
# latigid010@yahoo.com
# 01/06/2000
#
# This Nagios plugin was created to check Oracle status
#
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.15 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage:"
echo " $PROGNAME --tns <Oracle Sid or Hostname/IP address>"
echo " $PROGNAME --db <ORACLE_SID>"
echo " $PROGNAME --login <ORACLE_SID>"
echo " $PROGNAME --cache <ORACLE_SID> <USER> <PASS> <CRITICAL> <WARNING>"
echo " $PROGNAME --tablespace <ORACLE_SID> <USER> <PASS> <TABLESPACE> <CRITICAL> <WARNING>"
echo " $PROGNAME --oranames <Hostname>"
echo " $PROGNAME --help"
echo " $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "Check Oracle status"
echo ""
echo "--tns SID/IP Address"
echo " Check remote TNS server"
echo "--db SID"
echo " Check local database (search /bin/ps for PMON process) and check"
echo " filesystem for sgadefORACLE_SID.dbf"
echo "--login SID"
echo " Attempt a dummy login and alert if not ORA-01017: invalid username/password"
echo "--cache"
echo " Check local database for library and buffer cache hit ratios"
echo " ---> Requires Oracle user/password and SID specified."
echo " ---> Requires select on v_$sysstat and v_$librarycache"
echo "--tablespace"
echo " Check local database for tablespace capacity in ORACLE_SID"
echo " ---> Requires Oracle user/password specified."
echo " ---> Requires select on dba_data_files and dba_free_space"
echo "--oranames Hostname"
echo " Check remote Oracle Names server"
echo "--help"
echo " Print this help screen"
echo "--version"
echo " Print version and license information"
echo ""
echo "If the plugin doesn't work, check that the ORACLE_HOME environment"
echo "variable is set, that ORACLE_HOME/bin is in your PATH, and the"
echo "tnsnames.ora file is locatable and is properly configured."
echo ""
echo "When checking local database status your ORACLE_SID is case sensitive."
echo ""
echo "If you want to use a default Oracle home, add in your oratab file:"
echo "*:/opt/app/oracle/product/7.3.4:N"
echo ""
support
}
case "$1" in
1)
cmd='--tns'
;;
2)
cmd='--db'
;;
*)
cmd="$1"
;;
esac
# Information options
case "$cmd" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PLUGIN $REVISION
exit $STATE_OK
;;
-V)
print_revision $PLUGIN $REVISION
exit $STATE_OK
;;
esac
# Hunt down a reasonable ORACLE_HOME
if [ -z "$ORACLE_HOME" ] ; then
# Adjust to taste
for oratab in /var/opt/oracle/oratab /etc/oratab
do
[ ! -f $oratab ] && continue
ORACLE_HOME=`IFS=:
while read SID ORACLE_HOME junk;
do
if [ "$SID" = "$2" -o "$SID" = "*" ] ; then
echo $ORACLE_HOME;
exit;
fi;
done < $oratab`
[ -n "$ORACLE_HOME" ] && break
done
fi
# Last resort
[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle
if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then
echo "Cannot determine ORACLE_HOME for sid $2"
exit $STATE_UNKNOWN
fi
PATH=$PATH:$ORACLE_HOME/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export ORACLE_HOME PATH LD_LIBRARY_PATH
case "$cmd" in
--tns)
tnschk=` tnsping $2`
tnschk2=` echo $tnschk | grep -c OK`
if [ ${tnschk2} -eq 1 ] ; then
tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'`
echo "OK - reply time ${tnschk3} from $2"
exit $STATE_OK
else
echo "No TNS Listener on $2"
exit $STATE_CRITICAL
fi
;;
--oranames)
namesctl status $2 | awk '
/Server has been running for:/ {
msg = "OK: Up"
for (i = 6; i <= NF; i++) {
msg = msg " " $i
}
status = '$STATE_OK'
}
/error/ {
msg = "CRITICAL: " $0
status = '$STATE_CRITICAL'
}
END {
print msg
exit status
}'
;;
--db)
pmonchk=`ps -ef | grep -v grep | grep -c "ora_pmon_${2}$"`
if [ ${pmonchk} -ge 1 ] ; then
echo "${2} OK - ${pmonchk} PMON process(es) running"
exit $STATE_OK
#if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
#if [ ${pmonchk} -eq 1 ] ; then
#utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
#echo "${2} OK - running since ${utime}"
#exit $STATE_OK
#fi
else
echo "${2} Database is DOWN"
exit $STATE_CRITICAL
fi
;;
--login)
loginchk=`sqlplus dummy/user@$2 < /dev/null`
loginchk2=` echo $loginchk | grep -c ORA-01017`
if [ ${loginchk2} -eq 1 ] ; then
echo "OK - dummy login connected"
exit $STATE_OK
else
loginchk3=` echo "$loginchk" | grep "ORA-" | head -1`
echo "CRITICAL - $loginchk3"
exit $STATE_CRITICAL
fi
;;
--cache)
if [ ${5} -gt ${6} ] ; then
echo "UNKNOWN - Warning level is less then Crit"
exit $STATE_UNKNOWN
fi
result=`sqlplus -s ${3}/${4}@${2} << EOF
set pagesize 0
set numf '9999999.99'
select (1-(pr.value/(dbg.value+cg.value)))*100
from v\\$sysstat pr, v\\$sysstat dbg, v\\$sysstat cg
where pr.name='physical reads'
and dbg.name='db block gets'
and cg.name='consistent gets';
EOF`
if [ -n "`echo $result | grep ORA-`" ] ; then
error=` echo "$result" | grep "ORA-" | head -1`
echo "CRITICAL - $error"
exit $STATE_CRITICAL
fi
buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'`
buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'`
result=`sqlplus -s ${3}/${4}@${2} << EOF
set pagesize 0
set numf '9999999.99'
select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
from v\\$librarycache lc;
EOF`
if [ -n "`echo $result | grep ORA-`" ] ; then
error=` echo "$result" | grep "ORA-" | head -1`
echo "CRITICAL - $error"
exit $STATE_CRITICAL
fi
lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'`
lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'`
if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then
echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
exit $STATE_CRITICAL
fi
if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then
echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
exit $STATE_WARNING
fi
echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
exit $STATE_OK
;;
--tablespace)
if [ ${6} -lt ${7} ] ; then
echo "UNKNOWN - Warning level is more then Crit"
exit $STATE_UNKNOWN
fi
result=`sqlplus -s ${3}/${4}@${2} << EOF
set pagesize 0
set numf '9999999.99'
select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
from (
select tablespace_name,sum(bytes)/1024/1024 total
from dba_data_files group by tablespace_name) A
LEFT OUTER JOIN
( select tablespace_name,sum(bytes)/1024/1024 free
from dba_free_space group by tablespace_name) B
ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
EOF`
if [ -n "`echo $result | grep ORA-`" ] ; then
error=` echo "$result" | grep "ORA-" | head -1`
echo "CRITICAL - $error"
exit $STATE_CRITICAL
fi
ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'`
ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'`
ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'`
ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'`
if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then
echo "No data returned by Oracle - tablespace $5 not found?"
exit $STATE_UNKNOWN
fi
if [ "$ts_pct" -ge ${6} ] ; then
echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
exit $STATE_CRITICAL
fi
if [ "$ts_pct" -ge ${7} ] ; then
echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
exit $STATE_WARNING
fi
echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
exit $STATE_OK
;;
*)
print_usage
exit $STATE_UNKNOWN
esac

377
plugins-scripts/check_rpc.pl Executable file
View file

@ -0,0 +1,377 @@
#!/usr/local/bin/perl -w
#
# check_rpc plugin for nagios
#
# usage:
# check_rpc host service
#
# Check if an rpc serice is registered and running
# using rpcinfo - $proto $host $prognum 2>&1 |";
#
# Use these hosts.cfg entries as examples
#
# command[check_nfs]=/some/path/libexec/check_rpc $HOSTADDRESS$ nfs
# service[check_nfs]=NFS;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_rpc
#
# initial version: 3 May 2000 by Truongchinh Nguyen and Karl DeBisschop
# Modified May 2002 Subhendu Ghosh - support for ePN and patches
# current status: $Revision: 1.8 $
#
# Copyright Notice: GPL
# $Id: check_rpc.pl,v 1.8 2003/08/10 12:11:49 kdebisschop Exp $
#
use strict;
use lib utils.pm;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state);
my ($array_ref,$test,$element,@progkeys,$proto,$a,$b);
my ($opt_V,$opt_h,$opt_C,$opt_p,$opt_H,$opt_c,$opt_u,$opt_t);
my ($line, @progvers, $response2,$response3);
$opt_V = $opt_h = $opt_C = $opt_p = $opt_H = $opt_u = $opt_t ='';
$state = 'UNKNOWN';
$progver = $response=$response2= $response3 ='';
$PROGNAME = "check_rpc";
sub print_help ();
sub print_usage ();
sub in ($$);
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$ENV{'PATH'}='';
$ENV{'LC_ALL'}='C';
#Initialise protocol for each progname number
# 'u' for UDP, 't' for TCP
$proto[10003]='u';
$proto[10004]='u';
$proto[10007]='u';
use Getopt::Long;
Getopt::Long::Configure('bundling');
GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"C=s" => \$opt_C, "command=s" => \$opt_C,
"p=i" => \$opt_p, "port=i" => \$opt_p,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"c=s" => \$opt_c, "progver=s" => \$opt_c,
"v+" => \$verbose, "verbose+" => \$verbose,
"u" => \$opt_u, "udp" => \$opt_u,
"t" => \$opt_t, "tcp" => \$opt_t
);
# -h means display verbose help screen
if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
# -V means display version number
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.8 $ ');
exit $ERRORS{'OK'};
}
# Hash containing all RPC program names and numbers
# Add to the hash if support for new RPC program is required
%prognum = (
"portmapper" => 100000 ,
"portmap" => 100000 ,
"sunrpc" => 100000 ,
"rpcbind" => 100000 ,
"rstatd" => 100001 ,
"rstat" => 100001 ,
"rup" => 100001 ,
"perfmeter" => 100001 ,
"rstat_svc" => 100001 ,
"rusersd" => 100002 ,
"rusers" => 100002 ,
"nfs" => 100003 ,
"nfsprog" => 100003 ,
"ypserv" => 100004 ,
"ypprog" => 100004 ,
"mountd" => 100005 ,
"mount" => 100005 ,
"showmount" => 100005 ,
"ypbind" => 100007 ,
"walld" => 100008 ,
"rwall" => 100008 ,
"shutdown" => 100008 ,
"yppasswdd" => 100009 ,
"yppasswd" => 100009 ,
"etherstatd" => 100010 ,
"etherstat" => 100010 ,
"rquotad" => 100011 ,
"rquotaprog" => 100011 ,
"quota" => 100011 ,
"rquota" => 100011 ,
"sprayd" => 100012 ,
"spray" => 100012 ,
"3270_mapper" => 100013 ,
"rje_mapper" => 100014 ,
"selection_svc" => 100015 ,
"selnsvc" => 100015 ,
"database_svc" => 100016 ,
"rexd" => 100017 ,
"rex" => 100017 ,
"alis" => 100018 ,
"sched" => 100019 ,
"llockmgr" => 100020 ,
"nlockmgr" => 100021 ,
"x25_inr" => 100022 ,
"statmon" => 100023 ,
"status" => 100024 ,
"bootparam" => 100026 ,
"ypupdated" => 100028 ,
"ypupdate" => 100028 ,
"keyserv" => 100029 ,
"keyserver" => 100029 ,
"sunlink_mapper" => 100033 ,
"tfsd" => 100037 ,
"nsed" => 100038 ,
"nsemntd" => 100039 ,
"showfhd" => 100043 ,
"showfh" => 100043 ,
"ioadmd" => 100055 ,
"rpc.ioadmd" => 100055 ,
"NETlicense" => 100062 ,
"sunisamd" => 100065 ,
"debug_svc" => 100066 ,
"dbsrv" => 100066 ,
"ypxfrd" => 100069 ,
"rpc.ypxfrd" => 100069 ,
"bugtraqd" => 100071 ,
"kerbd" => 100078 ,
"event" => 100101 ,
"na.event" => 100101 ,
"logger" => 100102 ,
"na.logger" => 100102 ,
"sync" => 100104 ,
"na.sync" => 100104 ,
"hostperf" => 100107 ,
"na.hostperf" => 100107 ,
"activity" => 100109 ,
"na.activity" => 100109 ,
"hostmem" => 100112 ,
"na.hostmem" => 100112 ,
"sample" => 100113 ,
"na.sample" => 100113 ,
"x25" => 100114 ,
"na.x25" => 100114 ,
"ping" => 100115 ,
"na.ping" => 100115 ,
"rpcnfs" => 100116 ,
"na.rpcnfs" => 100116 ,
"hostif" => 100117 ,
"na.hostif" => 100117 ,
"etherif" => 100118 ,
"na.etherif" => 100118 ,
"iproutes" => 100120 ,
"na.iproutes" => 100120 ,
"layers" => 100121 ,
"na.layers" => 100121 ,
"snmp" => 100122 ,
"na.snmp" => 100122 ,
"snmp-cmc" => 100122 ,
"snmp-synoptics" => 100122 ,
"snmp-unisys" => 100122 ,
"snmp-utk" => 100122 ,
"traffic" => 100123 ,
"na.traffic" => 100123 ,
"nfs_acl" => 100227 ,
"sadmind" => 100232 ,
"nisd" => 100300 ,
"rpc.nisd" => 100300 ,
"nispasswd" => 100303 ,
"rpc.nispasswdd" => 100303 ,
"ufsd" => 100233 ,
"ufsd" => 100233 ,
"pcnfsd" => 150001 ,
"pcnfs" => 150001 ,
"amd" => 300019 ,
"amq" => 300019 ,
"bwnfsd" => 545580417 ,
"fypxfrd" => 600100069 ,
"freebsd-ypxfrd" => 600100069 ,
);
# -v means verbose, -v-v means verbose twice = print above hash
if (defined $verbose && ($verbose > 1) ){
my $key;
print "Supported programs:\n";
print " name\t=>\tnumber\n";
print " ===============================\n";
foreach $key (sort keys %prognum) {
print " $key \t=>\t$prognum{$key} \n";
}
print "\n\n";
print_usage();
exit $ERRORS{'OK'};
}
# -H means host name
unless ($opt_H) { print_usage(); exit $ERRORS{'UNKNOWN'}; }
if (! utils::is_hostname($opt_H)){
print "$opt_H is not a valid host name\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}else{
$host = $opt_H;
}
if ($opt_t && $opt_u) {
print "Cannot define tcp AND udp\n";
print_usage();
exit $ERRORS{'UNKNOWN'};
}
# -C means command name or number
$opt_C = shift unless ($opt_C);
unless ($opt_C) { print_usage(); exit -1; }
@progkeys = keys %prognum;
if ($opt_C =~ m/^([0-9]+)$/){
# $response = "RPC ok: program $opt_C (version ";
$prognum = $1;
} elsif ( in( \@progkeys, $opt_C)) {
# $response = "RPC ok: $opt_C (version ";
$prognum = $prognum{$opt_C};
} else {
print "Program $opt_C is not defined\n";
exit $ERRORS{'UNKNOWN'};
}
# -p means port number
if($opt_p =~ /^([0-9]+)$/){
$port = "-n $1";
} else {
$port = "";
}
$proto = 'u';
$proto = $proto[$prognum] if ($proto[$prognum]);
$proto = 't' if ($opt_t);
$proto = 'u' if ($opt_u);
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: No response from RPC server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
# -c is progver - if we need to check multiple specified versions.
if (defined $opt_c ) {
my $vers;
@progvers = split(/,/ ,$opt_c );
foreach $vers (sort @progvers) {
if($vers =~ /^([0-9]+)$/){
$progver = "$1";
print "Checking $opt_C version $progver proto $proto\n" if $verbose;
get_rpcinfo();
}else{
print "Version $vers is not an integer\n" if $verbose;
}
}
}else{
get_rpcinfo();
}
## translate proto for output
if ($proto eq "u" ){
$proto = "udp";
}else{
$proto = "tcp";
}
if ($state eq 'OK') {
print "$state: RPC program $opt_C".$response." $proto running\n";
}else{
if($response){
print "$state: RPC program $opt_C".$response2." $proto is not running,".$response." $proto is running\n";
}else{
print "$state: RPC program $opt_C $response2 $proto is not running\n";
}
}
exit $ERRORS{$state};
######## Subroutines ==========================
sub get_rpcinfo {
$cmd = "$utils::PATH_TO_RPCINFO $port -" . "$proto $host $prognum $progver 2>&1 |";
print "$cmd\n" if ($verbose);
open CMD, $cmd or die "Can't fork for rpcinfo: $!\n" ;
while ( $line = <CMD> ) {
printf "$line " if $verbose;
chomp $line;
if ( $line =~ /program $prognum version ([0-9]*) ready and waiting/ ) {
$response .= " version $1";
$state = 'OK' unless $state ne 'UNKNOWN';
print "1:$response \n" if $verbose;
}
if ( $line =~ /program $prognum version ([0-9]*) is not available/ ) {
$response2 .= " version $1";
$state = 'CRITICAL';
print "2:$response2 \n" if $verbose;
}
if ( $line =~ /program $prognum is not available/ ) {
$response3 = "";
$response3 = "tcp" if $opt_t;
$response3 = "udp" if $opt_u;
$state = 'CRITICAL';
print "3:$response3 \n" if $verbose;
}
}
close CMD;
}
sub print_help() {
print_revision($PROGNAME,'$Revision: 1.8 $ ');
print "Copyright (c) 2002 Karl DeBisschop/Truongchinh Nguyen/Subhendu Ghosh\n";
print "\n";
print "Check if a rpc service is registered and running using\n";
print " rpcinfo -H host -C rpc_command \n";
print "\n";
print_usage();
print "\n";
print " <host> The server providing the rpc service\n";
print " <rpc_command> The program name (or number).\n";
print " <program_version> The version you want to check for (one or more)\n";
print " Should prevent checks of unknown versions being syslogged\n";
print " e.g. 2,3,6 to check v2, v3, and v6\n";
print " [-u | -t] Test UDP or TCP\n";
print " [-v] Verbose \n";
print " [-v -v] Verbose - will print supported programs and numbers \n";
print "\n";
support();
}
sub print_usage () {
print "Usage: \n";
print " $PROGNAME -H host -C rpc_command [-p port] [-c program_version] [-u|-t] [-v]\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";
}
sub in ($$) {
$array_ref = shift;
$test = shift;
while ( $element = shift @{$array_ref} ) {
if ($test eq $element) {
return 1;
}
}
return 0;
}

View file

@ -0,0 +1,65 @@
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 1.2 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "This plugin checks hardware status using the lm_sensors package."
echo ""
support
exit 0
}
case "$1" in
--help)
print_help
exit 0
;;
-h)
print_help
exit 0
;;
--version)
print_revision $PROGNAME $REVISION
exit 0
;;
-V)
print_revision $PROGNAME $REVISION
exit 0
;;
*)
sensordata=`sensors 2>&1`
status=$?
if test "$1" = "-v" -o "$1" = "--verbose"; then
echo ${sensordata}
fi
if test ${status} -eq 127; then
echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)"
exit -1
elif test ${status} -ne 0 ; then
echo "WARNING - sensors returned state $status"
exit 1
fi
if echo ${sensordata} | egrep ALARM > /dev/null; then
echo SENSOR CRITICAL - Sensor alarm detected!
exit 2
else
echo sensor ok
exit 0
fi
;;
esac

123
plugins-scripts/check_wave.pl Executable file
View file

@ -0,0 +1,123 @@
#!/usr/bin/perl -wT
#
# $Id: check_wave.pl,v 1.4 2002/10/28 13:05:08 kdebisschop Exp $
use strict;
use lib utils.pm;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
use Getopt::Long;
use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
my (@test, $low1, $med1, $high1, $snr, $low2, $med2, $high2);
my ($low, $med, $high, $lowavg, $medavg, $highavg, $tot, $ss);
$PROGNAME = "check_wave";
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose, "verbose" => \$verbose,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1.4 $'); #'
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);
my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0]+(\.[a-zA-Z][-a-zA-Z0]+)*)$/);
print_usage() unless ($host);
($opt_c) || ($opt_c = shift) || ($opt_c = 120);
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
($opt_w) || ($opt_w = shift) || ($opt_w = 60);
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
$low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
@test = split(/ /,$low1);
$low1 = $test[2];
$med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
@test = split(/ /,$med1);
$med1 = $test[2];
$high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
@test = split(/ /,$high1);
$high1 = $test[2];
sleep(2);
$snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
@test = split(/ /,$snr);
$snr = $test[2];
$snr = int($snr*25);
$low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
@test = split(/ /,$low2);
$low2 = $test[2];
$med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
@test = split(/ /,$med2);
$med2 = $test[2];
$high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
@test = split(/ /,$high2);
$high2 = $test[2];
$low = $low2 - $low1;
$med = $med2 - $med1;
$high = $high2 - $high1;
$tot = $low + $med + $high;
if ($tot==0) {
$ss = 0;
} else {
$lowavg = $low / $tot;
$medavg = $med / $tot;
$highavg = $high / $tot;
$ss = ($medavg*50) + ($highavg*100);
}
printf("Signal Strength at: %3.0f%, SNR at $snr%",$ss);
if ($ss<$critical) {
exit(2);
} elsif ($ss<$warning) {
exit(1);
} else {
exit(0);
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1.4 $');
print "Copyright (c) 2000 Jeffery Blank/Karl DeBisschop\n";
print "\n";
print_usage();
print "\n";
print "<warn> = Signal strength at which a warning message will be generated.\n";
print "<crit> = Signal strength at which a critical message will be generated.\n\n";
support();
}

74
plugins-scripts/subst.in Normal file
View file

@ -0,0 +1,74 @@
#!/usr/bin/awk
function which(c,path) {
cmd = "test -x " c;
if (system(cmd)==0) {
return c;
}
sub(/\/.*\//,"",c);
for (dir in path) {
cmd = "test -x " path[dir] "/" c;
if (system(cmd)==0) {
return path[dir] "/" c;
}
}
return c;
}
# used to replace "use lib utils.pm" with "use lib @libexecdir"
#
function led() {
led1 = "@libexecdir@";
led2 = "@exec_prefix@";
led3 = "@prefix@";
if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) {
return "\"" led3 "/libexec\" " ;
}
return "\"" led1 "\"" ;
}
BEGIN {
split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/);
}
# scripting language (first line)
/^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");}
/^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");}
/^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");}
/^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");}
# add to libexecdir to INC for perl utils.pm
/^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } }
# Trusted path mechanism (deprecated)
/^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ {
sub(/\=[ \t]*['"][^"']+["']/,"='@with_trusted_path@' # autoconf-derived");
}
/^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ {
sub(/\=.*$/,"='@with_trusted_path@' # autoconf-derived");
}
# If a script contains a reference to a fully qualified command,
# subst will replace the fully qualified command with whatever is
# returned from the which subroutine
#
/^[^#]/ && /(\/.*)?\/(bin|sbin|lib|libexec)\// {
match($0,/(\/.*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/);
c=substr($0,RSTART,RLENGTH);
sub(c,which(c,path));
}
{
print;
}

View file

@ -0,0 +1,4 @@
/check_file_age.t/1.1/Thu Dec 15 15:17:49 2005//Tr1_4_5
/check_rpc.t/1.2/Mon Jul 25 01:47:15 2005//Tr1_4_5
/utils.t/1.2/Fri Oct 27 15:37:31 2006//Tr1_4_5
D

View file

@ -0,0 +1 @@
nagiosplug/plugins-scripts/t

View file

@ -0,0 +1 @@
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug

View file

@ -0,0 +1 @@
Nr1_4_5

View file

@ -0,0 +1,88 @@
#!/usr/bin/perl -w -I ..
#
# check_file_age tests
#
# $Id: check_file_age.t,v 1.1 2005/12/15 15:17:49 tonvoon Exp $
#
use strict;
use Test::More tests => 15;
use NPTest;
my $successOutput = '/^FILE_AGE OK: /';
my $warningOutput = '/^FILE_AGE WARNING: /';
my $criticalOutput = '/^FILE_AGE CRITICAL: /';
my $unknownOutput = '/^FILE_AGE UNKNOWN: /';
my $result;
my $temp_file = "/tmp/check_file_age.tmp";
my $temp_link = "/tmp/check_file_age.link.tmp";
unlink $temp_file, $temp_link;
$result = NPTest->testCmd(
"./check_file_age"
);
cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
like ( $result->output, $unknownOutput, "Output for unknown correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file"
);
cmp_ok( $result->return_code, '==', 2, "File not exists" );
like ( $result->output, $criticalOutput, "Output for file missing correct" );
write_chars(100);
$result = NPTest->testCmd(
"./check_file_age -f $temp_file"
);
cmp_ok( $result->return_code, '==', 0, "File is new enough" );
like ( $result->output, $successOutput, "Output for success correct" );
sleep 2;
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -w 1"
);
cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" );
like ( $result->output, $warningOutput, "Output for warning correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1"
);
cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" );
like ( $result->output, $criticalOutput, "Output for critical correct" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 100"
);
cmp_ok( $result->return_code, '==', 0, "Checking file size" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 101"
);
cmp_ok( $result->return_code, '==', 1, "One byte too short" );
$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -C 101"
);
cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" );
symlink $temp_file, $temp_link or die "Cannot create symlink";
$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10");
cmp_ok( $result->return_code, '==', 0, "Works for symlinks" );
unlink $temp_link;
unlink $temp_file;
mkdir $temp_file or die "Cannot create directory";
$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1");
cmp_ok( $result->return_code, '==', 0, "Works for directories" );
rmdir $temp_file;
sub write_chars {
my $size = shift;
open F, "> $temp_file" or die "Cannot write to $temp_file";
print F "A" x $size;
close F;
}

View file

@ -0,0 +1,22 @@
#! /usr/bin/perl -w -I ..
#
# Remote Procedure Call (RPC) Tests via check_rpc
#
# $Id: check_rpc.t,v 1.2 2005/07/25 01:47:15 illumino Exp $
#
use strict;
use Test;
use NPTest;
use vars qw($tests);
BEGIN {$tests = 2; plan tests => $tests}
my $successOutput = '/^check_rpc/';
my $t;
$t += checkCmd( "./check_rpc -V", 0, $successOutput );
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);

49
plugins-scripts/t/utils.t Normal file
View file

@ -0,0 +1,49 @@
#!/usr/bin/perl -w -I ..
#
# utils.pm tests
#
# $Id: utils.t,v 1.2 2006/10/27 15:37:31 tonvoon Exp $
#
# Run with perl t/utils.t
use warnings;
use strict;
use Test::More;
use NPTest;
use lib "..";
use utils;
my $hostname_checks = {
"www.altinity.com" => 1,
"www.888.com" => 1,
"888.com" => 1,
"host-hyphened.com" => 1,
"rubbish" => 1,
"-start.com" => 0,
"nonfqdn-but-endsindot." => 1,
"fqdn.and.endsindot." => 1,
"lots.of.dots.dot.org" => 1,
"endingwithdoubledots.." => 0,
"toomany..dots" => 0,
".start.with.dot" => 0,
"10.20.30.40" => 1,
"10.20.30.40.50" => 0,
"10.20.30" => 0,
"10.20.30.40." => 1, # This is considered a hostname because of trailing dot. It probably won't exist though...
"888." => 1, # This is because it could be a domain
"host.888." => 1,
"where.did.that.!.come.from." => 0,
"no.underscores_.com" => 0,
};
plan tests => ((scalar keys %$hostname_checks) + 4);
foreach my $h (sort keys %$hostname_checks) {
is (utils::is_hostname($h), $hostname_checks->{$h}, "$h should return ".$hostname_checks->{$h});
}
is(utils::is_hostname(), 0, "No parameter errors");
is(utils::is_hostname(""), 0, "Empty string errors");
is(utils::is_hostname(0), 0, "0 also errors");
is(utils::is_hostname(1), 0, "1 also errors");

View file

@ -0,0 +1,70 @@
# Utility drawer for Nagios plugins.
# $Id: utils.pm.in,v 1.11 2006/10/27 15:37:31 tonvoon Exp $
#
# This will be deprecated soon. Please use Nagios::Plugin from CPAN
# for new plugins
package utils;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw($TIMEOUT %ERRORS &print_revision &support &usage);
#use strict;
#use vars($TIMEOUT %ERRORS);
sub print_revision ($$);
sub usage;
sub support();
sub is_hostname;
## updated by autoconf
$PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ;
$PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";
## common variables
$TIMEOUT = 15;
%ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
## utility subroutines
sub print_revision ($$) {
my $commandName = shift;
my $pluginRevision = shift;
$pluginRevision =~ s/^\$Revision: //;
$pluginRevision =~ s/ \$\s*$//;
print "$commandName (@PACKAGE@ @VERSION@) $pluginRevision\n";
print "@WARRANTY@";
}
sub support () {
my $support='@SUPPORT@';
$support =~ s/@/\@/g;
$support =~ s/\\n/\n/g;
print $support;
}
sub usage {
my $format=shift;
printf($format,@_);
exit $ERRORS{'UNKNOWN'};
}
sub is_hostname {
my $host1 = shift;
return 0 unless defined $host1;
if ($host1 =~ m/^[\d\.]+$/ && $host1 !~ /\.$/) {
if ($host1 =~ m/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
return 1;
} else {
return 0;
}
} elsif ($host1 =~ m/^[a-zA-Z0-9][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*\.?$/) {
return 1;
} else {
return 0;
}
}
1;

View file

@ -0,0 +1,23 @@
#! /bin/sh
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
if test -x /usr/bin/printf; then
ECHO=/usr/bin/printf
else
ECHO=echo
fi
print_revision() {
echo "$1 (@PACKAGE@ @VERSION@) $2"
$ECHO "@WARRANTY@" | sed -e 's/\n/ /g'
}
support() {
$ECHO "@SUPPORT@" | sed -e 's/\n/ /g'
}