Imported Upstream version 1.4.16+git20130902

This commit is contained in:
Jan Wagner 2013-11-26 23:59:47 +01:00
parent e76be63abf
commit e70fb8c051
517 changed files with 44015 additions and 43295 deletions

3
BUGS
View file

@ -1,4 +1,4 @@
This file lists the major bugs from the Nagios Plugins page on Sourceforge
This file lists the major bugs from the Nagios Plugins page on Sourceforge
at http://sourceforge.net/tracker/?group_id=29880&atid=397597. These are not
necessarily verified as errors.
@ -30,4 +30,3 @@ For the 1.4.16 release:
1370031 - check_disk_smb requires DNS agree with NetBIOS names
1225470 - check_swap perf data incorrect
1090549 - check_dhcp ignores DHCP replies
990948 - check_disk_smb doesn't allow spaces in share names

View file

@ -1,3 +1,7 @@
2013-01-23 Robin Sonefors <robin.sonefors@op5.com>
* plugins/check_snmp.c: fix memory allocation if using >= 8 oids
2012-06-27 Holger Weiss <holger@zedat.fu-berlin.de>
* plugins/check_tcp.c: check_tcp: Print performance data even with

15
INSTALL
View file

@ -1,8 +1,8 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@ -226,6 +226,11 @@ order to use an ANSI C compiler:
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
@ -304,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
@ -362,4 +368,3 @@ operates.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View file

@ -5,9 +5,9 @@ SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
EXTRA_DIST = config.rpath \
ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \
NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
NPTest.pm contrib pkg nagios-plugins.spec \
NPTest.pm pkg nagios-plugins.spec \
config_test/Makefile config_test/run_tests config_test/child_test.c \
perlmods tools/build_perl_modules \
tools/build_perl_modules \
tools/tinderbox_build
ACLOCAL_AMFLAGS = -I gl/m4 -I m4
@ -24,7 +24,7 @@ install-root:
test test-debug:
cd lib && $(MAKE) $@
if test "$(PERLMODS_DIR)" != ""; then cd perlmods && $(MAKE) $@; fi
if test "$(PERLMODS_DIR)" != ""; then cd && $(MAKE) $@; fi
cd plugins && $(MAKE) $@
cd plugins-scripts && $(MAKE) $@

File diff suppressed because it is too large Load diff

46
NEWS
View file

@ -1,5 +1,51 @@
This file documents the major additions and syntax changes between releases.
...
ENHANCEMENTS
New check_dbi plugin for checking an (SQL) database using DBI
Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page)
Add performance data to check_apt
Add performance data to check_procs
Added -4/-6 options to check_dig (Ville Mattila)
New check_oracle --connect option to perform real login
New check_nagios -t option to override the default timeout
New check_disk -f/--freespace-ignore-reserved option to ignore space reserved for root
New check_disk -N/--include-type option to limit the filesystem types to check
Allow for building the plugins in parallel
Add --without-{dbi,ldap,radius} options to ./configure
Made Verbose output of check_sensors compliant (Gabriele Tozzi)
New switch -E/--extended-perfdata for check_http to print additional performance data (Sebastian Nohn)
New check_http -d option to specify a string to expect within the response headers
New check_http -J/-K options for client certificate authentication support
Add support for executing queries to check_pgsql
Let check_pgsql accept a UNIX socket directory as hostname
New check_pgsql -o option to specify additional connection parameters
New check_fping -S option to specify the source IP address
New check_fping -I option to specify the interface to bind to
Let check_fping support IPv6
New check_procs -k option to ignore kernel threads (on Linux)
Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
Let check_mysql support SSL
Let check_mysql add perfromance metrics for all checks
New check_mysql -f option to specify a client options file
New check_mysql -g option to specify a client options group
New check_snmp --offset option to allow for adding/substracting an offset value to sensor data
Let check_snmp support an arbitrary number of OIDs
Let check_ide_smart support NetBSD
FIXES
Change the MAIL FROM command generated by check_smtp to be RFC compliant
Fix compilation of check_http without SSL support
Fix check_snmp reversed threshold ranges (backward-compatibility)
Fix check_snmp memory violation when using more than 8 oids (Robin Sonefors)
Fix check_apt security regular expression (Alex Bradley)
Fix check_http handling extra header (-k) containing semicolons (Richard Leitner)
Fix check_apt handling unknown exit codes from apt-get (Richard Leitner)
Fix deprecated imports of check_nmap.py (Fabio Rueda)
WARNINGS
check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead.
1.4.16 27th June 2012
ENHANCEMENTS
check_nt UPTIME accepts warning/critical thresholds (Ryan Kelly)

View file

@ -36,16 +36,19 @@ check_ldap:
check_mysql, check_mysql_query:
- Requires the MySQL libraries available from
http://www.mysql.org/
http://dev.mysql.com/downloads/
Lib: libmysql, libmysqlclient
Redhat Powertools Source: mysql-3.20.32a-3.i386.rpm, mysql-devel-3.20.32a-3.i386.rpm (these seem to be broken, however)
RPMS from www.mysql.org work better
Redhat Source (RHEL6, YUM): mysql-devel, mysql-libs
Must have mysql_config in PATH or specified with --with-mysql=DIR for DIR/bin/mysql_config
check_pqsql:
- Requires the PostgreSQL libraries available from
http://www.postgresql.org/
check_dbi:
- Requires the DBI libraries available from
http://libdbi.sourceforge.net/
check_radius:
- Requires the radiusclient-ng library available from:
http://developer.berlios.de/projects/radiusclient-ng/

12
THANKS
View file

@ -2,6 +2,7 @@ This software is brought to you by the Nagios Plugins Development Team. However,
there have been many contributors to this project. Everyone below has helped in
raising bug reports, creating patches or contributing new plugins.
Diego Elio Pettenò
fabiodds
dag rob?le
Randy O'Meara
@ -39,6 +40,7 @@ Jeffery Blank
Tom De Blende
Eric Bollengier
Aurelien Bompard
Alex Bradley
Richard Brodie
Matthew Brown
Tobias Brox
@ -66,6 +68,7 @@ Phil Dibowitz
Jason Dixon
Paul Dlug
Andy Doran
Emmanuel Dreyfus
Rainer Duffner
Ian Duggan
Edwin Eefting
@ -87,6 +90,7 @@ Duncan Ferguson
Paulo Fessel
Paulo Afonso Graner Fessel
James Fidell
Roman Fiedler
Johan Fischer
Bernhard Fischer
Matthias Flacke
@ -128,6 +132,7 @@ Mark Jewiss
Nikita Kalabukhov
Frank Kannemann
Roy Sigurd Karlsbakk
Anders Kaseorg
Jason Kau
Ryan Kelly
Bo Kersey
@ -149,6 +154,7 @@ Lynne Lawrence
Sakari Lehtonen
William Leibzon
Pedro Leite
Richard Leitner
Craig Leres
Jan Lipphaus
Larry Low
@ -181,8 +187,10 @@ Sivakumar Nellurandi
Truongchinh Nguyen
Simon L Nielsen
Thomas Nilsen
Sebastian Nohn
Walbert Oberngruber
Craig Orsinger
Vaclav Ovsik
Remi Paulmier
Tom Payerle
Fabian Pehla
@ -217,6 +225,7 @@ Kenny Root
Wolfgang Rosenauer
John Rouillard
Jonathan Rozes
Fabio Rueda
Sascha Runschke
Dietmar Ruzicka
Ralph Rye
@ -239,6 +248,7 @@ Sean Shore
Antony Simmonds
John Sivak
Nik Soggia
Robin Sonefors
Lars Stavholm
Nikolay Sturm
David Sullivan
@ -249,6 +259,7 @@ Ben Timby
Ronald Tin
Ibere Tizio
Julien Touche
Gabriele Tozzi
Kyle Tucker
Jerome Tytgat
Stéphane Urbanovski
@ -277,4 +288,5 @@ Howard Wilkinson
Shawn Wills
Rob Windsor
Mario Witte
Brian De Wolf
Jamie Zawinski

643
aclocal.m4 vendored

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2009-10-06.20; # UTC
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
# Foundation, Inc.
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@ -29,21 +28,224 @@ scriptversion=2009-10-06.20; # UTC
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
@ -53,11 +255,13 @@ EOF
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
eat=
for arg
do
@ -66,8 +270,8 @@ do
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
@ -94,10 +298,10 @@ do
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
@ -106,7 +310,7 @@ fi
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/\\:.-]' here to ensure that we don't use the same name
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d

406
build-aux/config.guess vendored
View file

@ -1,14 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2009-12-30'
timestamp='2013-06-10'
# This file 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@ -17,26 +15,22 @@ timestamp='2009-12-30'
# 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., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner. Please send patches (context
# diff format) to <config-patches@gnu.org> and include a ChangeLog
# entry.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
# Originally written by Per Bothner.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
#
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
me=`echo "$0" | sed -e 's,.*/,,'`
@ -56,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -140,12 +132,33 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
;;
esac
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
@ -181,7 +194,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
fi
;;
*)
os=netbsd
os=netbsd
;;
esac
# The OS release
@ -202,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@ -224,7 +241,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
@ -270,7 +287,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;;
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
@ -296,12 +316,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@ -395,23 +415,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
@ -481,8 +501,8 @@ EOF
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@ -495,7 +515,7 @@ EOF
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
@ -552,7 +572,7 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[456])
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
@ -595,52 +615,52 @@ EOF
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
@ -731,22 +751,22 @@ EOF
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
@ -770,14 +790,14 @@ EOF
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@ -789,30 +809,35 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
UNAME_PROCESSOR=`/usr/bin/uname -p`
case ${UNAME_PROCESSOR} in
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:*)
case ${UNAME_MACHINE} in
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
@ -849,15 +874,22 @@ EOF
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
@ -867,52 +899,56 @@ EOF
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
@ -931,51 +967,63 @@ EOF
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
or1k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
echo sparc-unknown-linux-${LIBC}
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
echo hppa64-unknown-linux-${LIBC}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
*) echo hppa-unknown-linux-${LIBC} ;;
esac
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
echo powerpc64-unknown-linux-${LIBC}
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
echo powerpc-unknown-linux-${LIBC}
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-${LIBC}
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@ -984,11 +1032,11 @@ EOF
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
@ -1020,7 +1068,7 @@ EOF
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
@ -1048,13 +1096,13 @@ EOF
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
@ -1089,8 +1137,8 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
@ -1133,10 +1181,10 @@ EOF
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
@ -1162,11 +1210,11 @@ EOF
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
@ -1179,6 +1227,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@ -1205,19 +1256,21 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
eval $set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
@ -1231,7 +1284,10 @@ EOF
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@ -1276,13 +1332,13 @@ EOF
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
@ -1300,11 +1356,11 @@ EOF
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
@ -1322,11 +1378,11 @@ main ()
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
"4"
#else
""
""
#endif
); exit (0);
); exit (0);
#endif
#endif

View file

@ -2,7 +2,7 @@
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2010 Free Software Foundation, Inc.
# Copyright 1996-2013 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
@ -25,7 +25,7 @@
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except MSVC,
# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
@ -57,13 +57,6 @@ else
aix*)
wl='-Wl,'
;;
darwin*)
case $cc_basename in
xlc*)
wl='-Wl,'
;;
esac
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
;;
hpux9* | hpux10* | hpux11*)
@ -72,9 +65,7 @@ else
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
newsos6)
;;
linux* | k*bsd*-gnu)
linux* | k*bsd*-gnu | kopensolaris*-gnu)
case $cc_basename in
ecc*)
wl='-Wl,'
@ -85,17 +76,26 @@ else
lf95*)
wl='-Wl,'
;;
pgcc | pgf77 | pgf90)
nagfor*)
wl='-Wl,-Wl,,'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
xl* | bgxl* | bgf* | mpixl*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ F* | *Sun*Fortran*)
wl=
;;
*Sun\ C*)
wl='-Wl,'
;;
@ -103,13 +103,24 @@ else
;;
esac
;;
newsos6)
;;
*nto* | *qnx*)
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
wl='-Wl,'
case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
wl='-Qoption ld '
;;
*)
wl='-Wl,'
;;
esac
;;
sunos4*)
wl='-Qoption ld '
@ -171,15 +182,14 @@ if test "$with_gnu_ld" = yes; then
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
# that the semantics of dynamic libraries on AmigaOS, at least up
# to version 4, is to share data among multiple programs linked
# with the same dynamic library. Since this doesn't match the
# behavior of shared libraries on other platforms, we cannot use
# them.
ld_shlibs=no
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
@ -198,11 +208,13 @@ if test "$with_gnu_ld" = yes; then
ld_shlibs=no
fi
;;
haiku*)
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | k*bsd*-gnu)
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
@ -325,10 +337,14 @@ else
fi
;;
amigaos*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
# see comment about different semantics on the GNU ld section
ld_shlibs=no
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
bsdi[45]*)
;;
@ -342,24 +358,15 @@ else
;;
darwin* | rhapsody*)
hardcode_direct=no
if test "$GCC" = yes ; then
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
:
else
case $cc_basename in
xlc*)
;;
*)
ld_shlibs=no
;;
esac
ld_shlibs=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd1*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
@ -420,6 +427,8 @@ else
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
*nto* | *qnx*)
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
@ -515,7 +524,12 @@ case "$host_os" in
library_names_spec='$libname$shrext'
;;
amigaos*)
library_names_spec='$libname.a'
case "$host_cpu" in
powerpc*)
library_names_spec='$libname$shrext' ;;
m68k)
library_names_spec='$libname.a' ;;
esac
;;
beos*)
library_names_spec='$libname$shrext'
@ -534,8 +548,6 @@ case "$host_os" in
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd1*)
;;
freebsd* | dragonfly*)
case "$host_os" in
freebsd[123]*)
@ -547,6 +559,9 @@ case "$host_os" in
gnu*)
library_names_spec='$libname$shrext'
;;
haiku*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
@ -582,7 +597,7 @@ case "$host_os" in
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu)
linux* | k*bsd*-gnu | kopensolaris*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
@ -594,7 +609,7 @@ case "$host_os" in
newsos6)
library_names_spec='$libname$shrext'
;;
nto-qnx*)
*nto* | *qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
@ -625,6 +640,9 @@ case "$host_os" in
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
tpf*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;

293
build-aux/config.sub vendored
View file

@ -1,38 +1,31 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2010-01-22'
timestamp='2013-08-10'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file 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
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 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., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted GNU ChangeLog entry.
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@ -75,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -124,13 +115,18 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@ -153,12 +149,12 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze)
-apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
@ -174,10 +170,10 @@ case $os in
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
;;
-hiux*)
os=-hiuxwe2
;;
@ -222,6 +218,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
@ -246,20 +248,27 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@ -277,34 +286,45 @@ case $basic_machine in
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nios | nios2 \
| nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| or32 \
| open8 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rx \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
c54x)
basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@ -314,6 +334,21 @@ case $basic_machine in
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
@ -328,25 +363,30 @@ case $basic_machine in
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@ -364,30 +404,34 @@ case $basic_machine in
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nios-* | nios2-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| romp-* | rs6000-* | rx-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tile*-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
@ -412,7 +456,7 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
abacus)
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
@ -482,11 +526,20 @@ case $basic_machine in
basic_machine=powerpc-ibm
os=-cnk
;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
@ -518,7 +571,7 @@ case $basic_machine in
basic_machine=craynv-cray
os=-unicosmp
;;
cr16)
cr16 | cr16-*)
basic_machine=cr16-unknown
os=-elf
;;
@ -676,7 +729,6 @@ case $basic_machine in
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
@ -734,11 +786,15 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@ -773,10 +829,18 @@ case $basic_machine in
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i686-pc
os=-msys
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@ -841,6 +905,12 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@ -923,9 +993,10 @@ case $basic_machine in
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
@ -950,7 +1021,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
@ -1019,6 +1094,9 @@ case $basic_machine in
basic_machine=i860-stratus
os=-sysv4
;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
;;
@ -1075,25 +1153,8 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
tile*)
basic_machine=tile-unknown
basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
@ -1163,6 +1224,9 @@ case $basic_machine in
xps | xps100)
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp)
basic_machine=ymp-cray
os=-unicos
@ -1260,11 +1324,11 @@ esac
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
@ -1288,20 +1352,21 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@ -1348,7 +1413,7 @@ case $os in
-opened*)
os=-openedition
;;
-os400*)
-os400*)
os=-os400
;;
-wince*)
@ -1397,7 +1462,7 @@ case $os in
-sinix*)
os=-sysv4
;;
-tpf*)
-tpf*)
os=-tpf
;;
-triton*)
@ -1433,17 +1498,14 @@ case $os in
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-nacl*)
;;
-nacl*)
;;
-none)
;;
*)
@ -1466,10 +1528,10 @@ else
# system, and we'll never get to this point.
case $basic_machine in
score-*)
score-*)
os=-elf
;;
spu-*)
spu-*)
os=-elf
;;
*-acorn)
@ -1481,8 +1543,23 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
@ -1502,14 +1579,11 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mep-*)
mep-*)
os=-elf
;;
mips*-cisco)
@ -1518,6 +1592,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;
@ -1536,7 +1613,7 @@ case $basic_machine in
*-ibm)
os=-aix
;;
*-knuth)
*-knuth)
os=-mmixware
;;
*-wec)

View file

@ -1,10 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2009-04-28.21; # UTC
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
# Software Foundation, Inc.
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -28,9 +27,9 @@ scriptversion=2009-04-28.21; # UTC
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
@ -40,11 +39,11 @@ as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
@ -57,6 +56,66 @@ EOF
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
@ -69,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
@ -80,18 +142,32 @@ if test "$depmode" = hp; then
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u="sed s,\\\\\\\\,/,g"
depmode=msvisualcpp
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
@ -114,8 +190,7 @@ gcc3)
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -123,13 +198,17 @@ gcc3)
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
@ -137,31 +216,31 @@ gcc)
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well.
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -179,8 +258,7 @@ sgi)
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -188,43 +266,41 @@ sgi)
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> "$depfile"
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
@ -237,9 +313,7 @@ aix)
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
@ -248,44 +322,100 @@ aix)
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
@ -297,8 +427,8 @@ icc)
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -309,9 +439,8 @@ hp2)
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
@ -322,8 +451,7 @@ hp2)
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
@ -333,77 +461,107 @@ hp2)
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
@ -422,7 +580,7 @@ dashmstdout)
shift
fi
# Remove `-o $object'.
# Remove '-o $object'.
IFS=" "
for arg
do
@ -442,18 +600,18 @@ dashmstdout)
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -503,12 +661,15 @@ makedepend)
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
@ -525,7 +686,7 @@ cpp)
shift
fi
# Remove `-o $object'.
# Remove '-o $object'.
IFS=" "
for arg
do
@ -544,10 +705,10 @@ cpp)
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
@ -579,23 +740,23 @@ msvisualcpp)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;

View file

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2009-04-28.21; # UTC
scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -35,7 +35,7 @@ scriptversion=2009-04-28.21; # UTC
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
@ -156,6 +156,10 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
@ -194,13 +202,17 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
@ -228,9 +240,9 @@ fi
for src
do
# Protect names starting with `-'.
# Protect names problematic for 'test' and other utilities.
case $src in
-*) src=./$src;;
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
@ -252,12 +264,7 @@ do
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
@ -347,7 +354,7 @@ do
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
@ -385,7 +392,7 @@ do
case $dstdir in
/*) prefix='/';;
-*) prefix='./';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
@ -403,7 +410,7 @@ do
for d
do
test -z "$d" && continue
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then

View file

@ -1,11 +1,10 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2009-04-28.21; # UTC
scriptversion=2012-06-26.16; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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
@ -26,69 +25,40 @@ scriptversion=2009-04-28.21; # UTC
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
--is-lightweight)
# Used by our autoconf macros to check whether the available missing
# script is modern enough.
exit 0
;;
--run)
# Back-compat with the calling convention used by older automake.
shift
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
to PROGRAM being missing or too old.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
aclocal autoconf autoheader autom4te automake makeinfo
bison yacc flex lex help2man
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
@ -100,272 +70,141 @@ Send bug reports to <bug-automake@gnu.org>."
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
esac
# normalize program name to check for.
program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
# Run the given program, remember its exit status.
"$@"; st=$?
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program). This is about non-GNU programs, so use $1 not
# $program.
case $1 in
lex*|yacc*)
# Not GNU programs, they don't have --version.
# If it succeeded, we are done.
test $st -eq 0 && exit 0
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'automa4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
tar*)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
give_advice "$1" | sed -e '1s/^/WARNING: /' \
-e '2,$s/^/ /' >&2
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG="\${$#}"
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit $?
fi
;;
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar*)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Propagate the correct exit status (expected to be 127 for a program
# not found, 63 for a program that failed due to version mismatch).
exit $st
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)

View file

@ -81,9 +81,9 @@ case $dirmode in
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# On NextStep and OpenStep, the 'mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# directories to create, and then abort because '.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version

View file

@ -0,0 +1,10 @@
#if !defined _Noreturn && __STDC_VERSION__ < 201112
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))
# elif 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn
# endif
#endif

View file

@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
Copyright (C) 2009-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@ -9,7 +9,7 @@
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
Lesser General Public License for more details.
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

View file

@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2010-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@ -9,7 +9,7 @@
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
Lesser General Public License for more details.
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */

View file

@ -1,5 +1,5 @@
/* A C macro for emitting warnings if a function is used.
Copyright (C) 2010 Free Software Foundation, Inc.
Copyright (C) 2010-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@ -9,7 +9,7 @@
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
Lesser General Public License for more details.
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -55,7 +55,7 @@
rather than issue the nice warning, but the end result of informing
the developer about their portability problem is still achieved):
#if HAVE_RAW_DECL_ENVIRON
static inline char ***rpl_environ (void) { return &environ; }
static char ***rpl_environ (void) { return &environ; }
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
# undef environ
# define environ (*rpl_environ ())

127
build-aux/test-driver Executable file
View file

@ -0,0 +1,127 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2012-06-27.10; # UTC
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
#
# 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, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
# Make unconditional expansion of undefined variables an error. This
# helps a lot in preventing typo-related bugs.
set -u
usage_error ()
{
echo "$0: $*" >&2
print_usage >&2
exit 2
}
print_usage ()
{
cat <<END
Usage:
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
[--expect-failure={yes|no}] [--color-tests={yes|no}]
[--enable-hard-errors={yes|no}] [--] TEST-SCRIPT
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
END
}
# TODO: better error handling in option parsing (in particular, ensure
# TODO: $log_file, $trs_file and $test_name are defined).
test_name= # Used for reporting.
log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
-*) usage_error "invalid option: '$1'";;
esac
shift
done
if test $color_tests = yes; then
# Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
red='' # Red.
grn='' # Green.
lgn='' # Light green.
blu='' # Blue.
mgn='' # Magenta.
std='' # No color.
else
red= grn= lgn= blu= mgn= std=
fi
do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
trap "st=129; $do_exit" 1
trap "st=130; $do_exit" 2
trap "st=141; $do_exit" 13
trap "st=143; $do_exit" 15
# Test script is run here.
"$@" >$log_file 2>&1
estatus=$?
if test $enable_hard_errors = no && test $estatus -eq 99; then
estatus=1
fi
case $estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;
esac
# Report outcome to console.
echo "${col}${res}${std}: $test_name"
# Register the test result, and other relevant metadata.
echo ":test-result: $res" > $trs_file
echo ":global-test-result: $res" >> $trs_file
echo ":recheck: $recheck" >> $trs_file
echo ":copy-in-global-log: $gcopy" >> $trs_file
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

View file

@ -1,273 +0,0 @@
###############################################################################
# COMMAND CONFIGURATION
#
# SYNTAX:
# command[<command_name>]=<command_line>
#
# <command_name> = A short name used to identify the command
# <command_line> = The actual command line. The command line doesn't have to
# be surrounded in quotes, but may contain quotes as needed within
# the command line. Take care to use single quotes at the
# outer edges of commands or you will have command line
# expansion problems when the command is executed by the shell.
# Any valid shell command can be used. Multiple commands can
# be separated with semicolons, piping is allowed. The
# command line can contain macros, but not are macros are valid
# at all time (notifications, service checks, etc). See the
# HTML documentaion for more informationon on using macros in
# commands.
#
# Note: Service check, service notification, host check, host notification,
# service event handler, and host event handler functions are all defined
# here.
#
# Note: Use the convertcfg program in the contrib directory of the Nagios
# distribution to convert this file into a object file format.
#
###############################################################################
# Service notification command - send email with problem summary
command[notify-by-email]=/bin/printf "$OUTPUT$" | /bin/mail -s '$SERVICESTATE$ alert for $HOSTALIAS$/$SERVICEDESC$' $CONTACTEMAIL$
# Service notification command - send email to alphanumeric pager
# gateway The notify-by-epager command assumes that each contact has a
# pager email gateway, and that the address has been entered into the
# appropriate contact field instead of an actual pager number.
# (i.e. 'pagejoe@nowhere.com' routes mail to Joe's alphanumeric pager)
command[notify-by-epager]=/bin/echo "$OUTPUT$" | /bin/mail -s '$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$' $CONTACTPAGER$
# Host notification commands (one for email, one for alphanumeric
# pager with email gateway)
command[host-notify-by-email]=/bin/echo -e "***** Nagios *****\n\nHost "$HOSTALIAS$" is $HOSTSTATE$!\n\nDate/Time: $DATETIME$\n" | /bin/mail -s 'Host $HOSTNAME$ is $HOSTSTATE$!' $CONTACTEMAIL$
command[host-notify-by-epager]=/bin/echo '$HOSTALIAS$ is $HOSTSTATE$!' | /bin/mail -s 'Host $HOSTNAME$ is $HOSTSTATE$!' $CONTACTPAGER$
## Send notifications to a pager using modem with Qpage (www.qpage.com)
command[notify-by-qpage]=/usr/bin/printf "Service: %s\nHost: %s\nAddress: %s\nState: %s\nInfo: %s\nDate: %s" '$SERVICEDESC$' '$HOSTNAME$' '$HOSTADDRESS$' '$SERVICESTATE$' '$OUTPUT$' '$DATETIME' | /usr/local/bin/qpage -l 0 -p $CONTACTPAGER$
command[host-notify-by-qpage]=/usr/bin/printf "Host: %s is %s\nInfo: %s\nDate: %s" '$HOSTALIAS$' '$HOSTSTATES$' '$OUTPUT$' '$DATETIME' | /usr/local/bin/qpage -l 0 -p $CONTACTPAGER$
## Send notifications using SMSclient (www.smsclient.org)
command[notify-by-smsclient]=/usr/bin/sms_client -q $CONTACTPAGER$ "$NOTIFICATIONTYPE$: $HOSTADDRESS$ $HOSTALIAS$: $SERVICEDESC$ is $SERVICESTATE$"
command[host-notify-by-smsclient]=/usr/bin/sms_client -q $CONTACTPAGER$ "Host $HOSTALIAS$ is $HOSTSTATE$; $OUTPUT$; $DATETIME$"
# These are some example service check commands. See the HTML
# documentation on the plugins for examples of how to configure
# command definitions.
command[check_tcp]=@libexecdir@/check_tcp -H $HOSTADDRESS$ -p $ARG1$
command[check_udp]=@libexecdir@/check_udp -H $HOSTADDRESS$ -p $ARG1$
command[check_ftp]=@libexecdir@/check_ftp -H $HOSTADDRESS$
command[check_pop]=@libexecdir@/check_pop -H $HOSTADDRESS$
command[check_smtp]=@libexecdir@/check_smtp -H $HOSTADDRESS$
command[check_nntp]=@libexecdir@/check_nntp -H $HOSTADDRESS$
command[check_telnet]=@libexecdir@/check_tcp -H $HOSTADDRESS$ -p 23
command[check_users]=@libexecdir@/check_users -w $ARG1$ -c $ARG2$
command[check_ntp]=@libexecdir@/check_ntp -H $HOSTADDRESS$
command[check_ntp_ntpq]=@libexecdir@/check_ntp -H $HOSTADDRESS$ -j 10 -k 15
command[check_flexlm]=@libexecdir@/check_flexlm -F $ARG1$
command[check_hpjd]=@libexecdir@/check_hpjd -H $HOSTADDRESS$ -C public
command[check_mrtg]=@libexecdir@/check_mrtg $ARG1$ 10 AVG $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
command[traffic_average]=@libexecdir@/check_mrtgtraf $ARG1$ 10 AVG $ARG2$ $ARG3$ $ARG4$ $ARG5$
command[check_load]=@libexecdir@/check_load $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$
command[check_disk]=@libexecdir@/check_disk -w 85% -c 95% -p $ARG1$
command[check_dns]=@libexecdir@/check_dns -H www.yahoo.com -s $HOSTADDRESS$
command[check_http]=@libexecdir@/check_http -H $HOSTADDRESS$ -I $HOSTADDRESS$
command[check_http2]=@libexecdir@/check_http -H $ARG1$ -I $HOSTADDRESS$ -w $ARG2$ -c $ARG3$
command[check_pgsql]=@libexecdir@/check_pgsql -H $HOSTADDRESS$
command[check_ping]=@libexecdir@/check_ping -H $HOSTADDRESS$ -w 10:20% -c 60:100%
command[check_procs]=@libexecdir@/check_procs -w $ARG1$ -c $ARG2$
command[check_procs_zombie]=@libexecdir@/check_procs -w $ARG1$ -c $ARG2$ -s Z
command[check_procs_httpd]=@libexecdir@/check_procs -w 5:$ARG1$ -c 1:$ARG2$ -C httpd
command[check_procs_vsz]=@libexecdir@/check_procs -w 8096 -c 16182 -C httpd --metric VSZ
command[check_ups]=@libexecdir@/check_ups -H $HOSTADDRESS$ -u $ARG1$
# An example of using check_by_ssh as an active service check
command[ssh_disk]=@libexecdir@/check_by_ssh -H $HOSTADDRESS$ -C '@libexecdir@/check_disk -w 85% -c 95% -p $ARG1$'
#
# UCD_SNMP equivalents for some of the commands above
#
command[snmp_load]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.2021.10.1.5.1,.1.3.6.1.4.1.2021.10.1.5.2,.1.3.6.1.4.1.2021.10.1.5.3 -w :$ARG2$,:$ARG3$,:$ARG4$ -w :$ARG5$,:$ARG6$,:$ARG7$ -l load
command[snmp_cpustats]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.2021.11.9.0,.1.3.6.1.4.1.2021.11.10.0,.1.3.6.1.4.1.2021.11.11.0 -l 'CPU usage (user system idle)' -u '%'
command[snmp_procname]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o 1.3.6.1.4.1.2021.2.1.5.$ARG2$ -w $ARG3$:$ARG4$ -c $ARG5$:$ARG6$
command[snmp_disk]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o 1.3.6.1.4.1.2021.9.1.7.$ARG1$,1.3.6.1.4.1.2021.9.1.9.$ARG1$ -w $ARG2$:,:$ARG3$ -c $ARG4$:,:$ARG5$ -u 'kB free (','% used)' -l 'disk space'
command[snmp_mem]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.2021.4.6.0,.1.3.6.1.4.1.2021.4.5.0 -w $ARG2$: -c $ARG3$:
command[snmp_swap]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o .1.3.6.1.4.1.2021.4.4.0,.1.3.6.1.4.1.2021.4.3.0 -w $ARG2$: -c $ARG3$:
#
# Slightly more generic SNMP OIDs
# note: using partial textual OIDs here - use numeric oids if you don't have MIBDIRS defined per Net-SNMP (net-snmp.org)
command[snmp_procs]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrSystem.hrSystemProcesses -w :$ARG2$ -c :$ARG3$ -l processes
command[snmp_users]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrSystem.hrSystemNumUsers -w :$ARG2$ -c :$ARG3$ -l users
command[snmp_mem2]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.101,host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageSize.101 -w $ARG2$ -c $ARG3$
command[snmp_swap2]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.102,host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageSize.102 -w $ARG2$ -c $ARG3$
command[snmp_mem3]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.101,host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageSize.101 -w $ARG2$ -c $ARG3$
command[snmp_swap3]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.102,host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageSize.102 -w $ARG2$ -c $ARG3$
command[snmp_disk2]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o host.hrStorage.hrStorageTable.hrStorageEntry.hrStorageUsed.$ARG2$ -w $ARG3$ -c $ARG4$
command[snmp_tcpopen]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o tcp.tcpCurrEstab.0 -w $ARG2$ -c $ARG3$
command[snmp_tcpstats]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C $ARG1$ -o tcp.tcpActiveOpens.0,tcp.tcpPassiveOpens.0,tcp.tcpInSegs.0,tcp.tcpOutSegs.0,tcp.tcpRetransSegs.0 -l 'TCP stats'
# Some snmp based network device checks (requires Net::SNMP perl module)
# check all admin-up interfaces
command[check_ifstatus]=@libexecdir@/check_ifstatus -H $HOSTADDRESS$ -C public
# check particular interface by snmp ifIndex key
command[check_ifoperstatus_ifindex]=@libexecdir@/check_ifoperstatus -H $HOSTADDRESS$ -C public -k $ARG1$
# check particular interface by snmp ifDescr value (verify uniqueness before using)
command[check_ifoperstatus_ifdescr]=@libexecdir@/check_ifoperstatus -H $HOSTADDRESS$ -C public -d $ARG1$
# verify all you BGP session on a device are running (only returns warning due to some hardcoded option - to be fixed soon)
command[check_snmp_bgpstate]=@libexecdir@/check_bgpstate -H $HOSTADDRESS$ -C public
#
# SNMP NetApp checks (Jason Truong)
#
#
#command[check_netapp_uptime]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C public -o .1.3.6.1.2.1.1.3.0 --delimiter=')' -l "Uptime is"
#
#command[check_netapp_cpuload]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C public -o .1.3.6.1.4.1.789.1.2.1.3.0 -w 90 -c 95 -u '%' -l "CPU LOAD "
#
#command[check_netapp_numdisks]=@libexecdir@/check_snmp -H $HOSTADDRESS$ -C public -o .1.3.6.1.4.1.789.1.6.4.1.0,.1.3.6.1.4.1.789.1.6.4.2.0,.1.3.6.1.4.1.789.1.6.4.8.0,.1.3.6.1.4.1.789.1.6.4.7.0 -u 'Total Disks','Active','Spare','Failed' -l ""
#
#
# SNMP Compaq Insight Agent (oids courtesy of vol)
#
# the following 4 return the following codes: other=1, ok=2, degraded=3, failed=4
#
#command[check_compaq_thermalCondition]=@libexec@/check_snmp -H $HOSTADDRESS$ -C public -o .1.3.6.1.4.1.232.6.2.1.0,.1.3.6.1.4.1.232.6.2.2.0,.1.3.6.1.4.1.232.6.2.3.0,.1.3.6.1.4.1.232.6.2.4.0 -u 'ThermalCondition','ThermalTemp','ThermalSystem','ThermalCPUFan' -w 2:2,2:2,2:2,2:2 -c 1:2,1:2,1:2,1:2 -l "Thermal status "
#
#
# This command checks to see if a host is "alive" by pinging it. The
# check must result in a 100% packet loss or 5 second (5000ms) round
# trip average to produce an error.
# This command checks to see if a host is "alive" by pinging it.
command[check-host-alive]=@libexecdir@/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1
# This command checks to see if a printer is "alive" by pinging it.
command[check-printer-alive]=@libexecdir@/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1
# This command checks to see if a switch is "alive" by pinging it.
command[check-switch-alive]=@libexecdir@/check_ping $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1
# This command checks to see if a router is "alive" by pinging it.
command[check-router-alive]=@libexecdir@/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1
# Check if a host is alive by doing a fast ping instead of a regular ping
command[check-fast-alive]=@libexecdir@/check_fping -H $HOSTADDRESS$
# Check if the IMAP service is alive (default port=143)
command[check-imap]=@libexecdir@/check_imap -H $HOSTADDRESS$
# Check RPC services
command[check-rpc]=@libexecdir@/check_rpc -H $HOSTADDRESS$ -C $ARG1$
# Check if the NFS server is running (version 2 and version 3)
command[check-nfs]=@libexecdir@/check_rpc -H $HOSTADDRESS$ -C nfs -c2,3
# Check game servers
command[check_quake]=@libexecdir@/check_game qs $HOSTADDRESS$
command[check_unreal]=@libexecdir@/check_game uns $HOSTADDRESS$ -p $ARG1$ -pf 8
# Check a port that should be open
command[check_nmap]=@libexecdir@/check_nmap -H $HOSTADDRESS$ -t 30 -p $ARG1$
# Check a port that should be open and another that *could* be open,
# but no warning is given if optional port is closed.
command[check_nmap_optional]=@libexecdir@/check_nmap -H $HOSTADDRESS$ -t 60 -p $ARG1$ -o $ARG2$
# Specify range to nmap
command[check_nmap_range]=@libexecdir@/check_nmap -H $HOSTADDRESS$ -t 60 -p $ARG1$ -r $ARG2$
# Specify both optional and range
command[check_nmap_opt_range]=@libexecdir@/check_nmap -H $HOSTADDRESS$ -t 60 -p $ARG1$ -o $ARG2$ -r$ARG3$
# Check Radius
command[check_radius]=@libexecdir@/check_radius $ARG1$ $ARG2$ $HOSTADDRESS$ 1812 $ARG3$
# Check HTTP proxy
# This is a command for checking squid or other proxy servers which uses check
# http to ensure an HTTP 200 comes back ..... i.e. squid actually
# serves the page and not an error message.
# Using check_http will allow verification of authenticated proxies
#
# Note:: This used to call "check_reply" which was pretty close to check_tcp
# The functionality of check_reply has been merged into check_tcp
command[check_squid]=@libexecdir@/check_http -H $HOSTADDRESS$ -p $ARG1$ -u $ARG2$ -e 'HTTP/1.0 200 OK'
## Check RealAudio url
command[check_real_url]=@libexecdir@/check_real $HOSTADDRESS$ -p $ARG1$ -wt $ARG2$ -ct $ARG3$ -to 5 -u $ARG4$
## Check RealAudio server response
command[check_real]=@libexecdir@/check_real $HOSTADDRESS$ -p $ARG1$ -wt $ARG2$ -ct $ARG3$ -to 5
# NetWare checks via check_nwstat ( see "check_nwstat -h" for more options)
# how many current logins
command[check_netware_logins]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v "LOGINS" -w $ARG1$ -c $ARG2$
# how many current connections
command[check_nwstat_conns]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v CONNS -w $ARG1$ -c $ARG2$
# 1 minute avg cpu load
command[check_netware_1load]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v "LOAD1" -w 70 -c 90
# 5 minute avg cpu load
command[check_netware_5load]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v "LOAD5" -w 70 -c 90
# 15 minute avg cpu load
command[check_netware_15load]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v "LOAD15" -w 70 -c 90
# Disk volume (% free)
command[check_nwstat_vol_p]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v VPF$ARG1$ -w $ARG2$ -c $ARG3$
# Disk volume (KB free)
command[check_nwstat_vol_k]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v VKF$ARG1$ -w $ARG2$ -c $ARG3$
# % Long term cache hits
command[check_nwstat_ltch]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v LTCH -w $ARG1$ -c $ARG2$
# % (of max) used packet receive buffers
command[check_nwstat_puprb]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v PUPRB -w $ARG1$ -c $ARG2$
# Check to see if the DS database is open
command[check_nwstat_dsdb]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v DSDB
# Netware 5 abends
command[check_netware_abend]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v "ABENDS" -w 10 -c 30
# Netware 5 number of current service procs
command[check_nwstat_csprocs]=@libexecdir@/check_nwstat -H $HOSTADDRESS$ -v CSPROCS -w $ARG1$ -c $ARG2$
# Still have to write sample entries for the following:
#
# check_ldap
# check_overcr

File diff suppressed because it is too large Load diff

15562
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -255,54 +255,96 @@ fi
LIBS="$_SAVEDLIBS"
CPPFLAGS="$_SAVEDCPPFLAGS"
AC_ARG_WITH([dbi], [AS_HELP_STRING([--without-dbi], [Skips the dbi plugin])])
dnl Check for DBI libraries
AS_IF([test "x$with_dbi" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(dbi,dbi_initialize)
if test "$ac_cv_lib_dbi_dbi_initialize" = "yes"; then
EXTRAS="$EXTRAS check_dbi"
DBILIBS="-ldbi"
AC_SUBST(DBILIBS)
else
AC_MSG_WARN([Skipping dbi plugin])
AC_MSG_WARN([install DBI libs to compile this plugin (see REQUIREMENTS).])
fi
LIBS="$_SAVEDLIBS"
])
AC_ARG_WITH([radius], [AS_HELP_STRING([--without-radius], [Skips the radius plugin])])
dnl Check for radius libraries
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(radiusclient,rc_read_config)
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius"
RADIUSLIBS="-lradiusclient"
AC_SUBST(RADIUSLIBS)
else
AC_CHECK_LIB(radiusclient-ng,rc_read_config)
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
AS_IF([test "x$with_radius" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(radiusclient,rc_read_config)
if test "$ac_cv_lib_radiusclient_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius"
RADIUSLIBS="-lradiusclient-ng"
RADIUSLIBS="-lradiusclient"
AC_SUBST(RADIUSLIBS)
else
AC_MSG_WARN([Skipping radius plugin])
AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
AC_CHECK_LIB(radiusclient-ng,rc_read_config)
if test "$ac_cv_lib_radiusclient_ng_rc_read_config" = "yes"; then
EXTRAS="$EXTRAS check_radius"
RADIUSLIBS="-lradiusclient-ng"
AC_SUBST(RADIUSLIBS)
else
AC_MSG_WARN([Skipping radius plugin])
AC_MSG_WARN([install radius libs to compile this plugin (see REQUIREMENTS).])
fi
fi
fi
LIBS="$_SAVEDLIBS"
LIBS="$_SAVEDLIBS"
])
AC_ARG_WITH([ldap], [AS_HELP_STRING([--without-ldap], [Skips the LDAP plugin])])
dnl Check for LDAP libraries
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(ldap,main,,,-llber)
if test "$ac_cv_lib_ldap_main" = "yes"; then
LDAPLIBS="-lldap -llber"\
LDAPINCLUDE="-I/usr/include/ldap"
AC_SUBST(LDAPLIBS)
AC_SUBST(LDAPINCLUDE)
AC_CHECK_FUNCS(ldap_set_option)
EXTRAS="$EXTRAS check_ldap"
AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
else
AC_MSG_WARN([Skipping LDAP plugin])
AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
fi
LIBS="$_SAVEDLIBS"
AS_IF([test "x$with_ldap" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(ldap,main,,,-llber)
if test "$ac_cv_lib_ldap_main" = "yes"; then
LDAPLIBS="-lldap -llber"\
LDAPINCLUDE="-I/usr/include/ldap"
AC_SUBST(LDAPLIBS)
AC_SUBST(LDAPINCLUDE)
AC_CHECK_FUNCS(ldap_set_option)
EXTRAS="$EXTRAS check_ldap"
AC_CHECK_FUNCS(ldap_init ldap_set_option ldap_get_option ldap_start_tls_s)
else
AC_MSG_WARN([Skipping LDAP plugin])
AC_MSG_WARN([install LDAP libs to compile this plugin (see REQUIREMENTS).])
fi
LIBS="$_SAVEDLIBS"
])
dnl Check for headers used by check_ide_smart
AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
if test "$FOUNDINCLUDE" = "yes" ; then
AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
fi
case $host in
*linux*)
AC_CHECK_HEADER(linux/hdreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
if test "$FOUNDINCLUDE" = "yes" ; then
AC_CHECK_HEADER(linux/types.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
fi
if test "$FOUNDINCLUDE" = "no" ; then
AC_MSG_WARN([Skipping check_ide_smart plugin.])
AC_MSG_WARN([check_ide_smart requires linux/hdreg.h and linux/types.h.])
fi
;;
*netbsd*)
AC_CHECK_HEADER(dev/ata/atareg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
if test "$FOUNDINCLUDE" = "yes" ; then
AC_CHECK_HEADER(dev/ic/wdcreg.h, FOUNDINCLUDE=yes, FOUNDINCLUDE=no)
fi
if test "$FOUNDINCLUDE" = "no" ; then
AC_MSG_WARN([Skipping check_ide_smart plugin.])
AC_MSG_WARN([check_ide_smart requires dev/ata/atareg.h and dev/ic/wdcreg.h])
fi
;;
*)
AC_MSG_WARN([Skipping check_ide_smart plugin.])
AC_MSG_WARN([check_ide_smart works only on Linux and NetBSD])
esac
if test "$FOUNDINCLUDE" = "yes" ; then
EXTRAS="$EXTRAS check_ide_smart"
else
AC_MSG_WARN([Skipping check_ide_smart plugin.])
AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.])
fi
dnl Check for mysql libraries
@ -320,6 +362,26 @@ else
AC_SUBST(MYSQLCFLAGS)
fi
dnl Check for headers used by check_users
AC_CHECK_HEADERS(utmpx.h)
AM_CONDITIONAL([HAVE_UTMPX], [test "$ac_cv_header_utmpx_h" = "yes"])
dnl Fallback to who(1) if the system doesn't provide an utmpx(5) interface
if test "$ac_cv_header_utmpx_h" = "no"
then
AC_PATH_PROG(PATH_TO_WHO,who)
if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
then
ac_cv_path_to_who="$PATH_TO_WHO -q"
else
ac_cv_path_to_who="$PATH_TO_WHO"
fi
AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
[path and arguments for invoking 'who'])
fi
AC_ARG_WITH([ipv6],
[AS_HELP_STRING([--with-ipv6], [support IPv6 @<:@default=check@:>@])],
[], [with_ipv6=check])
@ -1244,10 +1306,18 @@ if test -n "$ac_cv_nslookup_command"; then
AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
fi
AC_MSG_CHECKING([for number of cpus])
AC_MSG_CHECKING([for number of online cpus])
AC_TRY_COMPILE([#include <unistd.h>],
[sysconf(_SC_NPROCESSORS_ONLN) > 0;],
AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of online cpus])
AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
AC_MSG_RESULT([cannot calculate])
)
AC_MSG_CHECKING([for number of available cpus])
AC_TRY_COMPILE([#include <unistd.h>],
[sysconf(_SC_NPROCESSORS_CONF) > 0;],
AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of available cpus])
AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
AC_MSG_RESULT([cannot calculate])
)
@ -1284,19 +1354,6 @@ else
AC_MSG_WARN([Get smbclient from Samba.org to monitor SMB shares])
fi
AC_PATH_PROG(PATH_TO_WHO,who)
if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null]
then
ac_cv_path_to_who="$PATH_TO_WHO -q"
else
ac_cv_path_to_who="$PATH_TO_WHO"
fi
AC_DEFINE_UNQUOTED(WHO_COMMAND,"$ac_cv_path_to_who",
[path and arguments for invoking 'who'])
AC_PATH_PROG(PATH_TO_SNMPGET,snmpget)
AC_ARG_WITH(snmpget_command,
ACX_HELP_STRING([--with-snmpget-command=PATH],
@ -1354,13 +1411,22 @@ then
fi
AC_PATH_PROG(PATH_TO_FPING,fping)
AC_PATH_PROG(PATH_TO_FPING6,fping6)
AC_ARG_WITH(fping_command,
ACX_HELP_STRING([--with-fping-command=PATH],
[Path to fping command]), PATH_TO_FPING=$withval)
AC_ARG_WITH(fping6_command,
ACX_HELP_STRING([--with-fping6-command=PATH],
[Path to fping6 command]), PATH_TO_FPING6=$withval)
if test -n "$PATH_TO_FPING"
then
AC_DEFINE_UNQUOTED(PATH_TO_FPING,"$PATH_TO_FPING",[path to fping])
EXTRAS="$EXTRAS check_fping"
if test x"$with_ipv6" != xno && test -n "$PATH_TO_FPING6"; then
AC_DEFINE_UNQUOTED(PATH_TO_FPING6,"$PATH_TO_FPING6",[path to fping6])
fi
else
AC_MSG_WARN([Get fping from http://www.fping.com in order to make check_fping plugin])
fi
@ -1721,7 +1787,6 @@ AC_OUTPUT(
plugins-scripts/utils.pm
plugins-scripts/utils.sh
perlmods/Makefile
command.cfg
test.pl
pkg/solaris/pkginfo
po/Makefile.in

View file

@ -1,56 +0,0 @@
Contrib Plugins README
----------------------
This directory contains plugins which have been contributed by various people, but that
have not yet been incorporated into the core plugins distribution.
Most Perl plugins should work without modification. Some of the C plugins may require
a few tweaks to compile.
If you have questions regarding the use of these plugins, try contacting the author(s)
or post a message to the nagiosplug-help mailing list (nagiosplug-help@lists.sourceforge.net)
requesting assistance.
Contrib Tarballs
----------------
In addition to the plugins located in this directory, there are some additional tarballs
containing plugins in the tarballs/ subdirectory. They have not yet been organized.
A brief description of their contents follows.
berger-ping.tar.gz - Perl script version of the check_ping plugin and a corresponding
CGI (mtr.cgi) that uses mtr to traceroute a path to a host.
(Gary Berger)
bowen-langley_plugins.tar.gz
- Several C plugins including check_inode, check_boot, etc.
(Adam Bown & Thomas Langley)
check_bgp-1.0.tar.gz - Perl script intended for monitoring BGP sessions on Cisco routers.
Uses Net::Telnet to telnet into a cisco router and
run "sh ip bgp"
check_memory.tgz - C plugin to check available system memory
check_radius.tar.gz - C program to check RADIUS authentication. This is a hacked version of
the Cistron Radiusd program radtest that acts as a plugin for Nagios.
The vast majority of the code was written by someone at Livingston
Enterprises and Cistron. NOTE: Due to the copyright restrictions in
this code, it cannot be distributed under the GPL license, and thus
will not appear in the core plugin distribution!
(Adam Jacob)
radius.tar.gz - Code modifications necessary to make the radexample app
supplied with the radiusclient code work as a RADIUS plugin
for Nagios (Nick Shore)
fetchlog-0.94.tar.gz - C program: The fetchlog utility displays the last new messages of a
logfile. It is similar like tail(1) but offers some extra functionality
for output formatting. fetchlog can be used standalone or as a Nagios
plugin to monitor local logfiles or together with Net-SNMP to monitor
remote logfiles. The README shows how to setup fetchlog for Nagios.
(Alexander Haderer)

View file

@ -1,48 +0,0 @@
#!/usr/bin/perl
#======================
# Created May 25, 2000
#======================
# This scripts is for checking for failed root login attempts on
# any machine running AIX which has a failedlogin file in /etc/security
# The purpose is to thwart (good word) any unauthorised people from
# even trying to log in as root. This plugin has been developed for Nagios
# running on AIX.
# Lonny Selinger SpEnTBoY lonny@abyss.za.org
# May
my $server = $ARGV[0];
if (!$ARGV[0]) {
print "You must specify a server to check\n";
print "usage: ./check_failed <Server Name>\n";
exit (-1);
} else {
open (DATE, "/bin/date '+%b %d' |");
while (<DATE>) {
$dline = $_;
@dresults = $dline;
chop $dresults[0];
}
open (SULOG, "rsh $server -l root who /etc/security/failedlogin | grep root |");
while (<SULOG>) {
$line = $_;
@results = split (/\s+/,$line);
if ($line =~ /^root/) {
if (join(' ', @results[2,3]) eq $dresults[0]) {
print "FAILED root login on $dresults[0], node: $ARGV[0] from $results[5]\n";
exit(2);
}
}
}
}
if (join(' ', @results[2,3]) ne $dresults[0]) {
print "No Failed Root Logins on This Node\n";
exit(0);
}
exit(0);
close(SULOG);
close(DATE);

View file

@ -1,69 +0,0 @@
#! /bin/sh
#=================================================================
#
# I/O Checker (KBPS)
# This Script uses iostat to monitor disk io
# Useful for notifications of disk thrashing.
#
# Authors: TheRocker
# SpEnTBoY
#
# Email: therocker@pawprints.2y.net
# lonny@abyss.za.org
#
#================================================================
NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line`
NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line`
TMPFILE=/tmp/iotest.hndl
TMPTOO=/tmp/iotwo.hndl
#===========================================================
#
# We do an evaluation on $NUMBER1 and $NUMBER2 to see if
# disk io is exceeding 40%.
#
#===========================================================
if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ]
then
`rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE`
#====================================================================
#
# Of course, there may be more than one hard disk on the node
# so we use this bit of code to report on more than one instance
# of excessive disk IO.
#
#====================================================================
LINES=`wc -l /tmp/iotest.hndl | cut -c8`
LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 `
echo "WARNING!!! Disk I/O Exceeding 40% on --> \c"
while [ $LINESCTL != 0 ]
do
cat $TMPFILE | tail -$LINESCTL > $TMPTOO
cat $TMPTOO > $TMPFILE
LINESCTL=$(( $LINESCTL -1 ))
LINES=$(( $LINES -1 ))
DATA=`head -1 /tmp/iotest.hndl`
echo "( $DATA ) "
done
echo "\n"
rm -f $TMPFILE
rm -f $TMPTOO
exit 1
else
print "No Disk I/O Exceeding 40%...OK"
exit 0
fi

View file

@ -1,49 +0,0 @@
#! /bin/sh
#=========================================================================
# Kerberos Ticket Checker
#
# This script is handy if you allow kerberos tickets to expire
# on your nodes. The script will simply warn you when a node has
# kerberos tickets expiring on the current date. This will allow to
# re-initialize the tickets if you wish to do so.
#
# Nothing fancy here, all Nagios will show is the number of tickets
# that are going to (or already have) expired.
#
# An item of note:
#
# We made no provisions for the weekend. If tickets expire on the
# weekend and nobody is around, you won't see a warning on the
# Nagios console because we look for expired on the current day
# only. It's a good idea to have this warning emailed to the
# appropriate admin and if there is something critical that relies
# on Kerberos, you might want to send a page.
#
# Authors: TheRocker
# SpEnTBoY
#
# Email: therocker@pawprints.2y.net
# lonny@abyss.za.org
#=========================================================================
TMPFILE=/tmp/kerbtmp.hndl
DATE=`date +%b' '%d`
rsh $1 -l root /usr/lpp/ssp/kerberos/bin/klist | tr -s ' ' | cut -d' ' -f4,5,6 | grep -e "$DATE" > $TMPFILE
if [ -s $TMPFILE ]
then
LINES=`wc -l /tmp/kerbtmp.hndl | cut -c7-8`
echo "Kerberos Tickets set to expire --> \c"
echo "$LINES \c"
echo "\n"
rm -f $TMPFILE
exit 1
fi
echo "Kerberos Tickets are valid"
exit 0

View file

@ -1,67 +0,0 @@
#! /bin/sh
#===============================================================
# Print Queue Checker
#
# The print queue checker simply looks for an occurance of a
# DOWN queue. A note of warning, if you use remote queues in
# AIX to redirect print jobs from the AIX queue to an NT print
# server that print through DLC rather than IP, it will be very
# s - l - o - w. But it will work.
#
# Author: TheRocker
# Email: therocker@pawprints.2y.net
#===============================================================
TMPFILE=/tmp/qtmp.hndl
TMPTOO=/tmp/qtwo.hndl
#=======================================================================
#
# This script will also work on AIX 4.2.1 BUT you have to change
# the following line. AIX 4.2.1 does not support the -W option
# with lpstat. For AIX 4.2.1 just remove the -W option and it should
# work just fine.
#
#=======================================================================
`rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err`
if [ -s $TMPFILE ]
then
#=======================================================
#
# If you've seen the other AIX scripts I wrote you may
# notice that I use this bit of code a lot. Well it
# works and appears to be all purpose.
#
#=======================================================
LINES=`wc -l /tmp/qtmp.hndl | cut -c8`
LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8`
echo "Print Queue DOWN --> \c"
while [ $LINESCTL != 0 ]
do
cat $TMPFILE | tail -$LINESCTL > $TMPTOO
cat $TMPTOO > $TMPFILE
LINESCTL=$(( $LINESCTL -1 ))
LINES=$(( $LINES -1 ))
DATA=`head -1 /tmp/qtmp.hndl`
echo "( $DATA ) \c"
done
echo "\n"
rm -f $TMPFILE
rm -f $TMPTOO
exit 2
fi
echo "Print Queues Running... OK"
exit 0

View file

@ -1,45 +0,0 @@
#!/bin/ksh
#==============================================================================
# Script was originally created to collect stats and dump then to a log file
# every five minutes. But we like this better (the log file thing is still
# good if you want to track availability).
#
# Authors: SpEnTBoY
# TheRocker
#
# Email: lonny@abyss.za.org
# therocker@pawprints.2y.net
#==============================================================================
#=========================================================================================
#
# The best way to do this is to use Kerberos but we use rsh here because our monitoring
# workstation doesn't have Kerberos installed. In order for this to work, the remote
# host ($1) must have a .rhosts file that contains a line like:
#
# monitorhost nagiosuser
#
#=========================================================================================
PAGING2=`rsh $1 -l root lsps -a -s | grep -v Paging | tr -s ' '| cut -d' ' -f3 | cut -d'%' -f1`
if [ "$PAGING2" -gt "35" ] && [ "$PAGING2" -lt "50" ]
then
echo "Paging Space is over 35% ("$PAGING2")%"
exit 1
fi
if [ "$PAGING2" -gt "49" ]
then
echo "WARNING! Paging Space is over 50% ("$PAGING2")%"
exit 2
fi
if [ "$PAGING2" -lt "34" ]
then
echo "Paging Space is less than 34% ("$PAGING2")%"
exit 0
fi

View file

@ -1,75 +0,0 @@
#! /bin/sh
#
# Modified check_sensors to check the alarm status of an Adaptec 3200S RAID
# controller.
#
# Scott Lambert -- lambert@lambertfam.org
#
# Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed. This
# package installs all it's programs into /usr/dpt.
#
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: 302 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
RAIDUTIL_CMD="/usr/dpt/raidutil -A ?"
print_usage() {
echo "Usage: $PROGNAME"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "This plugin checks alarm status of Adaptec 3200S RAID controller."
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
;;
*)
raidutiloutput=`$RAIDUTIL_CMD 2>&1`
status=$?
if test "$1" = "-v" -o "$1" = "--verbose"; then
echo ${raidutiloutput}
fi
if test ${status} -eq 127; then
echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)"
exit -1
elif test ${status} -ne 0 ; then
echo "WARNING - raidutil returned state $status"
exit 1
fi
if echo ${raidutiloutput} | egrep On > /dev/null; then
echo RAID CRITICAL - RAID alarm detected!
exit 2
else
echo raid ok
exit 0
fi
;;
esac

View file

@ -1,283 +0,0 @@
#!/usr/bin/perl
#
# (c)2001 Sebastian Hetze, Linux Information Systems AG
# send bug reports to <S.Hetze@Linux-AG.com>
#
# 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
#
#
# Check apache status information provided by mod_status to find
# out about the load (number of servers working) and the
# performance (average response time for recent requests).
#
# Usage:
# check_apache -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]
#
# check_apache <host> <warn> <crit> <url> (if you cannot avoid it)
#
use LWP::UserAgent;
use URI::URL;
use Getopt::Long;
Getopt::Long::Configure('bundling');
$version=0.01;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
#
# some default values
#
$perf_w=500;
$perf_c=1000;
$load_w=20;
$load_c=30;
$TIMEOUT=15;
#
# get command line options the regular way
#
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"l" => \$opt_l, "load" => \$opt_l,
"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,
"u=s" => \$opt_u, "url=s" => \$opt_u);
#
# handle the verbose stuff first
#
if ($opt_V) {
print "\n";
print "check_apache nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
print "copies of the plugins under the terms of the GNU General Public License.\n";
print "For more information about these matters, see the file named COPYING.\n";
print "\n";
print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
print "\n";
print "\n";
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'UNKNOWN'};
}
#
# now get options the weired way and set the defaults
# if nothing else is provided
#
$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);
if($opt_l) {
$autostring="?auto";
($opt_w) || ($opt_w = shift) || ($opt_w = $load_w);
$warn = $1 if ($opt_w =~ /([0-9]+)/);
($opt_c) || ($opt_c = shift) || ($opt_c = $load_c);
$alert = $1 if ($opt_c =~ /([0-9]+)/);
} else {
$autostring="";
($opt_w) || ($opt_w = shift) || ($opt_w = $perf_w);
$warn = $1 if ($opt_w =~ /([0-9]+)/);
($opt_c) || ($opt_c = shift) || ($opt_c = $perf_c);
$alert = $1 if ($opt_c =~ /([0-9]+)/);
}
($opt_u) || ($opt_u = shift) || ($opt_u = "/server-status");
#
# dont let us wait forever...
#
$SIG{'ALRM'} = sub {
print ("ERROR: No response from HTTP server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
#
# now we set things up for the real work
# and fire up the request
#
$ua = new LWP::UserAgent;
$ua->agent("Nagios/0.1 " . $ua->agent);
$urlstring = "http://" . $opt_H . $opt_u . $autostring;
$url = url($urlstring);
my $req = new HTTP::Request 'GET', $url;
my $res = $ua->request($req);
#
# hopefully we´ve got something usefull
#
if ($res->is_success) {
if($opt_l) {
foreach $_ (split /^/m, $res->content) {
next if /^\s*$/;
#
# this is the load checking section
# we parse the whole content, just in case someone
# wants to use this some day in the future
#
if (/^Total Accesses:\s+([0-9.]+)/) { $accesses = $1; next; }
if (/^Total kBytes:\s+([0-9.]+)/) { $kbytes = $1; next; }
if (/^CPULoad:\s+([0-9.]+)\s+/) { $load = $1; next; }
if (/^Uptime:\s+([0-9.]+)\s+/) { $uptime = $1; next; }
if (/^ReqPerSec:\s+([0-9.]+)\s+/) { $rps = $1; next; }
if (/^BytesPerSec:\s+([0-9.]+)\s+/) { $bps = $1; next; }
if (/^BytesPerReq:\s+([0-9.]+)\s+/) { $bpr = $1; next; }
if (/^BusyServers:\s+([0-9.]+)\s+/) { $busy = $1; next; }
if (/^IdleServers:\s+([0-9.]+)\s+/) { $idle = $1; next; }
if (/^Scoreboard:\s+([SRWKDLG_.]+)\s+/) { $score = $1; next; }
print "Unknown Status\n";
exit $ERRORS{"UNKNOWN"};
}
#
# now we even parse the whole scoreboard, just for fun
#
foreach $scorepoint (split //m, $score) {
if($scorepoint eq '.') { $scores{'.'}+=1; next; } # Unused
if($scorepoint eq '_') { $scores{'_'}+=1; next; } # Waiting
if($scorepoint eq 'S') { $scores{'S'}+=1; next; } # Starting
if($scorepoint eq 'R') { $scores{'R'}+=1; next; } # Reading
if($scorepoint eq 'W') { $scores{'W'}+=1; next; } # Writing
if($scorepoint eq 'K') { $scores{'K'}+=1; next; } # Keepalive
if($scorepoint eq 'D') { $scores{'D'}+=1; next; } # DNS Lookup
if($scorepoint eq 'L') { $scores{'L'}+=1; next; } # Logging
if($scorepoint eq 'G') { $scores{'G'}+=1; next; } # Going
}
if($busy>$alert) {
printf "HTTPD CRITICAL: %.0f servers running\n", $busy;
exit $ERRORS{"CRITICAL"};
}
if($busy>$warn) {
printf "HTTPD WARNING: %.0f servers running\n", $busy;
exit $ERRORS{"WARNING"};
}
printf "HTTPD ok: %.0f servers running, %d idle\n", $busy, $idle;
exit $ERRORS{"OK"};
} else {
#
# this is the performance check section
# We are a bit lazy here, no parsing of the initial data
# block and the scoreboard.
# However, you have the whole set of per server
# information to play with ;-)
# The actual performance is measured by adding up the
# milliseconds required to process the most recent
# requests of all instances and then taking the average.
#
foreach $tablerow (split /<tr>/m, $res->content) {
($empty,$Srv,$PID,$Acc,$M,$CPU,$SS,$Req,$Conn,$Child,$Slot,$Client,$VHost,$Request)
= split /<td>/, $tablerow;
if($Req) {
$lines+=1;
$req_sum+=$Req;
}
undef $Req;
}
$average=$req_sum/$lines;
if($average>$alert) {
printf "HTTPD CRITICAL: average response time %.0f
milliseconds\n", $average;
exit $ERRORS{"CRITICAL"};
}
if($average>$warn) {
printf "HTTPD WARNING: average response time %.0f
milliseconds\n", $average;
exit $ERRORS{"WARNING"};
}
if($average>0) {
printf "HTTPD ok: average response time %.0f milliseconds\n",
$average;
exit $ERRORS{"OK"};
}
print "Unknown Status\n";
exit $ERRORS{"UNKNOWN"};
}
} else {
print "HTTP request failed\n";
exit $ERRORS{"CRITICAL"};
}
#
# ok, now we are almost through
# These last subroutines do the things for those that do not
# read source code.
#
sub print_usage () {
print "Usage: $0 -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]\n"; }
sub print_help () {
print "\n";
print "\n";
print "check_apache nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
print "copies of the plugins under the terms of the GNU General Public License.\n";
print "For more information about these matters, see the file named COPYING.\n";
print "\n";
print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
print "\n";
print "\n";
print "This plugin checks the apache HTTP service on the specified host.\n";
print "It uses the mod_status facilities provided by the apache server.\n";
print "The monitoring server must be authorized in httpd.conf.\n";
print "\n";
print "\n";
print_usage();
print "\n";
print "Options:\n";
print " -H, --hostname=ADDRESS\n";
print " host name argument for server.\n";
print " -l, --load\n";
print " check load instead of performance.\n";
print " -h, --help\n";
print " print detailed help screen.\n";
print " -V, --version\n";
print " print version information.\n";
print " -w, --warning=INTEGER\n";
print " load / performance level at which a warning message will be gererated.\n";
print " -c, --critical=INTEGER\n";
print " load / performance level at which a critical message will be gererated.\n";
print " -u, --url=PATH\n";
print " location to call mod_status.\n";
print "\n";
print " Defaults for performance checking are $perf_w/$perf_c msec.\n";
print " Defaults for load checking are $load_w/$load_c servers running.\n";
print "\n";
print "\n";
}
#
# the end
#

View file

@ -1,307 +0,0 @@
#! /usr/bin/perl -wT
#
# Check_apc_ups - Check APC UPS status via SNMP
# Shamelessly copied from check_breeze.pl
#
# To do:
# - Send SNMP queries directly, instead of forking `snmpget`.
# - Make the status less verbose. Maybe we can send an "onLine, time
# remaining: hh:mm:ss" if all is well, and a list of specific problems
# if something is broken.
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R $opt_r
$opt_L $opt_l $PROGNAME);
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS &print_revision &support &usage);
sub print_help ();
sub print_usage ();
sub get_snmp_int_val ($);
sub escalate_exitval ($);
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"T=s" => \$opt_T, "temp-critical" => \$opt_T,
"t=s" => \$opt_t, "temp-warning" => \$opt_t,
"R=s" => \$opt_R, "runtime-critical" => \$opt_R,
"r=s" => \$opt_r, "runtime-warning" => \$opt_r,
"L=s" => \$opt_L, "load-critical" => \$opt_L,
"l=s" => \$opt_l, "load-warning" => \$opt_l,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1771 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n");
my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
($host) || usage("Invalid host: $opt_H\n");
# Defaults
$opt_R *= 60 * 100 if (defined $opt_R); # Convert minutes to secs/100
$opt_r *= 60 * 100 if (defined $opt_R);
my $tempcrit = $opt_T || 60;
my $tempwarn = $opt_t || 40;
my $runtimecrit = $opt_R || 30 * 60 * 100; # Secs / 100
my $runtimewarn = $opt_r || 60 * 60 * 100;
my $loadcrit = $opt_L || 85;
my $loadwarn = $opt_l || 50;
if ($tempcrit !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); }
if ($tempwarn !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); }
if ($runtimecrit !~ /\d+/) {
usage ("Invalid critical run time threshold.\n");
}
if ($runtimewarn !~ /\d+/) {
usage ("Invalid warning run time threshold.\n");
}
if ($loadcrit !~ /\d+/ || $loadcrit < 0 || $loadcrit > 100) {
usage ("Invalid critical load threshold.\n");
}
if ($loadwarn !~ /\d+/ || $loadwarn < 0 || $loadwarn > 100) {
usage ("Invalid warning load threshold.\n");
}
# APC UPS OIDs
# APC MIBs are available at ftp://ftp.apcftp.com/software/pnetmib/mib
my $upsBasicOutputStatus = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0";
my $upsBasicBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1.0";
my $upsAdvInputLineFailCause = ".1.3.6.1.4.1.318.1.1.1.3.2.5.0";
my $upsAdvBatteryTemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";
my $upsAdvBatteryRunTimeRemaining = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0";
my $upsAdvBatteryReplaceIndicator = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0";
my $upsAdvOutputLoad = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0";
my $upsAdvTestDiagnosticsResults = ".1.3.6.1.4.1.318.1.1.1.7.2.3.0";
my @outputStatVals = (
[ undef, undef ], # pad 0
[ undef, undef ], # pad 1
[ "onLine", $ERRORS{'OK'} ], # 2
[ "onBattery", $ERRORS{'WARNING'} ], # 3
[ "onSmartBoost", $ERRORS{'WARNING'} ], # 4
[ "timedSleeping", $ERRORS{'WARNING'} ], # 5
[ "softwareBypass", $ERRORS{'WARNING'} ], # 6
[ "off", $ERRORS{'CRITICAL'} ], # 7
[ "rebooting", $ERRORS{'WARNING'} ], # 8
[ "switchedBypass", $ERRORS{'WARNING'} ], # 9
[ "hardwareFailureBypass", $ERRORS{'CRITICAL'} ], # 10
[ "sleepingUntilPowerReturn", $ERRORS{'CRITICAL'} ], # 11
[ "onSmartTrim", $ERRORS{'WARNING'} ], # 12
);
my @failCauseVals = (
undef,
"noTransfer",
"highLineVoltage",
"brownout",
"blackout",
"smallMomentarySag",
"deepMomentarySag",
"smallMomentarySpike",
"largeMomentarySpike",
"selfTest",
"rateOfVoltageChnage",
);
my @battStatVals = (
[ undef, undef ], # pad 0
[ undef, undef ], # pad 1
[ "batteryNormal", $ERRORS{'OK'} ], # 2
[ "batteryLow", $ERRORS{'CRITICAL'} ], # 3
);
my @battReplVals = (
[ undef, undef ], # pad 0
[ "noBatteryNeedsReplacing", $ERRORS{'OK'} ], # 1
[ "batteryNeedsReplacing", $ERRORS{'CRITICAL'} ], # 2
);
my @diagnosticsResultsVals = (
[ undef, undef ], # pad 0
[ "OK", $ERRORS{'OK'} ], # 1
[ "failed", $ERRORS{'CRITICAL'} ], # 2
[ "invalidTest", $ERRORS{'CRITICAL'} ], # 3
[ "testInProgress", $ERRORS{'OK'} ], # 4
);
my $exitval = $ERRORS{'UNKNOWN'};
my $data;
my $onbattery = 3;
$data = get_snmp_int_val( $upsBasicOutputStatus );
print "Output status: ";
if (defined ($data) && defined ($outputStatVals[$data][0])) {
print "$outputStatVals[$data][0] | ";
escalate_exitval($outputStatVals[$data][1]);
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsAdvBatteryRunTimeRemaining );
print "Rem time: ";
if (defined ($data)) {
my $hrs = int($data / (60 * 60 * 100)); # Data is hundredths of a second
my $mins = int($data / (60 * 100)) % 60;
my $secs = ($data % 100) / 100;
printf "%d:%02d:%05.2f | ", $hrs, $mins, $secs;
if ($data <= $runtimecrit) {
escalate_exitval($ERRORS{'CRITICAL'});
} elsif ($data <= $runtimewarn) {
escalate_exitval($ERRORS{'WARNING'});
} else {
escalate_exitval($ERRORS{'OK'});
}
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsBasicBatteryStatus );
print "Battery status: ";
if (defined ($data) && defined ($battStatVals[$data][0])) {
my $failcause = "unknown";
my $fc = get_snmp_int_val( $upsAdvInputLineFailCause );
if ($data == $onbattery) {
if (defined ($failCauseVals[$fc])) { $failcause = $failCauseVals[$fc]; }
print "$battStatVals[$data][0] ($failcause) | ";
} else {
print "$battStatVals[$data][0] | ";
}
escalate_exitval($battStatVals[$data][1]);
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsAdvBatteryTemperature );
print "Battery temp(C): ";
if (defined ($data)) {
print "$data | ";
if ($data >= $tempcrit) {
escalate_exitval($ERRORS{'CRITICAL'});
} elsif ($data >= $tempwarn) {
escalate_exitval($ERRORS{'WARNING'});
} else {
escalate_exitval($ERRORS{'OK'});
}
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsAdvBatteryReplaceIndicator );
print "Battery repl: ";
if (defined ($data) && defined ($battReplVals[$data][0])) {
print "$battReplVals[$data][0] | ";
escalate_exitval($battReplVals[$data][1]);
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsAdvOutputLoad );
print "Output load (%): ";
if (defined ($data)) {
print "$data | ";
if ($data >= $loadcrit) {
escalate_exitval($ERRORS{'CRITICAL'});
} elsif ($data >= $loadwarn) {
escalate_exitval($ERRORS{'WARNING'});
} else {
escalate_exitval($ERRORS{'OK'});
}
} else {
print "unknown | ";
}
$data = get_snmp_int_val( $upsAdvTestDiagnosticsResults );
print "Diag result: ";
if (defined ($data) && defined ($diagnosticsResultsVals[$data][0])) {
print "$diagnosticsResultsVals[$data][0]\n";
escalate_exitval($diagnosticsResultsVals[$data][1]);
} else {
print "unknown\n";
}
exit $exitval;
sub print_usage () {
print "Usage: $PROGNAME -H <host> -T temp -t temp -R minutes -r minutes\n";
print " -L percent -l percent\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1771 $');
print "Copyright (c) 2001 Gerald Combs/Jeffrey Blank/Karl DeBisschop
This plugin reports the status of an APC UPS equipped with an SNMP management
module.
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-T --temp-critical
Battery degrees C above which a CRITICAL status will result (default: 60)
-t --temp-warning
Battery degrees C above which a WARNING status will result (default: 40)
-R --runtime-critical
Minutes remaining below which a CRITICAL status will result (default: 30)
-r --runtime-warning
Minutes remaining below which a WARNING status will result (default: 60)
-L --load-critical
Output load pct above which a CRITICAL status will result (default: 85
-l --load-warning
Output load pct above which a WARNING status will result (default: 50
";
support();
}
sub get_snmp_int_val ($) {
my $val=0;
my $oid = shift(@_);
$val = `/usr/bin/snmpget $host public $oid 2> /dev/null`;
my @test = split(/ /,$val,3);
return undef unless (defined ($test[2]));
if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP
($val) = ($test[2] =~ /\((\d+)\)/);
} elsif ($test[2] =~ /: \d+/) {
($val) = ($test[2] =~ /: (\d+)/);
} else {
$val = $test[2];
}
return $val;
}
sub escalate_exitval ($) {
my $newval = shift(@_);
if ($newval > $exitval) { $exitval = $newval; }
}

View file

@ -1,210 +0,0 @@
#! /usr/bin/perl -wT
#
# check_atalk_ping plugin for nagios
#
# usage:
# check_atalk_ping atalkaddress
#
# Checks if an atalkhost responds to an atalk echo
# using "aecho"
#
# initial version: 23 October 2002 by Stefan Beck, IT Software Solutions
# current status: $Revision: 1771 $
#
# Copyright Notice: GPL
#
BEGIN {
if ( $0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/ ) {
$runtimedir = $1;
$PROGNAME = $2;
}
delete $ENV{'LANG'};
}
use strict;
use lib "/usr/local/nagios/libexec";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
$PROGNAME = "check_atalk";
my (
$verbose, $host, $warning_avg, $warning_loss,
$critical_avg, $critical_loss, $count, $cmd,
$avg, $loss, $line
);
my ( $opt_c, $opt_w, $opt_H, $opt_p );
$opt_c = $opt_w = $opt_p = $opt_H = '';
sub print_help ();
sub print_usage ();
sub help ();
sub version ();
# Just in case of problems, let's not hang NetSaint
$SIG{'ALRM'} = sub {
print "Plugin Timeout\n";
exit 2;
};
alarm($TIMEOUT);
delete @ENV{ 'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' };
use Getopt::Long;
Getopt::Long::Configure( 'bundling', 'no_ignore_case' );
GetOptions(
"V|version" => \&version,
"h|help" => \&help,
"p|packets=i" => \$opt_p,
"c|critical=s" => \$opt_c,
"w|warning=s" => \$opt_w,
"H|hostname=s" => \$opt_H
);
# appletalk hostname ot address
$opt_H = shift unless ($opt_H);
unless ($opt_H) { print_usage (); exit $ERRORS{'UNKNOWN'}; }
if ( $opt_H && $opt_H =~ m/^([-a-zA-Z\.\:0-9]+)$/ ) {
$host = $1;
}
else {
print "$opt_H is not a valid host name\n";
exit $ERRORS{'UNKNOWN'};
}
# number of packets
$opt_p = 5 unless $opt_p;
if ( $opt_p && $opt_p =~ m/^([1-9]+[0-9]*)$/ ) {
$count = $1;
}
else {
print "$opt_p is not a valid packet number\n";
exit $ERRORS{'UNKNOWN'};
}
if ( $opt_w && $opt_w =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
$warning_avg = $1;
$warning_loss = $2;
}
else {
print "$opt_w is not a valid threshold\n";
exit $ERRORS{'UNKNOWN'};
}
if ( $opt_c && $opt_c =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
$critical_avg = $1;
$critical_loss = $2;
}
else {
print "$opt_c is not a valid threshold\n";
exit $ERRORS{'UNKNOWN'};
}
$cmd = "/usr/bin/aecho -c $count $host 2>&1 |";
print "$cmd\n" if ($verbose);
open CMD, $cmd;
while (<CMD>) {
print $_ if ($verbose);
$line = $_;
# 5 packets sent, 5 packets received, 0% packet loss
# round-trip (ms) min/avg/max = 0/0/0
if (/received, ([0-9]+)% packet loss/) {
$loss = $1;
}
if (/min\/avg\/max = [0-9]+\/([0-9]+)\/[0-9]+/) {
$avg = $1;
}
}
sub print_help() {
print_revision( $PROGNAME, '$Revision: 1771 $ ' );
print "Copyright (c) 2002 Stefan Beck\n";
print "\n";
print "Check if an atalkhost responds to an atalk echo using\n";
print " aecho -c <packets> <atalkhost>\n";
print "\n";
print_usage ();
print "\n";
print "-H, --hostname=HOST\n";
print " host to ping\n";
print "-w, --warning=THRESHOLD\n";
print " warning threshold pair\n";
print "-c, --critical=THRESHOLD\n";
print " critical threshold pair\n";
print "-p, --packets=INTEGER\n";
print " number of ICMP ECHO packets to send (Default: 5)\n";
print "\n";
print
"THRESHOLD is <rta>,<pl>% where <rta> is the round trip average
travel\n";
print
"time (ms) which triggers a WARNING or CRITICAL state, and <pl>
is the\n";
print "percentage of packet loss to trigger an alarm state.\n";
print "\n";
support();
}
sub print_usage () {
print "$PROGNAME -H atalkhost -w <wrta>,<wpl>% -c <crta>,<cpl>%\n";
print " [-p packets] [-t timeout] [-L]\n";
print "$PROGNAME [-h | --help]\n";
print "$PROGNAME [-V | --version]\n";
}
sub version () {
print_revision( $PROGNAME, '$Revision: 1771 $ ' );
exit $ERRORS{'OK'};
}
sub help () {
print_help ();
exit $ERRORS{'OK'};
}
my $state = "OK";
my $answer = undef;
if ( defined $loss && defined $avg ) {
if ( $loss >= $critical_loss ) {
$state = "CRITICAL";
}
elsif ( $avg >= $critical_avg ) {
$state = "CRITICAL";
}
elsif ( $loss >= $warning_loss ) {
$state = "WARNING";
}
elsif ( $avg >= $warning_avg ) {
$state = "WARNING";
}
else {
$state = "OK";
}
$answer = "Appletalk PING $state - Packet loss = $loss%, RTA = $avg
ms\n";
}
else {
$state = "UNKNOWN";
$answer = "UNKNOWN - $line";
}
print $answer;
exit $ERRORS{$state};
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nagios-devel mailing list
Nagios-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel

View file

@ -1,120 +0,0 @@
#! /usr/bin/perl -w
#
# check_arping.pl - Nagios plugin to check host status via ARP ping
#
# usage:
# check_arping -H hostname -I interface -T timeout
#
#
# Copyright (C) 2003 Kenny Root
#
# 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: kenny@the-b.org, nagiosplug-help@lists.sf.net
use POSIX;
use strict;
use lib "/usr/lib/nagios/plugins" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::Arping;
use Getopt::Long;
my $PROGNAME = "check_arping";
my($status, $state, $answer);
my($opt_V, $opt_h, $opt_t, $opt_I, $opt_H);
#Option checking
$status = GetOptions(
"V|version" => \$opt_V,
"help" => \$opt_h,
"I|interface=s" => \$opt_I,
"H|host=s" => \$opt_H,
"t|timeout=i" => \$opt_t);
if ($status == 0)
{
print_help() ;
exit $ERRORS{'OK'};
}
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1112 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if ($opt_t) {
if ($opt_t ne int($opt_t)) {
print "Timeout not in seconds!\n";
print_help();
exit $ERRORS{'OK'};
}
$opt_t = int($opt_t);
} else {
$opt_t = 3;
}
if (! utils::is_hostname($opt_H)){
usage();
exit $ERRORS{"UNKNOWN"};
}
my $ping = Net::Arping->new();
my $reply = $ping->arping(Host => $opt_H, Interface => $opt_I, Timeout => $opt_t);
if ($reply eq "0") {
$state = "CRITICAL";
print "$state: no reply from $opt_H on interface $opt_I in $opt_t seconds.\n";
exit $ERRORS{$state};
} else {
$state = "OK";
$answer = "replied with MAC address $reply";
}
print "ARPING $state - $answer\n";
exit $ERRORS{$state};
sub usage {
print "\nMissing arguments!\n";
print "\n";
print "check_arping -I <interface> -H <host IP> [-t <timeout>]\n";
print "\n\n";
support();
exit $ERRORS{"UNKNOWN"};
}
sub print_help {
print "check_arping pings hosts that normally wouldn't allow\n";
print "ICMP packets but are still on the local network.\n";
print "\nUsage:\n";
print " -H (--host) IP to query - (required)\n";
print " -I (--interface) Interface to use.\n";
print " -t (--timeout) Timeout in seconds.\n";
print " -V (--version) Plugin version\n";
print " -h (--help) usage help \n\n";
print_revision($PROGNAME, '$Revision: 1112 $');
}

View file

@ -1,259 +0,0 @@
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use Getopt::Long;
$|=1;
my (
$host, $username, $password, $verbose, $help, $command, $mode,
$ipaddr, $respaddr, $sendto, $msg, $recvfrom,
$version, $response, $message, $line,
$sock, $port, $reply,
$warning, $critical,
%warnval, %critval,
%channels,
$runmode,
$key,
$s,
);
my $stop = 0;
my $mgr_port = 5038;
my $iax_port = 4569;
my $exitcode = 0;
my $cause = "";
my $iax_answer = 0;
my $iax_maxlen = 1024;
my $iax_timeout = 5;
my $iax_src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc...
my $iax_dst_call = "0000";
my $iax_timestamp = "00000000";
my $iax_outbound_seq = "00";
my $iax_inbound_seq = "00";
my $iax_type = "06"; #IAX_Control
sub ok {
$s = shift;
$s =~ s/[\r\n]//g;
print "OK: $s\n";
exit(0);
}
sub warning {
$s = shift;
$s =~ s/[\r\n]//g;
print "WARNING: $s\n";
exit(1);
}
sub error {
$s = shift;
$s =~ s/[\r\n]//g;
print "ERROR: $s\n";
exit(2);
}
sub unknown {
$s = shift;
$s =~ s/[\r\n]//g;
print "UNKNOWN: $s\n";
exit(3);
}
sub syntax {
$s = shift;
unless ($s =~ m/Help:/) {
$s = "Error: (".$s.")" or $s = 'Unknown';
}
print "$s\n" unless ($help);
print "Syntax: $0 -m mgr -h <host> -u <username> -p <password> [-cwv]\n";
print "Syntax: $0 -m iax -h <host> [-v]\n";
print "* --host -h Host\n";
print "* --mode -m Mode - eithr 'mgr' or 'iax'\n";
print " --username -u Username\n";
print " --password -p Password\n";
print " --port -P n Port (if not using $mgr_port for manager or $iax_port for IAX)\n";
print " --warning xxx=n Return warning if > n channels of type xxx.\n";
print " --critical xxx=n Return critical if > n channels of type xxx.\n";
print " --verbose -v Verbose\n";
print " --help -h This help\n";
exit(3);
}
Getopt::Long::Configure('bundling');
GetOptions
("p=s" => \$password, "password=s" => \$password,
"u=s" => \$username, "username=s" => \$username,
"h=s" => \$host, "host=s" => \$host,
"P=i" => \$port, "port=i" => \$port,
"H" => \$help, "help" => \$help,
"v" => \$verbose, "verbose" => \$verbose,
"m=s" => \$mode, "mode=s" => \$mode,
"critical=s" => \$critical, "warning=s" => \$warning);
syntax("Help:") if ($help);
syntax("Missing host") unless (defined($host));
syntax("Missing mode") unless (defined($mode));
if ($mode =~ /^iax$/i) {
print "Running in IAX mode\n" if ($verbose);
$runmode = 1;
} elsif ($mode =~ /^mgr$/i) {
print "Running in Manager mode\n" if ($verbose);
$runmode = 2;
} else {
syntax("Unknown mode $mode")
}
##############################################################################
if ($runmode == 2) {
$port = $mgr_port;
syntax("Missing username") unless (defined($username));
syntax("Missing password") unless (defined($password));
if (defined($warning)) {
foreach $s (split(/,/, $warning)) {
syntax("Warning value given, $s, is invalid")
unless ($s =~ /^(\w+)=(\d+)$/);
$warnval{$1} = $2;
print "Clear to give WARNING after $2 connections on $1\n" if ($verbose);
}
}
if (defined($critical)) {
foreach $s (split(/,/, $critical)) {
syntax("Critical value given, $s, is invalid")
unless ($s =~ /^(\w+)=(\d+)$/);
$critval{$1} = $2;
print "Clear to give CRITICAL after $2 connections on $1\n" if ($verbose);
}
}
print "Connecting to $host:$port\n" if ($verbose);
unless ($sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp')) {
print("Could not connect to asterisk server ".$host.":".$port."\n");
exit(2);
}
print "Connected to $host:$port\n" if ($verbose);
$version = <$sock>;
print $version if ($verbose);
print $sock "Action: Login\r\nUsername: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n";
print "Action: Login\r\nUsername: $username\r\nSecret: $password\r\n\r\n" if ($verbose);
$response = <$sock>;
$message = <$sock>;
$s = <$sock>;
print $response.$message if ($verbose);
print $s if ($verbose);
exit(1) unless ($response =~ m/^Response:\s+(.*)$/i);
exit(1) unless ($1 =~ m/Success/i);
print $sock "Action: Status\r\n\r\n";
print "Action: Status\r\n\r\n" if ($verbose);
$response = <$sock>;
$message = <$sock>;
print $response.$message if ($verbose);
&unknown("Unknown answer $response (wanted Response: something)") unless ($response =~ m/^Response:\s+(.*)$/i);
&unknown("$response didn't say Success") unless ($1 =~ m/Success/i);
&unknown("Unknown answer $response (wanted Message: something)") unless ($message =~ m/^Message:\s+(.*)$/i);
&unknown("didn't understand message $message") unless ($1 =~ m/Channel status will follow/i);
$stop=0;
while (($stop == 0) && ($line = <$sock>)) {
print "$line" if ($verbose);
if ($line =~ m/Channel:\s+(\w+)\//) {
$channels{$1}++;
print "Found $1 channel\n" if ($verbose);
}
if ($line =~ m/Event:\s*StatusComplete/i) {
$stop++;
}
}
# Log out
print $sock "Action: Logoff\r\n\r\n";
undef($s);
foreach $key (keys %channels) {
$s .= " " . $key . " (" . $channels{$key} . ")";
}
foreach $key (keys %critval) {
print "key = $key\n" if ($verbose);
if (defined($channels{$key}) && ($channels{$key} > $critval{$key})) {
$exitcode = 2;
$cause .= $channels{$key} . " $key channels detected. ";
}
}
if ($exitcode < 2) {
foreach $key (keys %warnval) {
print "key = $key\n" if ($verbose);
if (defined($channels{$key}) && ($channels{$key} > $warnval{$key})) {
$exitcode = 1;
$cause .= $channels{$key} . " $key channels detected. ";
}
}
}
if ($exitcode == 0) {
print "OK ";
} elsif ($exitcode == 1) {
print "WARNING ";
} elsif ($exitcode == 2) {
print "CRITICAL ";
} elsif ($exitcode > 2) {
print "UNKNOWN ";
}
if (defined($s)) {
$cause .= " Channels:$s";
} else {
$cause .= " (idle)";
}
print $cause;
print "\n" if ($verbose);
exit($exitcode);
} elsif ($runmode == 1) {
$port = $iax_port;
socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp"));
$msg = pack "H24", $iax_src_call . $iax_dst_call . $iax_timestamp .
$iax_outbound_seq . $iax_inbound_seq . $iax_type . $iax_type;
$ipaddr = inet_aton($host);
$sendto = sockaddr_in($port,$ipaddr);
send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $host : $port : $!\n";
eval {
local $SIG{ALRM} = sub { die("alarm time out"); };
alarm $iax_timeout;
while (1) {
$recvfrom = recv(PING, $msg, $iax_maxlen, 0) or die "recv: $!";
($port, $ipaddr) = sockaddr_in($recvfrom);
$respaddr = inet_ntoa($ipaddr);
$iax_answer++;
# print "Response from $respaddr : $port\n";
}
};
if ($iax_answer) {
if ($iax_answer == 1) {
$reply = "reply";
} else {
$reply = "replies";
}
&ok("Got $iax_answer $reply");
} else {
&error("Got no reply");
}
}

View file

@ -1,95 +0,0 @@
#!/bin/sh
box=$1
port=$2
usr=$3
pass=$4
if [ ! "$#" == "4" ]; then
echo -e "\nYou did not supply enough command line arguments. \nUsage: ./check_axis.sh <host> <port> <username> <password> \n \nCheck_axis.sh checks the status of LPT ports on Axis print servers. \nIt was written by Tom De Blende (tom.deblende@village.uunet.be) in 2002. \n" && exit "3"
fi
tempfile=/tmp/status-$box.tmp
exit="3"
ftp -in $box &>/dev/null <<EOF
user $usr $pass
passive
prompt off
lcd /tmp
ascii
get status $tempfile
EOF
if [ ! -e "$tempfile" ]; then
stdio="Status file could not be transferred from the Axis box." && rm -f $tempfile && echo $stdio && exit 2;
fi
lines=`cat $tempfile | grep -i $port`
status=`echo $lines | awk '{ print $3 }'`
if [ "$status" == "Printing" ]; then
bytes=`echo $lines | awk '{ print $4 }'`;
comments=`echo $lines | tr -d "
" | awk '{ print $5 " " $6 }'`;
else
comments=`echo $lines | tr -d "
" | awk '{ print $4 " " $5 }'`;
fi
comma=`echo $comments | grep , | wc -l`
if [ "$comma" -eq "1" ]; then
comments=`echo $comments | cut -d, -f1`
fi
if [ "$status" == "Available" ]; then
if [ "$comments" == "Paper out" ]; then
exit="1" && stdio="WARNING - Out of paper.";
elif [ "$comments" == " " ]; then
exit="0" && stdio="OK - Printer is available but returns no comments.";
elif [ "$comments" == "No error" ]; then
exit="0" && stdio="OK - No error.";
elif [ "$comments" == "Ready " ]; then
exit="0" && stdio="OK - Ready.";
elif [ "$comments" == "Off line" ]; then
exit="1" && stdio="WARNING - Printer is off line.";
elif [ "$comments" == "Out of" ]; then
exit="1" && stdio="WARNING - Out of paper.";
elif [ "$comments" == "Busy Out" ]; then
exit="1" && stdio="WARNING - Busy, out of paper.";
elif [ "$comments" == "Printer off-line" ]; then
exit="1" && stdio="WARNING - Printer is off line.";
elif [ "$comments" == "Printer fault" ]; then
exit="2" && stdio="CRITICAL - Printer fault.";
else
exit="3" && stdio="Comments: $comments";
fi
elif [ "$status" == "Printing" ]; then
if [ "$comments" == "Printer busy" ]; then
exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
elif [ "$comments" == "No error" ]; then
exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
elif [ "$comments" == "Paper out" ]; then
exit="1" && stdio="WARNING - PRINTING. Out of paper.";
elif [ "$comments" == "Out of" ]; then
exit="1" && stdio="WARNING - PRINTING. Out of paper. Bytes printed: $bytes.";
elif [ "$comments" == "Busy Out" ]; then
exit="1" && stdio="WARNING - Busy, out of paper.";
elif [ "$comments" == "Ready " ]; then
exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
elif [ "$comments" == "Printer off-line" ]; then
exit="1" && stdio="WARNING - PRINTING. Printer is off line.";
elif [ "$comments" == "Busy " ]; then
exit="0" && stdio="OK - PRINTING. Busy. Bytes printed: $bytes.";
elif [ "$comments" == "Off line" ]; then
exit="1" && stdio="WARNING - PRINTING. Printer is off line.";
elif [ "$comments" == "Printer fault" ]; then
exit="2" && stdio="CRITICAL - PRINTING. Printer fault. Bytes printed: $bytes.";
else
exit="3" && stdio="Comments: $comments.";
fi
fi
rm -f $tempfile
echo $stdio
exit $exit

View file

@ -1,114 +0,0 @@
#! /usr/bin/perl -wT
# (c)2001 Patrick Greenwell, Stealthgeeks, LLC. (patrick@stealthgeeks.net)
# Licensed under the GNU GPL
# http://www.gnu.org/licenses/gpl.html
# check_backup: Checks a directory to see if at least one file was
# created within a specified period of time that is of equal to or greater
# than a given size.
# Version 1.0
# Last Updated: 9/12/01
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
require 5.004;
use strict;
use Getopt::Long;
use vars qw($opt_H $opt_d $opt_s $opt_t $verbose $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support &is_error);
sub help ();
sub print_help ();
sub print_usage ();
sub version ();
sub display_res($$);
my ($filesize, $answer) = ();
my $state = $ERRORS{'UNKNOWN'};
# Directory to check.
my $dir = "/backup/";
# Time period(in seconds)
my $within = "3600";
# Minimum size of file (in bytes)
my $minsize = "40000000";
delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"v|verbose" => \$verbose,
"d|directory=s" => \$opt_d,
"s|minsize=s" => \$opt_s,
"t|timeout=s" => \$opt_t,
);
($opt_s) || ($opt_s = shift) || usage("Minimum File size not specified\n");
usage("File size must be numeric value") unless ($opt_s =~ m/^[0-9]+$/);
(($opt_t) && ($TIMEOUT = $opt_t)) || ($TIMEOUT = 120);
usage("TIMEOUT must be numeric value") unless ($TIMEOUT =~ m/^[0-9]+$/);
# Don't hang if there are timeout issues
$SIG{'ALRM'} = sub {
print ("ERROR: No response from ftp server (alarm)\n");
exit $ERRORS{'UNKNOWN'};
};
alarm($TIMEOUT);
# Do stuff
my $time = time;
opendir(THISDIR, "$dir") or die "Can't open directory! $!";
my @allfiles = grep !/^\./, readdir THISDIR;
closedir THISDIR;
while (my $file = $dir . pop @allfiles){
my ($size, $mtime) = (stat($file))[7,9];
if (((my $a = ($time - $mtime)) <= $within) and ($size >= $opt_s)){
display_res("OK: File $file is <= $within and >=$opt_s bytes.\n","OK");
}
}
# If we got here nothing matched....
display_res("CRITICAL: No files in $dir are <= $within and >= $minsize.", "CRITICAL");
exit;
sub print_usage () {
print "Usage: $PROGNAME -s <minimum file size in bytes> -t <timeout> \n";
}
sub print_help () {
print_revision($PROGNAME,'$ Revision: 1.0 $ ');
print_usage();
support();
}
sub version () {
print_revision($PROGNAME,'$ Revision: 1.0 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}
sub display_res ($$) {
my ($answer, $state) = @_;
print $answer;
exit $ERRORS{$state};
}

View file

@ -1,215 +0,0 @@
#!/usr/bin/perl -w
#
# check_bgpstate.pl - nagios plugin
#
# Copyright (C) 2000 Christoph Kron
#
# 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
#
# 11.01.2000 Version 1.0
use strict;
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
# whois programm for RIPE database queries
my $whois = '/usr/bin/whois';
my $status;
my $TIMEOUT = 30;
# critical bgp sessions
my %uplinks = ( 1273, 'Uplink ECRC',
1755, 'Uplink EBONE',
3300, 'Uplink AUCS'
);
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my %bgpPeerState = (
'1',"idle",
'2',"connect",
'3',"active",
'4',"opensent",
'5',"openconfirm",
'6',"established"
);
my $state = "UNKNOWN";
my $answer = "";
my $snmpkey;
my $snmpoid;
my $key;
my $community = "public";
my $port = 161;
my @snmpoids;
my $snmpbgpPeerState = '1.3.6.1.2.1.15.3.1.2';
my $snmpbgpPeerLocalAddr = '1.3.6.1.2.1.15.3.1.5';
my $snmpbgpPeerRemoteAddr = '1.3.6.1.2.1.15.3.1.7';
my $snmpbgpPeerRemoteAs = '1.3.6.1.2.1.15.3.1.9';
my $hostname;
my $session;
my $error;
my $response;
my %bgpStatus;
my $bgpestablished =0 ;
my $bgpcritical =0;
my $bgpdown =0;
my $bgpidle =0;
my $bgpmessage;
my $asname;
my $remoteas;
my @output;
sub usage {
printf "\nMissing arguments!\n";
printf "\n";
printf "Perl bgpstate plugin for Nagios\n";
printf "monitors all BGP sessions\n";
printf "usage: \n";
printf "check_bgpstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "check_bgpstate.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"};
}
# 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);
$status = GetOptions("community=s",\$community,
"port=i",\$port);
if ($status == 0)
{
&usage;
}
#shift;
$hostname = shift || &usage;
push(@snmpoids, $snmpbgpPeerState);
push(@snmpoids, $snmpbgpPeerLocalAddr);
push(@snmpoids, $snmpbgpPeerRemoteAddr);
push(@snmpoids, $snmpbgpPeerRemoteAs);
foreach $snmpoid (@snmpoids) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
if (!defined($response = $session->get_table($snmpoid))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer,$snmpkey");
exit $ERRORS{$state};
}
foreach $snmpkey (keys %{$response}) {
$snmpkey =~ m/.*\.(\d+\.\d+\.\d+\.\d+$)/;
$key = $1;
# printf "debug: $snmpkey: $key -> $response->{$snmpkey}\n";
$bgpStatus{$key}{$snmpoid} = $response->{$snmpkey};
}
$session->close;
}
foreach $key (keys %bgpStatus) {
if ($bgpStatus{$key}{$snmpbgpPeerState} == 6 ) {
$bgpestablished++;
}
elsif ($bgpStatus{$key}{$snmpbgpPeerState} == 1 ) {
$bgpidle++;
}
else {
$bgpdown++ ;
if (exists($uplinks{$bgpStatus{$key}{$snmpbgpPeerRemoteAs}}) ) {
$bgpcritical++;
}
@output = `$whois -T aut-num AS$bgpStatus{$key}{$snmpbgpPeerRemoteAs}`;
$asname = "";
foreach (@output) {
if (m/as-name/) {
$asname = $_;
$asname =~ s/as-name://;
last;
}
if ( $asname =~ "" && m/descr/ ) {
$asname = $_;
$asname =~ s/descr://;
}
}
$asname =~ s/^\s*//;
$asname =~ s/\s*$//;
$bgpmessage .= sprintf("Peering with AS%s not established -> %s<BR>",
$bgpStatus{$key}{$snmpbgpPeerRemoteAs},
$asname);
}
}
if ($bgpdown > 0) {
if ($bgpcritical > 0) {
$state = 'CRITICAL';
}
else {
$state = 'WARNING';
}
$answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d<BR>",
$hostname,
$bgpestablished,
$bgpdown, $bgpidle);
$answer = $answer . $bgpmessage . "\n";
}
else {
$state = 'OK';
$answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d\n",
$hostname,
$bgpestablished,
$bgpdown,$bgpidle);
}
print ("$state: $answer");
exit $ERRORS{$state};

View file

@ -1,22 +0,0 @@
#!/usr/bin/perl
# Plugin to test signal strength on Breezecom wireless equipment
# Contributed by Jeffrey Blank
$Host=$ARGV[0];
$sig_crit=$ARGV[1];
$sig_warn=$ARGV[2];
$sig=0;
$sig = `snmpget $Host public .1.3.6.1.4.1.710.3.2.3.1.3.0`;
@test=split(/ /,$sig);
$sig=@test[2];
$sig=int($sig);
if ($sig>100){$sig=100}
print "Signal Strength at: $sig%\n";
if ($sig<$sig_crit)
{exit(2)}
if ($sig<$sig_warn)
{exit(1)}
exit(0);

View file

@ -1,332 +0,0 @@
/*****************************************************************************
*
* CHECK_CLUSTER.C - Host and Service Cluster Plugin for NetSaint
*
* Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)
* License: GPL
* Last Modified: 07-08-2000
*
* License:
*
* 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.
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#define OK 0
#define ERROR -1
#define TRUE 1
#define FALSE 0
#define CHECK_SERVICES 1
#define CHECK_HOSTS 2
#define MAX_INPUT_BUFFER 1024
#define STATE_OK 0
#define STATE_WARNING 1
#define STATE_CRITICAL 2
#define STATE_UNKNOWN 3
typedef struct clustermember_struct{
char *host_name;
char *svc_description;
struct clustermember_struct *next;
}clustermember;
int check_cluster_status(void);
int add_clustermember(char *,char *);
void free_memory(void);
clustermember *clustermember_list=NULL;
int total_services_ok=0;
int total_services_warning=0;
int total_services_unknown=0;
int total_services_critical=0;
int total_hosts_up=0;
int total_hosts_down=0;
int total_hosts_unreachable=0;
char status_log[MAX_INPUT_BUFFER]="";
int warning_threshold=0;
int critical_threshold=0;
int check_type=CHECK_SERVICES;
int main(int argc, char **argv){
char input_buffer[MAX_INPUT_BUFFER];
char *host_name;
char *svc_description;
int return_code=STATE_OK;
int error=FALSE;
if(argc!=5){
printf("Invalid arguments supplied\n");
printf("\n");
printf("Host/Service Cluster Plugin for NetSaint\n");
printf("Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)\n");
printf("Last Modified: 07-08-2000\n");
printf("License: GPL\n");
printf("\n");
printf("Usage: %s <--service | --host> <status_log> <warn_threshold> <crit_threshold>\n",argv[0]);
printf("\n");
printf("Options:\n");
printf(" --service = Check service cluster status\n");
printf(" --host = Check host cluster status\n");
printf(" <status_log> = This is the location of the NetSaint status log\n");
printf(" <warn_threshold> = This is the number of hosts or services in\n");
printf(" the cluster that must be in a non-OK state\n");
printf(" in order to result in a warning status level\n");
printf(" <crit_threshold> = This is the number of hosts or services in\n");
printf(" the cluster that must be in a non-OK state\n");
printf(" in order to result in a critical status level\n");
printf("\n");
printf("Notes:\n");
printf("Members of the host or service cluster are read from STDIN.\n");
printf("One host or service can be specified per line, services must\n");
printf("be in the format of <host_name>;<svc_description>\n");
printf("\n");
return STATE_UNKNOWN;
}
/* see if we're checking a host or service clust */
if(!strcmp(argv[1],"--host"))
check_type=CHECK_HOSTS;
else
check_type=CHECK_SERVICES;
/* get the status log */
strncpy(status_log,argv[2],sizeof(status_log)-1);
status_log[sizeof(status_log)-1]='\x0';
/* get the warning and critical thresholds */
warning_threshold=atoi(argv[3]);
critical_threshold=atoi(argv[4]);
/* read all data from STDIN until there isn't anymore */
while(fgets(input_buffer,sizeof(input_buffer)-1,stdin)){
if(feof(stdin))
break;
/*strip(input_buffer);*/
if(!strcmp(input_buffer,""))
continue;
if(!strcmp(input_buffer,"\n"))
continue;
/* get the host name */
if(check_type==CHECK_SERVICES)
host_name=(char *)strtok(input_buffer,";");
else
host_name=(char *)strtok(input_buffer,"\n");
if(host_name==NULL || !strcmp(host_name,"")){
printf("Error: Host name is NULL!\n");
continue;
}
if(check_type==CHECK_SERVICES){
/* get the service description */
svc_description=(char *)strtok(NULL,"\n");
if(svc_description==NULL || !strcmp(svc_description,"")){
printf("Error: Service description is NULL!\n");
continue;
}
}
/* add the cluster member to the list in memory */
if(add_clustermember(host_name,svc_description)!=OK)
printf("Error: Could not add cluster member\n");
#ifdef DEBUG
else
printf("Added cluster member\n");
#endif
}
/* check the status of the cluster */
if(check_cluster_status()==OK){
if(check_type==CHECK_SERVICES){
if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold)
return_code=STATE_CRITICAL;
else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
printf("Service cluster %s: %d ok, %d warning, %d unknown, %d critical\n",(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical);
}
else{
if((total_hosts_down+total_hosts_unreachable) >= critical_threshold)
return_code=STATE_CRITICAL;
else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
printf("Host cluster %s: %d up, %d down, %d unreachable\n",(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable);
}
}
else
return_code=STATE_UNKNOWN;
free_memory();
return return_code;
}
int add_clustermember(char *hst,char *svc){
clustermember *new_clustermember;
new_clustermember=(clustermember *)malloc(sizeof(clustermember));
if(new_clustermember==NULL)
return ERROR;
new_clustermember->host_name=NULL;
new_clustermember->svc_description=NULL;
if(hst!=NULL){
new_clustermember->host_name=(char *)malloc(strlen(hst)+1);
if(new_clustermember->host_name==NULL){
free(new_clustermember);
return ERROR;
}
strcpy(new_clustermember->host_name,hst);
}
if(svc!=NULL){
new_clustermember->svc_description=(char *)malloc(strlen(svc)+1);
if(new_clustermember->svc_description==NULL){
if(new_clustermember->host_name!=NULL)
free(new_clustermember->host_name);
free(new_clustermember);
return ERROR;
}
strcpy(new_clustermember->svc_description,svc);
}
new_clustermember->next=clustermember_list;
clustermember_list=new_clustermember;
return OK;
}
void free_memory(void){
clustermember *this_clustermember;
clustermember *next_clustermember;
for(this_clustermember=clustermember_list;this_clustermember!=NULL;this_clustermember=next_clustermember){
next_clustermember=this_clustermember->next;
if(this_clustermember->host_name!=NULL)
free(this_clustermember->host_name);
if(this_clustermember->svc_description!=NULL)
free(this_clustermember->svc_description);
free(this_clustermember);
}
return;
}
int check_cluster_status(void){
FILE *fp;
clustermember *temp_clustermember;
char input_buffer[MAX_INPUT_BUFFER];
char matching_entry[MAX_INPUT_BUFFER];
fp=fopen(status_log,"r");
if(fp==NULL){
printf("Error: Could not open status log '%s' for reading\n",status_log);
return ERROR;
}
#ifdef DEBUG
for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
if(check_type==CHECK_HOSTS)
printf("Cluster member: '%s'\n",temp_clustermember->host_name);
else
printf("Cluster member: '%s'/'%s'\n",temp_clustermember->host_name,temp_clustermember->svc_description);
}
#endif
for(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp);!feof(fp);fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
/* this is a host entry */
if(strstr(input_buffer,"] HOST;") && check_type==CHECK_HOSTS){
/* this this a match? */
for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
snprintf(matching_entry,sizeof(matching_entry)-1,";%s;",temp_clustermember->host_name);
if(strstr(input_buffer,matching_entry)){
if(strstr(input_buffer,";DOWN;"))
total_hosts_down++;
else if(strstr(input_buffer,";UNREACHABLE;"))
total_hosts_unreachable++;
else if(strstr(input_buffer,";UP;"))
total_hosts_up++;
}
}
}
/* this is a service entry */
else if(strstr(input_buffer,"] SERVICE;") && check_type==CHECK_SERVICES){
/* this this a match? */
for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
snprintf(matching_entry,sizeof(matching_entry)-1,";%s;%s;",temp_clustermember->host_name,temp_clustermember->svc_description);
if(strstr(input_buffer,matching_entry)){
if(strstr(input_buffer,";HOST DOWN;") || strstr(input_buffer,";UNREACHABLE;") || strstr(input_buffer,";CRITICAL;"))
total_services_critical++;
else if(strstr(input_buffer,";WARNING;"))
total_services_warning++;
else if(strstr(input_buffer,";UNKNOWN;"))
total_services_unknown++;
else if(strstr(input_buffer,";OK;") || strstr(input_buffer,";RECOVERY;"))
total_services_ok++;
}
}
}
}
fclose(fp);
return OK;
}

View file

@ -1,5 +0,0 @@
check_cluster2 is now part of the core Nagios-Plugins distribution and has
been renamed check_cluster. It will be installed automatically.
The threshold format has changed and is not backward-compatible; be sure to
understand it correctly. Use --help to print the full help.

View file

@ -1,232 +0,0 @@
/*****************************************************************************
*
* CHECK_CLUSTER2.C - Host and Service Cluster Plugin for Nagios 2.x
*
* Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)
* License: GPL
* Last Modified: 03-11-2004
*
* License:
*
* 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.
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#define OK 0
#define ERROR -1
#define TRUE 1
#define FALSE 0
#define CHECK_SERVICES 1
#define CHECK_HOSTS 2
#define MAX_INPUT_BUFFER 1024
#define STATE_OK 0
#define STATE_WARNING 1
#define STATE_CRITICAL 2
#define STATE_UNKNOWN 3
int total_services_ok=0;
int total_services_warning=0;
int total_services_unknown=0;
int total_services_critical=0;
int total_hosts_up=0;
int total_hosts_down=0;
int total_hosts_unreachable=0;
int warning_threshold=1;
int critical_threshold=1;
int check_type=CHECK_SERVICES;
char *data_vals=NULL;
char *label=NULL;
int process_arguments(int,char **);
int main(int argc, char **argv){
char input_buffer[MAX_INPUT_BUFFER];
char *ptr;
int data_val;
int return_code=STATE_OK;
int error=FALSE;
if(process_arguments(argc,argv)==ERROR){
printf("Invalid arguments supplied\n");
printf("\n");
printf("Host/Service Cluster Plugin for Nagios 2\n");
printf("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n");
printf("Last Modified: 03-11-2004\n");
printf("License: GPL\n");
printf("\n");
printf("Usage: %s (-s | -h) [-l label] [-w threshold] [-c threshold] [-d val1,val2,...,valn]\n",argv[0]);
printf("\n");
printf("Options:\n");
printf(" -s, --service = Check service cluster status\n");
printf(" -h, --host = Check host cluster status\n");
printf(" -l, --label = Optional prepended text output (i.e. \"Host cluster\")\n");
printf(" -w, --warning = Specifies the number of hosts or services in cluster that must be in\n");
printf(" a non-OK state in order to return a WARNING status level\n");
printf(" -c, --critical = Specifies the number of hosts or services in cluster that must be in\n");
printf(" a non-OK state in order to return a CRITICAL status level\n");
printf(" -d, --data = The status codes of the hosts or services in the cluster, separated\n");
printf(" by commas\n");
printf("\n");
return STATE_UNKNOWN;
}
/* check the data values */
for(ptr=strtok(data_vals,",");ptr!=NULL;ptr=strtok(NULL,",")){
data_val=atoi(ptr);
if(check_type==CHECK_SERVICES){
switch(data_val){
case 0:
total_services_ok++;
break;
case 1:
total_services_warning++;
break;
case 2:
total_services_critical++;
break;
case 3:
total_services_unknown++;
break;
default:
break;
}
}
else{
switch(data_val){
case 0:
total_hosts_up++;
break;
case 1:
total_hosts_down++;
break;
case 2:
total_hosts_unreachable++;
break;
default:
break;
}
}
}
/* return the status of the cluster */
if(check_type==CHECK_SERVICES){
if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold)
return_code=STATE_CRITICAL;
else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
printf("%s %s: %d ok, %d warning, %d unknown, %d critical\n",(label==NULL)?"Service cluster":label,(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical);
}
else{
if((total_hosts_down+total_hosts_unreachable) >= critical_threshold)
return_code=STATE_CRITICAL;
else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold)
return_code=STATE_WARNING;
else
return_code=STATE_OK;
printf("%s %s: %d up, %d down, %d unreachable\n",(label==NULL)?"Host cluster":label,(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable);
}
return return_code;
}
int process_arguments(int argc, char **argv){
int c;
int option=0;
static struct option longopts[]={
{"data", required_argument,0,'d'},
{"warning", required_argument,0,'w'},
{"critical", required_argument,0,'c'},
{"label", required_argument,0,'l'},
{"host", no_argument, 0,'h'},
{"service", no_argument, 0,'s'},
{0,0,0,0}
};
/* no options were supplied */
if(argc<2)
return ERROR;
while(1){
c=getopt_long(argc,argv,"hsw:c:d:l:",longopts,&option);
if(c==-1 || c==EOF || c==1)
break;
switch(c){
case 'h': /* host cluster */
check_type=CHECK_HOSTS;
break;
case 's': /* service cluster */
check_type=CHECK_SERVICES;
break;
case 'w': /* warning threshold */
warning_threshold=atoi(optarg);
break;
case 'c': /* warning threshold */
critical_threshold=atoi(optarg);
break;
case 'd': /* data values */
data_vals=(char *)strdup(optarg);
break;
case 'l': /* text label */
label=(char *)strdup(optarg);
break;
default:
return ERROR;
break;
}
}
if(data_vals==NULL)
return ERROR;
return OK;
}

View file

@ -1,296 +0,0 @@
From mm@elabnet.de Mon Nov 18 09:59:04 2002
Date: Mon, 18 Nov 2002 12:19:04 +0100
From: Michael Markstaller <mm@elabnet.de>
To: nagiosplug-devel@lists.sourceforge.net
Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq
Insight Agent status
Hi,
I've been looking to check the status/health of Compaq Insight Agents on
servers and found a spong plugin
(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi
ght) which I've slightly changed to work with Nagios.
I have pretty no idea of perl at all, just wanted to make it work for
me, so please don't shoot me for this copy-paste-code. I've tested some
basic things, it seems to work at least to report a warning if smthg is
degraded and OK of xcourse ;)
I'm also quite unsure if this is the right way to submit, so I'll just
try ;)
There're some "unknown" components on all servers I've checked so far,
if anybody has a documentation of what's exactly returned when getting
the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive)
I'd be happy to fix this.
--- cut ---
#!/usr/bin/perl
#
# (c)2002 Michael Markstaller, Elaborated Networks GmbH
# send bug reports to <mm@elabnet.de>
#
# 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
#
#
# Check Comapq Insight Management Agents Systems Status by SNMP
# based on the spong-plugin check_insight from:
#
http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig
ht
#
# Usage:
# check_insight -H <host> -C community
#
use Net::SNMP;
use Getopt::Long;
Getopt::Long::Configure('bundling');
$version=0.01;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
#
# some default values
#
$TIMEOUT=15;
#
# get command line options the regular way
#
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"v" => \$verbose, "verbose" => \$verbose,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"C=s" => \$opt_C, "community=s" => \$opt_C);
#
# handle the verbose stuff first
#
if ($opt_V) {
print "\n";
print "check_insight nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
may redistribute\n";
print "copies of the plugins under the terms of the GNU General
Public License.\n";
print "For more information about these matters, see the file
named COPYING.\n";
print "\n";
print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
print "\n";
print "\n";
exit $ERRORS{'UNKNOWN'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'UNKNOWN'};
}
#
# now get options the weired way and set the defaults
# if nothing else is provided
#
$opt_H = shift unless ($opt_H);
print_usage() unless ($opt_H);
#
# dont let us wait forever...
#
$SIG{'ALRM'} = sub {
print ("ERROR: No response from server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
#
# now we set things up for the real work
# and fire up the request
#
########################################################################
########
my ($host) = ($opt_H);
my ($color, $summary, $message ) = ( "green", "", "" );
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
my ($community) = $opt_C;
# We use some look up tables for checking some config options.
my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed");
my (@MIBName) = ("", "Std", "Unknown", "Array",
"Netware", "SCSI", "Health","Unknown",
"Store", "SM2", "Thresh", "OS", "UPS",
"Unknown", "IDE", "Clusters", "Fibre",
"MIB", "NIC");
# These are the positions within the table to actually look at.
my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18);
my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray
# Open the connection.
my ($session, $error) = Net::SNMP->session(Hostname => $host,
Community => $community);
# If we can't open a connection, just return red straight away.
if (! defined $session) {
print ("ERROR: Unable to contact server '$opt_H'\n");
exit $ERRORS{"UNKNOWN"};
}
$session->translate;
my ($response) = $session->get_request($oid);
if (!defined $response) {
# If there's no response, something screwy is going on, give up.
$summary = $session->error;
print ("ERROR: $summary\n");
exit $ERRORS{"UNKNOWN"};
$session->close;
} else {
$session->close;
# I'm not convinced that this is the easiest way to go about this,
this is
# from some code which I've inherited and I've modified for use in
here.
# Hi George!
%h = %$response;
my ($d) = $h{$oid};
my (@list) = ();
# Gobble the first two char's.
$d = substr $d,2;
while (length($d) > 0) {
my ($v) = substr($d,0,2);
$v = hex($v);
$d = substr $d,2;
push @list, $v;
}
# Value in $MIBs[1] is the overall status of the machine...
my ($cond) = $MIBs[1];
$message .= "Status: $State[$cond] ";
foreach my $v (@MIBs) {
$cond = $list[($v*4)+1]; # A little bit of magic.
# We only bother printing the status out if it's actually
available,
# as if it's N/A or Unknown then it's probably because the machine
# isn't available.
$message .= "$MIBName[$v]: $State[$cond] " if $cond > 1;
next if $cond < 2;
# What follows is some trickery to try and not to override a
previous
# message at the same or lower color.
if ($cond == 4) {
if ($color ne 'red') {
$color = 'red';
$summary = "$MIBName[$v] is failed";
}
} elsif ($cond == 3) {
if ($color ne 'red') {
$color = 'yellow';
$summary = "$MIBName[$v] is degraded" if $summary eq "";
}
} elsif ($cond < 2) {
if ($color eq 'green') {
$color = 'yellow';
$summary = "$MIBName[$v] is unknown ($cond)" if $summary eq
"";
}
}
}
}
$summary = "Ok" if $summary eq "";
# return ($color, $summary, $message);
if ($color eq 'red') {
print ("red Output: $message\n");
exit $ERRORS{"CRITICAL"};
} elsif ($color eq 'yellow') {
print ("$summary $message\n");
exit $ERRORS{"WARNING"};
} elsif ($color eq 'green') {
print ("$message\n");
exit $ERRORS{"OK"};
}
sub print_usage () {
print "Usage: $0 -H <host> -C <community> \n"; }
sub print_help () {
print "\n";
print "\n";
print "check_insight nagios plugin version $version\n";
print "\n";
print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
may redistribute\n";
print "copies of the plugins under the terms of the GNU General
Public License.\n";
print "For more information about these matters, see the file
named COPYING.\n";
print "\n";
print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
print "\n";
print "\n";
print "This plugin checks the Compaq Insight Management agents
system status via SNMP on the specified host.\n";
print "\n";
print "\n";
print_usage();
print "\n";
print "Options:\n";
print " -H, --hostname=ADDRESS\n";
print " host name argument for server.\n";
print " -C, --community=STRING\n";
print " SNMP Read-community string.\n";
print " -h, --help\n";
print " print detailed help screen.\n";
print " -V, --version\n";
print " print version information.\n";
print "\n";
print "\n";
}
--- cut ---
Michael
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing
your web site with SSL, click here to get a FREE TRIAL of a Thawte
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
Nagiosplug-devel mailing list
Nagiosplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel

View file

@ -1,430 +0,0 @@
/*
check_cpqarray, an extension for Netsaint / Nagios to check the
status of a Compaq SmartArray controller from the commandline.
Copyright (C) 2003 Guenther Mair
based on the work and using main parts of
CpqArray Deamon, a program to monitor and remotely configure a
SmartArray controller.
Copyright (C) 1999 Hugo Trippaers
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
*/
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "/usr/src/linux/drivers/block/ida_ioctl.h"
#include "/usr/src/linux/drivers/block/ida_cmd.h"
#include "/usr/src/linux/drivers/block/cpqarray.h"
const char *controllers[] =
{
"/dev/ida/c0d0",
"/dev/ida/c1d0",
"/dev/ida/c2d0",
"/dev/ida/c3d0",
"/dev/ida/c4d0",
"/dev/ida/c5d0",
"/dev/ida/c6d0",
"/dev/ida/c7d0"
};
const char *statusstr[] = {
"Logical drive /dev/ida/c%dd%d: OK\n",
"Logical drive /dev/ida/c%dd%d: FAILED\n",
"Logical drive /dev/ida/c%dd%d: not configured.\n",
"Logical drive /dev/ida/c%dd%d: using interim recovery mode, %3.2f%% done.\n",
"Logical drive /dev/ida/c%dd%d: ready for recovery operation.\n",
"Logical drive /dev/ida/c%dd%d: is currently recovering, %3.2f%% done.\n",
"Wrong physical drive was replaced.\n",
"A physical drive is not properly connected.\n",
"Hardware is overheating.\n",
"Hardware has overheated.\n",
"Logical drive /dev/ida/c%dd%d: currently expanding, %3.2f%% done.\n",
"Logical drive /dev/ida/c%dd%d: not yet available.\n",
"Logical drive /dev/ida/c%dd%d: queued for expansion.\n",
};
extern char *optarg;
extern int optind, opterr, optopt;
int ctrls_found_num;
int exit_code = 0;
struct controller ctrls_found[8];
#define DEBUG(x) fprintf(stderr, x)
struct opts
{
char debug;
};
struct slog_disk
{
int status;
float pvalue;
};
struct controller
{
char ctrl_devicename[20];
int num_logd_found;
struct slog_disk log_disk[16];
};
int status_check (struct opts opts)
{
int devicefd;
int ctrl_cntr;
int logd_cntr;
ida_ioctl_t io, io2;
int status, nr_blks, blks_tr;
float pvalue;
int counter;
for ( ctrl_cntr=0;
ctrl_cntr < ctrls_found_num;
ctrl_cntr++) {
devicefd = open (controllers[ctrl_cntr], O_RDONLY);
for ( logd_cntr=0;
logd_cntr < ctrls_found[ctrl_cntr].num_logd_found;
logd_cntr++) {
memset (&io, 0, sizeof (io));
io.cmd = SENSE_LOG_DRV_STAT;
io.unit = logd_cntr | UNITVALID;
if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
{
perror ("SENSE_LOG_DRV_STAT ioctl");
return 0;
}
status=io.c.sense_log_drv_stat.status;
if ((status == 3) || (status == 5) || (status == 7)) {
/* is a progress indicator required?
*/
memset (&io2, 0, sizeof (io));
io2.cmd = ID_LOG_DRV;
io2.unit = logd_cntr | UNITVALID;
if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0)
{
perror ("ID_LOG_DRV ioctl");
/* return 0; no return this isn't fatal for now */
}
else
{
nr_blks = io2.c.id_log_drv.nr_blks;
blks_tr = io.c.sense_log_drv_stat.blks_to_recover;
pvalue = ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100;
}
}
else {
pvalue = 0.0;
}
if (opts.debug) {
fprintf(stdout, "DEBUG: Status of controller %d unit %d is %d\n",
ctrl_cntr, logd_cntr, status);
fprintf(stdout, "DEBUG: ");
fprintf(stdout, statusstr[status],
ctrl_cntr, logd_cntr, pvalue);
fprintf(stdout, "\n");
}
printf(statusstr[status], ctrl_cntr, logd_cntr, pvalue);
switch(status)
{
case 1:
case 2:
case 6:
case 7:
case 9:
/* CRITICAL */
exit_code = 2;
break;
case 3:
case 4:
case 5:
case 8:
case 10:
case 11:
case 12:
/* WARNING (only if not yet at CRITICAL LEVEL) */
if (exit_code < 2) exit_code = 1;
break;
case 0:
default:
/* do nothing */
break;
}
ctrls_found[ctrl_cntr].log_disk[logd_cntr].pvalue = pvalue;
ctrls_found[ctrl_cntr].log_disk[logd_cntr].status = status;
}
close (devicefd);
}
return 1;
}
int discover_controllers (struct opts opts)
{
int cntr;
int foundone = 0;
for (cntr = 0; cntr < 8; cntr++)
{
/* does this device exist ? */
if ((access (controllers[cntr], R_OK | F_OK)) == 0)
{
/* it does :) */
if (interrogate_controller (opts, cntr))
{
foundone = 1;
if (opts.debug)
fprintf (stderr, "DEBUG: %s is a existing controller\n",
controllers[cntr]);
}
}
else if (opts.debug)
{
fprintf (stderr, "DEBUG: Device %s could not be opened\n", controllers[cntr]);
perror ("DEBUG: reason");
}
}
return foundone;
}
void boardid2str (unsigned long board_id, char *name)
{
switch (board_id)
{
case 0x0040110E: /* IDA */
strcpy (name, "Compaq IDA");
break;
case 0x0140110E: /* IDA-2 */
strcpy (name, "Compaq IDA-2");
break;
case 0x1040110E: /* IAES */
strcpy (name, "Compaq IAES");
break;
case 0x2040110E: /* SMART */
strcpy (name, "Compaq SMART");
break;
case 0x3040110E: /* SMART-2/E */
strcpy (name, "Compaq SMART-2/E");
break;
case 0x40300E11: /* SMART-2/P or SMART-2DH */
strcpy (name, "Compaq SMART-2/P (2DH)");
break;
case 0x40310E11: /* SMART-2SL */
strcpy (name, "Compaq SMART-2SL");
break;
case 0x40320E11: /* SMART-3200 */
strcpy (name, "Compaq SMART-3200");
break;
case 0x40330E11: /* SMART-3100ES */
strcpy (name, "Compaq SMART-3100ES");
break;
case 0x40340E11: /* SMART-221 */
strcpy (name, "Compaq SMART-221");
break;
case 0x40400E11: /* Integrated Array */
strcpy (name, "Compaq Integrated Array");
break;
case 0x40500E11: /* Smart Array 4200 */
strcpy (name, "Compaq Smart Array 4200");
break;
case 0x40510E11: /* Smart Array 4250ES */
strcpy (name, "Compaq Smart Array 4250ES");
break;
case 0x40580E11: /* Smart Array 431 */
strcpy (name, "Compaq Smart Array 431");
break;
default:
/*
* Well, its a SMART-2 or better, don't know which
* kind.
*/
strcpy (name, "Unknown Controller Type");
}
}
int interrogate_controller (struct opts opts, int contrnum)
{
int devicefd;
ida_ioctl_t io;
char buffer[30];
int foundone = 0;
int cntr;
devicefd = open (controllers[contrnum], O_RDONLY);
/* no checks, did that before */
/* clear io */
memset (&io, 0, sizeof (io));
io.cmd = ID_CTLR;
if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
{
if (opts.debug) perror ("DEBUG: ioctl");
return 0;
}
boardid2str (io.c.id_ctlr.board_id, buffer);
strncpy (ctrls_found[ctrls_found_num].ctrl_devicename,
buffer, 20);
ctrls_found[ctrls_found_num].num_logd_found = 0;
for (cntr = 0; cntr < io.c.id_ctlr.nr_drvs; cntr++)
{
if (interrogate_logical (opts, devicefd, cntr))
{
/* logical drive found, this could be used later one */
foundone = 1;
}
}
switch (ctrls_found[ctrls_found_num].num_logd_found)
{
case 0:
printf("Found a %s with no logical drives.\n", buffer);
break;
case 1:
printf("Found a %s with one Logical drive.\n", buffer,
ctrls_found[ctrls_found_num].num_logd_found);
break;
default:
printf("Found a %s with %d Logical drives.\n", buffer,
ctrls_found[ctrls_found_num].num_logd_found);
break;
}
ctrls_found_num++;
close (devicefd);
return 1;
}
int interrogate_logical (struct opts opts, int devicefd, int unit_nr)
{
ida_ioctl_t io;
ida_ioctl_t io2;
int nr_blks, blks_tr;
if (opts.debug) printf ("DEBUG: interrogating unit %d\n", unit_nr);
memset (&io, 0, sizeof (io));
io.cmd = ID_LOG_DRV;
io.unit = unit_nr | UNITVALID;
if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
{
perror ("FATAL: ID_LOG_DRV ioctl");
return 0;
}
memset (&io2, 0, sizeof (io2));
io2.cmd = SENSE_LOG_DRV_STAT;
io2.unit = unit_nr | UNITVALID;
if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0)
{
perror ("FATAL: SENSE_LOG_DRV_STAT ioctl");
return 0;
}
ctrls_found[ctrls_found_num].num_logd_found++;
/* ctrls_found[ctrls_found_num].log_disk[unit_nr].status =
* io2.c.sense_log_drv_stat.status;
* nr_blks = io2.c.id_log_drv.nr_blks;
* blks_tr = io.c.sense_log_drv_stat.blks_to_recover;
* ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue =
* ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100;
*/
ctrls_found[ctrls_found_num].log_disk[unit_nr].status = 0;
ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = 0;
return 1;
}
void print_usage()
{
printf("cpqarrayd [options]\n");
printf(" -h prints this text\n");
printf(" -d enables debugging\n");
}
int main(int argc, char *argv[])
{
char option;
struct opts opts; /* commandline options */
memset(&opts, 0, sizeof(struct opts));
/* check options */
while ((option = getopt (argc, argv, "dh:")) != EOF)
{
switch (option)
{
case 'd':
opts.debug = 1;
break;
case '?':
case 'h':
default:
print_usage();
exit(0);
break;
}
}
/* Check for existance of array controllers */
if (!discover_controllers(opts)) {
printf("No array controller found!\n\n");
exit(1);
}
status_check(opts);
return exit_code;
}

View file

@ -1,252 +0,0 @@
#!/usr/bin/perl -w
# check_digitemp.pl Copyright (C) 2002 by Brian C. Lane <bcl@brianlane.com>
#
# This is a NetSaint plugin script to check the temperature on a local
# machine. Remote usage may be possible with SSH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
# ===========================================================================
# Howto Install in NetSaint (tested with v0.0.7)
#
# 1. Copy this script to /usr/local/netsaint/libexec/ or wherever you have
# placed your NetSaint plugins
#
# 2. Create a digitemp config file in /usr/local/netsaint/etc/
# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/netsaint/etc/digitemp.conf
#
# 3. Make sure that the webserver user has permission to access the serial
# port being used.
#
# 4. Add a command to /usr/local/netsaint/etc/commands.cfg like this:
# command[check-temp]=$USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \
# -t $ARG3$ -f $ARG4$
# (fold into one line)
#
# 5. Tell NetSaint to monitor the temperature by adding a service line like
# this to your hosts.cfg file:
# service[kermit]=Temperature;0;24x7;3;5;1;home-admins;120;24x7;1;1;1;; \
# check-temp!65!75!1!/usr/local/netsaint/etc/digitemp.conf
# (fold into one line)
# 65 is the warning temperature
# 75 is the critical temperature
# 1 is the sensor # (as reported by digitemp -a) to monitor
# digitemp.conf is the path to the config file
#
# 6. If you use Centigrade instead of Fahrenheit, change the commands.cfg
# line to include the -C argument. You can then pass temperature limits in
# Centigrade in the service line.
#
# ===========================================================================
# Howto Install in Nagios (tested with v1.0b4)
#
# 1. Copy this script to /usr/local/nagios/libexec/ or wherever you have
# placed your Nagios plugins
#
# 2. Create a digitemp config file in /usr/local/nagios/etc/
# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/nagios/etc/digitemp.conf
#
# 3. Make sure that the webserver user has permission to access the serial
# port being used.
#
# 4. Add a command to /usr/local/nagios/etc/checkcommands.cfg like this:
#
# #DigiTemp temperature check command
# define command{
# command_name check_temperature
# command_line $USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \
# -t $ARG3$ -f $ARG4$
# (fold above into one line)
# }
#
# 5. Tell NetSaint to monitor the temperature by adding a service line like
# this to your service.cfg file:
#
# #DigiTemp Temperature check Service definition
# define service{
# use generic-service
# host_name kermit
# service_description Temperature
# is_volatile 0
# check_period 24x7
# max_check_attempts 3
# normal_check_interval 5
# retry_check_interval 2
# contact_groups home-admins
# notification_interval 240
# notification_period 24x7
# notification_options w,u,c,r
# check_command check_temperature!65!75!1! \
# /usr/local/nagios/etc/digitemp.conf
# (fold into one line)
# }
#
# 65 is the warning temperature
# 75 is the critical temperature
# 1 is the sensor # (as reported by digitemp -a) to monitor
# digitemp.conf is the path to the config file
#
# 6. If you use Centigrade instead of Fahrenheit, change the checkcommands.cfg
# line to include the -C argument. You can then pass temperature limits in
# Centigrade in the service line.
#
# ===========================================================================
# Modules to use
use strict;
use Getopt::Std;
# Define all our variable usage
use vars qw($opt_c $opt_f $opt_t $opt_w $opt_F $opt_C
$temperature $conf_file $sensor $temp_fmt
$crit_level $warn_level $null
%exit_codes
$percent $fmt_pct
$verb_err $command_line);
# Predefined exit codes for NetSaint
%exit_codes = ('UNKNOWN' ,-1,
'OK' , 0,
'WARNING' , 1,
'CRITICAL', 2,);
# Default to Fahrenheit input and result (use -C to change this)
$temp_fmt = 3;
# Get the options
if ($#ARGV le 0)
{
&usage;
} else {
getopts('f:t:FCc:w:');
}
# Shortcircuit the switches
if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0)
{
print "*** You must define WARN and CRITICAL levels!";
&usage;
}
# Check if levels are sane
if ($opt_w >= $opt_c)
{
print "*** WARN level must not be greater than CRITICAL when checking temperature!";
&usage;
}
$warn_level = $opt_w;
$crit_level = $opt_c;
# Default sensor to read is #0
if(!$opt_t)
{
$sensor = 0;
} else {
$sensor = $opt_t;
}
# Default config file is /etc/digitemp.conf
if(!$opt_f)
{
$conf_file = "/etc/digitemp.conf";
} else {
$conf_file = $opt_f;
}
# Check for config file
if( !-f $conf_file ) {
print "*** You must have a digitemp.conf file\n";
&usage;
}
if($opt_C)
{
$temp_fmt = 2;
}
# Read the output from digitemp
# Output in form 0\troom\tattic\tdrink
open( DIGITEMP, "/usr/local/bin/digitemp -c $conf_file -t $sensor -q -o $temp_fmt |" );
# Process the output from the command
while( <DIGITEMP> )
{
# print "$_\n";
chomp;
if( $_ =~ /^nanosleep/i )
{
print "Error reading sensor #$sensor\n";
close(DIGITEMP);
exit $exit_codes{'UNKNOWN'};
} else {
# Check for an error from digitemp, and report it instead
if( $_ =~ /^Error.*/i ) {
print $_;
close(DIGITEMP);
exit $exit_codes{'UNKNOWN'};
} else {
($null,$temperature) = split(/\t/);
}
}
}
close( DIGITEMP );
if( $temperature and $temperature >= $crit_level )
{
print "Temperature CRITICAL - Sensor #$sensor = $temperature ";
if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
exit $exit_codes{'CRITICAL'};
} elsif ($temperature and $temperature >= $warn_level ) {
print "Temperature WARNING - Sensor #$sensor = $temperature ";
if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
exit $exit_codes{'WARNING'};
} elsif( $temperature ) {
print "Temperature OK - Sensor #$sensor = $temperature ";
if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
exit $exit_codes{'OK'};
} else {
print "Error parsing result for sensor #$sensor\n";
exit $exit_codes{'UNKNOWN'};
}
# Show usage
sub usage()
{
print "\ncheck_digitemp.pl v1.0 - NetSaint Plugin\n";
print "Copyright 2002 by Brian C. Lane <bcl\@brianlane.com>\n";
print "See source for License\n";
print "usage:\n";
print " check_digitemp.pl -t <sensor> -f <config file> -w <warnlevel> -c <critlevel>\n\n";
print "options:\n";
print " -f DigiTemp Config File\n";
print " -t DigiTemp Sensor #\n";
print " -F Temperature in Fahrenheit\n";
print " -C Temperature in Centigrade\n";
print " -w temperature temperature >= to warn\n";
print " -c temperature temperature >= when critical\n";
exit $exit_codes{'UNKNOWN'};
}

View file

@ -1,221 +0,0 @@
#!/usr/bin/perl -w
#
# check_dlswcircuit.pl - nagios plugin
#
# Checks if a Cisco Dlsw circuit is connected.
#
#
# Copyright (C) 2000 Carsten Foss & Christoph Kron
#
# Basically this is an adapted version of Christoph Kron's (ck@zet.net) check_ifoperstatus.pl plugin.
# most of the thanks should go to him.
#
# 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.
#
# Arguments : -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME or IP-Addr>
# -
# Source & Dest Mac/Sap arguments must be given in Hex as this example : 40.00.01.37.45.01.ss (Where ss is the sap)
#
# Sample command line : check_dlswcircuit.pl -s 40.00.01.37.45.01.04 -d 40.00.02.37.45.02.04 -c secret 1.2.3.4
#
# Sample host.cfg entry :
#service[Dlsw-xx]=NCP1-NCP2;0;24x7;3;5;1;router-admins;240;24x7;1;1;0;;check_dlswcircuit!-s 40.00.01.37.45.01.04!-d 40.00..01.37.45.02.04!-c secret!1.2.3.4
# remember to add the service to commands.cfg , something like this:
# command[check_dlswcircuit]=$USER1$/check_dlswcircuit.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$
#
# Report bugs to: cfo@dmdata.dk
#
# 11.03.2000 Version 1.0
use strict;
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
my $status;
my $TIMEOUT = 15;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my %dlswCircuitStatus = (
'1','disconnected',
'2','circuitStart',
'3','resolvePending',
'4','circuitPending',
'5','circuitEstablished',
'6','connectPending',
'7','contactPending',
'8','connected',
'9','disconnectPending',
'10','haltPending',
'11','haltPendingNoack',
'13','circuitRestart',
'14','restartPending');
my $state = "UNKNOWN";
my $answer = "";
my $smac = "";
my $dmac = "";
my $community = "public";
my $port = 161;
#Dlsw Circuit Oid enterprises.9.10.9.1.5.2.1.17.6.0.96.148.47.230.166.4.6.64.0.1.55.69.2.4 = 8
my $enterpriseOid = "1.3.6.1.4.1";
my $ciscoDlswCircuitOid = ".9.10.9.1.5.2.1.17.";
my $unknownOid = "6.";
my $smacOid = "";
my $dmacOid = "";
my $tmpOid = "";
my @tmparg;
my $snmpoid;
my @snmpoids;
my $hostname;
my $session;
my $error;
my $response;
my $p = "";
my $q = "";
sub usage {
printf "\nMissing arguments!\n";
printf "\n";
printf "Perl Check Cisco Dlsw Circuit State plugin for Nagios\n";
printf "checks operational status of specified DLSW Circuit\n";
printf "usage: \n";
printf "check_dlswcircuit.pl -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME>";
printf "\nCopyright (C) 2000 Carsten Foss\n";
printf "check_dlswcircuit.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"};
}
# 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);
$status = GetOptions("sourcemac=s",\$smac,"destmac=s",\$dmac,
"community=s",\$community,
"port=i",\$port);
if ($status == 0)
{
&usage;
}
#
#Convert Source Mac & Sap
#
@tmparg = split(/\./,$smac);
#print "-$smac-\n";
#print "@tmparg\n";
#print "$#tmparg\n";
if($#tmparg != 6)
{
print "SourceMac/Sap format $smac not valid\n";
&usage;
}
while($p = shift @tmparg)
{
$q = hex($p);
$smacOid = $smacOid.$q;
$smacOid = $smacOid.'.';
}
#print "@tmparg1\n";
#print "$smacOid\n";
#
#Convert Dest Mac & Sap
#
@tmparg = split(/\./,$dmac);
#print "-$dmac-\n";
#print "@tmparg\n";
#print "$#tmparg\n";
if($#tmparg != 6)
{
print "DestMac/Sap format $dmac not valid\n";
&usage;
}
while($p = shift @tmparg)
{
$q = hex($p);
$dmacOid = $dmacOid.$q;
$dmacOid = $dmacOid.'.';
}
# Remove Trailing Dot
$dmacOid = substr($dmacOid,0,length($dmacOid)-1);
#print "@tmparg1\n";
#print "$dmacOid\n";
#Build the Dlsw Oic to use
$snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ;
#print "$snmpoid\n";
#shift;
$hostname = shift || &usage;
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
push(@snmpoids,$snmpoid);
#push(@snmpoids,$snmpLocIfDescr);
if (!defined($response = $session->get_request(@snmpoids))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer,$community,$smac - $dmac");
exit $ERRORS{$state};
}
$answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n",
$smac,
$dmac,
$hostname,
$dlswCircuitStatus{$response->{$snmpoid}}
);
$session->close;
if ( $response->{$snmpoid} == 8 ) {
$state = 'OK';
}
else {
$state = 'CRITICAL';
}
print ("$state: $answer");
exit $ERRORS{$state};

View file

@ -1,74 +0,0 @@
#!/usr/bin/perl
# ------------------------------------------------------------------------------
# File Name: check_dns_random.pl
# Author: Richard Mayhew - South Africa
# Date: 2000/01/26
# Version: 1.0
# Description: This script will check to see if dns resolves hosts
# randomly from a list using the check_dns plugin.
# 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 :)
# License GPL
# ------------------------------------------------------------------------------
# Date Author Reason
# ---- ------ ------
# 1999/09/26 RM Creation
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------[ Require ]--
require 5.004;
# --------------------------------------------------------------------[ Uses ]--
use Socket;
use strict;
# --------------------------------------------------------------[ Enviroment ]--
$ENV{PATH} = "/bin";
$ENV{BASH_ENV} = "";
$|=1;
my $host = shift || &usage;
my $domainfile = "/usr/local/nagios/etc/domains.list";
my $wc = `/usr/bin/wc -l $domainfile`;
my $check = "/usr/local/nagios/libexec/check_dns";
my $x = 0;
my $srv_file = "";
my $z = "";
my $y = "";
open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n";
while (<DOMAIN>) {
$srv_file .= $_;
}
close(DOMAIN);
my @data = split(/\n/,$srv_file);
chomp $wc;
$wc =~ s/ //g;
$wc =~ s/domains//g;
$x = rand $wc;
($z,$y) = split(/\./,$x);
system($check, $data[$z], $host);
exit ($? / 256);
sub usage
{
print "Minimum arguments not supplied!\n";
print "\n";
print "Perl Check Random DNS plugin for Nagios\n";
print "Copyright (c) 2000 Richard Mayhew\n";
print "\n";
print "Usage: check_dns_random.pl <host>\n";
print "\n";
print "<host> = DNS server you would like to query.\n";
exit -1;
}

View file

@ -1,309 +0,0 @@
#!/usr/bin/perl -w
#
# $Id: check_email_loop.pl 1290 2005-11-29 23:21:06Z harpermann $
#
# (c)2000 Benjamin Schmid, blueshift@gmx.net (emergency use only ;-)
# Copyleft by GNU GPL
#
#
# check_email_loop Nagios Plugin
#
# This script sends a mail with a specific id in the subject via
# an given smtp-server to a given email-adress. When the script
# is run again, it checks for this Email (with its unique id) on
# a given pop3 account and send another mail.
#
#
# Example: check_email_loop.pl -poph=mypop -popu=user -pa=password
# -smtph=mailer -from=returnadress@yoursite.com
# -to=remaileradress@friend.com -pendc=2 -lostc=0
#
# This example will send eacht time this check is executed a new
# mail to remaileradress@friend.com using the SMTP-Host mailer.
# Then it looks for any back-forwarded mails in the POP3 host
# mypop. In this Configuration CRITICAL state will be reached if
# more than 2 Mails are pending (meaning that they did not came
# back till now) or if a mails got lost (meaning a mail, that was
# send later came back prior to another mail).
#
# Michael Markstaller, mm@elabnet.de various changes/additions
# MM 021003: fixed some unquoted strings
# MM 021116: fixed/added pendwarn/lostwarn
# MM 030515: added deleting of orphaned check-emails
# changed to use "top" instead of get to minimize traffic (required changing match-string from "Subject: Email-ping [" to "Email-Ping ["
use Net::POP3;
use Net::SMTP;
use strict;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
# ----------------------------------------
my $TIMEOUT = 120;
my %ERRORS = ('OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
'UNKNOWN' , '3');
my $state = "UNKNOWN";
my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost,$keeporphaned);
my ($poptimeout,$smtptimeout,$pinginterval,$maxmsg)=(60,60,5,50);
my ($lostwarn, $lostcrit,$pendwarn, $pendcrit,$debug);
$debug = 0;
# Internal Vars
my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid);
my (%other_smtp_opts);
my ($matchcount,$statfile) = (0,"check_email_loop.stat");
# Subs declaration
sub usage;
sub messagematchs;
sub nsexit;
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: $0 Time-Out $TIMEOUT s \n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
# Evaluate Command Line Parameters
my $status = GetOptions(
"from=s",\$sender,
"to=s",\$receiver,
"debug", \$debug,
"pophost=s",\$pophost,
"popuser=s",\$popuser,
"passwd=s",\$poppasswd,
"poptimeout=i",\$poptimeout,
"smtphost=s",\$smtphost,
"smtptimeout=i",\$smtptimeout,
"statfile=s",\$statfile,
"interval=i",\$pinginterval,
"lostwarn=i",\$lostwarn,
"lostcrit=i",\$lostcrit,
"pendwarn=i",\$pendwarn,
"pendcrit=i",\$pendcrit,
"maxmsg=i",\$maxmsg,
"keeporphaned=s",\$keeporphaned,
);
usage() if ($status == 0 || ! ($pophost && $popuser && $poppasswd &&
$smtphost && $receiver && $sender ));
# Try to read the ids of the last send emails out of statfile
if (open STATF, "$statfile") {
@messageids = <STATF>;
chomp @messageids;
close STATF;
}
# Try to open statfile for writing
if (!open STATF, ">$statfile") {
nsexit("Failed to open mail-ID database $statfile for writing",'CRITICAL');
}
# Ok - check if it's time to release another mail
# ...
# creating new serial id
my $serial = time();
$serial = "ID#" . $serial . "#$$";
# sending new ping email
%other_smtp_opts=();
if ( $debug == 1 ) {
$other_smtp_opts{'Debug'} = 1;
}
my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts)
|| nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL');
($smtp->mail($sender) &&
$smtp->to($receiver) &&
$smtp->data() &&
$smtp->datasend("To: $receiver\nSubject: E-Mail Ping [$serial]\n\n".
"This is an automatically sent E-Mail.\n".
"It is not intended for a human reader.\n\n".
"Serial No: $serial\n") &&
$smtp->dataend() &&
$smtp->quit
) || nsexit("Error delivering message",'CRITICAL');
# no the interessting part: let's if they are receiving ;-)
$pop = Net::POP3->new( $pophost,
Timeout=>$poptimeout)
|| nsexit("POP3 connect timeout (>$poptimeout s, host: $pophost)",'CRITICAL');
$msgcount=$pop->login($popuser,$poppasswd);
$statinfo="$msgcount mails on POP3";
nsexit("POP3 login failed (user:$popuser)",'CRITICAL') if (!defined($msgcount));
# Check if more than maxmsg mails in pop3-box
nsexit(">$maxmsg Mails ($msgcount Mails on POP3); Please delete !",'WARNING') if ($msgcount > $maxmsg);
my ($mid, $nid);
# Count messages, that we are looking 4:
while ($msgcount > 0) {
@msglines = @{$pop->top($msgcount,1)};
for (my $i=0; $i < scalar @messageids; $i++) {
if (messagematchsid(\@msglines,$messageids[$i])) {
$matchcount++;
# newest received mail than the others, ok remeber id.
if (!defined $newestid) {
$newestid = $messageids[$i];
} else {
$messageids[$i] =~ /\#(\d+)\#/;
$mid = $1;
$newestid =~ /\#(\d+)\#/;
$nid = $1;
if ($mid > $nid) {
$newestid = $messageids[$i];
}
}
$pop->delete($msgcount); # remove E-Mail from POP3 server
splice @messageids, $i, 1;# remove id from List
last; # stop looking in list
}
}
# Delete orphaned Email-ping msg
my @msgsubject = grep /^Subject/, @msglines;
chomp @msgsubject;
# Scan Subject if email is an Email-Ping. In fact we match and delete also successfully retrieved messages here again.
if (!defined $keeporphaned && $msgsubject[0] =~ /E-Mail Ping \[/) {
$pop->delete($msgcount); # remove E-Mail from POP3 server
}
$msgcount--;
}
$pop->quit(); # necessary for pop3 deletion!
# traverse through the message list and mark the lost mails
# that mean mails that are older than the last received mail.
if (defined $newestid) {
$newestid =~ /\#(\d+)\#/;
$newestid = $1;
for (my $i=0; $i < scalar @messageids; $i++) {
$messageids[$i] =~ /\#(\d+)\#/;
my $akid = $1;
if ($akid < $newestid) {
$messageids[$i] =~ s/^ID/LI/; # mark lost
}
}
}
# Write list to id-Database
foreach my $id (@messageids) {
print STATF "$id\n";
}
print STATF "$serial\n"; # remember send mail of this session
close STATF;
# ok - count lost and pending mails;
my @tmp = grep /^ID/, @messageids;
my $pendingm = scalar @tmp;
@tmp = grep /^LI/, @messageids;
my $lostm = scalar @tmp;
# Evaluate the Warnin/Crit-Levels
if (defined $pendwarn && $pendingm > $pendwarn) { $state = 'WARNING'; }
if (defined $lostwarn && $lostm > $lostwarn) { $state = 'WARNING'; }
if (defined $pendcrit && $pendingm > $pendcrit) { $state = 'CRITICAL'; }
if (defined $lostcrit && $lostm > $lostcrit) { $state = 'CRITICAL'; }
if ((defined $pendwarn || defined $pendcrit || defined $lostwarn
|| defined $lostcrit) && ($state eq 'UNKNOWN')) {$state='OK';}
# Append Status info
$statinfo = $statinfo . ", $matchcount mail(s) came back,".
" $pendingm pending, $lostm lost.";
# Exit in a Nagios-compliant way
nsexit($statinfo);
# ----------------------------------------------------------------------
sub usage {
print "check_email_loop 1.1 Nagios Plugin - Real check of a E-Mail system\n";
print "=" x 75,"\nERROR: Missing or wrong arguments!\n","=" x 75,"\n";
print "This script sends a mail with a specific id in the subject via an given\n";
print "smtp-server to a given email-adress. When the script is run again, it checks\n";
print "for this Email (with its unique id) on a given pop3 account and sends \n";
print "another mail.\n";
print "\nThe following options are available:\n";
print " -from=text email adress of send (for mail returnr on errors)\n";
print " -to=text email adress to which the mails should send to\n";
print " -pophost=text IP or name of the POP3-host to be checked\n";
print " -popuser=text Username of the POP3-account\n";
print " -passwd=text Password for the POP3-user\n";
print " -poptimeout=num Timeout in seconds for the POP3-server\n";
print " -smtphost=text IP oder name of the SMTP host\n";
print " -smtptimeout=num Timeout in seconds for the SMTP-server\n";
print " -statfile=text File to save ids of messages ($statfile)\n";
print " -interval=num Time (in minutes) that must pass by before sending\n";
print " another Ping-mail (gibe a new try);\n";
print " -lostwarn=num WARNING-state if more than num lost emails\n";
print " -lostcrit=num CRITICAL \n";
print " -pendwarn=num WARNING-state if more than num pending emails\n";
print " -pendcrit=num CRITICAL \n";
print " -maxmsg=num WARNING if more than num emails on POP3 (default 50)\n";
print " -keeporphaned Set this to NOT delete orphaned E-Mail Ping msg from POP3\n";
print " -debug send SMTP tranaction info to stderr\n\n";
print " Options may abbreviated!\n";
print " LOST mails are mails, being sent before the last mail arrived back.\n";
print " PENDING mails are those, which are not. (supposed to be on the way)\n";
print "\nExample: \n";
print " $0 -poph=host -pa=pw -popu=popts -smtph=host -from=root\@me.com\n ";
print " -to=remailer\@testxy.com -lostc=0 -pendc=2\n";
print "\nCopyleft 19.10.2000, Benjamin Schmid / 2003 Michael Markstaller, mm\@elabnet.de\n";
print "This script comes with ABSOLUTELY NO WARRANTY\n";
print "This programm is licensed under the terms of the ";
print "GNU General Public License\n\n";
exit $ERRORS{"UNKNOWN"};
}
# ---------------------------------------------------------------------
sub nsexit {
my ($msg,$code) = @_;
$code=$state if (!defined $code);
print "$code: $msg\n" if (defined $msg);
exit $ERRORS{$code};
}
# ---------------------------------------------------------------------
sub messagematchsid {
my ($mailref,$id) = (@_);
my (@tmp);
my $match = 0;
# ID
$id =~ s/^LI/ID/; # evtl. remove lost mail mark
@tmp = grep /E-Mail Ping \[/, @$mailref;
chomp @tmp;
if (($tmp[0] =~ /$id/))
{ $match = 1; }
# Sender:
# @tmp = grep /^From:\s+/, @$mailref;
# if (@tmp && $sender ne "")
# { $match = $match && ($tmp[0]=~/$sender/); }
# Receiver:
# @tmp = grep /^To: /, @$mailref;
# if (@tmp && $receiver ne "")
# { $match = $match && ($tmp[0]=~/$receiver/); }
return $match;
}
# ---------------------------------------------------------------------

View file

@ -1,133 +0,0 @@
#!/usr/bin/perl
#
#
# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
#
# NetSaint host script to get the disk usage from NT snmp
#
# Changes and Modifications
# =========================
# 3-Aug-2000 - Xavier Dusart
# Created
# 2003 - Rainer Duffner
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
require 5.004;
use POSIX;
#use strict;
use Getopt::Std ;
use BER;
require 'SNMP_Session.pm';
use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
getopts('H:p:C:f:hV') ;
my $ip_address=undef ;
if ($opt_h) {&help();}
if ($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]*)*)$/) {
$ip_address = $opt_H ;
}
else {
usage();
print "IP-Address format wrong\n";
exit $ERRORS{'UNKNOWN'};
}
#if ($opt_p =~ m/^[0-9]
my $port = $opt_p;
my $community = $opt_C;
my $fan = $opt_f ;
#my $err_counter=0 ;
#my $err_status="";
my $fan_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,3,0,$fan );
# not used for the moment - gives no usable output
# if reused, enter at end of list to avoid renumbering !
my $fan_present_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,4,0,$fan );
my $fan_speed_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,6,0,$fan );
my $fan_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,9,0,$fan );
my $count=1 ;
my $label ;
my @r_array=();
my $q ;
my $diff ;
$warning=$warning/100 ;
$crititcal=$critical/100 ;
# get temperature, temperature_threshold bfore shutdown
my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
if ($session->get_request_response ($fan_present_oid, $fan_locale_oid, $fan_speed_oid, $fan_condition_oid )) {
(my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
while ($bindings ne '') {
($binding, $bindings) = &decode_sequence ($bindings) ;
($oid,$value) = &decode_by_template ($binding,"%O%@");
$r_array[$count]=&pretty_print($value);
$count++;
}
} else {
print "No response from agent\n";
exit $ERRORS{'CRITICAL'};
}
$result_fan_present= $r_array[1];
$result_fan_locale= $r_array[2];
$result_fan_speed= $r_array[3];
$result_fan_condition=$r_array[4];
if ( $result_fan_present != 3 || $result_fan_speed !=2 ) {
print "Fan ". $fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ;
exit $ERRORS{'CRITICAL'} ;
}
else {
print "Fan " .$fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ;
exit $ERRORS{'OK'} ;
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1113 $\n ');
print "Copyright (c) 2003 Rainer Duffner\n ";
print_usage();
print "\n";
print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
print "<port> = SNMP-Port (normaly 161)\n";
print "<community> = SNMP v1 community\n";
print "<fannumber> = Fannumber (1, 2, 3 etc.)\n";
}
sub version () {
print_revision($PROGNAME,'$Revision: 1113 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

View file

@ -1,135 +0,0 @@
#!/usr/bin/perl
#
#
# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
#
# NetSaint host script to get the disk usage from NT snmp
#
# Changes and Modifications
# =========================
# 3-Aug-2000 - Xavier Dusart
# Created
# 2003 - Rainer Duffner
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
require 5.004;
use POSIX;
#use strict;
use Getopt::Std ;
use BER;
require 'SNMP_Session.pm';
use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS);
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
getopts('H:p:C:f:hV') ;
my $ip_address=undef ;
if ($opt_h) {&help();}
if ($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]*)*)$/) {
$ip_address = $opt_H ;
}
else {
usage();
print "IP-Address format wrong\n";
exit $ERRORS{'UNKNOWN'};
}
#if ($opt_p =~ m/^[0-9]
my $port = $opt_p;
my $community = $opt_C;
my $fan = $opt_f ;
#my $err_counter=0 ;
#my $err_status="";
my $fan_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,4,0,$fan-1 );
# not used for the moment - gives no usable output
# if reused, enter at end of list to avoid renumbering !
my $fan_cur_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,8,0,$fan-1 );
my $fan_nom_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,9,0,$fan-1 );
my $fan_cur_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,10,0,$fan-1 );
my $fan_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,3,0,$fan-1 );
my $count=1 ;
my $label ;
my @r_array=();
my $q ;
my $diff ;
$warning=$warning/100 ;
$crititcal=$critical/100 ;
# get temperature, temperature_threshold bfore shutdown
my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
if ($session->get_request_response ($fan_locale_oid, $fan_cur_speed_oid, $fan_nom_max_speed_oid, $fan_cur_max_speed_oid, $fan_condition_oid )) {
(my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
while ($bindings ne '') {
($binding, $bindings) = &decode_sequence ($bindings) ;
($oid,$value) = &decode_by_template ($binding,"%O%@");
$r_array[$count]=&pretty_print($value);
$count++;
}
} else {
print "No response from agent\n";
exit $ERRORS{'CRITICAL'};
}
$result_fan_locale= $r_array[1];
$result_fan_cur_speed= $r_array[2];
$result_fan_nom_max_speed= $r_array[3];
$result_fan_cur_max_speed= $r_array[4];
$result_fan_condition=$r_array[5];
if ( $result_fan_condition != "3" ) {
print "Fan ". $fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ;
exit $ERRORS{'CRITICAL'} ;
}
else {
print "Fan " .$fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ;
exit $ERRORS{'OK'} ;
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1113 $\n ');
print "Copyright (c) 2003 Rainer Duffner\n ";
print_usage();
print "\n";
print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
print "<port> = SNMP-Port (normaly 161)\n";
print "<community> = SNMP v1 community\n";
print "<fannumber> = Fannumber (1, 2, 3 etc.)\n";
}
sub version () {
print_revision($PROGNAME,'$Revision: 1113 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

View file

@ -1,82 +0,0 @@
#!/usr/local/bin/perl
#
# 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
# current status: looks like working
#
# Copyright Notice: Do as you please, credit me, but don't blame me
#
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print "No Answer from Client\n";
exit 2;
};
alarm(20);
$lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat";
$licfile = shift;
#print "$licfile \n";
open CMD,"$lmstat -c $licfile |";
$serverup = 0;
while ( <CMD> ) {
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;
}
exit 0 if ( $servers == $lf1 + $lf2 + $lf3 );
exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
exit 2;

View file

@ -1,151 +0,0 @@
#! /usr/bin/perl -w
#
# $Id: check_frontpage 1112 2005-01-27 04:46:08Z stanleyhopcroft $
#
# Check that FrontPage extensions appear to be working on a specified host.
# Currently only checks that the hit counter is not returning an error.
#
# Probably not a good idea to use this on a host that someone's counting
# the hits on, so create a separate vhost for frontpage extensions testing,
# or just install the extensions on the default/root host for your server, and
# point it against that hostname, running it against all vhosts on a server is
# probably rather wasteful.
#
# Kev Green, oRe Net (http://www.orenet.co.uk/).
use strict;
use lib "/usr/lib/nagios/plugins";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
use Getopt::Long;
use LWP;
use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message);
my $rt = 0;
$PROGNAME = "check_frontpage";
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: 1112 $'); #'
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-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/);
print_usage() unless $host;
($opt_c) || ($opt_c = shift) || ($opt_c = 120);
if ($opt_c =~ /([0-9]+)/) {
$critical = $1;
} else {
$critical = 10;
}
($opt_w) || ($opt_w = shift) || ($opt_w = 60);
if ($opt_w =~ /([0-9]+)/) {
$warning = $1;
} else {
$warning = 5;
}
# Guts go here, once we're through argument parsing and have warning and
# critical thresholds.
my $browser = LWP::UserAgent->new;
my @urls = (
# This is the "Hit Counter", which continues to work if frontpage extensions
# are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed.
{
url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4",
mimetype => "image/gif",
message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?",
failtype => "CRITICAL"
},
# This is the "FrontPage Configuration Information" file, which is removed
# when you 'uninstall' the extensions from a site.
{
url => "_vti_inf.html",
mimetype => "text/html",
message => "Someone 'uninstall'ed extensions on virtual site?",
failtype => "WARNING"
}
);
print "FRONTPAGE: ";
foreach $temp (@urls) {
$url = $temp->{'url'};
$mimetype = $temp->{'mimetype'};
$failtype = $temp->{'failtype'};
$message = $temp->{'message'};
$stime = time();
$response=$browser->get("http://".$host."/".$url);
$etime = time();
$tt = $etime - $stime;
# If we got a server error, or unknown output type, report back as critical.
if ($response->status_line !~ "^200") {
print $message." (".$response->status_line.")\r\n";
exit $ERRORS{$failtype};
} elsif ($response->content_type !~ $mimetype) {
print $message." (Wrong Content-type: ".$response->content_type.")\r\n";
exit $ERRORS{$failtype};
} else {
# Because we're dealing with multiple URL's
$rt += $tt;
}
# Decide if the response time was critical or not.
#
if ($rt > $critical) {
print "Response time ".$rt." over critical threshold ".$critical."\r\n";
exit($ERRORS{'CRITICAL'});
} elsif ($rt > $warning) {
print "Response time ".$rt." over warning threshold ".$warning."\r\n";
exit($ERRORS{'WARNING'});
}
}
printf(" %s - %s second response time, ",$response->status_line, $rt);
# If all the required URL's give the right responses quick enough, then we
# should be okay.
exit($ERRORS{'OK'});
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
exit;
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1112 $');
print "Copyright (c) 2003 Kev Green\n";
print "\n";
print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n";
print_usage();
print "\n";
print "<warn> = Unknown.\n";
print "<crit> = Server error from FrontPage extensions.\n\n";
support();
}

View file

@ -1,209 +0,0 @@
/******************************************************************************************
*
* CHECK_HLTHERM.C
*
* Program: Hot Little Therm temperature plugin for Nagios
* License: GPL
* Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
*
* Last Modified: 02-28-2002
*
* Command line: check_hltherm <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower]
*
* Description:
*
* This plugin checks the temperature of a given temperature probe on a
* Hot Little Therm digital thermometer. The plugin uses the 'therm' utility
* that is included with the HLT software to check the probe temperature. Both
* the HLT digital thermometer and software are produced by Spiderplant. See
* their website at http://www.spiderplant.com/hlt for more information.
*
*****************************************************************************************/
#include "config.h"
#include "common.h"
#include "popen.h"
#define DEFAULT_TIMEOUT 10 /* default timeout in seconds */
#define HLTHERM_COMMAND "/usr/local/bin/therm" /* this should be moved out to the configure script */
static void timeout_alarm_handler(int); /* author must provide */
int process_arguments(int, char **);
int timeout_interval=DEFAULT_TIMEOUT;
double wtemp=0.0L;
double ctemp=0.0L;
int check_lower_temps=FALSE;
char probe[MAX_INPUT_BUFFER]="";
char label[MAX_INPUT_BUFFER]="Temperature";
char scale[MAX_INPUT_BUFFER]="Degrees";
FILE *fp;
int main(int argc, char **argv){
int result=STATE_OK;
char command[MAX_INPUT_BUFFER];
double temp=0.0L;
char input_buffer[MAX_INPUT_BUFFER];
int found=0;
/* process command line arguments */
result=process_arguments(argc,argv);
/* display usage if there was a problem */
if(result==ERROR){
printf("Incorrect arguments supplied\n");
printf("\n");
printf("Hot Little Therm temperature plugin for Nagios\n");
printf("Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)\n");
printf("Last Modified: 02-28-2002\n");
printf("License: GPL\n");
printf("\n");
printf("Usage: %s <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower]\n",argv[0]);
printf("\n");
printf("Options:\n");
printf(" <wtemp> = Temperature necessary to result in a WARNING state\n");
printf(" <ctemp> = Temperature necessary to result in a CRITICAL state\n");
printf(" [label] = A descriptive label for the probe. Example: \"Outside Temp\"\n");
printf(" [scale] = A descriptive label for the temperature scale. Example: \"Celsius\"\n");
printf(" [-lower] = Evaluate temperatures with lower values being more critical\n");
printf("\n");
printf("This plugin checks the temperature of a given temperature probe on a\n");
printf("Hot Little Therm digital thermometer. The plugin uses the 'therm' utility\n");
printf("included with the HLT software to check the probe temperature. Both the\n");
printf("HLT digital thermometer and software are produced by Spiderplant. See\n");
printf("their website at http://www.spiderplant.com/hlt for more information.\n");
printf("\n");
return STATE_UNKNOWN;
}
result=STATE_OK;
/* Set signal handling and alarm */
if(signal(SIGALRM,timeout_alarm_handler)==SIG_ERR){
printf("Cannot catch SIGALRM");
return STATE_UNKNOWN;
}
/* handle timeouts gracefully */
alarm(timeout_interval);
/* create the command line we're going to use */
snprintf(command,sizeof(command),"%s %s",HLTHERM_COMMAND,probe);
command[sizeof(command)-1]='\x0';
/* run the command to check the temperature on the probe */
fp=spopen(command);
if(fp==NULL){
printf("Could not open pipe: %s\n",command);
return STATE_UNKNOWN;
}
if(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
found=1;
temp=(double)atof(input_buffer);
}
/* close the pipe */
spclose(fp);
if(result==STATE_OK){
if(found==0){
printf("Therm problem - Could not read program output\n");
result=STATE_CRITICAL;
}
else{
if(check_lower_temps==TRUE){
if(temp<=ctemp)
result=STATE_CRITICAL;
else if(temp<=wtemp)
result=STATE_WARNING;
}
else{
if(temp>=ctemp)
result=STATE_CRITICAL;
else if(temp>=wtemp)
result=STATE_WARNING;
}
printf("Therm %s: %s = %2.1f %s\n",(result==STATE_OK)?"ok":"problem",label,temp,scale);
}
}
return result;
}
/* process command-line arguments */
int process_arguments(int argc, char **argv){
int x;
/* not enough options were supplied */
if(argc<4)
return ERROR;
/* first option is always the probe name */
strncpy(probe,argv[1],sizeof(probe)-1);
probe[sizeof(probe)-1]='\x0';
/* 2nd and 3rd options are temperature thresholds */
wtemp=(double)atof(argv[2]);
ctemp=(double)atof(argv[3]);
/* process all remaining arguments */
for(x=5;x<=argc;x++){
/* we got the lower temperature option */
if(!strcmp(argv[x-1],"-lower"))
check_lower_temps=TRUE;
/* we got the label */
else if(!strcmp(argv[x-1],"-l")){
if(x<argc){
strncpy(label,argv[x],sizeof(label));
label[sizeof(label)-1]='\x0';
x++;
}
else
return ERROR;
}
/* we got the scale */
else if(!strcmp(argv[x-1],"-s")){
if(x<argc){
strncpy(scale,argv[x],sizeof(scale));
scale[sizeof(scale)-1]='\x0';
x++;
}
else
return ERROR;
}
/* else we got something else... */
else
return ERROR;
}
return OK;
}
/* handle timeouts gracefully... */
static void timeout_alarm_handler(int signo){
if(signo==SIGALRM){
kill(childpid[fileno(fp)],SIGKILL);
printf("Therm problem - Check timed out after %d seconds\n",timeout_interval);
exit(STATE_CRITICAL);
}
}

View file

@ -1,221 +0,0 @@
#!/usr/bin/perl -wT
#
# Copyright (c) 2000 Hugo Gayosso
#
# Description:
# Nagios plug-in that monitors the resources on an HP-UX machine
# by querying the SNMP daemon
#
# License: General Public License (GPL)
# http://www.gnu.org/copyleft/gpl.txt
#
# ChangeLog
#
# Requirements: Perl 5.005 or higher
# Variable initialization
$ENV{'PATH'}="";
$ENV{'ENV'}="";
$ENV{'BASH_ENV'}="";
if (-e "/usr/bin/snmpwalk") {
$snmpwalk = "/usr/bin/snmpwalk";
} elsif (-e "/usr/local/bin/snmpwalk") {
$snmpwalk = "/usr/local/bin/snmpwalk";
}
# HP-UX SNMP OIDs
$filesystemID1_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.1";
$mounted_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.3";
$totalspace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.4";
$freespace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.6";
$path_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.10";
$cpu_5min_OID = ".1.3.6.1.4.1.11.2.3.1.1.4";
use Getopt::Long;
GetOptions( "check-filesystem" => \$chk_fs,
"show-filesystems" => \$show_fs,
"check-filesystemID" => \$chk_fsid,
"check-cpu" => \$chk_cpu,
"host=s" => \$target_host,
"community=s" => \$target_community,
"filesystemID1=i" => \$fsid1_opt,
"filesystem=s" => \$fs_opt,
"protocol:s" => \$proto_opt,
"warning=i" => \$warning_opt,
"critical=i" => \$critical_opt);
$proto_opt = 1
unless $proto_opt == 1 ||
$proto_opt == '2c' ||
$proto_opt == 3;
if ($chk_fs) {
walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID,$proto_opt );
walk_data($snmpwalk, $target_host, $target_community, $freespace_OID,$proto_opt ); check_filesystem($fs_opt, $warning_opt, $critical_opt);
} elsif ($show_fs) {
walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID,$proto_opt);
walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
walk_data($snmpwalk, $target_host, $target_community, $path_OID,$proto_opt);
show_filesystem();
} elsif ($chk_fsid){
$totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt";
$freespace_fsID_OID = "$freespace_OID.$fsid1_opt";
walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID,$proto_opt);
walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID,$proto_opt);
check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt);
} elsif ($chk_cpu) {
get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID,$proto_opt);
check_cpu_5min($cpu, $warning_opt, $critical_opt);
} else {
print "\n\nUsage:\n";
print "Checking 5-min CPU Load:\n";
print " $0 --check-cpu -warning <threshold> --critical <threshold> --host <yourhost> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
print "Checking local filesystem mounted on a host:\n";
print " $0 --show-filesystems --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
print "Checking by filesystem name:\n";
print " $0 --check-filesystem --filesystem </dev/vg00/lvol1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
print "Checking by filesystem ID:\n";
print " $0 --check-filesystemID --filesystemID <filesystemID1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
}
sub get_cpu_load {
my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
if ($pid) { # parent
while (<SNMPWALK>) {
my @snmpdata = split(/:/,$_);
$cpu = $snmpdata[1]/100;
}
close(SNMPWALK) or warn "kid exited $?";
} else { # child
exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
}
}
sub walk_data {
#This function queries the SNMP daemon for the specific OID
my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
if ($pid) { # parent
while (<SNMPWALK>) {
$output = $_;
sort_walk_data($output);
}
close(SNMPWALK) or warn "kid exited $?";
} else { # child
exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
}
}
sub sort_walk_data {
my ($snmp_data) = @_;
@fields = split(/\./,$snmp_data);
$item = $fields[8];
$filesystemID1 = $fields[9];
@fields2 = split(/=/,$fields[10]);
# $filesystemID2 = $fields2[0];
$value = $fields2[1];
chomp($value);
if ($value =~ /"/) {
@fields3 = split(/"/,$value);
$value = $fields3[1];
}
if ($item == 3) {
$mounted{$filesystemID1} = "$value";
} elsif ($item == 4) {
$totalspace{$filesystemID1} = "$value";
} elsif ($item == 6) {
$freespace{$filesystemID1} = "$value";
} elsif ($item == 10) {
$filesystempath{$filesystemID1} = "$value";
}
}
sub show_filesystem {
print "\n\nfilesystemID1\tmounted filesystem\tfilesystem path\n";
foreach $element (keys %mounted) {
print "$element\t$mounted{$element}\t\t$filesystempath{$element}\n";
}
print "\n\n";
}
sub check_filesystem {
# Warning = percentage of used space >= $warning and < $critical
# Critical = percentage of used space > $warning and >= $critical
# OK = percentage of used space < $warning and < $critical
my ($mounted_filesystem, $warning, $critical) = @_;
foreach $element (keys %mounted) {
if ($mounted{$element} eq $mounted_filesystem) {
my $warning_result = $totalspace{$element}*(100-$warning)/100;
my $critical_result = $totalspace{$element}*(100-$critical)/100;
my $result_percent = $freespace{$element}*100/$totalspace{$element};
if (($freespace{$element} <= $warning_result) && ($freespace{$element} > $critical_result)) {
printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 1;
} elsif ($freespace{$element} <= $critical_result) {
printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 2;
} else {
printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 0;
}
}
}
print "$mounted_filesystem doesn't exist in $target_host\n\n";
exit -1;
}
sub check_filesystemID1{
# Warning = percentage of used space >= $warning and < $critical
# Critical = percentage of used space > $warning and >= $critical
# OK = percentage of used space < $warning and < $critical
my ($fsid1, $warning, $critical) = @_;
foreach $element (keys %totalspace) {
if ($element eq $fsid1) {
my $warning_result = $totalspace{$element}*(100-$warning)/100;
my $critical_result = $totalspace{$element}*(100-$critical)/100;
my $result_percent = $freespace{$element}*100/$totalspace{$element};
if (($freespace{$element} <= $warning_result) && ($freespace{$element} >= $critical_result)) {
printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 1;
} elsif ($freespace{$element} <= $critical_result) {
printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 2;
} else {
printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
exit 0;
}
}
}
print "$fsid1 doesn't exist in $target_host\n\n";
exit -1;
}
sub check_cpu_5min {
my ($cpu, $warn, $crit) = @_;
if ($cpu >= $crit) {
print "Critical- 5-min load: $cpu\n";
exit 2;
} elsif ($cpu >= $warn) {
print "Warning - 5-min load: $cpu\n";
exit 1;
} else {
print "Load ok - 5-min load: $cpu\n";
exit 0;
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,66 +0,0 @@
#! /bin/sh
#
# Tested on SuSE 9.1 Professional with the hwinfo-8.62-0.2 package installed.
#
# Before you can run this plugin, you must do:
# /usr/sbin/hwinfo --short > /etc/hw.original
# add to cron job:
# /usr/sbin/hwinfo --short > /etc/hw.current
# /usr/bin/diff /etc/hw.original /etc/hw.current > /tmp/hw.check
#
#
# Rok Debevc -- rok.debevc@agenda.si
#
#
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: 939 $' | 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 changes."
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
;;
*)
if `du /tmp/hw.check | cut -c 1|grep "^[0]" > /dev/null` ; then
echo No hardware is changed
exit 0
else
echo ***hardware is changed*** look into /tmp/hw.check
exit 2
fi
;;
esac

View file

@ -1,228 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_ica_master_browser.pl 1099 2005-01-25 09:09:33Z stanleyhopcroft $
# Revision 1.1 2005/01/25 09:09:33 stanleyhopcroft
# New plugin - checks that ICA master browser is what it should be (important for firewalled dialup)
#
use strict ;
use IO::Socket;
use IO::Select;
use Getopt::Long ;
use lib qw(/usr/local/nagios/libexec) ;
use utils qw(%ERRORS &print_revision &support &usage);
use packet_utils qw(&pdump &tethereal) ;
my $PROGNAME = 'check_ica_master_browser' ;
# You might have to change this...
my $PACKET_TIMEOUT = 1;
# Number of seconds to wait for further UDP packets
my $TEST_COUNT = 2;
# Number of datagrams sent without reply
my $BUFFER_SIZE = 1500;
# buffer size used for 'recv' calls.
my $ICA_PORT = 1604;
# what port ICA runs on. Unlikely to change.
# End user config.
my ($debug, $preferred_master, $bcast_addr, $ica_browser, $timeout) ;
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"v|verbose" => \$debug,
"B|broadcast_addr:s" => \$bcast_addr,
"I|ica_browser:s" => \$ica_browser,
"P|preferred_master:s" => \$preferred_master,
"T|Packet_timeout:i" => \$timeout,
) ;
my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ;
usage("Invalid broadcast address: $bcast_addr")
if $bcast_addr and not defined($broadcast_addr) ;
usage("You must provide either the name of an ICA browser or the broadcast address of the subnet containing them\n")
unless ($ica_browser or $broadcast_addr) ;
usage("You must provide the name or address of a preferred ICA master browser\n")
unless ($preferred_master) ;
my $preferred_master_n = $preferred_master =~ m#(\d+\.\d+\.\d+\.\d+)#
? $preferred_master
: inet_ntoa(scalar gethostbyname($preferred_master)) ;
my $Timeout = $timeout || $PACKET_TIMEOUT ;
# Definitions of query strings. Change at your own risk :)
# this info was gathered with tcpdump whilst trying to use an ICA client,
# so I'm not 100% sure of what each value is.
my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ;
0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0..
0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0.......
0040 00 00 00 00 00 00 01 00 ........
End_of_Tethereal_trace
my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ;
0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0..
0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 00 00 00 00 00 00 00 00 ........
End_of_Tethereal_trace
my $Udp = IO::Socket::INET->new( Proto => 'udp' )
|| die "Socket failure: $!";
# select is here to allow us to set timeouts on the connections. Otherwise they
# just 'stop' until a server appears.
my $select = IO::Select->new($Udp)
|| die "Select failure: $!";
$Udp->sockopt(SO_BROADCAST, 1 );
my ($remote_host, $buff, $destination, $raddr, $rport, $rhost, @remote_response);
my ($query_message, $send_addr, $this_test) ;
$buff = '';
$this_test = 0;
# If there is no response to the first helo packet it will be resent
# up to $TEST_COUNT (see at the top).
$query_message = $broadcast_addr ? $bcast_helo : $direct_helo ;
$destination = $broadcast_addr ? $broadcast_addr: $ica_browser ;
$send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ) ;
while ( ++$this_test <= $TEST_COUNT && !$buff ) {
print "Sending helo datagram. datagram number: ", $this_test, "\n"
if $debug ;
print "Querying $destination for master browser\n"
if $debug ;
&pdump($query_message)
if $debug ;
$Udp->send($query_message, 0, $send_addr );
if ( $select->can_read($Timeout) ) {
$remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
}
last
if $buff ;
sleep 1 ;
}
# Ok we've looped several times, looking for a response. If we don't have one
# yet, we simply mark the whole lot as being unavailable.
unless ( $buff ) {
print "Failed. No response to helo datagram (master browser query) from $destination.\n" ;
exit $ERRORS{CRITICAL} ;
}
($rport, $raddr) = sockaddr_in( $remote_host );
$rhost = gethostbyaddr( $raddr, AF_INET );
my @tmpbuf = unpack('C*', $buff );
if ( $debug ) {
print "$rhost:$rport responded with: ",length($buff), " bytes\n";
&pdump($buff) ;
}
# Now we have a response, then we need to figure out the master browser, and
# query it for published applications...
my $master_browser = join '.', @tmpbuf[32..35] ;
my ($master_browser_a) = gethostbyaddr(inet_aton($master_browser), AF_INET) =~ /^(\w+?)\./ ;
# Ok should probably error check this, because it's remotely possible
# that a server response might be completely wrong...
print "Master browser = $master_browser_a/$master_browser\n"
if $debug ;
$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser));
my $subject_clause = $bcast_addr ? "of the \"$destination\" subnet" : "known to ICA server \"$destination\"" ;
if ( $master_browser eq $preferred_master_n ) {
print "Preferred master browser \"$preferred_master\" __is__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause.\n" ;
exit $ERRORS{OK} ;
} else {
print "\"\u$preferred_master\" is __not__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause: remote clients (dialup) may not find Published applications from Master Browser.\n" ;
exit $ERRORS{CRITICAL} ;
}
close $Udp;
sub print_usage () {
print "Usage: $PROGNAME (-B <broadcast_address>| -I <citrix_server>) - P <preferred_master_browser>" ;
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1099 $ ');
print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft
Perl Check Citrix Master Browser plugin for Nagios.
Returns OK if the Citrix master browser is that given by the -P option.
The plugin works by
If the -B option is specified, sends a broadcast helo to find the address of the Citrix master browser in the specified subnet.
return critical if there is no reply;
Else if the -I option is specified
send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser)
return Critical if the response does not contain the address of the 'preferred master browser' (-P option).
return OK
How ICA Clients Use the Master ICA Browser.
Citrix ICA Clients must locate the master browser to get the address of a server or published application.
The Citrix ICA Client can locate the master browser by sending out broadcast packets, or,
if the address of a Citrix server is specified in the Citrix ICA Client or in an ICA file,
the ICA Client locates the master browser by sending directed packets to the specified address.
The ICA Client requests the address of the ICA master browser from the Citrix server.
";
print_usage();
print '
-B, --broadcast_address:STRING
The broadcast address that should contain Citrix master browser. This option takes precedence over -I.
-I, --ica_browser:STRING
Optional name or address of an ICA server that could be the master browser (used when broadcast not possible).
-P, --preferred_master:STRING
Name or address of the ICA server that _should_ be the master browser.
Required.
-T, --packet-timeout:INTEGER
Time to wait for UDP packets (default 1 sec).
-v, --verbose
Debugging output.
-h, --help
This stuff.
';
support();
}
sub version () {
print_revision($PROGNAME,'$Revision: 1099 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

View file

@ -1,381 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_ica_metaframe_pub_apps.pl 1098 2005-01-25 09:07:39Z stanleyhopcroft $
# Revision 1.1 2005/01/25 09:07:39 stanleyhopcroft
# Replacement (structured name mainly) for check_citrix: check of ICA browse service
#
# Revision 1.1 2005-01-25 17:00:24+11 anwsmh
# Initial revision
#
use strict ;
use IO::Socket;
use IO::Select;
use Getopt::Long ;
my ($bcast_addr, $timeout, $debug, @citrix_servers, $crit_pub_apps, $warn_pub_apps, $long_list) ;
use lib qw(/usr/local/nagios/libexec) ;
use utils qw(%ERRORS &print_revision &support &usage) ;
use packet_utils qw(&pdump &tethereal) ;
my $PROGNAME = 'check_ica_metaframe_pub_apps' ;
sub print_help ();
sub print_usage ();
sub help ();
sub version ();
# You might have to change this...
my $PACKET_TIMEOUT = 1;
# Number of seconds to wait for further UDP packets
my $TEST_COUNT = 2;
# Number of datagrams sent without reply
my $BUFFER_SIZE = 1500;
# buffer size used for 'recv' calls.
my $LONG_LIST = 0 ;
# this is for if you have many published applications.
# if you set it, it won't do any harm, but may slow the test
# down a little. (Since it does a 'recv' twice instead of
# once and therefore may have to wait for a timeout).
my $ICA_PORT = 1604;
# what port ICA runs on. Unlikely to change.
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"v|verbose" => \$debug,
"B|broadcast_addr:s" => \$bcast_addr,
"C|citrix_servers:s" => \@citrix_servers,
"L|long_list" => \$long_list,
"P|crit_pub_apps:s" => \$crit_pub_apps,
"T|Packet_timeout:i" => \$timeout,
"W|warn_pub_apps:s" => \$warn_pub_apps,
) ;
my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ;
usage("Invalid broadcast address: $bcast_addr\n")
if $bcast_addr and not defined($broadcast_addr) ;
usage("You must provide either the names of citrix servers or the broadcast address of the subnet containing them\n")
unless (@citrix_servers or $broadcast_addr) ;
my @target = defined $broadcast_addr ? ($broadcast_addr) : @citrix_servers ;
usage("You must provide the names of the published applications that the Citrix browser should be advertising\n")
unless $crit_pub_apps or $warn_pub_apps ;
my $Timeout = $timeout
if defined $timeout ;
$Timeout = $PACKET_TIMEOUT
unless defined $Timeout ;
$long_list = $LONG_LIST
unless defined $long_list ;
my @crit_pub_apps = $crit_pub_apps ? split(/,/, $crit_pub_apps) : () ;
my @warn_pub_apps = $warn_pub_apps ? split(/,/, $warn_pub_apps) : () ;
# Definitions of query strings. Change at your own risk :)
# this info was gathered with tcpdump whilst trying to use an ICA client,
# so I'm not 100% sure of what each value is.
my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ;
0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0..
0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0.......
0040 00 00 00 00 00 00 01 00 .......
End_of_Tethereal_trace
my $bcast_query_app = &tethereal(<<'End_of_Tethereal_trace', '24') ;
0020 64 17 04 50 06 44 00 2c 85 6a 24 00 01 32 02 fd d..P.D.,.j$..2..
0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 00 00 00 00 21 00 02 00 00 00 00 00 ......!......
End_of_Tethereal_trace
my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ;
0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0..
0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 00 00 00 00 00 00 00 00 .........
End_of_Tethereal_trace
my $direct_query_app = &tethereal(<<'End_of_Tethereal_trace', '2c') ;
0020 64 17 05 10 06 44 00 34 7a 9a 2c 00 02 32 02 fd d....D.4z.,..2..
0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 00 00 00 00 21 00 02 00 01 00 00 00 00 00 ......!.........
0050 00 00 00 00 00 00 ......
End_of_Tethereal_trace
my $Udp = IO::Socket::INET->new( Proto => 'udp' )
|| die "Socket failure: $!";
# Select is here to allow us to set timeouts on the connections.
# Otherwise they just 'stop' until a server appears.
my $select = IO::Select->new($Udp)
|| die "Select failure: $!";
# Helo needs to be broadcastt, but query does not.
$Udp->sockopt(SO_BROADCAST, 1 );
my ($remote_host, $buff, $buff2, $raddr, $rport, $rhost, @remote_response);
my ($query_message, $send_addr, $this_test) ;
$buff = $buff2 = '';
$this_test = 0;
# If there is no response to the first helo packet it will be resent
# up to TEST_COUNT (see at the top).
while ( ++$this_test <= $TEST_COUNT && !$buff ) {
print "Sending helo datagram. datagram number: ", $this_test, "\n"
if $debug ;
# If we have multiple targets, we probe each of them until we get a
# response...
foreach my $destination (@target) {
$query_message = $broadcast_addr ? $bcast_helo : $direct_helo ;
print "Querying $destination for master browser\n"
if $debug ;
$send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) );
&pdump($query_message)
if $debug ;
$Udp->send($query_message, 0, $send_addr );
if ( $select->can_read($Timeout) ) {
$remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
}
last
if $buff ;
sleep 1 ;
}
}
# Ok we've looped several times, looking for a response. If we don't have one
# yet, we simply mark the whole lot as being unavailable.
unless ( $buff ) {
print "Failed. No response to helo datagram (master browser query) from ", $broadcast_addr ? $broadcast_addr : "@citrix_servers", ".\n" ;
exit $ERRORS{CRITICAL} ;
}
($rport, $raddr) = sockaddr_in( $remote_host );
$rhost = gethostbyaddr( $raddr, AF_INET );
my @tmpbuf = unpack('C*', $buff );
if ( $debug ) {
print "$rhost:$rport responded with: ", length($buff), " bytes\n";
&pdump($buff) ;
}
# Now we have a response, then we need to figure out the master browser, and
# query it for published applications...
my $master_browser = join '.', @tmpbuf[32..35] ;
# Ok should probably error check this, because it's remotely possible
# that a server response might be completely wrong...
print "Master browser = $master_browser\n"
if $debug ;
$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser));
if ( $broadcast_addr ) {
print "using broadcast query\n"
if $debug ;
$query_message = $bcast_query_app;
} else {
print "using directed query\n"
if $debug ;
$query_message = $direct_query_app;
}
# Now we send the appropriate query string, to the master browser we've found.
$buff = '';
$this_test = 0 ;
print "Querying master browser for published application list\n"
if $debug ;
while ( ++$this_test <= $TEST_COUNT && !$buff ) {
print "Sending application query datagram. datagram number: ", $this_test, "\n"
if $debug ;
&pdump($query_message)
if $debug ;
$Udp->send($query_message, 0, $send_addr);
if ( $select->can_read($Timeout) ) {
$remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
# $buff = substr($buff, 32) ;
# Hope that ICA preamble is first 32 bytes
}
# Long application lists are delivered in multiple packets
my $buff2 = '' ;
while ( $long_list && $select->can_read($Timeout) ) {
$remote_host = $Udp->recv($buff2, $BUFFER_SIZE, 0);
$buff .= $buff2
if $buff2 ;
# $buff .= substr($buff2, 32) if $buff2 ;
# Hope that ICA preamble is first 32 bytes
}
last if $buff ;
sleep 1 ;
}
unless ( $buff ) {
print "Failed. No response to application query datagram from ", $master_browser, ".\n" ;
exit $ERRORS{CRITICAL} ;
}
# we got a response from a couple of retries of the app query
($rport, $raddr) = sockaddr_in ( $remote_host );
$rhost = gethostbyaddr ( $raddr, AF_INET );
if ( $debug ) {
print "$rhost:$rport responded to app query with: ", length($buff), " bytes\n";
&pdump($buff) ;
}
my $app_list = $buff ;
# delete nulls in unicode
# but only if there is unicode (usually from
# broadcast query)
$app_list =~ s/(?:(\w| |-)\x00)/$1/g
if $app_list =~ /(?:(?:(?:\w| |-)\x00){3,})/ ;
# FIXME an application name is
# 3 or more unicoded characters
# FIXME locale
# extract null terminated strings
my (@clean_app_list, $clean_app_list) ;
$clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Za-z](?:\w| |-|[ÄÖÜäöüß])+?(?=\x00))#g ) ;
# patch for German umlauts et al from Herr Mike Gerber.
# $clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Z](?:\w| |-)+?(?=\x00))#g ) ;
# FIXME everyones apps don't start with caps
print qq(Received list of applications: "$clean_app_list".\n)
if $debug ;
if ( scalar @crit_pub_apps and my @missing = &simple_diff(\@clean_app_list, \@crit_pub_apps) ) {
print qq(Failed. "@missing" not found in list of published applications),
qq(" $clean_app_list" from master browser "$master_browser".\n) ;
exit $ERRORS{CRITICAL} ;
}
if ( my @missing = &simple_diff(\@clean_app_list, \@warn_pub_apps) ) {
print qq(Warning. "@missing" not found in list of published applications),
qq(" $clean_app_list" from master browser "$master_browser".\n) ;
exit $ERRORS{WARNING} ;
}
my @x = (@crit_pub_apps, @warn_pub_apps) ;
my $blah = ( scalar(@x) == 1
? 'the published application "' . join(',', @x) . '" is available'
: 'the published applications "' . join(',', @x) . '" are available' ) ;
print qq(Ok. Citrix master browser "$master_browser" reported that $blah.\n) ;
exit $ERRORS{OK} ;
# sleep $Timeout;
# because otherwise we can get responses from
# the WRONG servers. DOH
close $Udp;
sub print_usage () {
print "Usage: $PROGNAME (-B <broadcast_address>| -C <citrix_server>..) -W <pub_app1,pub_app2..> -P <pub_app1,pub_app2,>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1098 $ ');
print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft
Perl Check Citrix plugin for Nagios.
Returns OK if the Citrix master browser returns a 'published application' list that contain names specified by the -W or -P options
The plugin works by
If the -B option is specified, sending a broadcast helo to find the address of the Citrix master browser in the specified subnet.
return critical if there is no reply;
Else if the -C option is specified
send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser)
Query the master browser (using a 'broadcast published applications query ' if -B) and compare the published applications returned
to those specified by -W and -P options
return Critical if the published applications specified by -P is not a subset of the query responses;
return Warning if the published applications specified by -W is not a subset of the query responses;
return OK
";
print_usage();
print '
-B, --broadcast_address=STRING
The broadcast address that should contain Citrix master browser. This option takes precedence over -C.
-C, --citrix_server:STRING
Optional __name(s)__ of Citrix servers that could be the master browser (used when broadcast not possible).
-L, --long_list
Set this if you have heaps of published applications (ie more than will fit in _one_ UDP packet)
-P, --crit_published_app=STRING
Optional comma separated list of published application that must be in the response from the master browser.
Check returns critical otherwise.
-T, --packet-timeout:INTEGER
Time to wait for UDP packets (default 1 sec).
-W, --warn_published_app=STRING
Optional comma separated list of published application that should be in the response from the master browser.
Check returns warning otherwise.
-v, --verbose
Debugging output.
-h, --help
This stuff.
';
support();
}
sub version () {
print_revision($PROGNAME,'$Revision: 1098 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}
sub simple_diff {
my ( $a_list, $b_list) = @_ ;
# simple set difference 'Recipe 4.7 Perl Cookbook', Christiansen and Torkington
my (%seen, @missing) ;
@seen{@$a_list} = () ;
foreach my $item (@$b_list) {
push @missing, $item
unless exists $seen{$item} ;
}
@missing ;
}

View file

@ -1,618 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_ica_program_neigbourhood.pl 1097 2005-01-25 09:05:53Z stanleyhopcroft $
# Revision 1.1 2005/01/25 09:05:53 stanleyhopcroft
# New plugin to check Citrix Metaframe XP "Program Neighbourhood"
#
# Revision 1.1 2005-01-25 16:50:30+11 anwsmh
# Initial revision
#
use strict ;
use Getopt::Long;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use LWP 5.65 ;
use XML::Parser ;
my $PROGNAME = 'check_program_neigbourhood' ;
my ($debug, $xml_debug, $pn_server, $pub_apps, $app_servers, $server_farm, $usage) ;
Getopt::Long::Configure('bundling', 'no_ignore_case') ;
GetOptions
("V|version" => \&version,
"A|published_app:s" => \$pub_apps,
"h|help" => \&help,
'usage|?' => \&usage,
"F|server_farm=s" => \$server_farm,
"P|pn_server=s" => \$pn_server,
"S|app_server=s" => \$app_servers,
"v|verbose" => \$debug,
"x|xml_debug" => \$xml_debug,
) ;
$pn_server || do {
print "Name or IP Address of _one_ Program Neighbourhood server is required.\n" ;
&print_usage ;
exit $ERRORS{UNKNOWN} ;
} ;
$pub_apps ||= 'Word 2003' ;
$pub_apps =~ s/["']//g ;
my @pub_apps = split /,\s*/, $pub_apps ;
my @app_servers = split /,\s*/, $app_servers ;
@app_servers || do {
print "IP Address of _each_ Application server in the Metaframe Citrix XP server farm is required.\n" ;
&print_usage ;
exit $ERRORS{UNKNOWN} ;
} ;
my @non_ip_addresses = grep ! /\d+\.\d+\.\d+\.\d+/, @app_servers ;
scalar(@non_ip_addresses) && do {
print qq(Application servers must be specified by IP Address (not name): "@non_ip_addresses".\n) ;
&print_usage ;
exit $ERRORS{UNKNOWN} ;
} ;
$server_farm || do {
print "Name of Citrix Metaframe XP server farm is required.\n" ;
&print_usage ;
exit $ERRORS{UNKNOWN} ;
} ;
my %xml_tag = () ;
my @tag_stack = () ;
my $xml_p = new XML::Parser(Handlers => {Start => \&handle_start,
End => sub { pop @tag_stack },
Char => \&handle_char}) ;
# values required by Metaframe XP that don't appear to matter too much
my $client_host = 'Nagios server (http://www.Nagios.ORG)' ;
my $user_name = 'nagios' ;
my $domain = 'Nagios_Uber_Alles' ;
# end values required by Metaframe XP
my $nilpotent_req = <<'EOR' ;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"><NFuseProtocol version="1.1">
<RequestProtocolInfo>
<ServerAddress addresstype="dns-port" />
</RequestProtocolInfo>
</NFuseProtocol>
EOR
my $server_farm_req = <<'EOR' ;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<RequestServerFarmData>
<Nil />
</RequestServerFarmData>
</NFuseProtocol>
EOR
my $spec_server_farm_req = <<EOR ;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<RequestAddress>
<Name>
<UnspecifiedName>$server_farm*</UnspecifiedName>
</Name>
<ClientName>$client_host</ClientName>
<ClientAddress addresstype="dns-port" />
<ServerAddress addresstype="dns-port" />
<Flags />
<Credentials>
<UserName>$user_name</UserName>
<Domain>$domain</Domain>
</Credentials>
</RequestAddress>
</NFuseProtocol>
EOR
my $app_req = <<EOR ;
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<RequestAddress>
<Name>
<UnspecifiedName>PUBLISHED_APP_ENCODED</UnspecifiedName>
</Name>
<ClientName>Nagios_Service_Check</ClientName>
<ClientAddress addresstype="dns-port"/>
<ServerAddress addresstype="dns-port" />
<Flags />
<Credentials>
<UserName>$PROGNAME</UserName>
<Domain>$domain</Domain>
</Credentials>
</RequestAddress>
</NFuseProtocol>
EOR
my $ua = LWP::UserAgent->new ;
my $req = HTTP::Request->new('POST', "http://$pn_server/scripts/WPnBr.dll") ;
$req->content_type('text/xml') ;
my $svr ;
my @pubapp_encoded = map { my $x = $_ ; $x =~ s/(\W)/'&#' . ord($1) . ';'/eg; $x } @pub_apps ;
my $error_tag_cr = sub { ! exists($xml_tag{ErrorId}) } ;
my @app_reqs = (
# { Content => url, Ok => ok_condition, Seq => \d+ }
{ Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 0 },
{ Content => $server_farm_req, Ok => sub {
! exists($xml_tag{ErrorId}) &&
exists( $xml_tag{ServerFarmName}) &&
defined($xml_tag{ServerFarmName}) &&
$xml_tag{ServerFarmName} eq $server_farm
}, Seq => 2 },
{ Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 4 },
{ Content => $spec_server_farm_req, Ok => sub {
! exists($xml_tag{ErrorId}) &&
exists( $xml_tag{ServerAddress}) &&
defined($xml_tag{ServerAddress}) &&
$xml_tag{ServerAddress} =~ /\d+\.\d+\.\d+\.\d+:\d+/
}, Seq => 6 },
{ Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 8 },
{ Content => $app_req, Ok => sub {
! exists($xml_tag{ErrorId}) &&
exists( $xml_tag{ServerAddress}) &&
defined($xml_tag{ServerAddress}) &&
(($svr) = split(/:/, $xml_tag{ServerAddress})) &&
defined($svr) &&
scalar(grep $_ eq $svr, @app_servers)
}, Seq => 10 }
) ;
my $app_location ;
foreach my $pub_app (@pub_apps) {
my $pubapp_enc = shift @pubapp_encoded ;
my $app_req_tmp = $app_reqs[5]{Content} ;
$app_reqs[5]{Content} =~ s/PUBLISHED_APP_ENCODED/$pubapp_enc/ ;
foreach (@app_reqs) {
$req->content($_->{Content}) ;
$debug && print STDERR "App: $pub_app Seq: $_->{Seq}\n", $req->as_string, "\n" ;
my $resp = $ua->request($req) ;
$debug && print STDERR "App: $pub_app Seq: ", $_->{Seq} + 1, "\n", $resp->as_string, "\n" ;
$resp->is_error && do {
my $err = $resp->as_string ;
$err =~ s/\n//g ;
&outahere(qq(Failed. HTTP error finding $pub_app at seq $_->{Seq}: "$err")) ;
} ;
my $xml = $resp->content ;
my $xml_disp ;
($xml_disp = $xml) =~ s/\n//g ;
$xml_disp =~ s/ \s+/ /g ;
&outahere($resp->as_string)
unless $xml ;
my ($xml_ok, $whine) = &valid_xml($xml_p, $xml) ;
$xml_ok || &outahere(qq(Failed. Bad XML finding $pub_app at eq $_->{Seq} in "$xml_disp".)) ;
&{$_->{Ok}} || &outahere(qq(Failed. \"\&\$_->{Ok}\" false finding $pub_app at seq $_->{Seq} in "$xml_disp".)) ;
# Ugly but alternative is $_->{Ok}->().
# eval $_->{Ok} where $_->{Ok} is an
# expression returning a bool is possible. but
# sub { } prevent recompilation.
}
$app_reqs[5]{Content} = $app_req_tmp ;
$app_location .= qq("$pub_app" => $svr, ) ;
}
substr($app_location, -2, 2) = '' ;
print qq(Ok. Citrix XML service located all published apps $app_location.\n) ;
exit $ERRORS{'OK'} ;
sub outahere {
print "Citrix XML service $_[0]\n" ;
exit $ERRORS{CRITICAL} ;
}
sub valid_xml {
my ($p, $input) = @_ ;
%xml_tag = () ;
@tag_stack = () ;
eval {
$p->parse($input)
} ;
return (0, qq(XML::Parser->parse failed: Bad XML in "$input".!))
if $@ ;
if ( $xml_debug ) {
print STDERR pack('A4 A30 A40', ' ', $_, qq(-> "$xml_tag{$_}")), "\n"
foreach (keys %xml_tag)
}
return (1, 'valid xml')
}
sub handle_start {
push @tag_stack, $_[1] ;
$xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_start - tag', " -> '$_[1]'"), "\n" ;
$xml_debug && print STDERR pack('A8 A30 A60', ' ', 'handle_start - @tag_stack', " -> (@tag_stack)"), "\n" ;
}
sub handle_char {
my $text = $_[1] ;
!($text =~ /\S/ || $text =~ /^[ \t]$/) && return ;
$text =~ s/\n//g ;
my $tag = $tag_stack[-1] ;
$xml_debug && print STDERR pack('A8 A30 A30', ' ', 'handle_char - tag', " -> '$tag'"), "\n" ;
$xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_char - text', " -> '$text'"), "\n" ;
$xml_tag{$tag} .= $text ;
}
sub print_help() {
# 1 2 3 4 5 6 7 8
#12345678901234567890123456789012345678901234567890123456789012345678901234567890
print_revision($PROGNAME,'$Revision: 1097 $ ');
my $help = <<EOHELP ;
Copyright (c) 2004 Karl DeBisschop/S Hopcroft
$PROGNAME -P <pn_server> -S <svr1,svr2,..> -A <app1,app2,..>
-F <Farm> [-v -x -h -V]
Check the Citrix Metaframe XP service by completing an HTTP dialogue with a Program
Neigbourhood server (pn_server) that returns an ICA server in the named Server farm
hosting the specified applications (an ICA server in a farm which runs some MS app).
EOHELP
print $help ;
print "\n";
print "\n";
print_usage();
print "\n";
support();
}
sub print_usage () {
# 1 2 3 4 5 6 7 8
#12345678901234567890123456789012345678901234567890123456789012345678901234567890
my $usage = <<EOUSAGE ;
$PROGNAME
[-P | --pn_server] The name or address of the Citrix Metaframe XP
Program Neigbourhood server (required).
[-A | --pub_apps] The name or names of an application published by the
server farm (default 'Word 2003').
[-F | --server_farm] The name of a Citrix Metaframe XP server farm. (required)
[-S | --app_servers] The _IP addresses_ of _all_ of the Farms ICA servers expected
to host the published application.
Enter as a comma separated string eg 'Srv1, Svr2, ..,Srvn'.
Since the PN servers round-robin the app servers to the clients,
_all_ the server farm addresses must be specified or the check
will fail (required).
[-v | --verbose]
[-h | --help]
[-x | --xml_debug]
[-V | --version]
EOUSAGE
print $usage ;
}
sub usage {
&print_usage ;
exit $ERRORS{'OK'} ;
}
sub version () {
print_revision($PROGNAME,'$Revision: 1097 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}
=begin comment
This is the set of requests and responses transmitted between a Citrix Metaframe XP Program Neigbourhood (PN) client and a PN server.
This dialogue was captured by and reconstructed from tcpdump.
Citrix are not well known for documenting their protocols although the DTD may be informative. Note that the pair(s) 0 and 1, 4 and 5, ...
do not appear to do anything.
req 0
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 220
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:40 GMT
resp 1
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:40 GMT
Content-type: text/xml
Content-length: 253
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseProtocolInfo>
<ServerAddress addresstype="no-change"></ServerAddress>
</ResponseProtocolInfo>
</NFuseProtocol>
req 2
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 191
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1"><RequestServerFarmData><Nil /></RequestServerFarmData></NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:40 GMT
resp 3
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:40 GMT
Content-type: text/xml
Content-length: 293
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseServerFarmData>
<ServerFarmData>
<ServerFarmName>FOOFARM01</ServerFarmName>
</ServerFarmData>
</ResponseServerFarmData>
</NFuseProtocol>
req 4
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 220
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:55 GMT
resp 5
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:55 GMT
Content-type: text/xml
Content-length: 253
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseProtocolInfo>
<ServerAddress addresstype="no-change"></ServerAddress>
</ResponseProtocolInfo>
</NFuseProtocol>
req 6
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 442
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<RequestAddress><Name>i
<UnspecifiedName>FOOFARM01*</UnspecifiedName>
</Name><ClientName>WS09535</ClientName>
<ClientAddress addresstype="dns-port" />
<ServerAddress addresstype="dns-port" />
<Flags />
<Credentials>
<UserName>foo-user</UserName>
<Domain>some-domain</Domain>
</Credentials>
</RequestAddress></NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:56 GMT
resp 7
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:12:56 GMT
Content-type: text/xml
Content-length: 507
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseAddress>
<ServerAddress addresstype="dot-port">10.1.2.2:1494</ServerAddress>
<ServerType>win32</ServerType>
<ConnectionType>tcp</ConnectionType>
<ClientType>ica30</ClientType>
<TicketTag>10.1.2.2</TicketTag>
<SSLRelayAddress addresstype="dns-port">ica_svr01.some.domain:443</SSLRelayAddress>
</ResponseAddress>
</NFuseProtocol>
req 8
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 220
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:13:29 GMT
resp 9
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:13:29 GMT
Content-type: text/xml
Content-length: 253
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseProtocolInfo>
<ServerAddress addresstype="no-change"></ServerAddress>
</ResponseProtocolInfo>
</NFuseProtocol>
req 10
POST /scripts/WPnBr.dll HTTP/1.1
Content-type: text/xml
Host: 10.1.2.2:80
Content-Length: 446
Connection: Keep-Alive
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<RequestAddress>i
<Name>
<UnspecifiedName>EXCEL#32;2003</UnspecifiedName>
</Name>
<ClientName>WS09535</ClientName>
<ClientAddress addresstype="dns-port" />
<ServerAddress addresstype="dns-port" />
<Flags />
<Credentials><UserName>foo-user</UserName>
<Domain>some-domain</Domain>
</Credentials>
</RequestAddress>i
</NFuseProtocol>
HTTP/1.1 100 Continue
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:13:29 GMT
resp 11
HTTP/1.1 200 OK
Server: Citrix Web PN Server
Date: Thu, 30 Sep 2004 00:13:29 GMT
Content-type: text/xml
Content-length: 509
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseAddress>
<ServerAddress addresstype="dot-port">10.1.2.14:1494</ServerAddress>
<ServerType>win32</ServerType>
<ConnectionType>tcp</ConnectionType>
<ClientType>ica30</ClientType>
<TicketTag>10.1.2.14</TicketTag>
<SSLRelayAddress addresstype="dns-port">ica_svr02.some.domain:443</SSLRelayAddress>
</ResponseAddress>
</NFuseProtocol>
** One sees this XML on an error (there may well be other error XML also, but I haven't seen it) **
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
<NFuseProtocol version="1.1">
<ResponseAddress>
<ErrorId>unspecified</ErrorId>
<BrowserError>0x0000000E</BrowserError>
</ResponseAddress>
</NFuseProtocol>
=end comment
=cut
# You never know when you may be embedded ...

View file

@ -1,127 +0,0 @@
#!/usr/bin/perl
# check_inodes.pl for FreeBSD
# Designed on FreeBSD 4.6 (although this should not matter)
# parses df output, splits, and then takes variables
# df.pl -f mountpoint -w warningnumber -c critical number
# USE NUMBERS AND NOT PERCENTS FOR wanring and critical values
# -h is help
# -v is version
# Mountpoints:
# like / or /usr or /var (whatever you mount drives NOT the device names)
# Andrew Ryder - 20020804 - atr@mrcoffee.org
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME);
use lib "/usr/local/libexec/nagios" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);
my $df = "/bin/df";
my $grep = "/usr/bin/grep";
$PROGNAME="df.pl";
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,
"f=s" => \$opt_f, "filesystem=s" => \$opt_f);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 72 $ ');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
($opt_w) || ($opt_w = shift) || ($opt_w = 50);
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
($opt_c) || ($opt_c = shift) || ($opt_c = 75);
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
if ($opt_c < $opt_w) {
print "Critical offset should be larger than warning offset\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
($opt_f) || ($opt_f = "/");
unless (-e $df) {
print "UNKNOWN: $df is not where df is\n";
exit $ERRORS{'UNKNOWN'};
}
unless (-e $grep) {
print "UNKNOWN: $grep is not where grep is\n";
exit $ERRORS{'UNKNOWN'};
}
unless (-d $opt_f) {
print "UNKNOWN: $opt_f is not a mount point\n";
exit $ERRORS{'UNKNOWN'};
}
my $state = $ERRORS{'UNKNOWN'};
my $answer;
open(DF, "$df -i $opt_f| $grep -v Filesystem |");
while (<DF>) {
my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split;
$ipercent =~ s/%//s;
if ($ipercent > $opt_w) {
$state = $ERRORS{'WARNING'};
$answer = "WARNING: $ipercent percent inodes free on $opt_f\n";
} elsif ($ipercent > $opt_w) {
$state = $ERRORS{'CRITCAL'};
$answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n";
} elsif ($ipercent < $opt_w) {
$state = $ERRORS{'OK'};
$answer = "OK: $ipercent percent inodes free on $opt_f\n";
}
}
close(DF);
print "$answer";
exit $state;
sub print_usage () {
print "Usage: $PROGNAME <filesystem> [-w <warn>] [-c <crit>]\n";
print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 72 $');
print "Copyright (c) 2002 Andrew Ryder\n";
print "\n";
print_usage();
print "\n";
print "<warn> = Inode Percent at which a warning message is returned. Defaults to 50.\n";
print "<crit> = Inode Percent at which a critical message is returned..\n Defaults to 75.\n\n";
support();
}

View file

@ -1,69 +0,0 @@
#!/usr/bin/perl
##############################################################################
# This plugin uses df to gather filesystem statistics and check the percent #
# used of inodes. I've put a switch in here since i've got both aix and #
# linux systems...adjust for your syntax's results. #
# Note: the percentages passed in MUST NOT have % after them #
# No warranty is either implied, nor expressed herein. #
# #
##############################################################################
$filesystem = $ARGV[0];
$warnpercent = $ARGV[1];
$critpercent = $ARGV[2];
#------Find out what kind of syntax to expect
$systype=`uname`;
chomp($systype);
#------Make sure we got called with the right number of arguments
#------you could also put a check in here to make sure critical level is
#------greater than warning...but what the heck.
die "Usage: check_inodes filesystem warnpercent critpercent" unless @ARGV;
if ($#ARGV < 2) {
die "Usage: check_inodes filesystem warnpercent critpercent";
}#end if
#------This gets the data from the df command
$inputline = `df -i $filesystem|grep -v "Filesystem"`;
#------replaces all spaces with a single :, that way we can use split
$inputline =~ y/ /:/s;
#------different oses give back different sets of columns from the df -i
#------(at least mine do). This way I can use this plugin on all my hosts
#------if neither of these work, add your own in, or if you've got one that
#------just flat out reports something different...well...perl is your friend.
SWITCH: {
if ($systype eq "Linux") {
($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline);
last SWITCH;
}#end if
if ($systype eq "AIX") {
($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline);
last SWITCH;
}#end if
}#end switch
#------First we check for critical, since that is, by definition and convention
#------going to exceed the warning threshold
$ipercent =~ y/%//ds;
if ($ipercent > $critpercent) {
print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)";
exit 1;
}# end if
#------Next we check the warning threshold
if ($ipercent > $warnpercent) {
print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)";
exit 2;
}# end if
#------thanks to the magic of procedural programming, we figure if we got here,
#------everything MUST be fine.
print "$filesystem inode use within limits ($ipercent)";
exit 0;

View file

@ -1,201 +0,0 @@
/******************************************************************************************
*
* CHECK_IPXPING.C
*
* Program: IPX ping plugin for Nagios
* License: GPL
* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
*
* Last Modified: 09-24-1999
*
* Command line: CHECK_IPXPING <dest_network> <dest_address> <wrtt> <crtt>
*
* Description:
*
* This plugin will use the /usr/bin/ipxping command to ping the specified host using the
* IPX protocol. Note: Linux users must have IPX support compiled into the kernerl and
* must have IPX configured correctly in order for this plugin to work.
* If the round trip time value is above the <wrtt> level, a STATE_WARNING is
* returned. If it exceeds the <crtt> level, a STATE_CRITICAL is returned.
*
*
*
* IMPORTANT!!
*
* This plugin will only work with the ipxping command that has been ported to Linux.
* The version for Sun takes different command line arguments and differs in its output.
*
*****************************************************************************************/
#include "config.h"
#include "common.h"
#include "netutils.h"
#include "popen.h"
/* this should be moved out to the configure script! */
#define IPXPING_COMMAND "/tmp/ipxping/ipxping"
/* these should be moved to the common header file */
#define MAX_IPXNET_ADDRESS_LENGTH 12
#define MAX_IPXHOST_ADDRESS_LENGTH 18
int socket_timeout=DEFAULT_SOCKET_TIMEOUT;
char dest_network[MAX_IPXNET_ADDRESS_LENGTH];
char dest_address[MAX_IPXHOST_ADDRESS_LENGTH];
int wrtt;
int crtt;
int process_arguments(int,char **);
FILE * spopen(const char *);
int spclose(FILE *);
int main(int argc, char **argv){
char command_line[MAX_INPUT_BUFFER];
int rtt;
int bytes_returned;
int result=STATE_OK;
FILE *fp;
char input_buffer[MAX_INPUT_BUFFER];
char *substr;
int current_line;
if(process_arguments(argc,argv)!=OK){
printf("Incorrect arguments supplied\n");
printf("\n");
printf("IPX ping plugin for Nagios\n");
printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n");
printf("Last Modified: 09-24-1999\n");
printf("License: GPL\n");
printf("\n");
printf("Usage: %s <dest_network> <dest_address> <wrtt> <crtt> [-to to_sec]\n",argv[0]);
printf("\n");
printf("Options:\n");
printf(" <dest_network> = IPX network that the remote host lies on. (Hex Format - 00:00:00:00)\n");
printf(" <dest_address> = MAC address of the remote host. (Hex Format - 00:00:00:00:00:00)\n");
printf(" <wrtt> = Round trip time in milliseconds necessary to result in a WARNING state\n");
printf(" <crtt> = Round trip time in milliseconds necessary to result in a CRITICAL state\n");
printf(" [to_sec] = Seconds before we should timeout waiting for ping result. Default = %d sec\n",DEFAULT_SOCKET_TIMEOUT);
printf("\n");
printf("Notes:\n");
printf("This plugin will use the /usr/bin/ipxping command to ping the specified host using\n");
printf("the IPX protocol. IPX support must be compiled into the kernel and your host must\n");
printf("be correctly configured to use IPX before this plugin will work! An RPM package of\n");
printf("the ipxping binary can be found at...\n");
printf("http://www.rpmfind.net/linux/RPM/contrib/libc5/i386/ipxping-0.0-2.i386.shtml\n");
printf("\n");
return STATE_UNKNOWN;
}
/* create the command line to use... */
sprintf(command_line,"%s %s %s",IPXPING_COMMAND,dest_network,dest_address);
/* initialize alarm signal handling */
signal(SIGALRM,socket_timeout_alarm_handler);
/* set socket timeout */
alarm(socket_timeout);
/* run the command */
fp = spopen(command_line);
if(fp==NULL){
printf("Unable to open pipe: %s",command_line);
return STATE_UNKNOWN;
}
current_line=0;
while(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
current_line++;
/* skip the first line of the output */
if(current_line==1)
continue;
/* we didn't get the "is alive" */
if(current_line==2 && !strstr(input_buffer,"is alive"))
result=STATE_CRITICAL;
/* get the round trip time */
if(current_line==3){
substr=strtok(input_buffer,":");
substr=strtok(NULL,"\n");
rtt=atoi(substr);
}
/* get the number of bytes returned */
if(current_line==4 && strstr(input_buffer,"bytes returned")){
bytes_returned=atoi(input_buffer);
}
}
/* close the pipe */
spclose(fp);
/* reset the alarm */
alarm(0);
if(current_line==1 || result==STATE_CRITICAL)
printf("IPX Ping problem - No response from host\n");
else{
if(rtt>crtt)
result=STATE_CRITICAL;
else if(rtt>wrtt)
result=STATE_WARNING;
printf("IPX Ping %s - RTT = %d ms, %d bytes returned from %s %s\n",(result==STATE_OK)?"ok":"problem",rtt,bytes_returned,dest_network,dest_address);
}
return result;
}
/* process all arguments passed on the command line */
int process_arguments(int argc, char **argv){
int x;
/* no options were supplied */
if(argc<5)
return ERROR;
/* get the destination network address */
strncpy(dest_network,argv[1],sizeof(dest_network)-1);
dest_network[sizeof(dest_network)-1]='\x0';
/* get the destination host address */
strncpy(dest_address,argv[2],sizeof(dest_address)-1);
dest_address[sizeof(dest_address)-1]='\x0';
/* get the round trip time variables */
wrtt=atoi(argv[3]);
crtt=atoi(argv[4]);
/* process remaining arguments */
for(x=6;x<=argc;x++){
/* we got the timeout to use */
if(!strcmp(argv[x-1],"-to")){
if(x<argc){
socket_timeout=atoi(argv[x]);
if(socket_timeout<=0)
return ERROR;
x++;
}
else
return ERROR;
}
/* else we got something else... */
else
return ERROR;
}
return OK;
}

View file

@ -1,278 +0,0 @@
#!/usr/bin/perl -w
#
# Author: Wim Rijnders, 17-10-2002
#
# Description:
# -----------
#
# Nagios host script to check if any specified java processes are running.
#
# Implementation Notes:
# ---------------------
#
# check_disk_smb was used as a starting point, since it was written in perl.
#
# This script has been created and tested on Linux RH 7.1.
#
# I tried OS-X Darwin (BSD), but the ps command works differently.
# Notably, you can't get a combined list of child processes. The best approach
# appears to be to use 'ps -wwaxo command' combined with 'ps -M' (or suchlike)
#
########################################################################
####
require 5.004;
use POSIX;
use strict;
use Getopt::Long;
use vars qw($opt_w $opt_c $verbose $classname);
use vars qw($PROGNAME);
use lib "utils.pm" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
$PROGNAME="check_javaprocs";
sub getJavaList ();
sub check_ranges ($ $ $ $);
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"v|verbose" => \$verbose,
"w|warning=s" => \$opt_w,
"c|critical=s" => \$opt_c,
"n|name=s" => \$classname
);
my $state = 'OK';
my $min_warn = undef
my $max_warn = undef;
my $min_crit = undef;
my $max_crit = undef;
($opt_w) || ($opt_w = shift);
check_ranges($opt_w,\$min_warn, \$max_warn, "warning");
($opt_c) || ($opt_c = shift);
check_ranges($opt_c,\$min_crit, \$max_crit, "critical");
#
# Determine # of running processes for the java programs that interest us.
#
my @javalist = getJavaList();
my $total = 0;
my $msgout = "";
my @fields;
if ( defined $classname ) {
#filter out a single java process based on class name
foreach (@javalist) {
@fields = split(/\s+/, $_);
$total = $fields[-1] and last if $classname eq $fields[0];
}
$msgout .= "$total processes for $classname\n";
} else {
#Handle all java processes
$msgout .= "\n";
foreach (@javalist) {
@fields = split(/\s+/, $_);
$total += $fields[-1];
$msgout .= " $fields[-1] processes for ";
$msgout .= (scalar @fields > 1)? $fields[0] : "unknown" ;
$msgout .= "\n";
}
my $msgtotal = "$total java processes for ". scalar @javalist . " applications";
if ( defined $verbose ) {
$msgout = $msgtotal . $msgout;
} else {
$msgout = $msgtotal;
}
}
#
# Set the state with the data we now have accumulated
# Note that due to the order of testing, warnings have precedence over
# criticals. This is logical, since you should be able to create a criticals
# range which encompasses a warning range. eg. following should be possible:
#
# check_javaproc -w 5:10 -c 3:12
# proper specification of the ranges is the responsibility of the script user.
#
$state = 'CRITICAL' if (defined $min_crit && $total < $min_crit);
$state = 'CRITICAL' if (defined $max_crit && $total > $max_crit);
$state = 'CRITICAL' if (!defined $min_crit && !defined $max_crit && $total==0 );
$state = 'WARNING' if (defined $min_warn && $total < $min_warn);
$state = 'WARNING' if (defined $max_warn && $total > $max_warn);
print $msgout;
print "$state\n" if ($verbose);
exit $ERRORS{$state};
###################################
# Support routines for Nagios
###################################
sub check_ranges($$$$) {
my ($opt, $min, $max, $rangename) = @_;
if ( defined $opt ) {
if ( $opt =~ /^([0-9]*)\:([0-9]*)$/) {
$$min = $1 if $1 > 0;
$$max= $2 if $2 > 0;
} else {
usage("Invalid $rangename range: $opt\n");
}
}
if ( defined $$min && defined $$max ) {
usage("Min value of $rangename range larger than max value: $opt\n") if ( $$min > $$max);
}
}
sub print_usage () {
print "Usage: $PROGNAME [-v] [-w <min:max>] [-c <min:max>] [ -n <classname>]\n";
}
sub print_help () {
revision();
print "Copyright (c) 2002 by Wim Rijnders
Perl Check java processes plugin for Nagios
";
print_usage();
print "
-v, --verbose
Return additional information.
Intended as a command-line aid, not recommended for Nagios script usage.
-w, --warning=INTEGER:INTEGER
Minimum and maximum number of processes outside of which a warning will be
generated. If omitted, no warning is generated.
-c, --critical=INTEGER:INTEGER
Minimum and maximum number of processes outside of which a critical will be
generated. If omitted, a critical is generated if no processes are running.
-n, --name=STRING
Name of class specified on the java command line (from which main() is run).
If omitted, all java processes are taken into account.
";
support();
}
sub revision() {
print_revision($PROGNAME,'$Revision: 211 $ ');
}
sub version () {
revision();
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}
###################################
# Routines for delivering the data
###################################
#
# Generate a formatted list of running java processes.
#
# Returns an array of strings having the following syntax:
#
# <java class running as main> <parameters if any> <#processes for this class>
#
sub getJavaList() {
my @output;
# Untaint
local $ENV{'PATH'} = '/bin:/usr/bin';
local $ENV{'BASH_ENV'} = '~/.bashrc';
# We are only interested in the full command line
# The -H opstion is important for the order of the processes;
# this option ensures that all child processes are listed under
# their parents
@output=`ps -AHo \"\%a\" -ww`;
#remove preceding whitespace and final EOL
foreach (@output) {
s/^\s*//;
chop;
}
#Combine any consecutive processes with exactly the same command line
#into a single item
@output = checkSameLine(@output);
#Filter out all java processes
my @javalist;
for (my $i = 0; $i < scalar @output; ++$i) {
push @javalist, $output[$i] if $output[$i] =~ /^\S*java/;
}
foreach (@javalist) {
#The java statement at the beginning is redundant; remove it
s/^\S*java//;
#remove all defines
s/\-D\S+//g;
#remove classpath
s/\-(classpath|cp)\s+\S+//g;
#remove any other parameters we don't want to see
s/\-server\s+//g;
s/\-X\S*\s+//g;
#remove any redundant whitespaces at the beginning
s/^\s+//;
}
@javalist;
}
#
# Combine all consecutive lines with an identical command line
# to a signle line with a count at the end
#
sub checkSameLine {
my @input = @_;
my @output;
my $prevline= "";
my $prevcount = 0;
foreach my $a (@input) {
if ( $prevline eq $a) {
++$prevcount;
} else {
push @output, $prevline . " " . ($prevcount + 1);
$prevcount = 0;
}
$prevline = $a;
}
#don't forget the last item!
if ( $prevcount > 0 ) {
push @output, $prevline . " " . ($prevcount + 1);
}
@output;
}
#======= end check_javaproc =====

View file

@ -1,69 +0,0 @@
#! /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: 2 $' | sed -e 's/[^0-9.]//g'`
STATUS=""
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME /dev/js<#> <button #>"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "This plugin checks a joystick button status using the "
echo "joyreadbutton utility from the joyd package."
echo ""
support
exit 0
}
if [ $# -ne 2 ]; then
print_usage
exit 0
fi
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
;;
/dev/js*)
joyreadbutton $1 $2 1>&1 1>/dev/null
STATUS=$?
if [ "$STATUS" -eq 0 ]; then
echo OK
exit 0
elif [ "$STATUS" -eq 1 ];then
echo CRITICAL
exit 2
else
echo UNKNOWN
exit -1
fi
;;
*)
print_usage
exit 0
;;
esac

View file

@ -1,115 +0,0 @@
#!/usr/bin/perl -w
# Copyright (c) 2002 ISOMEDIA, Inc.
# originally written by Steve Milton
# later updates by sean finney <seanius@seanius.net>
#
# 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
#
# Usage: check_raid [raid-name]
# Example: check_raid md0
# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min
use strict;
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS);
# die with an error if we're not on Linux
if ($^O ne 'linux') {
print "This plugin only applicable on Linux.\n";
exit $ERRORS{'UNKNOWN'};
}
sub max_state($$){
my ($a, $b) = @_;
if ($a eq "CRITICAL" || $b eq "CRITICAL") { return "CRITICAL"; }
elsif ($a eq "WARNING" || $b eq "WARNING") { return "WARNING"; }
elsif ($a eq "OK" || $b eq "OK") { return "OK"; }
elsif ($a eq "UNKNOWN" || $b eq "UNKNOWN") { return "UNKNOWN"; }
elsif ($a eq "DEPENDENT" || $b eq "DEPENDENT") { return "DEPENDENT"; }
return "UNKNOWN";
}
my $nextdev;
if(defined $ARGV[0]) { $nextdev = shift; }
else { $nextdev = "md[0-9]+"; }
my $code = "UNKNOWN";
my $msg = "";
my %status;
my %recovery;
my %finish;
my %active;
my %devices;
while(defined $nextdev){
open (MDSTAT, "< /proc/mdstat") or die "Failed to open /proc/mdstat";
my $device = undef;
while(<MDSTAT>) {
if (defined $device) {
if (/(\[[_U]+\])/) {
$status{$device} = $1;
} elsif (/recovery = (.*?)\s/) {
$recovery{$device} = $1;
($finish{$device}) = /finish=(.*?min)/;
$device=undef;
} elsif (/^\s*$/) {
$device=undef;
}
} elsif (/^($nextdev)\s*:/) {
$device=$1;
$devices{$device}=$device;
if (/\sactive/) {
$status{$device} = ''; # Shall be filled later if available
$active{$device} = 1;
}
}
}
$nextdev = shift;
}
foreach my $k (sort keys %devices){
if (!exists($status{$k})) {
$msg .= sprintf " %s inactive with no status information.",
$devices{$k};
$code = max_state($code, "CRITICAL");
} elsif ($status{$k} =~ /_/) {
if (defined $recovery{$k}) {
$msg .= sprintf " %s status=%s, recovery=%s, finish=%s.",
$devices{$k}, $status{$k}, $recovery{$k}, $finish{$k};
$code = max_state($code, "WARNING");
} else {
$msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k};
$code = max_state($code, "CRITICAL");
}
} elsif ($status{$k} =~ /U+/) {
$msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k};
$code = max_state($code, "OK");
} else {
if ($active{$k}) {
$msg .= sprintf " %s active with no status information.",
$devices{$k};
$code = max_state($code, "OK");
} else {
# This should't run anymore, but is left as a catch-all
$msg .= sprintf " %s does not exist.\n", $devices{$k};
$code = max_state($code, "CRITICAL");
}
}
}
print $code, $msg, "\n";
exit ($ERRORS{$code});

View file

@ -1,19 +0,0 @@
#!/usr/bin/perl
# NetSaint Temp warning script
# Written by: Nathan LeSueur
if ($#ARGV < 1) {
print "Usage: $0 <critical temp> <warning temp> <normal temp>\n";
exit; } $crit = shift; $warn = shift; $norm = shift; if ($warn >
$crit) { print "Warning level cannot be greater than critical
level!\n"; exit; } @b = qx{/usr/local/bin/lmmon -s}; foreach(@b) { @c
= split(/ \/ /, $_); $d = $c[1]; } @e = split(/F/, $d); $f = $e[0];
$status = "$f degrees F\n";
if($f >= $crit) {print "CRITICAL - $status"; exit 2;}
if($f >= $warn) {print "WARNING - $status"; exit 1;}
if($f <= $norm && $f != 0) {print "OK - $status"; exit 0;}
else{print "UNKNOWN - unable to access smb\n"; exit (-1);}

View file

@ -1,202 +0,0 @@
#!/usr/bin/perl -w
#
# $Id: check_log2.pl 1300 2005-12-16 18:41:45Z harpermann $
#
# Log file regular expression detector for Nagios.
# Written by Aaron Bostick (abostick@mydoconline.com)
# Last modified: 05-02-2002
#
# Thanks and acknowledgements to Ethan Galstad for Nagios and the check_log
# plugin this is modeled after.
#
# Usage: check_log2 -l <log_file> -s <seek_file> -p <pattern> [-n <negpattern>]
#
# Description:
#
# This plugin will scan arbitrary text files looking for regular expression
# matches. The text file to scan is specified with <log_file>.
# <log_seek_file> is a temporary file used to store the seek byte position
# of the last scan. This file will be created automatically on the first
# scan. <pattern> can be any RE pattern that perl's s/// syntax accepte. Be
# forewarned that a bad pattern will send this script into never never land!
#
# Output:
#
# This plugin returns OK when a file is successfully scanned and no pattern
# matches are found. WARNING is returned when 1 or more patterns are found
# along with the pattern count and the line of the last pattern matched.
# CRITICAL is returned when an error occurs, such as file not found, etc.
#
# Notes (paraphrased from check_log's notes):
#
# 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 <log_Seek_file> 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 error notices in messages
# check_log2 -l /var/log/messages -s ./check_log2.messages.seek -p 'err'
#
BEGIN {
if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
$prog_dir = $1;
$prog_name = $2;
}
}
require 5.004;
use lib $main::prog_dir;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
use Getopt::Long;
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks);
sub print_usage ();
sub print_version ();
sub print_help ();
# Initialize strings
$log_file = '';
$seek_file = '';
$critical = '';
$re_pattern = '';
$neg_re_pattern = '';
$pattern_count = 0;
$pattern_line = '';
$plugin_revision = '$Revision: 1300 $ ';
# Grab options from command line
GetOptions
("l|logfile=s" => \$log_file,
"s|seekfile=s" => \$seek_file,
"c|critical" => \$critical,
"p|pattern=s" => \$re_pattern,
"n|negpattern:s" => \$neg_re_pattern,
"v|version" => \$version,
"h|help" => \$help);
!($version) || print_version ();
!($help) || print_help ();
# Make sure log file is specified
($log_file) || usage("Log file not specified.\n");
# Make sure seek file is specified
($seek_file) || usage("Seek file not specified.\n");
# Make sure re pattern is specified
($re_pattern) || usage("Regular expression not specified.\n");
# Open log file
open (LOG_FILE, $log_file) || die "Unable to open log file $log_file: $!";
# Try to open log seek file. If open fails, we seek from beginning of
# file by default.
if (open(SEEK_FILE, $seek_file)) {
chomp(@seek_pos = <SEEK_FILE>);
close(SEEK_FILE);
# If file is empty, no need to seek...
if ($seek_pos[0] != 0) {
# Compare seek position to actual file size.
# If file size is smaller
# then we just start from beginning i.e. file was rotated, etc.
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE);
if ($seek_pos[0] <= $size) {
seek(LOG_FILE, $seek_pos[0], 0);
}
}
}
# Loop through every line of log file and check for pattern matches.
# Count the number of pattern matches and remember the full line of
# the most recent match.
while (<LOG_FILE>) {
if ($neg_re_pattern) {
if ((/$re_pattern/) && !(/$neg_re_pattern/)) {
$pattern_count += 1;
$pattern_line = $_;
}
} elsif (/$re_pattern/) {
$pattern_count += 1;
$pattern_line = $_;
}
}
# Overwrite log seek file and print the byte position we have seeked to.
open(SEEK_FILE, "> $seek_file") || die "Unable to open seek count file $seek_file: $!";
print SEEK_FILE tell(LOG_FILE);
# Close seek file.
close(SEEK_FILE);
# Close the log file.
close(LOG_FILE);
# Print result and return exit code.
if ($pattern_count) {
if ($critical) {
print "CRITICAL: ";
} else {
print "WARNING: ";
}
print "($pattern_count): $pattern_line";
if ($critical) {
exit $ERRORS{'CRITICAL'};
} else {
exit $ERRORS{'WARNING'};
}
} else {
print "OK - No matches found.\n";
exit $ERRORS{'OK'};
}
#
# Subroutines
#
sub print_usage () {
print "Usage: $prog_name -l <log_file> -s <log_seek_file> -p <pattern> [-n <negpattern>] -c | --critical\n";
print "Usage: $prog_name [ -v | --version ]\n";
print "Usage: $prog_name [ -h | --help ]\n";
}
sub print_version () {
print_revision($prog_name, $plugin_revision);
exit $ERRORS{'OK'};
}
sub print_help () {
print_revision($prog_name, $plugin_revision);
print "\n";
print "Scan arbitrary log files for regular expression matches.\n";
print "\n";
print_usage();
print "\n";
print "-l, --logfile=<logfile>\n";
print " The log file to be scanned\n";
print "-s, --seekfile=<seekfile>\n";
print " The temporary file to store the seek position of the last scan\n";
print "-p, --pattern=<pattern>\n";
print " The regular expression to scan for in the log file\n";
print "-n, --negpattern=<negpattern>\n";
print " The regular expression to skip in the log file\n";
print "-c, --critical\n";
print " Return critical instead of warning on error\n";
print "\n";
support();
exit $ERRORS{'OK'};
}

View file

@ -1,260 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_lotus.pl 1096 2005-01-25 09:04:26Z stanleyhopcroft $
# Revision 1.1 2005/01/25 09:04:26 stanleyhopcroft
# New plugin to check responsiveness of Louts Notes (v5 at least) servers
#
# Revision 1.10 2005-01-25 15:44:07+11 anwsmh
# 1 use packet_utils instead of hard coding subroutines (pdump and tethereal)
# 2 redo indentation using tabs (set at 4 spaces)
#
use strict ;
use IO::Socket;
use Getopt::Long ;
my ($timeout, $debug, $lotus_host, $server, $indiv_dn, $packet_debug) ;
use lib qw(/usr/local/nagios/libexec) ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage) ;
use packet_utils qw(pdump &tethereal) ;
my $PROGNAME = 'check_lotus_notes' ;
sub print_help ();
sub print_usage ();
sub help ();
sub version ();
my $TEST_COUNT = 2 ;
# Number of Lotus client hellos sent without reply
my $BUFFER_SIZE = 1500 ;
# buffer size used for 'recv' calls.
my $LOTUS_PORT = 1352 ;
Getopt::Long::Configure('no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"v|debug" => \$debug,
"vv|i_packet_debug" => \$packet_debug,
"H|lotus_host=s"=> \$lotus_host,
# "I|indivual_dn:s" => \$indiv_dn,
"S|server:s" => \$server,
"T|t_timeout:i" => \$timeout,
) ;
usage("You must provide the DNS name or IP (v4) address of the Lotus server to be checked.\n")
unless $lotus_host and (
$lotus_host =~ m#^\d+\.\d+\.\d+\.\d+$# or
$lotus_host =~ m#^[\w\._-]+$#
) ;
$server ||= $lotus_host
if $lotus_host =~ m#^[\w-]+$# ;
usage("You must provide a server option unless the lotus_host option looks like an unqualified host name.\n")
unless $server ;
$timeout ||= $TIMEOUT ;
$debug = 1
if $packet_debug ;
my $server_dn = "CN=\U$server" . '(?:/\w+=[\w -]+)*' ;
# Definitions of query strings. Change at your own risk :)
# This info was gathered with tcpdump while using a Lotus Notes 5 client,
# so I'm not sure of what each value is.
my $lotus_client_hello = &tethereal(<<'End_of_Tethereal_trace', '82') ;
0030 ff ff dc c5 00 00 82 00 00 00 77 00 00 00 02 00 ..........w.....
0040 00 40 02 0f 00 07 00 39 05 9e 45 54 ad ad 03 00 .@.....9..ET....
0050 00 00 00 02 00 2f 00 00 00 00 00 00 00 00 00 40 ...../.........@
0060 1f a0 af 19 d8 92 da 37 78 c9 ce 60 5e 35 b8 f7 .......7x..`^5..
0070 4e 05 00 10 00 0d 00 00 00 00 00 00 00 00 00 00 N...............
0080 00 00 00 00 00 02 00 08 00 9c dc 22 00 7c 6f 25 ...........".|o%
0090 4a 08 00 10 00 00 00 00 00 00 00 00 00 00 00 00 J...............
00a0 00 00 00 00 00 04 00 10 00 ba ac 8c 49 67 ee a1 ............Ig..
00b0 22 6f 63 bb 04 b4 75 0b 8f 00 "oc...u...
End_of_Tethereal_trace
# XXXX
# Notes 5 accepts this
# _wrongly_ encoded DN
# but in general the
# server will reset
# the connection if
# it receives malformed
# packets.
my $lotus_client_m1 = &tethereal(<<'End_of_Tethereal_trace', 'de') ;
0000 de 00 00 00 d4 00 00 00 13 00 00 40 01 00 9e 45 ...........@...E
0010 54 ad ad 03 00 00 00 00 02 00 29 13 23 00 b9 68 T.........).#..h
0020 25 00 9f 87 27 00 8f f4 25 00 00 00 88 00 24 00 %...'...%.....$.
0030 28 00 00 00 42 56 04 00 31 2e 30 00 42 43 01 00 (...BV..1.0.BC..
0040 03 42 41 01 00 30 42 4c 02 00 76 02 4e 4e 50 00 .BA..0BL..v.NNP.
0050 cf ee 9d 19 99 ca e0 bf 97 d3 59 a1 c5 78 16 82 ..........Y..x..
0060 76 09 8c 2c 96 ae 5a c1 15 bd 4e e9 b7 0f a9 d4 v..,..Z...N.....
0070 5a 03 d9 0d bc e4 7d 4f e0 f2 79 89 cf cd 23 19 Z.....}O..y...#.
0080 40 55 98 81 98 be d9 17 8d 69 8e 09 de c8 e8 92 @U.......i......
0090 24 86 6f 5a 09 81 1f 71 be 29 b7 47 78 8c 2e 00 $.oZ...q.).Gx...
00a0 45 4e 04 00 95 63 00 00 4d 41 08 00 64 a1 b4 b3 EN...c..MA..d...
00b0 a1 01 45 c2 80 00 50 55 52 53 41 46 22 00 43 4e ..E...PURSAF".CN
00c0 3d 4d 72 20 46 6f 6f 2f 4f 55 3d 42 61 72 20 68 =Mr Foo/OU=Bar h
00d0 6f 74 65 6c 2f 4f 3d 42 61 7a 20 4a 75 6e 63 74 otel/O=Baz Junct
00e0 69 6f 6e ion
End_of_Tethereal_trace
my $buff = '';
my $valid_resp_cr = sub {
my ($resp, $dn, $err_ind_sr) = @_ ;
if ( $resp =~ /($dn)/ ) {
return $1
} else {
($$err_ind_sr) = $resp =~ m#(CN=[\w -]+(?:/\w+=[\w -]+)*)# ;
return 0 ;
}
} ;
my @send = (
{ Msg => 'Helo', Send => $lotus_client_hello, Ok => $valid_resp_cr },
{ Msg => 'm1', Send => $lotus_client_m1, Ok => $valid_resp_cr },
) ;
my $tcp ;
eval {
$tcp = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $lotus_host, PeerPort => $LOTUS_PORT, Timeout => $timeout)
# Some versions (eg 1.1603) croak on a connect failure ..
} ;
&outahere("Connect to $lotus_host:$LOTUS_PORT failed:", $@)
if $@ || ! defined($tcp) ;
my $found = '' ;
foreach (@send) {
print STDERR "Sending Lotus client $_->{Msg} to $lotus_host.\n"
if $debug ;
&pdump($_->{Send})
if $packet_debug ;
eval {
local $SIG{"ALRM"} = sub { die 'Alarm clock restart' } ;
alarm($timeout) ;
$tcp->send($_->{Send}, 0) ||
&outahere("Send to $lotus_host failed: $!") ;
defined( $tcp->recv($buff, $BUFFER_SIZE, 0 ) ) ||
&outahere("Recv from $lotus_host failed: $!")
} ;
alarm(0) ;
&outahere('Unexpected exception raised by eval:', $@)
if $@ and $@ !~ /Alarm clock restart/ ;
&outahere("Timeout after $timeout secs - no response from $lotus_host")
if $@ and $@ =~ /Alarm clock restart/ ;
&outahere("Lotus server $lotus_host reset connection - client protocol (malformed packet sent) error", $@)
if $@ and $@ =~ /reset/ ;
&outahere("Empty recv buff after sending client $_->{Msg} and waiting $timeout secs. NB _no_ timeout exception.")
unless $buff ;
&pdump($buff)
if $packet_debug ;
my $err = '' ;
&outahere(qq(Response from $lotus_host failed to match CN=$server/.. got "$err") )
unless $found = $_->{Ok}->($buff, $server_dn, \$err) ;
print STDERR "Received Ok reply from $lotus_host - found DN $found in response.\n"
if $debug ;
}
close $tcp;
print "Ok. Lotus server $lotus_host responded with $found after ", scalar @send, " packet dialogue.\n" ;
exit $ERRORS{OK} ;
=begin comment
Normal response from Lotus Notes 5 server
0000 74 00 00 00 69 00 00 00 03 00 00 40 02 0f 00 05 t...i......@....
0010 00 3d 05 60 f0 3a 38 03 03 00 00 00 00 02 00 2f .=.`.:8......../
0020 00 26 00 00 00 00 00 00 00 40 1f 3d 73 76 0e 57 .&.......@.=sv.W
0030 e0 d7 67 cd a3 50 10 e0 99 24 b4 43 4e 3d 43 42 ..g..P...$.CN=CB
0040 52 4e 4f 54 45 53 30 31 2f 4f 55 3d 53 45 52 56 RNOTES01/OU=SERV
0050 45 52 53 2f 4f 3d 49 50 41 75 73 74 72 61 6c 69 ERS/O=IPAustrali
0060 61 05 00 10 00 09 00 00 00 00 00 00 00 00 00 00 a...............
0070 00 00 00 00 00 00
=end comment
=cut
sub outahere {
print "Failed. @_.\n" ;
exit $ERRORS{CRITICAL} ;
}
sub print_usage () {
print "Usage: $PROGNAME -H <lotus_host (name _or_ address)>..) [-S <lotus_server name> -T <timeout> -v ]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1096 $ ');
print "Copyright (c) 2004 Ed Rolison/S Hopcroft
Perl Check Lotus Notes plugin for Nagios.
Returns OK if the named server responds with its name.
";
print_usage();
print '
-H, --lotus_host:STRING
Name or IP Address of Lotus server to be checked.
-I, --individual_dn:NOT IMPLEMENTED
String of form CN=\w+(?:/OU=\w+)?/O=\w+
-S, --server:STRING
Alpha numeric string specifying the Lotus server name (the CN by which the server is known by
in the Domino directory). Defaults to host name if the host name does not look like an IP address.
-T, --packet-timeout:INTEGER
Time to wait for TCP dialogue to complete = send + rcv times (default Nagios timeout [$TIMEOUT sec]).
-v, --debug
Debugging output.
-vv, --packet_debug
Packet dump. Please post to Nag users in the event of trouble with this plugin.
-h, --help
This stuff.
';
support();
}
sub version () {
print_revision($PROGNAME,'$Revision: 1096 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

View file

@ -1,231 +0,0 @@
#!/usr/bin/perl -w
#
# check_maxchannels.pl - nagios plugin
#
#
# Copyright (C) 2000 Christoph Kron
#
# 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
#
# 11.01.2000 Version 1.0
use strict;
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
my $status;
my $TIMEOUT = 15;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my $state = "UNKNOWN";
my $answer = "";
my $snmpkey;
my $snmpoid;
my $key;
my $community = "public";
my $port = 161;
my @snmpoids;
# free channels
my $snmpWanAvailableChannels = '1.3.6.1.4.1.529.4.23.0';
# maximum channels
my $snmpWanSwitchedChannels = '1.3.6.1.4.1.529.4.24.0';
my $snmpWanDisabledChannels = '1.3.6.1.4.1.529.4.25.0';
my $snmpWanActiveChannels = '1.3.6.1.4.1.529.4.26.0';
my $snmpWanNailedChannels = '1.3.6.1.4.1.529.4.27.0';
my $snmpWanOutOfServiceChannels = '1.3.6.1.4.1.529.4.28.0';
my $snmpEventCurrentActiveSessions = '1.3.6.1.4.1.529.10.6.0';
# since startup
my $snmpEventTotalNoModems = '1.3.6.1.4.1.529.10.15.0';
# lan modem
my $snmpDeadLanModem = '1.3.6.1.4.1.529.15.7.0';
my $snmpDisabledLanModem = '1.3.6.1.4.1.529.15.5.0';
my $snmpSuspectLanModem = '1.3.6.1.4.1.529.15.3.0';
my $snmpAvailLanModem = '1.3.6.1.4.1.529.15.1.0';
my $snmpBusyLanModem = '1.3.6.1.4.1.529.15.9.0';
# max modems
my $snmpMdmNumber = '1.3.6.1.2.1.38.1.1.0';
my $hostname;
my $session;
my $error;
my $response;
my %wanStatus;
my $WanAvailableChannels;
my $WanSwitchedChannels;
my $WanDisabledChannels;
my $WanActiveChannels;
my $WanNailedChannels;
my $WanOutOfServiceChannels;
my $EventCurrentActiveSessions;
my $EventTotalNoModems;
my $DeadLanModem;
my $DisabledLanModem;
my $SuspectLanModem;
my $AvailLanModem;
my $BusyLanModem;
my $MdmNumber;
sub usage {
printf "\nMissing arguments!\n";
printf "\n";
printf "Perl Check maxchannels plugin for Nagios\n";
printf "monitors ISDN lines and modems on Ascend MAX 2000/4000/6000/TNT\n";
printf "usage: \n";
printf "check_maxchannel.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "check_maxchannels.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"};
}
# 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);
$status = GetOptions("community=s",\$community,
"port=i",\$port);
if ($status == 0)
{
&usage;
}
#shift;
$hostname = shift || &usage;
push(@snmpoids,$snmpWanAvailableChannels);
push(@snmpoids,$snmpWanSwitchedChannels);
push(@snmpoids,$snmpWanDisabledChannels);
push(@snmpoids,$snmpWanActiveChannels);
push(@snmpoids,$snmpWanNailedChannels);
push(@snmpoids,$snmpWanOutOfServiceChannels);
push(@snmpoids,$snmpEventCurrentActiveSessions);
push(@snmpoids,$snmpEventTotalNoModems);
push(@snmpoids,$snmpDeadLanModem);
push(@snmpoids,$snmpDisabledLanModem);
push(@snmpoids,$snmpSuspectLanModem);
push(@snmpoids,$snmpAvailLanModem);
push(@snmpoids,$snmpBusyLanModem);
push(@snmpoids,$snmpMdmNumber);
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
if (!defined($response = $session->get_request(@snmpoids))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer,$community");
exit $ERRORS{$state};
}
$WanAvailableChannels = $response->{$snmpWanAvailableChannels};
$WanSwitchedChannels = $response->{$snmpWanSwitchedChannels};
$WanDisabledChannels = $response->{$snmpWanDisabledChannels};
$WanActiveChannels = $response->{$snmpWanActiveChannels};
$WanNailedChannels = $response->{$snmpWanNailedChannels};
$WanOutOfServiceChannels = $response->{$snmpWanOutOfServiceChannels};
$EventCurrentActiveSessions = $response->{$snmpEventCurrentActiveSessions};
$EventTotalNoModems = $response->{$snmpEventTotalNoModems};
$DeadLanModem = $response->{$snmpDeadLanModem};
$DisabledLanModem = $response->{$snmpDisabledLanModem};
$SuspectLanModem = $response->{$snmpSuspectLanModem};
$AvailLanModem = $response->{$snmpAvailLanModem};
$BusyLanModem = $response->{$snmpBusyLanModem};
$MdmNumber = $response->{$snmpMdmNumber};
# less than 50% -> WARNING
if ( 0 < $WanOutOfServiceChannels
&& $WanOutOfServiceChannels < ($snmpWanSwitchedChannels * 0.5) ) {
$state = 'WARNING';
}
elsif ($WanOutOfServiceChannels > 0) {
$state = 'CRITICAL';
}
elsif ($DeadLanModem > 0) {
$state = 'CRITICAL';
}
elsif ($SuspectLanModem > 0) {
$state = 'WARNING';
}
elsif ($AvailLanModem == 0) {
$state = 'WARNING';
}
else {
$state = 'OK';
}
$answer = sprintf("active sessions: %d (%d), active modems: %d (%d)<BR>",
$EventCurrentActiveSessions,
$WanSwitchedChannels,
$BusyLanModem,
$MdmNumber);
$answer .= sprintf("channels available: %d, disabled: %d",
$WanAvailableChannels,
$WanDisabledChannels);
$answer .= sprintf(", out of service: %d, nailed: %d<BR>",
$WanOutOfServiceChannels,
$WanNailedChannels);
$answer .= sprintf("modems avail.: %d, disabled: %d, suspect: %d, dead: %d<BR>",
$AvailLanModem,
$DisabledLanModem,
$SuspectLanModem,
$DeadLanModem);
$answer .= sprintf("unserviced modem calls: %d (since startup)\n",
$EventTotalNoModems);
$session->close;
print ("$state: $answer");
exit $ERRORS{$state};

View file

@ -1,201 +0,0 @@
#!/usr/bin/perl -w
#
# check_maxwanstate.pl - nagios plugin
#
#
# Copyright (C) 2000 Christoph Kron
#
# 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
#
# 11.01.2000 Version 1.0
use strict;
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
my $status;
my $TIMEOUT = 1500;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my %wanLineState = (
1,'ls-unknown',
2,'ls-does-not-exist',
3,'ls-disabled',
4,'ls-no-physical',
5,'ls-no-logical',
6,'ls-point-to-point',
7,'ls-multipoint-1',
8,'ls-multipoint-2',
9,'ls-loss-of-sync',
10,'ls-yellow-alarm',
11,'ls-ais-receive',
12,'ls-no-d-channel',
13,'ls-active',
14,'ls-maintenance');
my %wanLineType = (
'1.3.6.1.4.1.529.4.1','Any',
'1.3.6.1.4.1.529.4.2','T1',
'1.3.6.1.4.1.529.4.3','E1',
'1.3.6.1.4.1.529.4.4','Dpnss',
'1.3.6.1.4.1.529.4.5','Bri',
'1.3.6.1.4.1.529.4.6','S562',
'1.3.6.1.4.1.529.4.7','S564',
'1.3.6.1.4.1.529.4.8','Sdsl',
'1.3.6.1.4.1.529.4.9','AdslCap');
my $state = "UNKNOWN";
my $answer = "";
my $snmpkey;
my $snmpoid;
my $key;
my $community = "public";
my $port = 161;
my @snmpoids;
my $snmpWanLineName = '1.3.6.1.4.1.529.4.21.1.2';
my $snmpWanLineType = '1.3.6.1.4.1.529.4.21.1.3';
my $snmpWanLineState = '1.3.6.1.4.1.529.4.21.1.5';
my $snmpWanLineUsage = '1.3.6.1.4.1.529.4.21.1.8';
my $hostname;
my $session;
my $error;
my $response;
my %wanStatus;
my $ifup =0 ;
my $ifdown =0;
my $ifdormant = 0;
my $ifmessage;
sub usage {
printf "\nMissing arguments!\n";
printf "\n";
printf "Perl Check maxwanstate plugin for Nagios\n";
printf "monitors E1/T1 interface status\n";
printf "usage: \n";
printf "check_maxwanstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "check_maxwanstate.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"};
}
# 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);
$status = GetOptions("community=s",\$community,
"port=i",\$port);
if ($status == 0)
{
&usage;
}
#shift;
$hostname = shift || &usage;
push(@snmpoids,$snmpWanLineUsage);
push(@snmpoids,$snmpWanLineState);
push(@snmpoids,$snmpWanLineName);
push(@snmpoids,$snmpWanLineType);
foreach $snmpoid (@snmpoids) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: $answer");
exit $ERRORS{$state};
}
if (!defined($response = $session->get_table($snmpoid))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer,$community,$snmpkey");
exit $ERRORS{$state};
}
foreach $snmpkey (keys %{$response}) {
$snmpkey =~ /.*\.(\d+)$/;
$key = $1;
$wanStatus{$key}{$snmpoid} = $response->{$snmpkey};
}
$session->close;
}
foreach $key (keys %wanStatus) {
# look only at active Interfaces lu-trunk(5)
if ($wanStatus{$key}{$snmpWanLineUsage} == 5 ) {
# 13 -> active
if ($wanStatus{$key}{$snmpWanLineState} == 13 ) {
$ifup++;
}
else {
$ifdown++ ;
$ifmessage .= sprintf("%s interface status : %s (%s)<BR>",
$wanLineType{$wanStatus{$key}{$snmpWanLineType}},
$wanLineState{$wanStatus{$key}{$snmpWanLineState}},
$wanStatus{$key}{$snmpWanLineName});
}
}
}
if ($ifdown > 0) {
$state = 'CRITICAL';
$answer = sprintf("host '%s', interfaces up: %d, down: %d<BR>",
$hostname,
$ifup,
$ifdown);
$answer = $answer . $ifmessage . "\n";
}
else {
$state = 'OK';
$answer = sprintf("host '%s', interfaces up: %d, down: %d\n",
$hostname,
$ifup,
$ifdown);
}
print ("$state: $answer");
exit $ERRORS{$state};

View file

@ -1,146 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_mem.pl 2 2002-02-28 06:42:51Z egalstad $
# check_mem.pl Copyright (C) 2000 Dan Larsson <dl@tyfon.net>
#
# 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
# Tell Perl what we need to use
use strict;
use Getopt::Std;
use vars qw($opt_c $opt_f $opt_u $opt_w
$free_memory $used_memory $total_memory
$crit_level $warn_level
%exit_codes @memlist
$percent $fmt_pct
$verb_err $command_line);
# Predefined exit codes for Nagios
%exit_codes = ('UNKNOWN' ,-1,
'OK' , 0,
'WARNING' , 1,
'CRITICAL', 2,);
# Turn this to 1 to see reason for parameter errors (if any)
$verb_err = 0;
# This the unix command string that brings Perl the data
$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;
chomp $command_line;
@memlist = split(/ /, $command_line);
# Define the calculating scalars
$used_memory = $memlist[0];
$free_memory = $memlist[1];
$total_memory = $used_memory + $free_memory;
# Get the options
if ($#ARGV le 0)
{
&usage;
}
else
{
getopts('c:fuw:');
}
# Shortcircuit the switches
if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0)
{
print "*** You must define WARN and CRITICAL levels!" if ($verb_err);
&usage;
}
elsif (!$opt_f and !$opt_u)
{
print "*** You must select to monitor either USED or FREE memory!" if ($verb_err);
&usage;
}
# Check if levels are sane
if ($opt_w <= $opt_c and $opt_f)
{
print "*** WARN level must not be less than CRITICAL when checking FREE memory!" if ($verb_err);
&usage;
}
elsif ($opt_w >= $opt_c and $opt_u)
{
print "*** WARN level must not be greater than CRITICAL when checking USED memory!" if ($verb_err);
&usage;
}
$warn_level = $opt_w;
$crit_level = $opt_c;
if ($opt_f)
{
$percent = $free_memory / $total_memory * 100;
$fmt_pct = sprintf "%.1f", $percent;
if ($percent <= $crit_level)
{
print "Memory CRITICAL - $fmt_pct% ($free_memory kB) free\n";
exit $exit_codes{'CRITICAL'};
}
elsif ($percent <= $warn_level)
{
print "Memory WARNING - $fmt_pct% ($free_memory kB) free\n";
exit $exit_codes{'WARNING'};
}
else
{
print "Memory OK - $fmt_pct% ($free_memory kB) free\n";
exit $exit_codes{'OK'};
}
}
elsif ($opt_u)
{
$percent = $used_memory / $total_memory * 100;
$fmt_pct = sprintf "%.1f", $percent;
if ($percent >= $crit_level)
{
print "Memory CRITICAL - $fmt_pct% ($used_memory kB) used\n";
exit $exit_codes{'CRITICAL'};
}
elsif ($percent >= $warn_level)
{
print "Memory WARNING - $fmt_pct% ($used_memory kB) used\n";
exit $exit_codes{'WARNING'};
}
else
{
print "Memory OK - $fmt_pct% ($used_memory kB) used\n";
exit $exit_codes{'OK'};
}
}
# Show usage
sub usage()
{
print "\ncheck_mem.pl v1.0 - Nagios Plugin\n\n";
print "usage:\n";
print " check_mem.pl -<f|u> -w <warnlevel> -c <critlevel>\n\n";
print "options:\n";
print " -f Check FREE memory\n";
print " -u Check USED memory\n";
print " -w PERCENT Percent free/used when to warn\n";
print " -c PERCENT Percent free/used when critical\n";
print "\nCopyright (C) 2000 Dan Larsson <dl\@tyfon.net>\n";
print "check_mem.pl comes with absolutely NO WARRANTY either implied or explicit\n";
print "This program is licensed under the terms of the\n";
print "GNU General Public License (check source code for details)\n";
exit $exit_codes{'UNKNOWN'};
}

View file

@ -1,324 +0,0 @@
#!/usr/bin/perl -w
# $Id: check_ms_spooler.pl 64 2002-07-16 00:04:42Z stanleyhopcroft $
# Revision 1.1 2002/07/16 00:04:42 stanleyhopcroft
# Primitive and in need of refinement test of MS spooler (with smbclient)
#
# Revision 2.5 2002-02-13 07:36:08+11 anwsmh
# Correct 'apostrophe' disaster.
# Apostrophes in plugin output cause Netsaint notification commands
# ( sh echo 'yada $PLUGINOUTPUT$ ..') to fail, usually mysteriously
# eg notify OK works but notify CRITICAL does not.
# Replace '$var' in print "output" with \"$var\".
#
# Revision 2.4 2001-11-21 21:36:05+11 anwsmh
# Minor corrections
# . replace 'die' by print .. exit $ERRORS{CRITICAL}
# . change concluding message to list the queues (sorted) if there are no enqueued docs.
#
# Revision 2.3 2001-11-20 11:00:58+11 anwsmh
# Major corrections.
# 1. to sub AUTOLOAD: coderef parms must be @_ (ie the parm when the new sub is called)
# 2. to processing of queue report (no inspection of $last_line; entire $queue_report is
# checked for errors)
# 3. cosmetic and debug changes in many places.
#
# Revision 2.2 2001-11-17 23:30:34+11 anwsmh
# After adapting two different queue reports resulting from
# different name resolution methods.
#
# Revision 2.1 2001-11-17 13:21:54+11 anwsmh
# Adapt to Netsaint ('use utils, Getopt::Long, and standard switch processing).
# Fix many peculiarities.
#
use strict ;
use Getopt::Long ;
use utils ;
use vars qw($opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $debug);
use vars '$AUTOLOAD' ;
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
my $PROGNAME = 'check_ms_spooler' ;
sub print_help ();
sub print_usage ();
sub help ();
sub version ();
delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
use constant SMBCLIENT_PATH => '/usr/local/samba/bin/smbclient' ;
use constant MAX_QUEUES_TO_CHECK => 20 ; # So that the check doesn't take longer than $TIMEOUT
use constant SMBCLIENT_SVC => sub { return `${\SMBCLIENT_PATH} -L //$_[0] -U $_[1]%$_[2]` } ;
use constant SMBCLIENT_QUEUE => sub { return `${\SMBCLIENT_PATH} //$_[0]/$_[1] -U $_[2]%$_[3] -c 'queue; quit' 2>/dev/null` } ;
# The queue results depend on the name resolution method.
# Forcing 'wins' or 'bcat' name resolution makes the queue results the
# same for all spoolers (those that are resolved with WINS have an extra line
# 'Got a positive name query response from <ip address of WINS> ..)
# but would fail if there is no WINS and when miscreant spoolers
# don't respond to broadcasts.
use constant MIN => sub { my $min = $_[0] ; foreach (@_) { $min = $_ if $_ <= $min; } return $min ; } ;
$SIG{"ALRM"} = sub { die "Alarm clock restart" } ;
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("V|version" => \&version,
"h|help" => \&help,
"d|debug" => \$debug,
"p|password=s" => \$opt_p,
"u|username=s" => \$opt_u,
"H|hostname=s" => \$opt_H);
($opt_H) || usage("MS Spooler name not specified\n");
my $spooler = $1 if $opt_H =~ m#(\w+)# ; # MS host names allow __any__ characters (more than \w)
($spooler) || usage("Invalid MS spooler name: $opt_H\n");
($opt_u) || ($opt_u = 'guest');
my $user = $1 if $opt_u =~ m#(\w+)# ;
($user) || usage("Invalid user: $opt_u\n");
($opt_p) || ($opt_p = 'guest');
my $pass = $1 if ($opt_p =~ /(.*)/);
($pass) || usage("Invalid password: $opt_p\n");
my ($printer, $queue, @queues, $ms_spooler_status, @results, %junk) ;
my (@fault_messages, @queue_contents, @services, @prandom_queue_indices) ;
my ($queue_contents, $number_of_queues, $state, $queue_report) ;
$state = "getting service list (${\SMBCLIENT_PATH} -L $spooler -U $user%$pass) from spooler\n" ;
eval {
alarm($TIMEOUT) ;
@services = SMBCLIENT_SVC->( $spooler, $user, $pass ) ;
} ;
alarm(0) ;
if ($@ and $@ !~ /Alarm clock restart/) {
print "Failed. $PROGNAME failed $state. Got \"$@\"\n" ;
exit $ERRORS{"CRITICAL"} ;
}
if ($@ and $@ =~ /Alarm clock restart/) {
print "Failed. $PROGNAME timed out $state. Got \"@services\"\n" ;
exit $ERRORS{"CRITICAL"} ;
}
# tsitc> /usr/local/samba/bin/smbclient //ipaprint1/tt03 -U blah%blah -P -c 'queue; quit'
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Connection to ipaprint1 failed
# tsitc> /usr/local/samba/bin/smbclient -L sna_spl1 -U blah%blah | & more
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Got a positive name query response from 10.0.100.29 ( 10.0.6.20 )
# session setup failed: ERRDOS - ERRnoaccess (Access denied.)
if ( grep /Connection to $spooler failed|ERR/, @services ) {
print "Failed. $PROGNAME failed $state. Got \"@services\"\n" ;
# print "Failed. Request for services list to $spooler failed. Got \"@services\"\n" ;
exit $ERRORS{"CRITICAL"} ;
}
# tsitc# /usr/local/samba/bin/smbclient -L ipaprint -U blah%blah
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
#
# Sharename Type Comment
# --------- ---- -------
# TH02 Printer TH02
# ADMIN$ Disk Remote Admin
# IPC$ IPC Remote IPC
# S431 Printer S431
# S402 Printer S402
# S401 Printer S401
# C$ Disk Default share
# BW01 Printer BW01
# BW02 Printer BW02
# TL11 Printer TL11
# TL07 Printer TL07
# S225 Printer Discovery South - 2nd Floor - HP CLJ4500
# S224 Printer S224
# S223 Printer Discovery South 2nd Floor Trademarks Training
# S222 Printer S222
# S203 Printer S203
# S202 Printer S202
my @printers = map { my @junk = split; $junk[0] }
grep { my @junk = split; defined $junk[1] and $junk[1] eq 'Printer' } @services ;
# don't check IPC$, ADMIN$ etc.
$ms_spooler_status = 0 ;
$number_of_queues = MIN->(MAX_QUEUES_TO_CHECK, (scalar(@services) >> 3) + 1) ;
$state = "checking queues on $spooler" ;
eval {
# foreach queues to check
# generate a pseudo-random int in 0 .. $#printers
# drop it if the index has already been generated ;
%junk = () ;
@prandom_queue_indices = grep { ! $junk{$_}++ }
map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ;
@queues = @printers[@prandom_queue_indices] ;
# @queues = @printers[ map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ] ;
alarm($TIMEOUT) ;
@queue_contents = @fault_messages = () ;
foreach $printer (sort @queues) {
# Expect 3 lines from a queue report.
# If queue is empty, last line is null otherwise
# it will contain a queue report or an SMB error
# Empty Queue.
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
# Queue command from a spooler with a DNS name.
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
# 65 16307 Microsoft Word - Servicesweoffer2.doc
# 68 10410 Microsoft Word - Servicesweoffer.doc
# 143 24997 Microsoft Word - Miss Samantha Anne Craig.doc
# 182 15635 Microsoft Word - services we provide.doc
# Error.
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
# tree connect failed: ERRDOS - ERRnosuchshare (You specified an invalid share name)
# Can't connect error.
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Connection to sna_spl2 failed
# Empty Queue from a spooler with no DNS name, NetBIOS name resolved by WINS.
# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
# Got a positive name query response from 10.0.100.29 ( 10.0.6.20 )
# Domain=[SNA_PRINT] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
# There are 3 lines of output from smbclient for those spoolers whose names are
# resolved by WINS (because those names are NetBIOS and therefore not in DNS);
# 4 lines for errors or enqueued jobs
print STDERR "${\SMBCLIENT_PATH} //$spooler/$printer -U $user%$pass -c 'queue; quit' ==>\n" if $debug ;
@results = SMBCLIENT_QUEUE->( $spooler, $printer, $user, $pass ) ;
print STDERR "\"@results\"\n" if $debug ;
# set $ms_spooler_status somehow
chomp( @results ) ;
$queue_report = queue_report->(@results) ;
print STDERR '$queue_report for $printer ', "$printer: \"$queue_report\"\n\n" if $debug ;
if ( defined $queue_report and ($queue_report !~ /ERR/ && $queue_report !~ /failed/) ) {
$ms_spooler_status = 1 ;
push @queue_contents, "$printer: $queue_report" if $queue_report ;
} else {
push @fault_messages, "$printer: $queue_report" ;
}
}
alarm(0) ;
} ;
if ($@ and $@ !~ /Alarm clock restart/) {
print "Failed. $PROGNAME failed at $state. Got \"$@\"\n" ;
exit $ERRORS{"CRITCAL"} ;
}
if ($@ and $@ =~ /Alarm clock restart/) {
my $i ;
foreach (@queues) { $i++ ; last if $_ eq $printer }
print "Failed. Timed out connecting to $printer ($i of $number_of_queues) on //$spooler after $TIMEOUT secs. Got \"@fault_messages\"\n" ;
exit $ERRORS{"CRITICAL"} ;
}
if (! $ms_spooler_status) {
print "Failed. Couldn't connect to @queues on //$spooler as user $user. Got \"@fault_messages\"\n" ;
exit $ERRORS{"CRITICAL"} ;
}
$queue_contents = ( @queue_contents != 0 ? join(" ", (@queue_contents == 1 ? "Queue" : "Queues"), @queue_contents) :
"All Queues empty" ) ;
print "Ok. Connected to ", $queue_contents =~ /empty$/ ? "@{[sort @queues]}" : scalar @queues, " queues on //$spooler. $queue_contents\n" ;
exit $ERRORS{"OK"} ;
sub print_usage () {
print "Usage: $PROGNAME -H <spooler> -u <user> -p <password>\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 64 $ ');
print "Copyright (c) 2001 Karl DeBisschop/S Hopcroft
Perl Check MS Spooler plugin for NetSaint. Display a subset of the queues on an SMB (Samba or MS) print spooler.
";
print_usage();
print '
-H, --hostname=STRING
NetBIOS name of the SMB Print spooler (Either Samba or MS spooler)
-u, --user=STRING
Username to log in to server. (Default: "guest")
-p, --password=STRING
Password to log in to server. (Default: "guest")
-d, --debug
Debugging output.
-h, --help
This stuff.
';
support();
}
sub version () {
print_revision($PROGNAME,'$Revision: 64 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}
sub AUTOLOAD {
my @queue_rep = @_ ;
# 'Object Oriented Perl', D Conway, p 95
no strict 'refs' ;
if ( $AUTOLOAD =~ /.*::queue_report/ ) {
if ( grep /Got a positive name query response from/, @queue_rep ){
*{$AUTOLOAD} = sub { return join ' ', splice(@_, 3) } ;
return join '', splice(@queue_rep, 3) ;
} else {
*{$AUTOLOAD} = sub { return join ' ',splice(@_, 2) } ;
return join '', splice(@queue_rep, 2) ;
}
} else {
die "No such subroutine: $AUTOLOAD" ;
}
}

View file

@ -1,104 +0,0 @@
#!/bin/sh
# This script is designed to be used by Nagios. It checks for the availability of both Microsoft SQL Server 7 and 2000.
#
# Requirements:
#
# FreeTDS 6.0+ (http://www.freetds.org/)
#
# It was written by Tom De Blende (tom.deblende@village.uunet.be) in 2003.
#
# Version 1.0.
# Version 1.1: Rewritten the initial script so that it not only works from the CLI but also from within Nagios. Always helpful...
# Version 1.2: Grouped output so things look a bit better.
# Version 2.0: Rewritten the plugin to support version 6.0+ of FreeTDS.
# Removed sqsh requirement as version 6.0+ of FreeTDS now offers its own CLI client: tsql.
# Older versions of FreeTDS are no longer supported.
#
#
# You might want to change these values:
tsqlcmd=`which tsql`
catcmd=`which cat`
grepcmd=`which grep`
rmcmd=`which rm`
mktempcmd=`which mktemp`
wccmd=`which wc`
sedcmd=`which sed`
trcmd=`which tr`
uniqcmd=`which uniq`
###################################################################################################################
hostname=$1
usr=$2
pswd=$3
srv=$4
if [ ! "$#" == "4" ]; then
echo -e "\nYou did not supply enough arguments. \nUsage: $0 <host> <username> <password> <version> \n \n$0 checks Microsoft SQL Server connectivity. It works with versions 7 and 2000.\n\nYou need a working version of FreeTDS (http://www.freetds.org/) and tsql (included in FreeTDS 6.0+) to connect to the SQL server. \nIt was written by Tom De Blende (tom.deblende@village.uunet.be) in 2003. \n\nExample:\n $0 dbserver sa f00bar 2000\n" && exit "3"
elif [ $tsqlcmd == "" ]; then
echo -e "tsql not found! Please verify you have a working version of tsql (included in the FreeTDS version 6.0+) and enter the full path in the script." && exit "3"
fi
exit="3"
# Creating the command file that contains the sql statement that has to be run on the SQL server.
tmpfile=`$mktempcmd /tmp/$hostname.XXXXXX`
if [ $srv == "7" ]; then
spid=7
elif [ $srv == "2000" ]; then
spid=50
else
echo -e "$srv is not a supported MS SQL Server version!" && exit "3"
fi
echo -e "select loginame from sysprocesses where spid > $spid order by loginame asc\ngo" > $tmpfile
# Running tsql to get the results back.
resultfile=`$mktempcmd /tmp/$hostname.XXXXXX`
errorfile=`$mktempcmd /tmp/$hostname.XXXXXX`
$tsqlcmd -S $hostname -U $usr -P $pswd < $tmpfile 2>$errorfile > $resultfile
$grepcmd -q "Login failed for user" $errorfile
if [ "$?" == "0" ]; then
$rmcmd -f $tmpfile $resultfile $errorfile;
echo CRITICAL - Could not make connection to SQL server. Login failed.;
exit 2;
fi
$grepcmd -q "There was a problem connecting to the server" $errorfile
if [ "$?" == "0" ]; then
$rmcmd -f $tmpfile $resultfile $errorfile;
echo CRITICAL - Could not make connection to SQL server. Incorrect server name or SQL service not running.;
exit 2;
fi
resultfileln=`$catcmd $resultfile | $wccmd -l | $sedcmd 's/ //g'`
if [ "$resultfileln" == "2" ]; then
$rmcmd -f $tmpfile $resultfile $errorfile;
echo CRITICAL - Could not make connection to SQL server. No data received from host.;
exit 2;
else
nmbr=`$catcmd $resultfile | $grepcmd -v locale | $grepcmd -v charset| $grepcmd -v 1\> | $sedcmd '/^$/d' | $sedcmd 's/ //g' | $wccmd -l | sed 's/ //g'`
users=`$catcmd $resultfile | $grepcmd -v locale | $grepcmd -v charset| $grepcmd -v 1\> | $sedcmd '/^$/d' | $sedcmd 's/ //g' | $uniqcmd -c | $trcmd \\\n , | $sedcmd 's/,$/./g' | $sedcmd 's/,/, /g' | $sedcmd 's/ //g' | $trcmd \\\t " " | $sedcmd 's/ \./\./g' | $sedcmd 's/ ,/,/g'`
$rmcmd -f $tmpfile $resultfile;
echo "OK - MS SQL Server $srv has $nmbr user(s) connected: $users" | sed 's/: $/./g';
exit 0;
fi
# Cleaning up.
$rmcmd -f $tmpfile $resultfile $errorfile
echo $stdio
exit $exit

View file

@ -1,48 +0,0 @@
#!/usr/bin/perl
# denao - denao@uol.com.br - Systems Engineering
# Universo Online - http://www.uol.com.br
use DBI;
use Time::Local;
my $t_lambuja = 5; # (expire_minutes)
my $databasename = ""; # The name of nagios database (i.e.: nagios)
my $table = "programstatus";
my $where = "localhost"; # The machine where the database
my $port = "3306";
my $base = "DBI:mysql:$databasename:$where:$port";
my $user = ""; # the user to connect to the database
# (needs permission to "select at programstatus table only"
my $password = ""; # the password (if any)
my %results;
my @fields = qw( last_update );
my $dbh = DBI->connect($base,$user,$password);
my $fields = join(', ', @fields);
my $query = "SELECT $fields FROM $table";
my $sth = $dbh->prepare($query);
$sth->execute();
@results{@fields} = ();
$sth->bind_columns(map { \$results{$_} } @fields);
$sth->fetch();
$sth->finish();
$dbh->disconnect();
check_update();
sub check_update {
($yea,$mon,$day,$hou,$min,$sec)=($results{last_update}=~/(\d+)\-(\d+)\-(\d+)\s(\d+)\:(\d+)\:(\d+)/);
($sec_now, $min_now, $hou_now, $day_now, $mon_now, $yea_now) = (localtime(time))[0,1,2,3,4,5];
$mon_now+=1; $yea_now+=1900;
$unixdate=timelocal($sec,$min,$hou,$day,$mon,$yea);
$unixdate_now=timelocal($sec_now,$min_now,$hou_now,$day_now,$mon_now,$yea_now);
if (scalar($unixdate_now - $unixdate) > scalar($t_lambuja * 60)) {
print "Nagios problem: nagios is down, for at least " . scalar($t_lambuja) . " minutes.\n";
exit(1);
} else {
print "Nagios ok: status data updated " . scalar($unixdate_now - $unixdate) . " seconds ago\n";
exit(0);
}
}

View file

@ -1,89 +0,0 @@
#!/usr/local/bin/perl -w
use strict;
$|++;
use vars qw/$opt_e $opt_c/;
$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin";
use Getopt::Std;
use DBI;
my $driver = "mysql";
my $CFG_DEF = "/opt/nagios/etc/cgi.cfg";
my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
my $EXPIRE_DEF = 5; ## expressed in minutes
my $PROCCNT = 0;
use constant OK => 1;
use constant WARN => 2;
my $STAT = WARN;
sub usage {
print STDERR "\n";
print STDERR "$0 -F -e <expire time in minutes> -C <process string>\n";
print STDERR "\n";
exit -1;
}
getopt("e:c:");
my $EXPIRE = $opt_e || $EXPIRE_DEF;
my $CFG = $opt_c || $CFG_DEF;
( -f $CFG ) or die "Can't open config file '$CFG': $!\n";
my ($dbhost, $dbport, $dbuser, $dbpass, $dbname);
open(F, "< $CFG");
while ( <F> ) {
if (/^xsddb_host=(.+)/) { $dbhost = $1; next; };
if (/^xsddb_port=(.+)/) { $dbport = $1; next; };
if (/^xsddb_database=(.+)/) { $dbname = $1; next; };
if (/^xsddb_username=(.+)/) { $dbuser = $1; next; };
if (/^xsddb_password=(.+)/) { $dbpass = $1; next; };
}
close(F);
# print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
my $sth = $dbh->prepare($QUERY);
if (!$sth) { die "Error:" . $dbh->errstr . "\n"; }
$sth->execute;
if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; }
my %status = ();
my $names = $sth->{'NAME'};
my $numFields = $sth->{'NUM_OF_FIELDS'};
my $ref = $sth->fetchrow_arrayref;
for (my $i = 0; $i < $numFields; $i++) {
$status{"$$names[$i]"} = $$ref[$i];
}
#foreach (keys(%status)) {
# print "$_: $status{$_}\n";
#}
my $lastupdated = time() - $status{"ut"};
if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds
$STAT = OK;
}
open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | ");
$PROCCNT = 0;
while(<PS>) {
$PROCCNT++;
}
close(PS);
if ( $STAT == OK ) {
print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
}

View file

@ -1,91 +0,0 @@
#!/usr/bin/perl -w
use strict;
$|++;
use vars qw/$opt_e $opt_c/;
$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin";
use Getopt::Std;
use DBI;
my $driver = "Pg";
my $CFG_DEF = "/etc/nagios/cgi.cfg";
# this works only in mysql
# my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
# the following is the same for postgres
my $QUERY = "select *, round(date_part('epoch',last_update)) as ut from programstatus;";
my $EXPIRE_DEF = 5; ## expressed in minutes
my $PROCCNT = 0;
use constant OK => 1;
use constant WARN => 2;
my $STAT = WARN;
sub usage {
print STDERR "\n";
print STDERR "$0 -F -e &lt;expire time in minutes&gt; -C &lt;process string&gt;\n";
print STDERR "\n";
exit -1;
}
getopt("e:c:");
my $EXPIRE = $opt_e || $EXPIRE_DEF;
my $CFG = $opt_c || $CFG_DEF;
( -f $CFG ) or die "Can't open config file '$CFG': $!\n";
my ($dbhost, $dbport, $dbuser, $dbpass, $dbname);
open(F, "< $CFG");
while ( <F> ) {
if (/^xsddb_host=(.+)/) { $dbhost = $1; next; };
if (/^xsddb_port=(.+)/) { $dbport = $1; next; };
if (/^xsddb_database=(.+)/) { $dbname = $1; next; };
if (/^xsddb_username=(.+)/) { $dbuser = $1; next; };
if (/^xsddb_password=(.+)/) { $dbpass = $1; next; };
}
close(F);
#print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport";
my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
my $sth = $dbh->prepare($QUERY);
if (!$sth) { die "Error:" . $dbh->errstr . "\n"; }
$sth->execute;
if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; }
my %status = ();
my $names = $sth->{'NAME'};
my $numFields = $sth->{'NUM_OF_FIELDS'};
my $ref = $sth->fetchrow_arrayref;
for (my $i = 0; $i < $numFields; $i++) {
$status{"$$names[$i]"} = $$ref[$i];
}
#foreach (keys(%status)) {
# print "$_: $status{$_}\n";
#}
my $lastupdated = time() - $status{"ut"};
if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds
$STAT = OK;
}
open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | ");
$PROCCNT = 0;
while(<PS>) {
$PROCCNT++;
}
close(PS);
if ( $STAT == OK ) {
print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
}

View file

@ -1,178 +0,0 @@
#!/usr/bin/perl -wT
# check_netapp
#
# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com>
#
# 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
####################################
# checks for overtemperature, fans, psu, and nfs operations/second on
# Network Appliance Filers.
# Returns:
# OK if temp, fans, psu OK and Ops/Sec below warning and critical
# Thresholds (default is warning=3500, critical=5000)
# ** Note: See the specifications for your Filer model for
# the thresholds !
# Returns Warning if NFS Ops/Sec is above warning threshold
# (default 3500, or specified by -o command line option)
# Returns Critical if NFS Ops/Sec is above critical threshold
# ( -m option, or default 5000), or if overtem, psufault, or
# fanfault detected.
#
####################################
# Notes on operational limits for NetApp Filers:
# Platform Maximum Ops/Second (recommended)
# -------------------------------------------------------------
# F230 1000
# F740 5500
# F760 9000
####################################
use Net::SNMP;
use Getopt::Long;
&Getopt::Long::config('auto_abbrev');
my $status;
my $response = "";
my $TIMEOUT = 10;
my $community = "public";
my $port = 161;
my $opsthresh = "3500";
my $critical = "5000";
my $status_string = "";
my %OIDLIST = (
overtemp => '1.3.6.1.4.1.789.1.2.4.1.0',
failedfan => '1.3.6.1.4.1.789.1.2.4.2.0',
failedpsu => '1.3.6.1.4.1.789.1.2.4.4.0',
nfsops => '1.3.6.1.4.1.789.1.2.2.1.0'
);
my %STATUSCODE = ( 'UNKNOWN' => '-1',
'OK' => '0',
'WARNING' => '1',
'CRITICAL' => '2');
my $state = "UNKNOWN";
$SIG{'ALRM'} = sub {
print "ERROR: No snmp response from $hostname (sigALRM)\n";
exit($STATUSCODE{"UNKNOWN"});
};
alarm($TIMEOUT);
sub get_nfsops {
my $nfsops_start = &SNMPGET($OIDLIST{nfsops});
sleep(1);
my $nfsops_end = &SNMPGET($OIDLIST{nfsops});
my $nfsopspersec = $nfsops_end - $nfsops_start;
return($nfsopspersec);
}
sub show_help {
printf("\nPerl NetApp filer plugin for Nagios\n");
printf("Usage:\n");
printf("
check_netapp [options] <hostname>
Options:
-c snmp-community
-p snmp-port
-o Operations per second warning threshold
-m Operations per second critical threshold
");
printf("Copyright (C)2000 Leland E. Vandervort\n");
printf("check_netapp comes with absolutely NO WARRANTY either implied or explicit\n");
printf("This program is licensed under the terms of the\n");
printf("GNU General Public License\n(check source code for details)\n\n\n");
exit($STATUSCODE{"UNKNOWN"});
}
$status = GetOptions( "community=s", \$community,
"port=i", \$port,
"opsthresh=i", \$opsthresh,
"maxops=i", \$critical );
if($status == 0) {
&show_help;
}
sub SNMPGET {
$OID = shift;
($session,$error) = Net::SNMP->session(
Hostname => $hostname,
Community => $community,
Port => $port
);
if(!defined($session)) {
printf("$state %s\n", $error);
exit($STATUSCODE{$state});
}
if(!defined($response = $session->get_request($OID))) {
printf("$state %s\n", $session->error());
$session->close();
exit($STATUSCODE{$state});
}
$session->close();
return($response->{$OID});
}
$hostname = shift || &show_help;
my $tempcheck = &SNMPGET($OIDLIST{overtemp});
if($tempcheck == 1) {
$state = "OK";
$status_string .= "Temp OK ";
}
else {
$state = "CRITICAL";
$status_string .= "Temp CRIT";
}
foreach $element ('failedfan','failedpsu') {
my $my_return = &SNMPGET($OIDLIST{$element});
if(($my_return =~ /no/) || ($my_return == 0)) {
$status_string .= "$element = $my_return ";
$state = "OK";
}
else {
$status_string .= "$element = $my_return ";
$state = "CRITICAL";
}
}
my $tmp_opssec = &get_nfsops();
if ($tmp_opssec >= $critical) {
$state = "CRITICAL";
}
elsif ($tmp_opssec >= $opsthresh) {
$state = "WARNING";
}
else {
$state = "OK";
}
$status_string .= "Ops\/Sec = $tmp_opssec ";
print "$state $status_string\n";
exit($STATUSCODE{$state});

View file

@ -1,442 +0,0 @@
#!/usr/bin/python
# Change the above line if python is somewhere else
#
# check_nmap
#
# Program: nmap plugin for Nagios
# License: GPL
# Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com)
#
_version_ = '1.21'
#
#
# Description:
#
# Does a nmap scan, compares open ports to those given on command-line
# Reports warning for closed that should be open and error for
# open that should be closed.
# If optional ports are given, no warning is given if they are closed
# and they are included in the list of valid ports.
#
# Requirements:
# python
# nmap
#
# History
# -------
# 1.21 2004-07-23 rippeld@hillsboroughcounty.org Updated parsing of nmap output to correctly identify closed ports
# 1.20 2000-07-15 jaclu Updated params to correctly comply to plugin-standard
# moved support classes to utils.py
# 1.16 2000-07-14 jaclu made options and return codes more compatible with
# the plugin developer-guidelines
# 1.15 2000-07-14 jaclu added random string to temp-file name
# 1.14 2000-07-14 jaclu added check for error from subproc
# 1.10 2000-07-14 jaclu converted main part to class
# 1.08 2000-07-13 jaclu better param parsing
# 1.07 2000-07-13 jaclu changed nmap param to -P0
# 1.06 2000-07-13 jaclu make sure tmp file is deleted on errors
# 1.05 2000-07-12 jaclu in debug mode, show exit code
# 1.03 2000-07-12 jaclu error handling on nmap output
# 1.01 2000-07-12 jaclu added license
# 1.00 2000-07-12 jaclu implemented timeout handling
# 0.20 2000-07-10 jaclu Initial release
import sys, os, string, whrandom
import tempfile
from getopt import getopt
#
# import generic Nagios-plugin stuff
#
import utils
# Where temp files should be placed
tempfile.tempdir='/usr/local/nagios/var'
# Base name for tempfile
tempfile.template='check_nmap_tmp.'
# location and possibly params for nmap
nmap_cmd='/usr/bin/nmap -P0'
#
# the class that does all the real work in this plugin...
#
#
class CheckNmap:
# Retcodes, so we are compatible with nagios
#ERROR= -1
UNKNOWN= -1
OK= 0
WARNING= 1
CRITICAL= 2
def __init__(self,cmd_line=[]):
"""Constructor.
arguments:
cmd_line: normaly sys.argv[1:] if called as standalone program
"""
self.tmp_file=''
self.host='' # host to check
self.timeout=10
self.debug=0 # 1= show debug info
self.ports=[] # list of mandatory ports
self.opt_ports=[] # list of optional ports
self.ranges='' # port ranges for nmap
self.exit_code=0 # numerical exit-code
self.exit_msg='' # message to caller
self.ParseCmdLine(cmd_line)
def Run(self):
"""Actually run the process.
This method should be called exactly once.
"""
#
# Only call check_host if cmd line was accepted earlier
#
if self.exit_code==0:
self.CheckHost()
self.CleanUp()
return self.exit_code,self.exit_msg
def Version(self):
return 'check_nmap %s' % _version_
#-----------------------------------------
#
# class internal stuff below...
#
#-----------------------------------------
#
# Param checks
#
def param2int_list(self,s):
lst=string.split(string.replace(s,',',' '))
try:
for i in range(len(lst)):
lst[i]=int(lst[i])
except:
lst=[]
return lst
def ParseCmdLine(self,cmd_line):
try:
opt_list=getopt(cmd_line,'vH:ho:p:r:t:V',['debug','host=','help',
'optional=','port=','range=','timeout','version'])
for opt in opt_list[0]:
if opt[0]=='-v' or opt[0]=='--debug':
self.debug=1
elif opt[0]=='-H' or opt[0]=='--host':
self.host=opt[1]
elif opt[0]=='-h' or opt[0]=='--help':
doc_help()
self.exit_code=1 # request termination
break
elif opt[0]=='-o' or opt[0]=='--optional':
self.opt_ports=self.param2int_list(opt[1])
elif opt[0]=='-p' or opt[0]=='--port':
self.ports=self.param2int_list(opt[1])
elif opt[0]=='-r' or opt[0]=='--range':
r=string.replace(opt[1],':','-')
self.ranges=r
elif opt[0]=='-t' or opt[0]=='--timeout':
self.timeout=opt[1]
elif opt[0]=='-V' or opt[0]=='--version':
print self.Version()
self.exit_code=1 # request termination
break
else:
self.host=''
break
except:
# unknown param
self.host=''
if self.debug:
print 'Params:'
print '-------'
print 'host = %s' % self.host
print 'timeout = %s' % self.timeout
print 'ports = %s' % self.ports
print 'optional ports = %s' % self.opt_ports
print 'ranges = %s' % self.ranges
print
#
# a option that wishes us to terminate now has been given...
#
# This way, you can test params in debug mode and see what this
# program recognised by suplying a version param at the end of
# the cmd-line
#
if self.exit_code<>0:
sys.exit(self.UNKNOWN)
if self.host=='':
doc_syntax()
self.exit_code=self.UNKNOWN
self.exit_msg='UNKNOWN: bad params, try running without any params for syntax'
def CheckHost(self):
'Check one host using nmap.'
#
# Create a tmp file for storing nmap output
#
# The tempfile module from python 1.5.2 is stupid
# two processes runing at aprox the same time gets
# the same tempfile...
# For this reason I use a random suffix for the tmp-file
# Still not 100% safe, but reduces the risk significally
# I also inserted checks at various places, so that
# _if_ two processes in deed get the same tmp-file
# the only result is a normal error message to nagios
#
r=whrandom.whrandom()
self.tmp_file=tempfile.mktemp('.%s')%r.randint(0,100000)
if self.debug:
print 'Tmpfile is: %s'%self.tmp_file
#
# If a range is given, only run nmap on this range
#
if self.ranges<>'':
global nmap_cmd # needed, to avoid error on next line
# since we assigns to nmap_cmd :)
nmap_cmd='%s -p %s' %(nmap_cmd,self.ranges)
#
# Prepare a task
#
t=utils.Task('%s %s' %(nmap_cmd,self.host))
#
# Configure a time-out handler
#
th=utils.TimeoutHandler(t.Kill, time_to_live=self.timeout,
debug=self.debug)
#
# Fork of nmap cmd
#
t.Run(detach=0, stdout=self.tmp_file,stderr='/dev/null')
#
# Wait for completition, error or timeout
#
nmap_exit_code=t.Wait(idlefunc=th.Check, interval=1)
#
# Check for timeout
#
if th.WasTimeOut():
self.exit_code=self.CRITICAL
self.exit_msg='CRITICAL - Plugin timed out after %s seconds' % self.timeout
return
#
# Check for exit status of subprocess
# Must do this after check for timeout, since the subprocess
# also returns error if aborted.
#
if nmap_exit_code <> 0:
self.exit_code=self.UNKNOWN
self.exit_msg='nmap program failed with code %s' % nmap_exit_code
return
#
# Read output
#
try:
f = open(self.tmp_file, 'r')
output=f.readlines()
f.close()
except:
self.exit_code=self.UNKNOWN
self.exit_msg='Unable to get output from nmap'
return
#
# Store open ports in list
# scans for lines where first word contains '/'
# and stores part before '/'
#
self.active_ports=[]
try:
for l in output:
if len(l)<2:
continue
s=string.split(l)[0]
if string.find(s,'/')<1:
continue
p=string.split(s,'/')[0]
if string.find(l,'open')>1:
self.active_ports.append(int(p))
except:
# failure due to strange output...
pass
if self.debug:
print 'Ports found by nmap: ',self.active_ports
#
# Filter out optional ports, we don't check status for them...
#
try:
for p in self.opt_ports:
self.active_ports.remove(p)
if self.debug and len(self.opt_ports)>0:
print 'optional ports removed:',self.active_ports
except:
# under extreame loads the remove(p) above failed for me
# a few times, this exception hanlder handles
# this bug-alike situation...
pass
opened=self.CheckOpen()
closed=self.CheckClosed()
if opened <>'':
self.exit_code=self.CRITICAL
self.exit_msg='PORTS CRITICAL - Open:%s Closed:%s'%(opened,closed)
elif closed <>'':
self.exit_code=self.WARNING
self.exit_msg='PORTS WARNING - Closed:%s'%closed
else:
self.exit_code=self.OK
self.exit_msg='PORTS ok - Only defined ports open'
#
# Compares requested ports on with actually open ports
# returns all open that should be closed
#
def CheckOpen(self):
opened=''
for p in self.active_ports:
if p not in self.ports:
opened='%s %s' %(opened,p)
return opened
#
# Compares requested ports with actually open ports
# returns all ports that are should be open
#
def CheckClosed(self):
closed=''
for p in self.ports:
if p not in self.active_ports:
closed='%s %s' % (closed,p)
return closed
def CleanUp(self):
#
# If temp file exists, get rid of it
#
if self.tmp_file<>'' and os.path.isfile(self.tmp_file):
try:
os.remove(self.tmp_file)
except:
# temp-file colition, some other process already
# removed the same file...
pass
#
# Show numerical exits as string in debug mode
#
if self.debug:
print 'Exitcode:',self.exit_code,
if self.exit_code==self.UNKNOWN:
print 'UNKNOWN'
elif self.exit_code==self.OK:
print 'OK'
elif self.exit_code==self.WARNING:
print 'WARNING'
elif self.exit_code==self.CRITICAL:
print 'CRITICAL'
else:
print 'undefined'
#
# Check if invalid exit code
#
if self.exit_code<-1 or self.exit_code>2:
self.exit_msg=self.exit_msg+' - undefined exit code (%s)' % self.exit_code
self.exit_code=self.UNKNOWN
#
# Help texts
#
def doc_head():
print """
check_nmap plugin for Nagios
Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com)
License: GPL
Version: %s""" % _version_
def doc_syntax():
print """
Usage: check_ports [-v|--debug] [-H|--host host] [-V|--version] [-h|--help]
[-o|--optional port1,port2,port3 ...] [-r|--range range]
[-p|--port port1,port2,port3 ...] [-t|--timeout timeout]"""
def doc_help():
'Help is displayed if run without params.'
doc_head()
doc_syntax()
print """
Options:
-h = help (this screen ;-)
-v = debug mode, show some extra output
-H host = host to check (name or IP#)
-o ports = optional ports that can be open (one or more),
no warning is given if optional port is closed
-p ports = ports that should be open (one or more)
-r range = port range to feed to nmap. Example: :1024,2049,3000:7000
-t timeout = timeout in seconds, default 10
-V = Version info
This plugin attempts to verify open ports on the specified host.
If all specified ports are open, OK is returned.
If any of them are closed, WARNING is returned (except for optional ports)
If other ports are open, CRITICAL is returned
If possible, supply an IP address for the host address,
as this will bypass the DNS lookup.
"""
#
# Main
#
if __name__ == '__main__':
if len (sys.argv) < 2:
#
# No params given, show syntax and exit
#
doc_syntax()
sys.exit(-1)
nmap=CheckNmap(sys.argv[1:])
exit_code,exit_msg=nmap.Run()
#
# Give Nagios a msg and a code
#
print exit_msg
sys.exit(exit_code)

View file

@ -1,82 +0,0 @@
#!/usr/bin/perl
#
# Program check_ora_table_space
# Written by: Erwan Arzur (erwan@netvalue.com)
# License: GPL
#
# Last Modified: $Date: 2002-02-28 01:42:51 -0500 (Thu, 28 Feb 2002) $
# Revisiin: $Revision: 2 $
#
# "check_ora_table_space.pl" plugin to check the state of Oracle
# table spaces. Scarce documentation.
#
# you need DBD-Oracle-1.03.tar.gz and DBI-1.13.tar.gz from CPAN.org as
# well as some Oracle client stuff to use it.
#
# The SQL request comes from www.dbasupport.com
#
use DBI;
$ENV{"ORACLE_HOME"}="/intranet/apps/oracle";
my $host = shift || &usage ("no host specified");
my $sid = shift || &usage ("no sid specified");
my $port = shift || &usage ("no port specified");
my $dbuser = shift || &usage ("no user specified");
my $dbpass = shift || &usage ("no password specified");
my $tablespace = shift || &usage ("no table space specified");
my $alertpct = int(shift) || &usage ("no warning state percentage specified");
my $critpct = int(shift) || &usage ("no critical state percentage specified");
my $dbh = DBI->connect( "dbi:Oracle:host=$host;port=$port;sid=$sid", $dbuser, $dbpass, { PrintError => 0, AutoCommit => 1, RaiseError => 0 } )
|| &error ("cannot connect to $dbname: $DBI::errstr\n");
#$sth = $dbh->prepare(q{SELECT tablespace_name, SUM(BYTES)/1024/1024 FreeSpace FROM dba_free_space group by tablespace_name})
my $exit_code = -1;
$sth = $dbh->prepare(<<EOF
select a.TABLESPACE_NAME, a.total,nvl(b.used,0) USED,
nvl((b.used/a.total)*100,0) PCT_USED
from (select TABLESPACE_NAME, sum(bytes)/(1024*1024) total
from sys.dba_data_files group by TABLESPACE_NAME) a,
(select TABLESPACE_NAME,bytes/(1024*1024) used from sys.SM\$TS_USED) b
where a.TABLESPACE_NAME='$tablespace' and
a.TABLESPACE_NAME=b.TABLESPACE_NAME(+)
EOF
)
|| &error("Cannot prepare request : $DBI::errstr\n");
$sth->execute
|| &error("Cannot execute request : $DBI::errstr\n");
while (($tbname, $total, $used, $pct_used) = $sth->fetchrow)
{
$pct_used=int($pct_used);
print STDOUT "size: " . $total . " MB Used:" . int($used) . " MB (" . int($pct_used) . "%)\n";
#print "table space $answer\n";
if ($pct_used > $alertpct) {
if ($pct_used > $critpct) {
$exit_code = 2
} else {
$exit_code = 1;
}
} else {
$exit_code = 0;
}
}
$rc = $dbh->disconnect
|| &error ("Cannot disconnect from database : $dbh->errstr\n");
exit ($exit_code);
sub usage {
print "@_\n" if @_;
print "usage : check_ora_table_space.pl <host> <sid> <port> <user> <passwd> <tablespace> <pctwarn> <pctcrit>\n";
exit (-1);
}
sub error {
print "@_\n" if @_;
exit (2);
}

View file

@ -1,470 +0,0 @@
#!/usr/bin/perl
# $Id: check_oracle_instance.pl 10 2002-04-03 02:58:47Z sghosh $
# Copyright (c) 2002 Sven Dolderer
# some pieces of Code adopted from Adam vonNieda's oracletool.pl
# (http://www.oracletool.com)
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file,
# with the exception that it cannot be placed on a CD-ROM or similar media
# for commercial distribution without the prior approval of the author.
# This software is provided without warranty of any kind.
require 5.003;
use strict;
use Getopt::Long;
# We need the DBI and DBD-Oracle Perl modules:
require DBI || die "It appears that the DBI module is not installed! aborting...\n";
require DBD::Oracle || die "It appears that the DBD::Oracle module is not installed! aborting...\n";
use vars qw($VERSION $PROGNAME $logfile $debug $state $dbh $database $username $password $message $sql $cursor $opt_asession $opt_nsession $opt_tablespace $opt_nextents $opt_fextents $opt_aextents $privsok $warn $critical);
'$Revision: 10 $' =~ /^.*(\d+.\d+) \$$/; # Use The Revision from RCS/CVS
$VERSION = $1;
$0 =~ m!^.*/([^/]+)$!;
$PROGNAME = $1;
#$debug="true";
$logfile = "/tmp/check_oracle_instance.log";
my %ERRORS = (UNKNOWN => -1, OK => 0, WARNING => 1, CRITICAL => 2);
# Read cmdline opts:
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions (
"V|version" => \&version,
"h|help" => \&usage,
"u|user=s" => \$username,
"p|passwd=s" => \$password,
"c|connect=s" => \$database,
"a|active-sessions:s" => \$opt_asession,
"s|num-sessions:s" => \$opt_nsession,
"t|tablespaces:s" => \$opt_tablespace,
"n|num-extents:s" => \$opt_nextents,
"f|free-extents:s" => \$opt_fextents,
"x|allocate-extents" => \$opt_aextents
);
($database && $username && $password) || die "mandatory parameters missing (try -h)\n";
logit(" \$opt_asession = \"$opt_asession\"");
logit(" \$opt_nsession = \"$opt_nsession\"");
logit(" \$opt_tablespace = \"$opt_tablespace\"");
logit(" \$opt_nextents = \"$opt_nextents\"");
logit(" \$opt_fextents = \"$opt_fextents\"");
logit(" \$opt_aextents = \"$opt_aextents\"");
# so let's connect to the instance...
$dbh = dbConnect($database,$username,$password);
$message="$database: ";
check_sessions($opt_nsession) if ($opt_nsession && $privsok);
check_sessions($opt_asession,"active") if ($opt_asession && $privsok);
check_tablespaces($opt_tablespace) if ($opt_tablespace && $privsok);
check_nextents($opt_nextents) if ($opt_nextents && $privsok);
check_fextents($opt_fextents) if ($opt_fextents && $privsok);
check_aextents() if ($opt_aextents && $privsok);
$message=$message . "ok. " . getDbVersion($dbh) unless ($state);
print "$message\n";
exit $state;
sub usage {
copyright();
print "
This plugin will check various things of an oracle database instance.
Prerequisties are: a local oracle client,
perl > v5.003, and DBI and DBD::Oracle perl modules.
Usage: $PROGNAME -u <user> -p <passwd> -c <connectstring>
[-a <w>/<c>] [-s <w>/<c>] [-t <w>/<c>] [-n <w>/<c>] [-f <w>/<c>] [-x]
$PROGNAME [-V|--version]
$PROGNAME [-h|--help]
";
print "
Options:
-u, --user=STRING
the oracle user
-p, --passwd=STRING
the oracle password
-c, --connect=STRING
the oracle connectstring as defined in tnsnames.ora
-a, --active-sessions=WARN/CRITICAL
check the number of active (user-)sessions
WARN(Integer): number of sessions to result in warning status,
CRITICAL(Integer): number of sessions to result in critical status
-s, --num-sessions=WARN/CRITICAL
check the total number of (user-)sessions
WARN(Integer): number of sessions to result in warning status,
CRITICAL(Integer): number of sessions to result in critical status
-t, --tablespaces=WARN/CRITICAL
check the percent of used space in every tablespace
WARN(Integer): percentage to result in warning status,
CRITICAL(Integer): percentage to result in critical status
-n, --num-extents=WARN/CRITICAL
check the number of extents of every object (excluding SYS schema)
WARN(Integer): number of extents to result in warning status,
CRITICAL(Integer): number of extents to result in critical status
-f, --free-extents=WARN/CRITICAL
check the number of free extents of every object: max_extents - #extents
WARN(Integer): number of free extents to result in warning status,
CRITICAL(Integer): number of free extents to result in critical status
-x, --allocate-extents
warn if an object cannot allocate a next extent.
";
exit $ERRORS{"UNKNOWN"};
}
sub version {
copyright();
print "
$PROGNAME $VERSION
";
exit $ERRORS{"UNKNOWN"};
}
sub copyright {
print "The netsaint plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Copyright (c) 2002 Sven Dolderer\n";
}
sub logit {
my $text = shift;
if ($debug) {
open (LOG,">>$logfile") || die "Cannot open log file \"$logfile\"!";
print LOG "$text\n";
close (LOG);
}
}
sub dbConnect {
logit("Enter subroutine dbConnect");
my $database = shift;
my $username = shift;
my $password = shift;
# Attempt to make connection to the database..
my $data_source = "dbi:Oracle:$database";
$dbh = DBI->connect($data_source,$username,$password,{PrintError=>0});
# Show an error message for these errors.
# ORA-12224 - "The connection request could not be completed because the listener is not running."
# ORA-01034 - "Oracle was not started up."
# ORA-01090 - "Shutdown in progress - connection is not permitted""
# ORA-12154 - "The service name specified is not defined correctly in the TNSNAMES.ORA file."
# ORA-12505 - "TNS:listener could not resolve SID given in connect descriptor."
# ORA-12545 - "TNS:name lookup failure."
unless ($dbh) {
logit(" Error message is ~$DBI::errstr~");
if ( $DBI::errstr =~ /ORA-01017|ORA-1017|ORA-01004|ORA-01005/ ) {
$message="Login error: ~$DBI::errstr~";
$state=$ERRORS{"UNKNOWN"};
} elsif ( $DBI::errstr =~ /ORA-12224/ ) {
$message= "You received an ORA-12224, which usually means the listener is down, or your connection definition in your tnsnames.ora file is incorrect. Check both of these things and try again.";
$state=$ERRORS{"CRITICAL"};
} elsif ( $DBI::errstr =~ /ORA-01034/ ) {
$message= "You received an ORA-01034, which usually means the database is down. Check to be sure the database is up and try again.";
$state=$ERRORS{"CRITICAL"};
} elsif ( $DBI::errstr =~ /ORA-01090/ ) {
$message= "You received an ORA-01090, which means the database is in the process of coming down.";
$state=$ERRORS{"CRITICAL"};
} elsif ( $DBI::errstr =~ /ORA-12154/ ) {
$message= "You received an ORA-12154, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose.";
$state=$ERRORS{"UNKNOWN"};
} elsif ( $DBI::errstr =~ /ORA-12505/ ) {
$message= "You received an ORA-12505, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose, or the database you are trying to connect to is not defined to the listener that is running on that node.";
$state=$ERRORS{"UNKNOWN"};
} elsif ( $DBI::errstr =~ /ORA-12545/ ) {
$message= "You received an ORA-12545, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose. (Possibly the node name).";
$state=$ERRORS{"UNKNOWN"};
} else {
$message="Unable to connect to Oracle ($DBI::errstr)\n";
$state=$ERRORS{"UNKNOWN"};
}
} else {
logit(" Login OK.");
# check to be sure this user has "SELECT ANY TABLE" privilege.
logit(" checking for \"SELECT ANY TABLE\" privilege");
if (checkPriv("SELECT ANY TABLE") < 1) {
$message="user $username needs \"SELECT ANY TABLE\" privilege.";
$state=$ERRORS{"UNKNOWN"};
} else {
$privsok="yep";
$state=$ERRORS{"OK"};
}
}
return ($dbh);
}
sub getDbVersion {
logit("Enter subroutine getDbVersion");
my $dbh = shift;
my $oraversion;
# Find out if we are dealing with Oracle7 or Oracle8
logit(" Getting Oracle version");
$sql = "select banner from v\$version where rownum=1";
$cursor = $dbh->prepare($sql) or logit("Error: $DBI::errstr");
$cursor->execute;
(($oraversion) = $cursor->fetchrow_array);
$cursor->finish;
logit(" Oracle version = $oraversion");
return $oraversion;
}
sub checkPriv {
logit("Enter subroutine checkPriv");
my ($privilege,$yesno);
$privilege = shift;
logit(" Checking for privilege \"$privilege\"");
$sql = "SELECT COUNT(*) FROM SESSION_PRIVS WHERE PRIVILEGE = '$privilege'";
$cursor=$dbh->prepare($sql);
$cursor->execute; $yesno = $cursor->fetchrow_array;
$cursor->finish;
return($yesno);
}
sub get_values {
logit("Enter subroutine get_values");
my ($args, $inverse, $abort);
$args = shift;
$inverse = shift;
if ($args =~ m!^(\d+)/(\d+)$!) {
$warn = $1;
$critical = $2;
# TODO: check for positive numbers!
if (! $inverse && $warn >= $critical) {
print "\"$args\": warning threshold must be less than critical threshold. aborting...\n";
$abort="yep";
}
if ($inverse && $warn <= $critical) {
print "\"$args\": warning threshold must be greater than critical threshold. aborting...\n";
$abort="yep";
}
} else {
print "\"$args\": invalid warn/critical thresholds. aborting...\n";
$abort="yep";
}
exit $ERRORS{"UNKNOWN"} if $abort;
logit (" args=$args, warn=$warn, critical=$critical");
}
sub check_sessions {
logit("Enter subroutine check_sessions");
my ($args, $add, $sqladd, $count);
$args = shift;
$add = shift || '#'; # Default: Number of sessions
$sqladd = "AND STATUS = 'ACTIVE'" if ($add eq "active");
get_values($args);
$sql = "SELECT COUNT(*) FROM V\$SESSION WHERE TYPE <> 'BACKGROUND' $sqladd";
$cursor=$dbh->prepare($sql);
$cursor->execute;
$count = $cursor->fetchrow_array;
$cursor->finish;
logit (" $add sessions is $count");
if ($count >= $critical) {
$message = $message . "$add sessions critical ($count) ";
$state=$ERRORS{"CRITICAL"};
} elsif ($count >= $warn) {
$message = $message . "$add sessions warning ($count) ";
$state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
}
}
sub check_tablespaces {
logit("Enter subroutine check_tablespaces");
my ($args, $tablespace, $pctused, $mymsg, $mywarn, $mycritical);
$args = shift;
$mymsg = "Tablespace usage ";
get_values($args);
$sql = "SELECT
DF.TABLESPACE_NAME \"Tablespace name\",
NVL(ROUND((DF.BYTES-SUM(FS.BYTES))*100/DF.BYTES),100) \"Percent used\"
FROM DBA_FREE_SPACE FS,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES FROM DBA_DATA_FILES GROUP BY
TABLESPACE_NAME ) DF
WHERE FS.TABLESPACE_NAME (+) = DF.TABLESPACE_NAME
GROUP BY DF.TABLESPACE_NAME, DF.BYTES
ORDER BY 2 DESC";
$cursor=$dbh->prepare($sql);
$cursor->execute;
while (($tablespace, $pctused) = $cursor->fetchrow_array) {
logit (" $tablespace - $pctused% used");
if ($pctused >= $critical) {
unless ($mycritical) {
$mymsg = $mymsg . "critical: ";
$mycritical="yep";
}
$mymsg = $mymsg . "$tablespace ($pctused%) ";
$state=$ERRORS{"CRITICAL"};
} elsif ($pctused >= $warn) {
unless ($mywarn) {
$mymsg = $mymsg . "warning: ";
$mywarn="yep";
}
$mymsg = $mymsg . "$tablespace ($pctused%) ";
$state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
}
}
$cursor->finish;
$message = $message . $mymsg . " " if ($mycritical || $mywarn);
}
sub check_nextents {
logit("Enter subroutine check_nextents");
my ($args, $owner, $objname, $objtype, $extents, $mymsg, $mywarn, $mycritical);
$args = shift;
$mymsg = "#Extents ";
get_values($args);
$sql = "SELECT
OWNER \"Owner\",
SEGMENT_NAME \"Object name\",
SEGMENT_TYPE \"Object type\",
COUNT(*) \"Extents\"
FROM DBA_EXTENTS WHERE OWNER <> 'SYS'
GROUP BY SEGMENT_TYPE, SEGMENT_NAME, TABLESPACE_NAME, OWNER
HAVING COUNT(*) >= $warn
ORDER BY 4 DESC";
$cursor=$dbh->prepare($sql);
$cursor->execute;
while (($owner, $objname, $objtype, $extents) = $cursor->fetchrow_array) {
if ($extents >= $critical) {
unless ($mycritical) {
$mymsg = $mymsg . "critical: ";
$mycritical="yep";
}
$mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
$state=$ERRORS{"CRITICAL"};
} elsif ($extents >= $warn) {
unless ($mywarn) {
$mymsg = $mymsg . "warning: ";
$mywarn="yep";
}
$mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
$state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
}
}
$cursor->finish;
$message = $message . $mymsg . " " if ($mycritical || $mywarn);
}
sub check_fextents {
logit("Enter subroutine check_fextents");
my ($args, $owner, $objname, $objtype, $extents, $maxextents, $freextents, $mymsg, $mywarn, $mycritical);
$args = shift;
$mymsg = "Free extents ";
get_values($args, "inverse");
$sql = "SELECT
OWNER \"Owner\",
SEGMENT_NAME \"Object name\",
SEGMENT_TYPE \"Object type\",
EXTENTS \"Extents\",
MAX_EXTENTS \"Max extents\",
MAX_EXTENTS - EXTENTS \"Free extents\"
FROM DBA_SEGMENTS
WHERE (EXTENTS + $warn) >= MAX_EXTENTS
AND SEGMENT_TYPE != 'CACHE'
ORDER BY 6";
$cursor=$dbh->prepare($sql);
$cursor->execute;
while (($owner, $objname, $objtype, $extents, $maxextents, $freextents) = $cursor->fetchrow_array) {
if ($freextents <= $critical) {
unless ($mycritical) {
$mymsg = $mymsg . "critical: ";
$mycritical="yep";
}
$mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
$state=$ERRORS{"CRITICAL"};
} elsif ($freextents <= $warn) {
unless ($mywarn) {
$mymsg = $mymsg . "warning: ";
$mywarn="yep";
}
$mymsg = $mymsg . "$owner.$objname($objtype)=$extents/$maxextents ";
$state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
}
}
$cursor->finish;
$message = $message . $mymsg . " " if ($mycritical || $mywarn);
}
sub check_aextents {
logit("Enter subroutine check_aextents");
my ($args, $owner, $objname, $objtype, $tablespace_name, $mymsg, $mywarn);
my (@tablespaces);
# Get a list of all tablespaces
$sql = "SELECT TABLESPACE_NAME
FROM DBA_TABLESPACES ORDER BY TABLESPACE_NAME";
$cursor = $dbh->prepare($sql);
$cursor->execute;
while ($tablespace_name = $cursor->fetchrow_array) {
push @tablespaces, $tablespace_name;
}
$cursor->finish;
# Search every tablespace for objects which cannot allocate a next extent.
foreach $tablespace_name(@tablespaces) {
logit (" checking tablespace $tablespace_name");
$sql = "SELECT
OWNER \"Owner\",
SEGMENT_NAME \"Object name\",
SEGMENT_TYPE \"Object type\"
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME = '$tablespace_name'
AND NEXT_EXTENT > (SELECT NVL(MAX(BYTES),'0') FROM DBA_FREE_SPACE
WHERE TABLESPACE_NAME = '$tablespace_name')";
$cursor = $dbh->prepare($sql);
$cursor->execute;
while (($owner, $objname, $objtype) = $cursor->fetchrow_array) {
logit (" found: $owner.$objname($objtype)");
unless ($mywarn) {
$mymsg = $mymsg . "warning: ";
$mywarn="yep";
}
$mymsg = $mymsg . "$owner.$objname($objtype) ";
$state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
}
$cursor->finish;
}
$message = $message . $mymsg . "cannot allocate a next extent. " if $mywarn;
}

View file

@ -1,218 +0,0 @@
#!/usr/local/bin/perl -w
# (c)2004 John Koyle, RFP Depot, LLC.
# This is free software use it however you would like.
use strict;
use DBI;
use Getopt::Long 2.16;
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS);
#*******************************************************************************
# Set user configureable options here.
#
# Global Oracle info set here rather than command line to avoid output in ps -ef
# Make sure this script is mode 700 and owner of the nrpe user
#
#*******************************************************************************
my $orasid = "";
my $orauser = "";
my $orapwd = "";
if (!$ENV{ORACLE_HOME}) {
$ENV{ORACLE_HOME} = '/u01/app/oracle/product/9.2';
}
#*******************************************************************************
my $state = $ERRORS{'UNKNOWN'};
my $answer = undef;
my ($MAJOR_VERSION, $MINOR_VERSION) = q$Revision: 1134 $ =~ /(\d+)\.(\d+)/;
my $VERSION = sprintf("%d.%02d", $MAJOR_VERSION - 1, $MINOR_VERSION);
my $opt_debug; # -d|--debug
my $opt_help; # -h|--help
my $opt_version; # -V|--version
my $opt_warn_space; # -w|--warn-space
my $opt_crit_space; # -c|--crit-space
my $help = <<MARK; # help statement
check_oracle_tbs v$VERSION
Checks the tablespaces in an Oracle database for available free space.
Usage: check_oracle_tbs [-w <warn>] [-c <crit>]
-d, --debug Output debug to screen.
-h, --help Displays this help and exits.
-w, --warn-space=... Warning threshold % free (default 15)
-c, --crit-space=... Critical threshold % free (default 10)
-V, --version Output version information and exit.
MARK
## We want exact matches to the switches
Getopt::Long::config('no_auto_abbrev', 'no_ignore_case');
my $rc = GetOptions(
"debug|d" => \$opt_debug,
"help|h" => \$opt_help,
"w|warn-space=s" => \$opt_warn_space,
"c|crit-space=s" => \$opt_crit_space,
"V|version" => \$opt_version,
);
#***********************************************************************
# Process command-line switches
#***********************************************************************
if (! $rc || defined $opt_help)
{
print STDERR $help;
exit (defined $opt_help ? 0 : 1);
}
if (defined $opt_version)
{
print STDERR "check_oracle_tbs v$VERSION\n";
exit 0;
}
if (! defined $opt_warn_space)
{
if(defined $opt_debug) {
print STDOUT "Warn space not defined, using 80%\n\n";
}
$opt_warn_space = 15;
}
if (! defined $opt_crit_space)
{
if(defined $opt_debug) {
print STDOUT "Crit space not defined, using 90%\n\n";
}
$opt_crit_space = 10;
}
my $array_ref = executeSQL();
# Don't match certain tablespaces.
foreach my $row (@$array_ref) {
my ( $tbs_name, $free_mb, $tot_mb, $free_pct) = @$row;
if ($opt_debug) { print STDOUT "Output: $tbs_name\t$tot_mb\t$free_mb\t$free_pct\n\n"; }
if ($free_pct < $opt_crit_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) {
$state = $ERRORS{'CRITICAL'};
$answer .= "Critical: $tbs_name = $free_pct\% ";
last;
}
if ($free_pct < $opt_warn_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) {
$state = $ERRORS{'WARNING'};
$answer .= "Warning: $tbs_name = $free_pct\% ";
}
}
if ($state != $ERRORS{'CRITICAL'} && $state != $ERRORS{'WARNING'}) {
$state = $ERRORS{'OK'};
$answer = "All Tablespaces OK";
}
if ($opt_debug && $state != $ERRORS{'OK'}) { print STDOUT "The following tablespaces are in question: $answer\n\n"; }
foreach my $key (keys %ERRORS) {
if ($state==$ERRORS{$key}) {
print ("$key: $answer");
last;
}
}
exit $state;
#------------------SUBS-------------------------------------------------------
sub executeSQL
{
my ($dbh, $sth, $results);
$dbh = openOracle();
eval {
$dbh->{RaiseError} = 1;
$sth = $dbh->prepare(q{
select ts.tablespace_name,
trunc(sum(ts.free_b)/1024/1024) free,
trunc(sum(ts.max_b)/1024/1024) total,
trunc( sum(ts.free_b)/sum(ts.max_b)*1000) / 10 as pct_free
from
(select a.file_id,
a.tablespace_name,
decode(a.autoextensible,'YES',a.maxsize-a.bytes+b.free,'NO',b.free) free_b,
a.maxsize max_b
from (select file_id,
tablespace_name,
autoextensible,
bytes,
decode(autoextensible,'YES',maxbytes,bytes) maxsize
from dba_data_files) a,
(select file_id,
tablespace_name,
sum(bytes) free
from dba_free_space
group by file_id, tablespace_name) b
where a.file_id=b.file_id(+)) ts
group by tablespace_name
});
$sth->execute();
$results = $sth->fetchall_arrayref();
$sth->finish;
$dbh->{RaiseError} = 0;
};
if ($@) {
closeOracle($dbh);
if($opt_debug) { print STDOUT "DB Failed Query: $@\n"; }
CleanupAndExit($ERRORS{'UNKNOWN'});
}
closeOracle($dbh);
return $results;
}
#------ Open the connection to the database and return the handle
sub openOracle
{
my ($dbh);
$dbh = DBI->connect("$orasid", "$orauser", "$orapwd", "Oracle");
if (!$dbh) {
if ($opt_debug) { print "ERROR: Could not connect to Oracle!\n\n"; }
CleanupAndExit($ERRORS{'UNKNOWN'});
}
if ($opt_debug) { print "Connected to Oracle SID $orasid\n\n"; }
return $dbh;
}
#------- Close the database connection
sub closeOracle()
{
my ($dbh) = @_;
$dbh->disconnect;
}
#------ Exit with the current return code
sub CleanupAndExit
{
my ($rc) = @_;
exit($rc);
}

View file

@ -1,106 +0,0 @@
#! /usr/bin/env python
#
# Nagios client for checking Performance Co-Pilot metrics
#
#
from sys import argv,exit
import popen2, getopt, string, types
DEBUG=0
nagios_pcpclient_version = 0.01
PMVAL='/usr/bin/pmval'
COMMANDLINE=PMVAL + " -s 1"
METRIC='undefined'
CRITICAL=0
WARNING=0
def usage():
print "Usage:", argv[0], "[options]"
print "Options:"
print "\t[-H host]\tHostname to contact"
print "\t[-m metric]\tPCP metric to check"
print "\t[-i instance]\tPCP metric instance"
print "\t[-w warn]\tIssue warning alert if value is larger than this"
print "\t[-c critical]\tIssue critical alert value is larger than this"
print "\t[-V]\t\tProgram version"
print "\t[-h]\t\tThis helptext"
print ""
print "F.ex. to check 5 minute loadaverage, warn if the load is above 2,"
print "and give critical warning if it's above 10:"
print "\n\t%", argv[0], " -i 5 -m kernel.all.load -w 2 -c 10"
print ""
print "A list of all PCP metrics can be found with the command 'pminfo'."
print "A list of all instances within a metric can be found with 'pminfo -f metric'."
print "F.ex. to see all available instances of 'filesys.full' execute:"
print "\n\t% pminfo -f filesys.full"
print "\tfilesys.full"
print """\t\tinst [0 or "/dev/root"] value 45.35514044640914"""
print """\t\tinst [1 or "/dev/sda1"] value 46.74285959344712"""
print """\t\tinst [2 or "/dev/sdb1"] value 0.807766570678168"""
print ""
print "And the command to have nagios monitor the /dev/sda1 filesystem would be:"
print "\n\t", argv[0], " -i /dev/sda1 -m filesys.full -w 70 -c 90"
opts, args = getopt.getopt(argv[1:],'hH:c:w:m:i:V')
for opt in opts:
key,value = opt
if key == '-H':
COMMANDLINE = COMMANDLINE + " -h " + value
elif key == '-m':
METRIC=value
elif key == '-i':
COMMANDLINE = COMMANDLINE + " -i " + value
elif key == '-c':
CRITICAL = value
elif key == '-w':
WARNING = value
elif key == '-h':
usage()
exit(0)
elif key == '-V':
print "Nagios Performance CoPilot client v%.2f" % nagios_pcpclient_version
print "Written by Jan-Frode Myklebust <janfrode@parallab.uib.no>"
exit(0)
if METRIC == 'undefined':
usage()
exit(3)
COMMANDLINE = COMMANDLINE + " " + METRIC
if DEBUG: print COMMANDLINE
p=popen2.Popen4(COMMANDLINE)
exitcode=p.wait()
# Get the last line of output from 'pmval':
buffer = p.fromchild.readline()
while (buffer != ''):
output=buffer
buffer = p.fromchild.readline()
returndata = string.split(output)[0]
# Confirm that we have gotten a float, and not
# some errormessage in the returndata. If not,
# print the error, and give the UNKNOWN exit code:
try:
retval = string.atof(returndata)
except ValueError, e:
print e
exit(3)
if (retval < WARNING):
EXITCODE=0
elif (retval > CRITICAL):
EXITCODE=2
elif (retval > WARNING):
EXITCODE=1
else:
EXITCODE=3
print retval
exit(EXITCODE)

View file

@ -1,75 +0,0 @@
#!/usr/bin/perl
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_P $opt_H $opt_w $opt_c $PROGNAME);
use lib "/usr/local/nagios/libexec" ;
use utils qw(%ERRORS &print_revision &support &usage);
my $remote_user = "root";
my $path_to_ssh = "/usr/bin/ssh";
my $path_to_grep = "/usr/bin/grep";
my $path_to_awk = "/usr/bin/awk";
my $warn = 50000;
my $crit = 60000;
$PROGNAME = "check_pfstate";
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
"w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c);
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 1112 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {
print_help();
exit $ERRORS{'OK'};
}
if ($opt_w) {
if ($opt_w =~ /(\d+)/) {
$warn = $1;
} else {
usage("Invalid values: $opt_w\n");
exit $ERRORS{'OK'};
}
}
if ($opt_c) {
if ($opt_c =~ /(\d+)/) {
$crit = $1;
} else {
usage("Invalid values: $opt_c\n");
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");
my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`;
chomp $result;
$result =~ /(\d+)/;
$result = $1;
print "$result PF state entries\n";
exit $ERRORS{'CRITICAL'} if ($result >= $crit);
exit $ERRORS{'WARNING'} if ($result >= $warn);
exit $ERRORS{'OK'};
sub print_help {
print_revision($PROGNAME,'$Revision: 1112 $');
print "Copyright (c) 2002 Jason Dixon\n\nThis plugin checks the number of state table entries on a PF-enabled OpenBSD system.\n\n";
print "Usage:\t-H, --hostname=<HOST> [-w, --warning=<WARNING>] [-c, --critical=<CRITICAL>]\n\n\tDefault warning is 50000 and critical is 60000.\n\n";
support();
}

View file

@ -1,121 +0,0 @@
#!/usr/bin/perl
#
# check_qmailq.pl - nagios plugin
# This plugin allows you to check the number of Mails in a qmail-
# queue. PLUGIN NEEDS CONFIGURATION ! (see below)
#
# Copyright 2000 Benjamin Schmid
#
# 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.
#
#
# Emergency E-Mail :) blueshift@gmx.net
#
### CONFIGURATION SECTION ####################
my $statcommand = "/var/qmail/bin/qmail-qstat";
my $queuewarn = 5; # Warning, if more than x mail in Queue
my $queuecrit = 10; # Critical if "--"
my $prewarn = 1; # Warning, if more than x unhandled mails
# (not in Queue
my $precrit = 5; # Critical, if "--"
### CONFIURATION SECTION END ################
use strict;
use Carp;
#use Getopt::Long;
#&Getopt::Long::config('auto_abbrev');
my $TIMEOUT = 15;
my %ERRORS = ('UNKNOWN' , '-1',
'OK' , '0',
'WARNING', '1',
'CRITICAL', '2');
my $state = "UNKNOWN";
my $answer = "";
#sub usage {
# printf "\nMissing arguments!\n";
# printf "\n";
# printf "Printer Server Queue Nagios Plugin\n";
# printf "monitors jobs in lpr queues\n";
# printf "usage: \n";
# printf "check_lpq.pl \n";
# printf "Copyright (C) 2000 Benjamin Schmid\n";
# printf "check_lpq.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"};
#}
# Just in case of problems, let's not hang Nagios
$SIG{'ALRM'} = sub {
print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n");
exit $ERRORS{"UNKNOWN"};
};
alarm($TIMEOUT);
#$status = GetOptions("community=s",\$community,
# "port=i",\$port);
#if ($status == 0)
#{
# &usage;
#}
# $hostname = shift || &usage;
if (! open STAT, "$statcommand|") {
print ("$state: $statcommand returns no result!");
exit $ERRORS{$state};
}
my @lines = <STAT>;
close STAT;
# Mails in Queues
if ($lines[0]=~/^messages in queue: (\d+)/) {
my $anzq = $1;
$answer = $answer . "$anzq";
$state='WARNING' if ($anzq >= $queuewarn);
$state='CRITICAL' if ($anzq >= $queuecrit);
} else {
$state='CRITICAL';
$answer="Keine gueltigte Antwort (Zeile #1) von $statcommand\n";
}
# Unverarbeite Mails
if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
my $anzp = $1;
$answer = $answer . " E-Mail(s) nicht ausgeliefert, $anzp unverarbeitet.";
$state='WARNING' if ($anzp >= $prewarn && $state eq 'UNKNOWN');
$state='CRITICAL' if ($anzp >= $precrit);
} else {
$state='CRITICAL';
$answer=$answer . "Keine gueltigte Antwort (Zeile #2) von $statcommand\n";
}
$state = 'OK' if ($state eq 'UNKNOWN');
print ("$state: $answer\n");
exit $ERRORS{$state};

View file

@ -1,328 +0,0 @@
/******************************************************************************
*
* check_rbl.c
*
* Modified by Tim Bell <bhat@trinity.unimelb.edu.au> 2002-06-05
* based on:
*
* * check_dig.c
* *
* * Program: dig plugin for NetSaint
* * License: GPL
* * Copyright (c) 2000
* *
* * $Id: check_rbl.c 970 2004-12-02 00:30:32Z opensides $
*
*****************************************************************************/
#include "config.h"
#include "common.h"
#include "utils.h"
#include "popen.h"
#include "string.h"
const char progname = "check_rbl";
const char *revision = "$Revision: 970 $";
//const char *copyright = "2000-2003";
//const char *email = "nagiosplug-devel@lists.sourceforge.net";
int process_arguments(int, char **);
int call_getopt(int, char **);
int validate_arguments(void);
int check_disk(int usp,int free_disk);
void print_help(void);
void print_usage(void);
char *reverse_ipaddr(char *ipaddr);
char *query_address=NULL;
char *query_address_rev=NULL;
char *dns_server=NULL;
char *rbl_name=NULL;
int verbose=FALSE;
int main(int argc, char **argv){
char input_buffer[MAX_INPUT_BUFFER];
char *command_line=NULL;
char *output=NULL;
int result=STATE_OK;
/* Set signal handling and alarm */
if (signal(SIGALRM,popen_timeout_alarm_handler)==SIG_ERR)
usage("Cannot catch SIGALRM\n");
if (process_arguments(argc,argv)!=OK)
usage (_("check_rbl: could not parse arguments\n"));
/* reverse the octets in the IP address */
query_address_rev = reverse_ipaddr(query_address);
/* build the command to run */
if (dns_server) {
command_line=ssprintf(command_line,"%s @%s %s.%s",
PATH_TO_DIG,dns_server,
query_address_rev, rbl_name);
} else {
command_line=ssprintf(command_line,"%s %s.%s",
PATH_TO_DIG,
query_address_rev, rbl_name);
}
alarm(timeout_interval);
time(&start_time);
if (verbose)
printf("%s\n",command_line);
/* run the command */
child_process=spopen(command_line);
if (child_process==NULL) {
printf("Could not open pipe: %s\n",command_line);
return STATE_UNKNOWN;
}
child_stderr=fdopen(child_stderr_array[fileno(child_process)],"r");
if(child_stderr==NULL)
printf("Could not open stderr for %s\n",command_line);
output=strscpy(output,"");
while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process)) {
/* the server is responding, we just got the host name... */
if (strstr(input_buffer,";; ANSWER SECTION:")) {
/* get the host address */
if (!fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process))
break;
if (strpbrk(input_buffer,"\r\n"))
input_buffer[strcspn(input_buffer,"\r\n")] = '\0';
if (strstr(input_buffer,query_address_rev)==input_buffer) {
output=strscpy(output,input_buffer);
/* we found it, which means it's listed! */
result=STATE_CRITICAL;
} else {
strcpy(output,"Server not RBL listed.");
result=STATE_OK;
}
continue;
}
}
/*
if (result!=STATE_OK) {
strcpy(output,"No ANSWER SECTION found");
}
*/
while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_stderr)) {
/* If we get anything on STDERR, at least set warning */
result=error_set(result,STATE_WARNING);
printf("%s",input_buffer);
if (!strcmp(output,""))
strcpy(output,1+index(input_buffer,':'));
}
(void)fclose(child_stderr);
/* close the pipe */
if (spclose(child_process)) {
result=error_set(result,STATE_WARNING);
if (!strcmp(output,""))
strcpy(output,"nslookup returned an error status");
}
(void)time(&end_time);
if (result==STATE_OK)
printf("RBL check okay - not listed.\n");
else if (result==STATE_WARNING)
printf("RBL WARNING - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output);
else if (result==STATE_CRITICAL)
printf("RBL CRITICAL - %s is listed on %s\n",query_address, rbl_name);
else
printf("DNS problem - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output);
return result;
}
/* reverse the ipaddr */
char *reverse_ipaddr(char *ipaddr)
{
static char revip[MAX_HOST_ADDRESS_LENGTH];
int a, b, c, d;
if (strlen(ipaddr) >= MAX_HOST_ADDRESS_LENGTH ||
sscanf(ipaddr, "%d.%d.%d.%d", &a, &b, &c, &d) != 4) {
usage("IP address invalid or too long");
}
sprintf(revip, "%d.%d.%d.%d", d, c, b, a);
return revip;
}
/* process command-line arguments */
int process_arguments(int argc, char **argv)
{
int c;
if(argc<2)
return ERROR;
c=0;
while((c+=(call_getopt(argc-c,&argv[c])))<argc){
if (is_option(argv[c]))
continue;
if (query_address==NULL) {
if (is_host(argv[c])) {
query_address=argv[c];
} else {
usage("Invalid host name");
}
}
}
return validate_arguments();
}
int call_getopt(int argc, char **argv)
{
int c,i=0;
#ifdef HAVE_GETOPT_H
int option_index = 0;
static struct option long_options[] =
{
{"hostname", required_argument,0,'H'},
{"server", required_argument,0,'s'},
{"rblname", required_argument,0,'r'},
{"verbose", no_argument, 0,'v'},
{"version", no_argument, 0,'V'},
{"help", no_argument, 0,'h'},
{0,0,0,0}
};
#endif
while (1){
#ifdef HAVE_GETOPT_H
c = getopt_long(argc,argv,"+hVvt:s:H:r:",long_options,&option_index);
#else
c = getopt(argc,argv,"+?hVvt:s:H:r:");
#endif
i++;
if(c==-1||c==EOF||c==1)
break;
switch (c)
{
case 't':
case 'l':
case 'H':
i++;
}
switch (c)
{
case 'H': /* hostname */
if (is_host(optarg)) {
query_address=optarg;
} else {
usage("Invalid host name (-H)\n");
}
break;
case 's': /* server */
if (is_host(optarg)) {
dns_server=optarg;
} else {
usage("Invalid host name (-s)\n");
}
break;
case 'r': /* rblname */
rbl_name=optarg;
break;
case 'v': /* verbose */
verbose=TRUE;
break;
case 't': /* timeout */
if (is_intnonneg(optarg)) {
timeout_interval=atoi(optarg);
} else {
usage("Time interval must be a nonnegative integer\n");
}
break;
case 'V': /* version */
print_revision(progname,"$Revision: 970 $");
exit(STATE_OK);
case 'h': /* help */
print_help();
exit(STATE_OK);
case '?': /* help */
printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
print_usage ();
exit (STATE_UNKNOWN);
}
}
return i;
}
int validate_arguments(void)
{
if (query_address == NULL || rbl_name == NULL)
return ERROR;
else
return OK;
}
void print_help(void)
{
print_revision(progname,"$Revision: 970 $");
printf
("Copyright (c) 2000 Karl DeBisschop\n\n"
"This plugin uses dig to test whether the specified host is on any RBL lists.\n\n");
print_usage();
printf
("\nOptions:\n"
" -H, --hostname=IPADDRESS\n"
" Check status of indicated host\n"
" -s, --server=STRING or IPADDRESS\n"
" DNS server to use\n"
" -r, --rblname=STRING\n"
" RBL domain name to use (e.g. relays.ordb.org)\n"
" -t, --timeout=INTEGER\n"
" Seconds before connection attempt times out (default: %d)\n"
" -v, --verbose\n"
" Print extra information (command-line use only)\n"
" -h, --help\n"
" Print detailed help screen\n"
" -V, --version\n"
" Print version information\n\n",
DEFAULT_SOCKET_TIMEOUT);
support();
}
void print_usage(void)
{
printf
("Usage: %s -H hostip -r rblname [-s server] [-t timeout] [-v]\n"
" %s --help\n"
" %s --version\n",
progname, progname, progname);
}

View file

@ -1,666 +0,0 @@
#!/usr/bin/perl -w
# check_status.pl Nagios Plugin - Version 1.3
# Last Updated: 1/9/2003
#
# Report any bugs/questions to Russell Scibetti at russell@quadrix.com
#
# check_status Change Log:
#
# To do for 1.4
# - Better help and documentation (separate doc?)
# - Take argument (patterns to match) from a separate spec file
#
# New Addition to 1.3
# - Added ChangeLog information and updated --help output
# - hostdown (hd) argument for how a service check should respond
# when its host is Down/Unreachable
# (--hostdown="ok|warning|critical|unknown")
# - Changed name from check_state to check_status
# - Set hostdown to default to OK when the argument isn't specified
# - Number of Hosts checked is now output in OK result
#
# Version 1.2 additions:
#
# - Added ability to handle ack'd and downtimed services differently
# depending on argument provided
# (--ack="ok|warning|critical|unknown|down|unreachable"
# --dt="ok|warning|critical|unknown|down|unreachable")
#
# Version 1.1 additions:
#
# - Added --host=<regex>, --servhost=<regex> to allow for specific field
# matching (host for matching hostname in host checks, servhost for
# matching the hostname in service checks, service for matching the
# service name in service checks)
# - Output the number of OK services for an OK output
#
# Version 1.0 features:
#
# - Freshness check of status.log (timestamp)
# - Match service or host checks
# - Can ignore acknowledged or downtimes services/hosts (--ack, --dt)
# - Can output different levels of detail dependent on # of problems
# - Can check for number of critical, warning, or unknowns
#
#############################################################
use Getopt::Long;
use File::stat;
Getopt::Long::Configure('bundling');
GetOptions
("V" => \$version, "version" => \$version,
"h" => \$help, "help" => \$help,
"v" => \$verbose, "verbose" => \$verbose,
"w=s" => \$warning, "warning=s" => \$warning,
"c=s" => \$critical, "critical=s" => \$critical,
"u=s" => \$unknown, "unknown=s" => \$unknown,
"p=s" => \$pattern, "pattern=s" => \$pattern,
"S:s" => \$service, "service:s" => \$service,
"s=s" => \$status, "status=s" => \$status,
"d=s" => \$dir, "dir=s" => \$dir,
"D=s" => \$details, "details=s" => \$details,
"H:s" => \$host, "host:s" => \$host,
"f=s" => \$freshness, "freshness=s" => \$freshness,
"servhost=s" => \$servhost,
"a:s" => \$ack, "ack:s" => \$ack,
"dt:s"=> \$dt, "downtime:s" => \$dt,
"hd:s"=> \$hdown, "hostdown:s" => \$hdown,
"ok" => \$ok);
#Constants:
my $OK = 0;
my $WARNING = 1;
my $CRITICAL = 2;
my $UNKNOWN = 3;
my $crit="CRITICAL";
my $warn="WARNING";
my $unk="UNKNOWN";
my $down="DOWN";
my $unreach="UNREACHABLE";
# Print out Help information
if ($help) {
printVersion();
printHelp();
exitcheck($UNKNOWN);
}
# Print out version information
if ($version) {
printVersion();
exitcheck($UNKNOWN);
}
# Check for status log or directory argument or print usage
if (!$status) {
if (!$dir) {
print "Usage: $0 -s <status file> | -d <Nagios log dir>\n";
print "Use the --help option for full list of arguments\n";
exitcheck($UNKNOWN);
}
elsif ($dir =~ m#[^/]/$#) {
$status = $dir . "status.log";
}
else {
$status = $dir . "/status.log";
}
}
if (defined $host) {
if (!$host) {
$host="[^\\s]*";
}
}
if (!$host && !$servhost) {
$servhost="[^\\s]*";
}
if (!$host && !$service) {
$service="[^\\s]*";
}
if (defined $ack) {
if (!$ack) {
$ack="ok";
}
elsif (!($ack =~ "ok|critical|warning|unknown|down|unreachable")) {
print "Invalid value for ack\n";
exitcheck($UNKNOWN);
}
}
if (defined $dt) {
if (!$dt) {
$dt="ok";
}
elsif (!($dt =~ "ok|critical|warning|unknown|down|unreachable")) {
print "Invalid value for dt\n";
exitcheck($UNKNOWN);
}
}
if (defined $hdown) {
if (!$hdown) {
$hdown="ok";
}
elsif (!($hdown =~ "ok|critical|warning|unknown|down|unreachable")) {
print "Invalid value for hostdown\n";
exitcheck($UNKNOWN);
}
}
my $much_details = 0;
my $ServiceNotOK = "CRITICAL|WARNING|UNKNOWN";
my $HostNotOK = "DOWN|UNREACHABLE";
my %numprob = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
my $CritOnly = 0;
my $WarnOnly = 0;
my $UnkOnly = 0;
my @wlev;
my @clev;
my @ulev;
my %warnlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
my %critlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
my %unklevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
my %hostlevel = ("DOWN",0,"UNREACHABLE",0);
# Store Hosts in downtime
my @hostdowntime;
my $numdowntime = 0;
# Store Hosts in a Down/Unreachable state
my @hostdown;
my $numdown = 0;
# Hash for storing state-change to OK times for hosts:
my %hostoktimes;
# Number of matches in parsing
my $nummatch = 0;
if ($warning) {
if ($warning =~ /,/) {
@wlev = split /,/,$warning;
$warnlevel{"WARNING"} = $wlev[0];
$warnlevel{"CRITICAL"} = $wlev[1];
if ($wlev[2] ) {
$warnlevel{"UNKNOWN"} = $wlev[2];
}
}
else {
$WarnOnly = $warning;
}
}
else {
$WarnOnly = 1;
}
if ($critical) {
if ($critical =~ /,/) {
@clev = split /,/,$critical;
$critlevel{"WARNING"} = $clev[0];
$critlevel{"CRITICAL"} = $clev[1];
if ($clev[2] ) {
$critlevel{"UNKNOWN"} = $clev[2];
}
}
else {
$CritOnly = $critical;
}
}
else {
$CritOnly = 1;
}
if ($unknown) {
if ($unknown =~ /,/) {
@ulev = split /,/,$unknown;
$unklevel{"WARNING"} = $ulev[0];
$unklevel{"CRITICAL"} = $ulev[1];
if ($ulev[2] ) {
$unklevel{"UNKNOWN"} = $ulev[2];
}
}
else {
$UnkOnly = $unknown;
}
}
else {
$UnkOnly = 1;
}
if (!$freshness) {
$freshness = 30 * 60;
}
else {
$freshness = $freshness * 60;
}
my %ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
my %much_ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
my %output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE","");
my %much_output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE","");
if ($details) {
if ($details =~ /,/) {
my @tempv = split /,/,$details;
$much_details = $tempv[0];
$details = $tempv[1];
}
}
open("sta","$status") || die "Cannot open status file $status!";
$curr_time = time;
$file_time = stat($status)->mtime;
if ($curr_time - $file_time > $freshness) {
printf "State CRITICAL - Status file is stale!!!\n";
exitcheck($CRITICAL);
}
while(<sta>) {
chomp;
if (/^[^\s]+[\s]+HOST;/) {
@hdata = split /;/,$_;
# If you care about matching hosts (not services):
if ($host && $hdata[1] =~ /$host/) {
$nummatch++;
if ( $hdata[2] =~ /$HostNotOK/ ) {
addproblem($_,$hdata[2]);
}
}
# If you are matching services, gather host information:
else {
if ( $hdata[2] =~ /$HostNotOK/ ) {
$hostdown[$numdown] = $hdata[1];
$numdown++;
}
else {
$hostoktimes{$hdata[1]} = $hdata[4];
}
if ( $hdata[17] ne "0" ) {
$hostdowntime[$numdowntime] = $hdata[1];
$numdowntime++;
}
}
}
elsif (!$host && /^[^\s]+[\s]+SERVICE;/) {
@servdata = split /;/,$_;
if ( ( $pattern && ($_ =~ /$pattern/)) ||
(($servdata[1] =~ /$servhost/) && ($servdata[2] =~ /$service/)) ){
$nummatch++;
if (($servdata[5] eq "HARD") && ($servdata[3] =~ /$ServiceNotOK/)) {
addproblem($_,$servdata[3]);
}
}
}
}
close("sta");
if ($nummatch==0) {
print "Nothing Matches your criteria!\n";
exitcheck($UNKNOWN);
}
# Count the number of problems (for reference):
if ($host) {
$total = $numprob{"DOWN"} + $numprob{"UNREACHABLE"};
}
else {
$total = $numprob{"WARNING"} + $numprob{"CRITICAL"} + $numprob{"UNKNOWN"};
}
my $numok = $nummatch - $total;
# If this is a host state check:
if ($host) {
if ($numprob{"DOWN"}>0 || $numprob{"UNREACHABLE"}>0 ) {
if ($details && ($total <= $details)) {
print "State CRITICAL - $total Host Problems: $output{$down} $output{$unreach}\n";
exitcheck($CRITICAL);
}
else {
print "State CRITICAL - $numprob{$down} Hosts Down, $numprob{$unreach} Hosts Unreachable\n";
exitcheck($CRITICAL);
}
}
else {
print "State OK - $numok Hosts Up, $total Problems\n";
exitcheck($OK);
}
}
#If you only defined a Critical level in terms of # of criticals...
elsif ($CritOnly && ($numprob{"CRITICAL"} >= $CritOnly)) {
countAndPrint($crit,$numprob{$crit},0);
exitcheck($CRITICAL);
}
#Critical in terms on # criticals and # warnings...
elsif (!$CritOnly && ($numprob{"WARNING"} >= $critlevel{"WARNING"} ||
$numprob{"CRITICAL"} >= $critlevel{"CRITICAL"} ||
$numprob{"UNKNOWN"} >= $critlevel{"UNKNOWN"} )) {
countAndPrint($crit,$total,1);
exitcheck($CRITICAL);
}
#Warning in terms of # warnings only...
elsif ($WarnOnly && ($numprob{"WARNING"} >= $WarnOnly)) {
countAndPrint($warn,$numprob{$warn},0);
exitcheck($WARNING);
}
#Warning in terms of # warnings and # criticals...
elsif (!$WarnOnly && ($numprob{"WARNING"} >= $warnlevel{"WARNING"} ||
$numprob{"CRITICAL"} >= $warnlevel{"CRITICAL"} ||
$numprob{"UNKNOWN"} >= $warnlevel{"UNKNOWN"})) {
countAndPrint($warn,$total,1);
exitcheck($WARNING);
}
#Unknown in terms on # unknown only...
elsif ( $UnkOnly && ($numprob{"UNKNOWN"}>=$UnkOnly) ) {
countAndPrint($unk,$numprob{$unk},0);
exitcheck($UNKNOWN);
}
#Unknown in terms of # warning, critical, and unknown...
elsif (!$UnkOnly && ($numprob{"WARNING"} >= $unklevel{"WARNING"} ||
$numprob{"CRITICAL"} >= $unklevel{"CRITICAL"} ||
$numprob{"UNKNOWN"} >= $unklevel{"UNKNOWN"})) {
countAndPrint($unk,$total,1);
exitcheck($UNKNOWN);
}
# Everything is OK!
else {
print "State OK - $numok OK, $total problems\n";
exitcheck($OK);
}
############################
# Subroutines
############################
# Return the proper exit code for Critical, Warning, Unknown, or OK
sub exitcheck {
if ($ok) {
exit 0;
}
else {
exit $_[0];
}
}
# Decide what to print for services:
sub countAndPrint {
my $state = $_[0];
my $count = $_[1];
my $alltypes = $_[2];
my $output = "State $state - ";
if ($details) {
if ($count<=$much_details) {
if ($alltypes) {
$output .= "$count problems: $much_output{$crit} $much_output{$warn} $much_output{$unk}";
}
else {
$output .= "$count \L$state\E: $much_output{$state}";
}
}
elsif ($count<=$details) {
if ($alltypes) {
$output .= "$count problems: $output{$crit} $output{$warn} $output{$unk}";
}
else {
$output .= "$count \L$state\E: $output{$state}";
}
}
else {
if ($alltypes) {
$output .= "$numprob{$crit} critical, $numprob{$warn} warning, $numprob{$unk} unknown";
}
else {
$output .= "$count \L$state\E";
}
}
}
else {
$output .= "$count problems";
}
print "$output\n";
}
# Add-in the problem found in the status log
sub addproblem {
$test = 1;
$type = $_[1];
my $diffout = "";
my @values = split /;/,$_[0];
if (!$host) {
my $namehold = $values[1];
if ($ack && ($values[13] eq "1")) {
if ($ack =~ "ok") {
$test = 0;
}
else {
$type = "\U$ack";
}
}
elsif ($hdown && grep /$namehold/, @hostdown) {
if ($hdown =~ "ok") {
$test = 0;
}
else {
$type = "\U$hdown";
$diffout = "$values[1] is down";
}
}
elsif ($dt && (($values[27] ne "0") || (grep /$namehold/, @hostdowntime))){
if ($dt =~ "ok") {
$test = 0;
}
else {
$type = "\U$dt";
}
}
elsif (exists $hostoktimes{$namehold}) {
# If the state change time of the host is more recent than the last
# service check, must wait until the next service check runs!
if ($hostoktimes{$namehold} > $values[6]) {
$test = 0;
}
}
}
else {
if ($ack && $values[5]) {
if ($ack =~ "ok") {
$test = 0;
}
else {
$type = "\U$ack";
}
}
elsif ($dt && ($values[17] ne "0")) {
if ($dt =~ "ok") {
$test = 0;
}
else {
$type = "\U$dt";
}
}
}
if ($details && $test) {
if (!$host) {
if ($diffout) {
$much_output{$type} .= " $diffout;";
$output{$type} .= "$diffout;";
$much_ct{$type}++;
$ct{$type}++;
}
else {
if ($much_details && $much_ct{$type}<$much_details) {
$much_output{$type} .= " $values[2] on $values[1] $values[31];";
$much_ct{$type}++;
}
if ($ct{$type} < $details) {
$output{$type} .= " $values[2] on $values[1];";
$ct{$type}++;
}
}
}
else {
$much_output{$type} .= " $values[1] $_[1] $values[20],";
$much_ct{type}++;
$output{$type} .= " $values[1] HOST $_[1],";
$ct{$type}++;
}
}
if ($test) {
$numprob{$type}++;
}
}
################################
#
# Version and Help Information
#
################################
sub printVersion {
printf <<EndVersion;
$0 (nagios-plugins) 1.3
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
EndVersion
}
sub printHelp {
printf <<EOF;
This plugin parses through the Nagios status log and will return a
Critical, Warning, or Unknown state depending on the number of
Critical, Warning, and/or Unknown services found in the log
(or Down/Unreachable hosts when matching against hosts)
Usage: $0 -s <Status File> | -d <Nagios Log Directory>
[-w #[,#][,#]] [-c #[,#][,#]] [-u #[,#][,#]]
[--service=<RegEx> | --servhost=<RegEx> | --pattern=<RegEx> |
--host | --host=<RegEx>]
[--ack[=string]] [--dt[=string]] [--hostdown[=string]]
[-D #[,#]] [--ok] [-f <Log freshness in # minutes>]
$0 --help
$0 --version
NOTE: One of -s and -d must be specified
Options:
-s, --status=FILE_NAME
Location and name of status log (e.g. /usr/local/nagios/var/status.log)
-d, --dir=DIRECTORY_NAME
Directory that contains the nagios logs (e.g. /usr/local/nagios/var/)
-w, --warning=INTEGER[,INTEGER][,INTEGER]
#: Number of warnings to result in a WARNING state
OR
#,#: Warning,Criticals to result in a WARNING state
OR
#,#,#: Warning,Critical,Unknown to result in a WARNING state
Default: -w=1
-c, --critical=INTEGER[,INTEGER][,INTEGER]
#: Number of criticals to result in a CRITICAL state
OR
#,#: Warning,Criticals to result in a CRITICAL state
OR
#,#,#: Warning,Critical,Unknown to result in a CRITICAL state
Default: -c=1
-u, --unknown=INTEGER[,INTEGER][,INTEGER]
#: Number of unknowns to result in a UNKNOWN state
OR
#,#: Warning,Criticals to result in a UNKNOWN state
OR
#,#,#: Warning,Critical,Unknown to result in a UNKNOWN state
Default: -u=1
-r, --service[=REGEX]
Only match services [that match the RegEx]
(--service is default setting if no other matching arguments provided)
--servhost=REGEX
Only match services whose host match the RegEx
-p, --pattern=REGEX
Only parse for this regular expression (services only, not hosts)
--host[=REGEX]
Report on the state of hosts (whose name matches the RegEx if provided)
-a, --ack[=ok|warning|critical|unknown|down|unreachable]
Handle Acknowledged problems [--ack defaults to ok]
--dt, --downtime[=ok|warning|critical|unknown|down|unreachable]
Handle problems in scheduled downtime [--dt defaults to ok]
--hd, --hostdown[=ok|warning|critical|unknown|down|unreachable]
Handle services whose Host is down [--hd defaults to ok]
-D, --details=INTEGER[,INTEGER]
Amount of verbosity to output
If # problems:
<= 1st integer, return full details (each plugin's output)
<= 2nd integer, return some details (list each service host pair)
> 2nd integer, return the # of problems
-f, --freshness=INTEGER
Number of minutes old the log can be to make sure Nagios is running
(Default = 30 minutes)
--ok
Return an OK exit code, regardless of number of problems found
-h, --help
Print detailed help screen
-V, --version
Print version information
For service checking (use --service and/or --servhost):
1. The values of warning, critical, and unknown default to 1, i.e.
$0 will return CRITICAL if there is at least 1 critical service,
WARNING if there is at least 1 warning service, and UNKNOWN if there is
at least one unknown service.
2. If a service's host is DOWN or UNREACHABLE, $0 will use the
value of --hostdown to determine how to treat the service. Without that
argument, $0 will count the service as OK.
3. If a service's host is OK, but the last host-state change occurred more
recently than the last service check, $0 will ignore that service
(want to wait until the service has been checked after a host has recovered
or you may get service alert for services that still need to be checked)
4. If the --dt, --ack, or --hd tags are used, $0 will use the value
of the arguments to determine how to handle services in downtime, acknowledged,
or with down hosts (default=OK). For service checks, --dt will also check
if the service's host is in a downtime.
For host checking (use --host):
1. Using the --host argument, $0 will look for DOWN and UNREACHABLE
hosts. If any are found, $0 will return a CRITICAL. You can provide
an REGEX for --host to only check hosts with matching host names.
2. If the --dt or --ack tags are used, $0 will use the value of the
--dt/--ack arguments to determine the state of the host (default is OK)
EOF
}

View file

@ -1,129 +0,0 @@
#!/usr/bin/perl -wT
# check_rrd_data plugin for nagios
#
# usage:
# check_rrd machine_id perlexp_warn perlexp_crit perlexp_default [ds]
#
# Checks data from a RRD file. machine_id is normally an IP address, that has
# to be mapped to a RRD file, by means of the config file (by default
# /var/spool/nagios/rrd-files, a file with pairs of (machine_id,rrd_file),
# separated by whitespace). It can be a RRD file, too.
#
# The Perl expressions are expressions to be evaluated in the following cases:
#
# - perlexp_crit. The first one, to check if there is a critical situation. If
# it returns other than "", it will be a critical message.
# - perlexp_warn. The second one to be evaluated. If returns other than "", a
# warning will be issued to Nagios.
# - perlexp_default. If both of the above return "", it will be evaluated, and
# wathever returns this expression will be returned by the script. NOTE that
# this is different from the other two cases, to allow the user issue a
# warning or critical failure even if the other two don't return it.
#
# Use these hosts.cfg entries as examples
#
# command[check_ping]=$USER1$/check_rrd_data.pl $HOSTADDRESS$ \
# 'return "CHECK_CRICKET_PING: Warning\n" if ($value > 10);' 'return \
# "CHECK_CRICKET_PING: Critical\n" if ($value > 100);' 'printf \
# "PING OK - RTA = %.2fms\n", $value; return 0;' 1
# service[machine]=PING;0;24x7;3;5;1;router-admins;240;24x7;1;1;1;;check_ping
#
# initial version: 28 Nov 2000 by Esteban Manchado Velázquez
# current status: 0.1
#
# Copyright Notice: GPL
#
# Doesn't work! Why?
# BEGIN {
# my $runtimedir = substr($0,0,rindex($0,'/'));
# require "$runtimedir/utils.pm";
# }
require '/usr/libexec/nagios/plugins/utils.pm';
use RRD::File;
# use strict; # RRD:File and utils.pm don't like this
my $configfilepath = "/var/spool/nagios/rrd-files"; # Change if needed
my %hostfile; # For storing config
my $rrdfile; # RRD file to open
$ENV{'PATH'} = "/bin:/usr/bin";
$ENV{'ENV'} = "";
if (scalar @ARGV != 4 && scalar @ARGV != 5) {
print STDERR join "' '", @ARGV, "\n";
my $foo = 'check_rrd_data';
print STDERR $foo, " <file.rrd> <perl_exp_warn> <perl_exp_crit> <perl_exp_default> [<ds>]\n\n";
print STDERR "<perl_exp_*> is an expression that gets evaluated with \$_ at the current\n";
print STDERR "value of the data source. If it returns something other than \"\", there\n";
print STDERR "will be a warning or a critical failure. Else, the expression\n";
print STDERR "<perl_exp_default> will be evaluated\n";
exit;
}
# Check configuration file
open F, $configfilepath or do {
print "Can't open config file $configfilepath\n";
return $ERRORS{'UNKNOWN'};
};
while (<F>) {
next unless /(.+)\s+(.+)/;
$hostfile{$1} = $2;
}
close F;
# Default
my $ds = defined $ARGV[4]?$ARGV[4]:0;
# print "\$ds = " . $ds . ":";
# print "\$ARGV[4] = " . $ARGV[4] . ":";
$ds =~ s/\$//g; # Sometimes Nagios gives 1$ as the last parameter
# Guess which RRD file have to be opened
$rrdfile = $ARGV[0] if (-r $ARGV[0]); # First the parameter
$rrdfile = $hostfile{$ARGV[0]} unless $rrdfile; # Second, the config file
# print "$ARGV[0]:";
if (! $rrdfile) {
print "Can't open data file for $ARGV[0]\n"; # Aaaargh!
return $ERRORS{'UNKNOWN'}; # Unknown
}
# print "Opening file $rrdfile:";
my $rrd = new RRD::File ( -file => $rrdfile );
$rrd->open();
if (! $rrd->loadHeader()) {
print "Couldn't read header from $rrdfile\n";
exit $ERRORS{'UNKNOWN'}; # Unknown
}
my $value = $rrd->getDSCurrentValue($ds);
$rrd->close();
# Perl expressions to evaluate
my ($perl_exp_warn, $perl_exp_crit, $perl_exp_default) =
($ARGV[1], $ARGV[2], $ARGV[3]);
my $result; # Result of the expressions (will be printed)
my @data; # Special data reserved for the expressions, to pass data
# First check for critical errors
$perl_exp_crit =~ /(.*)/;
$perl_exp_crit = $1;
$result = eval $perl_exp_crit;
if ($result) {
print $result;
exit 2; # Critical
}
# Check for warnings
$perl_exp_warn =~ /(.*)/;
$perl_exp_warn = $1;
$result = eval $perl_exp_warn;
if ($result) {
print $result;
exit 1; # Warning
}
$perl_exp_default =~ /(.*)/;
$perl_exp_default = $1;
eval $perl_exp_default; # Normally returns 0 (OK)

View file

@ -1,89 +0,0 @@
#!/bin/sh
################################################################################
#
# CHECK_SAP plugin for Nagios
#
# Originally Written by Karel Salavec (karel.salavec@ct.cz)
#
# Last Modified: 26 May 2003 by Tom De Blende (tom.deblende@village.uunet.be)
#
# Version 1.1 (Tom De Blende)
# - Added output to feed to Nagios instead of just an exit code.
# - Changed info on where to get the SAP client tools for Linux.
#
# Version 1.0 (Karel Salavec)
#
# Command line: check_sap.sh <typ_of_check> <param1> <param2> [<param3>]
#
# Description:
# This plugin will attempt to open an SAP connection with the message
# server or application server.
# It need the sapinfo program installed on your server (see Notes).
#
# Notes:
# - This plugin requires that the sapinfo program is installed.
# - Sapinfo is part of a client package that can be found
# at ftp://ftp.sap.com/pub/linuxlab/contrib/.
#
#
# Parameters:
# $1 - type of checking - valid values: "ms" = message server
# "as" = application server
# $2 - SAP server identification - can be IP address, DNS name or SAP
# connect string (for example: /H/saprouter/S/sapdp01/H/sapserv3)
# $3 - for $1="ms" - SAP system name (for example: DEV, TST, ... )
# for $1="as" - SAP system number - note: central instance have sysnr=00
# $4 - valid only for $1="ms" - logon group name - default: PUBLIC
#
# Example of command definitions for nagios:
#
# command[check_sap_ms]=/usr/local/nagios/libexec/check_sap ms $HOSTADDRESS$ $ARG1$ $ARG2$
# command[check_sap_as]=/usr/local/nagios/libexec/check_sap as $HOSTADDRESS$ $ARG1$
# command[check_sap_ex]=/usr/local/nagios/libexec/check_sap as $ARG1$ $ARG2$
# (for ARG1 see SAP OOS1 transaction)
#
##############################################################################
sapinfocmd='/usr/sap/rfcsdk/bin/sapinfo'
grepcmd=`which grep`
wccmd=`which wc`
cutcmd=`which cut`
awkcmd=`which awk`
##############################################################################
if [ $# -lt 3 ]; then
echo "Usage: $0 <typ_of_check> <param1> <param2> [<param3>]"
exit 2
fi
case "$1"
in
ms)
if [ $4 ]
then
params="r3name=$3 mshost=$2 group=$4"
else
params="r3name=$3 mshost=$2"
fi
;;
as)
params="ashost=$2 sysnr=$3"
;;
*)
echo "The first parameter must be ms (message server) or as (application server)!"
exit 2
;;
esac
output="$($sapinfocmd $params)"
error="$(echo "$output" | $grepcmd ERROR | $wccmd -l)"
if [ "$error" -gt "0" ]; then
output="$(echo "$output" | $grepcmd Key | $cutcmd -dy -f2)"
echo "CRITICAL - SAP server not ready: " $output.
exit 2
else
output="$(echo "$output" | $grepcmd Destination | $awkcmd '{ print $2 }')"
echo "OK - SAP server $output available."
exit 0
fi

View file

@ -1,180 +0,0 @@
#!/usr/bin/perl -w
# chec_smart
# Check S.M.A.R.T. enabled disks status.
#
# This uses smartmontools to check for disk status.
# This is NOT compatible with smartsuite
# Please use smartctl --smart=on --offlineauto=on --saveauto=on /dev/something
# or similar to enable automatic data collection, and RTFM about it.
#
# this uses sudo to access the smartctl program, so please add a line in sudoers
# nagios computername = NOPASSWD:/usr/sbin/smartctl
#
# CopyLeft Roy Sigurd Karlsbakk <roy@karlsbakk.net>
# Developed under Debian/SID
# No warranties what so ever. If this toasts your PC, or your wife
# runs away with your girlfriend, or even me, don't blame me.
#
# Licenced under GPL
#
use strict;
use Getopt::Long;
my (
$s, $i, $out, $retcode, $errtxt, $exitcode,
$device, $text_mode, $exitcode_mode, $help, $verbose, $type,
);
my $smartctl = "sudo /usr/sbin/smartctl";
my $e_commandline = 0;
my $e_devopen = 0;
my $e_chksum = 0;
my $e_disk_failing = 0;
my $e_prefail = 0;
my $e_mayprefail = 0;
my $e_errlog = 0;
my $e_selftestlog = 0;
sub end {
$s = shift;
$i = shift;
if ($i == 0) {
$s = "OK: $s";
} elsif ($i == 1) {
$s = "WARNNG: $s";
} elsif ($i == 2) {
$s = "CRITICAL: $s";
} elsif ($i == 3) {
$s = "UNKNOWN: $s";
} else {
$s = "OUT OF RANGE: $s";
}
print "$s\n";
exit($i);
}
sub syntax {
$s = shift or $s = 'Unknown';
printf STDERR ("Error: $s\n") unless ($help);
printf STDERR ("Syntax: %s (-t|-e) -d <device> [-vh]\n", $0);
printf STDERR (" --text-mode -t check by parsing smartctl's output\n");
printf STDERR (" --exitcode-mode -e check smartctl's exitcode (only works on IDE)\n");
printf STDERR (" --device -d disk device to check\n");
printf STDERR (" --type -T drive type. See the -d flag in the smartctl manual\n");
printf STDERR (" --verbose -v verbose\n");
printf STDERR (" --help -h this help\n");
exit(0) if $help;
exit(3);
}
Getopt::Long::Configure('bundling');
GetOptions(
"d=s" => \$device, "device=s" => \$device,
"T=s" => \$type, "type=s" => \$type,
"t" => \$text_mode, "text-mode" => \$text_mode,
"e" => \$exitcode_mode, "exitcode-mode" => \$exitcode_mode,
"h" => \$help, "help" => \$help,
"v" => \$verbose, "verbose" => \$verbose
) || syntax("RTFM!");
syntax if ($help);
syntax("Need device to check") unless ($device);
syntax("Conflicting modes") if ($text_mode && $exitcode_mode);
syntax("Need test mode") unless ($text_mode || $exitcode_mode);
syntax("Exitcode mode only works on ATA drives") if ($exitcode_mode && ! ($device =~ /\/dev\/hd./));
if ($type) {
$type =~ s/[\r\n]*?//g;
print "type: '$type'\n" if ($verbose);
syntax("Valid --type entries include ata, scsi and 3ware,n")
unless (($type =~ /^ata$/) || ($type =~ /^scsi$/) || ($type =~ /^3ware,\d+$/));
}
if (defined($type)) {
$type = "--device=$type";
} else {
$type = "";
}
if ($text_mode) {
print "running $smartctl $type -H $device" if ($verbose);
unless (open SMARTCTL,"$smartctl $type -H $device|") {
print STDERR "Can't execute $smartctl: $!\n";
exit(3);
}
while (<SMARTCTL>) {
last if (/=== START OF READ SMART DATA SECTION ===/);
}
$out = <SMARTCTL>;
print $out;
exit(0) if ($out =~ /PASSED/);
exit(2) if ($out =~ /SAVE ALL DATA/ || $out =~ /FAILED/);
exit(3);
} elsif ($exitcode_mode) {
print "Running $smartctl $type -q silent $device\n" if ($verbose);
system("$smartctl $type -q silent $device");
$retcode = $?;
$e_commandline = 1 if ($retcode & 0x0100);
$e_devopen = 1 if ($retcode & 0x0200);
$e_chksum = 1 if ($retcode & 0x0400);
$e_disk_failing = 1 if ($retcode & 0x0800);
$e_prefail = 1 if ($retcode & 0x1000);
$e_mayprefail = 1 if ($retcode & 0x2000);
$e_errlog = 1 if ($retcode & 0x4000);
$e_selftestlog = 1 if ($retcode & 0x8000);
print "$e_commandline $e_devopen $e_chksum $e_disk_failing $e_prefail $e_mayprefail $e_errlog $e_selftestlog\n"
if ($verbose);
$exitcode = 0;
$errtxt = "";
if ($exitcode) {
if ($e_commandline) {
$errtxt .= "Commandline didn't parse, ";
$exitcode = 3 if ($exitcode == 0);
}
if ($e_devopen) {
$errtxt .= "Device could not be opened, ";
$exitcode = 3 if ($exitcode == 0);
}
if ($e_chksum) {
$errtxt .= "Checksum failure somewhere, ";
$exitcode = 1 if ($exitcode != 2);
}
if ($e_disk_failing) {
$errtxt .= "Disk is failing!, ";
$exitcode = 2;
}
if ($e_prefail) {
$errtxt .= "Disk is in prefail, ";
$exitcode = 1 if ($exitcode != 2);
}
if ($e_mayprefail) {
$errtxt .= "Disk is close to prefail. Please check manually, ";
$exitcode = 1 if ($exitcode != 2);
}
if ($e_errlog) {
$errtxt .= "The device error log contains records of errors, ";
$exitcode = 1 if ($exitcode != 2);
}
if ($e_selftestlog) {
$errtxt .= "The device self-test log contains records of errors, ";
$exitcode = 1 if ($exitcode != 2);
}
if ($exitcode == 1) {
$errtxt = "WARNNG: $errtxt";
} elsif ($exitcode == 2) {
$errtxt = "CRITICAL: $errtxt";
} else {
$errtxt = "UNKNOWN: $errtxt";
}
} else {
$errtxt = "OK";
}
print "$errtxt\n";
exit($exitcode);
} else {
print STDERR "Something's strange is going on :~|\n";
exit(3);
}
# vim:ts=4:sw=4:cindent

View file

@ -1,111 +0,0 @@
#!/bin/bash
#
# Program : check_smb
# :
# Author : Cal Evans <cal@calevans.com>
# :
# Purpose : Nagios plugin to return the number of users logged into a smb
# : server and the number of files open.
# :
# Parameters : --help
# : --version
# :
# Returns : Standard Nagios status_* codes as defined in utils.sh
# :
# Notes :
#============:==============================================================
# 1.0 : 06/27/2002
# : Initial coding
# :
# 1.1 : 06/28/2002
# : Re-wrote the user counter to match the file-lock counter.
# :
#
# Shamelessly stolen from other Nagios plugins.
#
PROGNAME=`basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 71 $' | sed -e 's/[^0-9.]//g'`
. $PROGPATH/utils.sh
print_usage() {
echo "Usage: $PROGNAME --help"
echo "Usage: $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "Samba status check."
echo ""
support
}
# No command line arguments are required for this script. We accept only 2,
# --help and --version. If more than 1 is passed in then we have an error
# condition.
if [ $# -gt 1 ]; then
print_usage
exit $STATE_UNKNOWN
fi
#
# If we have arguments, process them.
#
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 $REVISION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
#
# No arguments. Let's kick this pig.
#
total_users=$(smbstatus -b | grep "^[0-9]" | wc -l)
#
# Ok, now let's grab a count of the files.
#
total_files=$(smbstatus | grep "^[0-9]" | wc -l)
#
# now for the dismount.
#
echo "Total Users:$total_users Total Files:$total_files"
#
# let Nagios know that everything is ok.
#
exit $STATE_OK

View file

@ -1,185 +0,0 @@
#!/usr/local/bin/perl
# author: Al Tobey <albert.tobey@priority-health.com>
# what: monitor diskspace using the host-resources mib
# license: GPL - http://www.fsf.org/licenses/gpl.txt
#
# Todo:
use strict;
require 5.6.0;
use lib qw( /opt/nagios/libexec );
use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);
use SNMP 5.0;
use Getopt::Long;
use vars qw( $exit $message $opt_version $opt_timeout $opt_help $opt_command $opt_host $opt_community $opt_verbose $opt_warning $opt_critical $opt_port $opt_mountpoint $opt_stats $snmp_session $PROGNAME $TIMEOUT %mounts );
$PROGNAME = "snmp_disk_monitor.pl";
$opt_verbose = undef;
$opt_host = undef;
$opt_community = 'public';
$opt_command = undef;
$opt_warning = 99;
$opt_critical = 100;
$opt_port = 161;
$opt_stats = undef;
$message = undef;
$exit = 'OK';
%mounts = ();
sub process_options {
my( $opt_crit, $opt_warn ) = ();
Getopt::Long::Configure( 'bundling' );
GetOptions(
'V' => \$opt_version, 'version' => \$opt_version,
'v' => \$opt_verbose, 'verbose' => \$opt_verbose,
'h' => \$opt_help, 'help' => \$opt_help,
's' => \$opt_stats, 'statistics' => \$opt_stats,
'H:s' => \$opt_host, 'hostname:s' => \$opt_host,
'p:i' => \$opt_port, 'port:i' => \$opt_port,
'C:s' => \$opt_community, 'community:s' => \$opt_community,
'c:i' => \$opt_crit, 'critical:i' => \$opt_crit,
'w:i' => \$opt_warn, 'warning:i' => \$opt_warn,
't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT,
'm:s' => \$opt_mountpoint, 'mountpoint:s'=> \$opt_mountpoint
);
if ( defined($opt_version) ) { local_print_revision(); }
if ( defined($opt_verbose) ) { $SNMP::debugging = 1; }
if ( !defined($opt_host) || defined($opt_help) || !defined($opt_mountpoint) ) {
print_help();
exit $ERRORS{UNKNOWN};
}
$opt_mountpoint = [ split(/,/, $opt_mountpoint) ];
}
sub local_print_revision {
print_revision( $PROGNAME, '$Revision: 82 $ ' )
}
sub print_usage {
print "Usage: $PROGNAME -H <host> -C <snmp_community> [-s] [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] -m <mountpoint>\n";
}
sub print_help {
local_print_revision();
print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n",
"SNMP Disk Monitor plugin for Nagios\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent
-m, --mountpoint=MOUNTPOINT
a mountpoint, or a comma delimited list of mountpoints
-w, --warning=INTEGER
percent of disk used to generate WARNING state (Default: 99)
-c, --critical=INTEGER
percent of disk used to generate CRITICAL state (Default: 100)
-s, --statistics
output statistics in Nagios format
EOT
}
sub verbose (@) {
return if ( !defined($opt_verbose) );
print @_;
}
sub check_for_errors {
if ( $snmp_session->{ErrorNum} ) {
print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n";
exit $ERRORS{UNKNOWN};
}
}
# =========================================================================== #
# =====> MAIN
# =========================================================================== #
process_options();
alarm( $TIMEOUT ); # make sure we don't hang Nagios
$snmp_session = new SNMP::Session(
DestHost => $opt_host,
Community => $opt_community,
RemotePort => $opt_port,
Version => '2c'
);
# retrieve the data from the remote host
my( $mps, $alloc, $size, $used ) = $snmp_session->bulkwalk( 0, 4, [['hrStorageDescr'],['hrStorageAllocationUnits'],['hrStorageSize'],['hrStorageUsed']] );
check_for_errors();
alarm( 0 ); # all done with the network connection
# move all the data into a nice, convenient hash for processing
foreach my $mp ( @$mps ) { $mounts{$mp->iid}->{mountpoint} = $mp->val; }
foreach my $a ( @$alloc ) { $mounts{$a->iid}->{alloc_units} = $a->val; }
foreach my $si ( @$size ) {
if ( exists($mounts{$si->iid}->{alloc_units}) ) {
$mounts{$si->iid}->{size} = $si->val * $mounts{$si->iid}->{alloc_units};
}
else {
$mounts{$si->iid}->{size} = $si->val;
}
}
foreach my $us ( @$used ) {
if ( exists($mounts{$us->iid}->{alloc_units}) ) {
$mounts{$us->iid}->{used} = $us->val * $mounts{$us->iid}->{alloc_units};
}
else {
$mounts{$us->iid}->{used} = $us->val;
}
}
# now find the mountpoint or mountpoints that were actually requested and push onto an array for output
my @matches = ();
foreach my $mp ( @$opt_mountpoint ) {
my $found = scalar(@matches); # count all matches
foreach my $key ( keys(%mounts) ) {
if ( $mounts{$key}->{mountpoint} eq $mp ) {
# find the percentate - eval to avoid divide by zero errors
eval { $mounts{$key}->{percent_used} = $mounts{$key}->{used} / $mounts{$key}->{size} };
$mounts{$key}->{percent_used} =~ s/^0\.([0-9]{1,2})([0-9]?).*/\1/; # truncate
if ( $2 >= 5 ) { $mounts{$key}->{percent_used}++ }; # round the number number
verbose "mountpoint $mp has ", $mounts{$key}->{percent_used}, "% used, ",
$mounts{$key}->{size}, " bytes and ",$mounts{$key}->{used}, " used\n";
push( @matches, $mounts{$key} );
}
}
if ( scalar(@matches) == $found ) {
print "UNKNOWN - could not locate mountpoint $mp on host\n";
exit $ERRORS{UNKNOWN};
}
}
# now run through and check the thresholds
foreach my $mp ( @matches ) {
if ( $mp->{percent_used} >= $opt_warning ) {
$exit = 'WARNING';
if ( $mp->{percent_used} >= $opt_critical ) { $exit = 'CRITICAL'; }
}
$message .= $mp->{percent_used}.'% used on '.$mp->{mountpoint}.', ';
}
$message =~ s/,\s*$//;
# append statistics if requested
if ( defined($opt_stats) ) {
my @tmp = ();
foreach my $mp ( @matches ) {
push( @tmp, join(',',$mp->{mountpoint},$mp->{size},$mp->{used}) );
}
$message .= '|'.join( ':', @tmp );
}
print "Disk $exit - $message\n";
exit $ERRORS{$exit};

View file

@ -1,605 +0,0 @@
#!/usr/local/bin/perl -w
# check_snmp_printer - check for printer status via snmp
# Supports both standard PRINT-MIB (RFC-1759) and HP Enterprise print-mib
# that is supported by some of the older JetDirect interfaces
# Acknowledgements:
# the JetDirect code is taken from check_hpjd.c by Ethan Galstad
#
# The idea for the plugin (as well as some code) were taken from Jim
# Trocki's pinter alert script in his "mon" utility, found at
# http://www.kernel.org/software/mon
#
# Notes:
# 'JetDirect' is copyrighted by Hewlett-Packard
#
#
# 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.
#
############################################################################
#
# TODO: Query HOST-RESOURCE MIB for a quick status
#
# hrPrinterStatus = .1.3.6.1.2.1.25.3.5.1;
# hrPrinterDetectedErrorState = .1.3.6.1.2.1.25.3.5.1.2
#
# hrPrinterStatus OBJECT-TYPE
# SYNTAX INTEGER {
# other(1),
# unknown(2),
# idle(3),
# printing(4),
# warmup(5)
# }
#
# hrPrinterDetectedErrorState OBJECT-TYPE
# SYNTAX OCTET STRING
# MAX-ACCESS read-only
# STATUS current
# DESCRIPTION
# "This object represents any error conditions detected
# by the printer. The error conditions are encoded as
# bits in an octet string, with the following
# definitions:
#
# Condition Bit #
#
# lowPaper 0
#
# noPaper 1
# lowToner 2
# noToner 3
# doorOpen 4
# jammed 5
# offline 6
# serviceRequested 7
# inputTrayMissing 8
# outputTrayMissing 9
# markerSupplyMissing 10
# outputNearFull 11
# outputFull 12
# inputTrayEmpty 13
# overduePreventMaint 14
#
#
#
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_H $opt_P $opt_t $opt_d $session $error $answer $key
$response $PROGNAME $port $hostname );
use lib "utils.pm";
use utils qw(%ERRORS &print_revision &support &usage );
use Net::SNMP;
sub print_help ();
sub print_usage ();
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
# defaults
my $ptype = 1; # to standard RFC printer type
my $state = $ERRORS{'UNKNOWN'};
my $community = "public";
my $snmp_version = 1;
my $port = 161;
Getopt::Long::Configure('bundling');
GetOptions
("d" => \$opt_d, "debug" => \$opt_d,
"V" => \$opt_V, "version" => \$opt_V,
"P=s" => \$opt_P, "Printer=s" => \$opt_P, # printer type - HP or RFC
"v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version,
"p=i" => \$port, "port=i" => \$port,
"C=s" => \$community,"community=s" => \$community,
"h" => \$opt_h, "help" => \$opt_h,
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
$PROGNAME = "check_snmp_printer";
if ($opt_V) {
print_revision($PROGNAME,'$Revision: 795 $');
exit $ERRORS{'OK'};
}
if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
unless (defined $opt_H) {
print "No target hostname specified\n";
exit $ERRORS{"UNKNOWN"};
}
$hostname = $opt_H;
if (! utils::is_hostname($hostname)){
usage(" $hostname did not match pattern\n");
exit $ERRORS{"UNKNOWN"};
}
if (defined $opt_P) {
if ($opt_P eq "HP" ) {
$ptype = 2;
}elsif ($opt_P eq "RFC" ) {
$ptype = 1;
}else{
print "Only \"HP\" and \"RFC\" are supported as printer options at this time.\n";
exit $ERRORS{"UNKNOWN"};
}
}
if ( $snmp_version =~ /[12]/ ) {
($session, $error) = Net::SNMP->session(
-hostname => $hostname,
-community => $community,
-port => $port,
-version => $snmp_version
);
if (!defined($session)) {
$state='UNKNOWN';
$answer=$error;
print ("$state: no session - $answer\n");
exit $ERRORS{$state};
}
print "Opened session|" if (defined ($opt_d));
}elsif ( $snmp_version =~ /3/ ) {
$state='UNKNOWN';
print ("$state: No support for SNMP v3 yet\n");
exit $ERRORS{$state};
}else{
$state='UNKNOWN';
print ("$state: No support for SNMP v$snmp_version yet\n");
exit $ERRORS{$state};
}
### main logic
if ( $ptype == 1 ) { # STD MIB
print "STD-MIB|" if (defined ($opt_d));
my %snmp_response;
my $snmp_index;
my $col_oid;
my %std_mib_inst_count ;
my %std_mib_instances;
my $display;
my $inst;
my $group;
#### RFC1759 MIB OIDS
# sub-unit status - textual convention
my $subunit_status; # integer from 0-126
# column oid - not instances
my %std_mib = (
std_mib_input_status => ".1.3.6.1.2.1.43.8.2.1.11", # 2 element index
std_mib_input_name => ".1.3.6.1.2.1.43.8.2.1.13",
std_mib_output_remaining_capacity => ".1.3.6.1.2.1.43.9.2.1.5",
std_mib_output_status => ".1.3.6.1.2.1.43.9.2.1.6",
std_mib_marker_tech => ".1.3.6.1.2.1.43.10.2.1.2",
std_mib_marker_counter_unit => ".1.3.6.1.2.1.43.10.2.1.3",
std_mib_marker_life_count => ".1.3.6.1.2.1.43.10.2.1.4",
std_mib_marker_status => ".1.3.6.1.2.1.43.10.2.1.15",
std_mib_supplies_type => ".1.3.6.1.2.1.43.11.1.1.5",
std_mib_supplies_level => ".1.3.6.1.2.1.43.11.1.1.9",
std_mib_media_path_type => ".1.3.6.1.2.1.43.13.4.1.9",
std_mib_media_path_status => ".1.3.6.1.2.1.43.13.4.1.11",
std_mib_status_display => ".1.3.6.1.2.1.43.16.5.1.2", # 2 element index
std_mib_alert_sev_level => ".1.3.6.1.2.1.43.18.1.1.2",
std_mib_alert_grp => ".1.3.6.1.2.1.43.18.1.1.4",
std_mib_alert_location => ".1.3.6.1.2.1.43.18.1.1.5",
);
my %std_mib_marker_tech = (
1 => "other",
2 => "unknown",
3 => "electrophotographicLED",
4 => "electrophotographicLaser",
5 => "electrophotographicOther",
6 => "impactMovingHeadDotMatrix9pin",
7 => "impactMovingHeadDotMatrix24pin",
8 => "impactMovingHeadDotMatrixOther",
9 => "impactMovingHeadFullyFormed",
10 => "impactBand",
11 => "impactOther",
12 => "inkjectAqueous",
13 => "inkjetSolid",
14 => "inkjetOther",
15 => "pen",
16 => "thermalTransfer",
17 => "thermalSensitive",
18 => "thermalDiffusion",
19 => "thermalOther",
20 => "electroerosion",
21 => "electrostatic",
22 => "photographicMicrofiche",
23 => "photographicImagesetter",
24 => "photographicOther",
25 => "ionDeposition",
26 => "eBeam",
27 => "typesetter",
);
my %std_mib_marker_counter_units = (
3 => "tenThousandthsOfInches",
4 => "micrometers",
5 => "characters",
6 => "lines",
7 => "impressions",
8 => "sheets",
9 => "dotRow",
11 => "hours",
16 => "feet",
17 => "meters",
);
my %std_mib_alert_groups = (
1 => "unspecifiedOther",
3 => "printerStorageMemory", # hostResourcesMIBStorageTable
4 => "internalDevice", # hostResourcesMIBDeviceTable
5 => "generalPrinter",
6 => "cover",
7 => "localization",
8 => "input",
9 => "output",
10 => "marker",
11 => "markerSupplies",
12 => "markerColorant",
13 => "mediaPath",
14 => "connectionChannel",
15 => "interpreter",
16 => "consoleDisplayBuffer",
17 => "consoleLights",
);
my %std_mib_prt_alert_code = (
1 => "other", # ok if on power save
2 => "unknown",
# -- codes common to serveral groups
3 => "coverOpen",
4 => "coverClosed",
5 => "interlockOpen",
6 => "interlockClosed",
7 => "configurationChange",
8 => "jam", # critical
# -- general Printer group
501 => "doorOpen",
502 => "doorClosed",
503 => "powerUp",
504 => "powerDown",
# -- Input Group
801 => "inputMediaTrayMissing",
802 => "inputMediaSizeChange",
803 => "inputMediaWeightChange",
804 => "inputMediaTypeChange",
805 => "inputMediaColorChange",
806 => "inputMediaFormPartsChange",
807 => "inputMediaSupplyLow",
808 => "inputMediaSupplyEmpty",
# -- Output Group
901 => "outputMediaTrayMissing",
902 => "outputMediaTrayAlmostFull",
903 => "outputMediaTrayFull",
# -- Marker group
1001 => "markerFuserUnderTemperature",
1002 => "markerFuserOverTemperature",
# -- Marker Supplies group
1101 => "markerTonerEmpty",
1102 => "markerInkEmpty",
1103 => "markerPrintRibbonEmpty",
1104 => "markerTonerAlmostEmpty",
1105 => "markerInkAlmostEmpty",
1106 => "markerPrintRibbonAlmostEmpty",
1107 => "markerWasteTonerReceptacleAlmostFull",
1108 => "markerWasteInkReceptacleAlmostFull",
1109 => "markerWasteTonerReceptacleFull",
1110 => "markerWasteInkReceptacleFull",
1111 => "markerOpcLifeAlmostOver",
1112 => "markerOpcLifeOver",
1113 => "markerDeveloperAlmostEmpty",
1114 => "markerDeveloperEmpty",
# -- Media Path Device Group
1301 => "mediaPathMediaTrayMissing",
1302 => "mediaPathMediaTrayAlmostFull",
1303 => "mediaPathMediaTrayFull",
# -- interpreter Group
1501 => "interpreterMemoryIncrease",
1502 => "interpreterMemoryDecrease",
1503 => "interpreterCartridgeAdded",
1504 => "interpreterCartridgeDeleted",
1505 => "interpreterResourceAdded",
1506 => "interpreterResourceDeleted",
);
## Need multiple passes as oids are all part of tables
foreach $col_oid (sort keys %std_mib ){
if ( !defined( $response = $session->get_table($std_mib{$col_oid}) ) ) {
print "Error col_oid $col_oid|" if (defined ($opt_d));
if (! ($col_oid =~ m/std_mib_alert/ ) ) { # alerts don't have to exist all the time!
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer for $std_mib{$col_oid}\n");
exit $ERRORS{$state};
}
}
print "NoError col_oid $col_oid|" if (defined ($opt_d));
foreach $key (keys %{$response}) {
$key =~ /.*\.(\d+)\.(\d+)$/; # all oids have a two part index appended
$snmp_index = $1 . "." . $2;
print "\n$key => $col_oid.$snmp_index = $response->{$key} \n" if (defined ($opt_d));
$snmp_response{$key} = $response->{$key} ;
$std_mib_inst_count{$col_oid} += 1 ; # count how many instances
$std_mib_instances{$col_oid} .= $snmp_index .":" ;
}
}
#foreach $key ( keys %std_mib_inst_count) {
# print "$key = $std_mib_inst_count{$key} $std_mib_instances{$key} \n";
#}
# get (total) "page count" - perfdata
#print "\n \n $std_mib_instances{'std_mib_marker_tech'} \n";
# how many marker technologies are in use?
my ($pg, $pt, $pfd);
my @mark_tech = split(/:/, $std_mib_instances{'std_mib_marker_tech'});
foreach $inst (sort @mark_tech){
$pfd = $std_mib_marker_tech{$snmp_response{$std_mib{'std_mib_marker_tech'}."." .$inst}} ;
$pfd .= ",".$snmp_response{$std_mib{'std_mib_marker_life_count'}.".".$inst};
$pfd .= ",".$std_mib_marker_counter_units{$snmp_response{$std_mib{'std_mib_marker_counter_unit'}.".".$inst}};
$pfd .= ";"; #perf data separator for multiple marker tech
print "pfd = $pfd\n" if (defined ($opt_d));
};
# combine all lines of status display into one line
#$std_mib_instances{'std_mib_status_display'} = substr($std_mib_instances{'std_mib_status_display'}, 1);
my @display_index = split(/:/, $std_mib_instances{'std_mib_status_display'} );
foreach $inst ( sort @display_index) {
$display .= $snmp_response{$std_mib{'std_mib_status_display'} . "." . $inst} . " ";
}
# see if there are any alerts
if (defined ( $std_mib_inst_count{'std_mib_alert_sev_level'} ) ) {
if ( ( lc($display) =~ /save/ || lc($display) =~ /warm/ ) && $std_mib_inst_count{'std_mib_alert_sev_level'} == 1 ) {
$state='OK';
$answer = "Printer ok - $display";
print $answer . "|$pfd\n";
exit $ERRORS{$state};
}
# sometime during transitions from power save to warming there are 2 alerts
# if the 2nd alert is for something else it should get caught in the
# next call since warmup typically is much smaller than check time
# interval.
if ( lc($display) =~ /warm/ && $std_mib_inst_count{'std_mib_alert_sev_level'} == 2 ) {
$state='OK';
$answer = "$state: Printer - $display";
print $answer . "|$pfd\n";
exit $ERRORS{$state};
}
# We have alerts and the display does not say power save or warming up
$std_mib_instances{'std_mib_alert_sev_level'} = substr($std_mib_instances{'std_mib_alert_sev_level'}, 1);
@display_index = split(/:/, $std_mib_instances{'std_mib_alert_sev_level'} );
$answer = "Alert location(s): ";
for $inst (@display_index) {
$state = 'WARNING';
if ( $snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} < 1) {
$answer .= "unknown location ";
}else{
$answer .= $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} } . " ";
#print $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'}. "." . $inst}} ;
}
}
print "$state: $answer|$pfd\n";
exit $ERRORS{$state};
}else{
$state='OK';
$answer = "$state: Printer ok - $display ";
print $answer . "|$pfd\n";
exit $ERRORS{$state};
}
}
elsif( $ptype == 2 ) { # HP MIB - JetDirect
#### HP MIB OIDS - instance OIDs
my $HPJD_LINE_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.1.0";
my $HPJD_PAPER_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.2.0";
my $HPJD_INTERVENTION_REQUIRED= ".1.3.6.1.4.1.11.2.3.9.1.1.2.3.0";
my $HPJD_GD_PERIPHERAL_ERROR= ".1.3.6.1.4.1.11.2.3.9.1.1.2.6.0";
my $HPJD_GD_PAPER_JAM= ".1.3.6.1.4.1.11.2.3.9.1.1.2.8.0";
my $HPJD_GD_PAPER_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.9.0";
my $HPJD_GD_TONER_LOW= ".1.3.6.1.4.1.11.2.3.9.1.1.2.10.0";
my $HPJD_GD_PAGE_PUNT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.11.0";
my $HPJD_GD_MEMORY_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.12.0";
my $HPJD_GD_DOOR_OPEN= ".1.3.6.1.4.1.11.2.3.9.1.1.2.17.0";
my $HPJD_GD_PAPER_OUTPUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.19.0";
my $HPJD_GD_STATUS_DISPLAY= ".1.3.6.1.4.1.11.2.3.9.1.1.3.0";
#define ONLINE 0
#define OFFLINE 1
my @hp_oids = ( $HPJD_LINE_STATUS,$HPJD_PAPER_STATUS,$HPJD_INTERVENTION_REQUIRED,$HPJD_GD_PERIPHERAL_ERROR,
$HPJD_GD_PAPER_JAM,$HPJD_GD_PAPER_OUT,$HPJD_GD_TONER_LOW,$HPJD_GD_PAGE_PUNT,$HPJD_GD_MEMORY_OUT,
$HPJD_GD_DOOR_OPEN,$HPJD_GD_PAPER_OUTPUT,$HPJD_GD_STATUS_DISPLAY);
$state = $ERRORS{'OK'};
if (!defined($response = $session->get_request(@hp_oids))) {
$answer=$session->error;
$session->close;
$state = 'CRITICAL';
print ("$state: $answer \n");
exit $ERRORS{$state};
}
# cycle thru the responses and set the appropriate state
if($response->{$HPJD_GD_PAPER_JAM} ) {
$state='WARNING';
$answer = "Paper Jam";
}
elsif($response->{$HPJD_GD_PAPER_OUT} ) {
$state='WARNING';
$answer = "Out of Paper";
}
elsif($response->{$HPJD_LINE_STATUS} ) {
if ($response->{$HPJD_LINE_STATUS} ne "POWERSAVE ON" ) {
$state='WARNING';
$answer = "Printer Offline";
}
}
elsif($response->{$HPJD_GD_PERIPHERAL_ERROR} ) {
$state='WARNING';
$answer = "Peripheral Error";
}
elsif($response->{$HPJD_INTERVENTION_REQUIRED} ) {
$state='WARNING';
$answer = "Intervention Required";
}
elsif($response->{$HPJD_GD_TONER_LOW} ) {
$state='WARNING';
$answer = "Toner Low";
}
elsif($response->{$HPJD_GD_MEMORY_OUT} ) {
$state='WARNING';
$answer = "Insufficient Memory";
}
elsif($response->{$HPJD_GD_DOOR_OPEN} ) {
$state='WARNING';
$answer = "Insufficient Memory";
}
elsif($response->{$HPJD_GD_PAPER_OUTPUT} ) {
$state='WARNING';
$answer = "OutPut Tray is Full";
}
elsif($response->{$HPJD_GD_PAGE_PUNT} ) {
$state='WARNING';
$answer = "Data too slow for Engine";
}
elsif($response->{$HPJD_PAPER_STATUS} ) {
$state='WARNING';
$answer = "Unknown Paper Error";
}
else # add code to parse STATUS DISPLAY here
{
$state='OK';
$answer = "Printer ok - $response->{$HPJD_GD_STATUS_DISPLAY} ";
}
# print and exit
print "$state: $answer \n";
exit $ERRORS{$state};
}
else{ # 3rd printer type - not yet supported
print "Printer type $opt_P has not been implemented\n";
$state='UNKNOWN';
exit $ERRORS{$state};
}
#### subroutines
sub unit_status {
my $stat = shift;
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> [-C community] [-P HP or RFC] [-p port] [-v snmp_version] [-h help] [-V version]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 795 $');
print "Copyright (c) 2002 Subhendu Ghosh/Ethan Galstad.
This plugin reports the status of an network printer with an SNMP management
module.
";
print_usage();
print "
-H, --hostname=HOST
Name or IP address of host to check
-C --community
snmp community string (default: public)
-P --Printer
supported values are \"HP\" for Jetdirect printers and
\"RFC\" for RFC 1759 Print MIB based implementations (default: RFC)
-p --port
Port where snmp agent is listening (default: 161)
-v --snmp_version
SNMP version to use (default: version 1)
-h --help
This screen
-V --version
Plugin version
";
support();
}

View file

@ -1,331 +0,0 @@
#!/usr/local/bin/perl
# author: Al Tobey <albert.tobey@priority-health.com>
# what: monitor a process using the host-resources mib
# license: GPL - http://www.fsf.org/licenses/gpl.txt
#
# Todo:
# * implement memory and cpu utilization checks
# * maybe cache pids in DBM files if snmp agents get overworked
###############################################################################
# to get a list of processes over snmp try this command:
# snmptable -v2c -c public hostname hrSWRunTable
# for just a list of valid arguments for the '-e' option:
# snmpwalk -v2c -c public hostname hrSWRunName |perl -pe 's:.*/::'
###############################################################################
use strict;
require 5.6.0;
use lib qw( /opt/nagios/libexec /usr/local/libexec );
use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);
use SNMP 5.0;
use Getopt::Long;
use Storable;
use vars qw( $exit $opt_version $opt_timeout $opt_help $opt_command $opt_host $opt_community $opt_verbose $opt_warning $opt_critical $opt_memory $opt_cpu $opt_port $opt_regex $opt_stats $opt_cache $opt_nocache $cache_exp $interpreters $snmp_session $PROGNAME $TIMEOUT );
$PROGNAME = "snmp_process_monitor.pl";
$opt_verbose = undef;
$opt_host = undef;
$opt_community = 'public';
$opt_command = undef;
$opt_warning = [ 1, -1 ];
$opt_critical = [ 1, -1 ];
$opt_memory = undef;
$opt_cpu = undef;
$opt_port = 161;
$opt_cache = 1;
$opt_nocache = undef;
$cache_exp = 600;
$exit = $ERRORS{OK};
$interpreters = '(perl|/bin/sh|/usr/bin/sh|/bin/bash|/bin/ksh|python)';
our $cachefile = '/var/opt/nagios/tmp/'; # completed later
our %processes = ();
sub process_options {
my( $opt_crit, $opt_warn ) = ();
Getopt::Long::Configure( 'bundling' );
GetOptions(
'V' => \$opt_version, 'version' => \$opt_version,
'v' => \$opt_verbose, 'verbose' => \$opt_verbose,
'h' => \$opt_help, 'help' => \$opt_help,
's' => \$opt_stats, 'statistics' => \$opt_stats,
'nocache' => \$opt_nocache,
'H:s' => \$opt_host, 'hostname:s' => \$opt_host,
'p:i' => \$opt_port, 'port:i' => \$opt_port,
'C:s' => \$opt_community, 'community:s' => \$opt_community,
'c:s' => \$opt_crit, 'critical:s' => \$opt_crit,
'w:s' => \$opt_warn, 'warning:s' => \$opt_warn,
't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT,
'e:s' => \$opt_command, 'command:s' => \$opt_command,
'r:s' => \$opt_regex, 'regex:s' => \$opt_regex,
'cpu:i' => \$opt_cpu, 'memory:i' => \$opt_memory,
);
if ( defined($opt_version) ) { local_print_revision(); }
if ( defined($opt_verbose) ) { $SNMP::debugging = 1; }
if ( !defined($opt_host) || defined($opt_help) || (!defined($opt_command) && !defined($opt_regex)) ) {
print_help();
exit $ERRORS{UNKNOWN};
}
if ( defined($opt_crit) ) {
if ( $opt_crit =~ /,/ ) {
$opt_critical = [ split(',', $opt_crit) ];
}
else {
$opt_critical = [ $opt_crit, -1 ];
}
}
if ( defined($opt_warn) ) {
if ( $opt_warn =~ /,/ ) {
$opt_warning = [ split(',', $opt_warn) ];
}
else {
$opt_warning = [ $opt_crit, -1 ];
}
}
if ( defined($opt_memory) ) { $opt_memory = 0 }
if ( defined($opt_cpu) ) { $opt_cpu = 0 }
if ( defined($opt_nocache)) { $opt_cache = 0 }
# complete the cachefile's name
$cachefile .= $opt_host . '.proc';
}
sub local_print_revision {
print_revision( $PROGNAME, '$Revision: 84 $ ' )
}
sub print_usage {
print "Usage: $PROGNAME -H <host> -C <snmp_community> -e <command> [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] [-s|--statistics] [--memory] [--cpu] [--nocache]\n";
}
sub print_help {
local_print_revision();
print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n",
"SNMP Process Monitor plugin for Nagios\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent
-e, --command=COMMAND NAME (ps -e style)
what command should be monitored?
-r, --regex=Perl RE
use a perl regular expression to find your process
-w, --warning=INTEGER[,INTEGER]
minimum and maximum number of processes before a warning is issued (Default 1,-1)
-c, --critical=INTEGER[,INTEGER]
minimum and maximum number of processes before a critical is issued (Default 1,-1)
--memory
combined with '-s', will print the number of bytes of real memory used by process
--cpu
combined with '-s', will print the number of seconds of cpu time consumed by process
EOT
}
sub verbose (@) {
return if ( !defined($opt_verbose) );
print @_;
}
sub check_for_errors {
if ( $snmp_session->{ErrorNum} ) {
%processes = ();
print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n";
exit $ERRORS{UNKNOWN};
}
}
sub init_cache {
if ( !defined($opt_cache) ) {
%processes = ();
return;
}
if ( -r $cachefile ) {
eval {
verbose "loading cache from $cachefile\n";
%processes = %{ retrieve( $cachefile ) };
};
if ( $@ ) {
verbose "cache loading failed - using blank cache: $@\n";
%processes = ()
}
}
else {
%processes = ();
}
}
sub snmpget {
my $tmpvar = SNMP::Varbind->new( shift );
$snmp_session->get( $tmpvar );
check_for_errors();
return $tmpvar->val;
}
sub update_cache {
# expire the cache after $cache_exp seconds
if ( $opt_cache != 0 && exists($processes{__last_update})
&& $processes{__last_update} >= time - $cache_exp ) {
verbose "cache file is recent enough - using it\n";
return 1;
}
verbose "retrieving full listing of processes from $opt_host\n";
my $process_count = snmpget( ['hrSystemProcesses', 0] );
# retrieve the data from the remote host
my ($names) = $snmp_session->bulkwalk( 0, $process_count + 1, [['hrSWRunName']] );
check_for_errors();
# make sure the number of processes from the bulkwalk is close to hrSystemProcesses
if ( scalar(@$names) + 10 < $process_count ) {
print "UNKNOWN - only ", scalar(@$names), " of ",$process_count, " processes returned\n";;
exit $ERRORS{UNKNOWN};
}
# sort through the process names and create a nice hash of processes
foreach my $row ( @$names ) {
my %hash = {};
$hash{name} = $row->val;
$hash{abs_name} = $row->val;
$hash{name} =~ s#.*/##; # strip path
if ( defined($opt_regex) ||
($row->val =~ m#$interpreters$#
&& $opt_command !~ m#$interpreters$#) ) {
# fetch the runtime parameters of the process
my $parameters = snmpget( ['hrSWRunParameters', $row->iid] );
# only strip if we're looking for a specific command
if ( defined($opt_command) ) {
verbose "process ",$row->iid," uses $1 as an interpreter - getting parameters\n";
$hash{name} = $parameters;
$hash{name} =~ s#.*/##; # strip path name off the front
$hash{name} =~ s/\s+.*$//; # strip everything from the first space to the end
}
else {
# use the full 'ps -efl' style listing for regular expression matching
my $path = snmpget( ['hrSWRunPath', $row->iid] );
$hash{name} = "$path $parameters";
}
}
# store in the global hash
$processes{$row->iid} = \%hash;
}
# update the timestamp so the cache can expire
$processes{__last_update} = time;
return 0;
}
# process the %processes hash and see if there any matches for our command or regex
sub check_for_matches {
my $ret_match = 0;
foreach my $key ( keys(%processes) ) {
next if ( $key eq '__last_update' );
my $match = 0;
# static matches are letter-for-letter (-e)
if ( defined($opt_command) && $processes{$key}->{name} eq $opt_command ) { $match++; }
# use /o to make sure the user-supplied regex (-r) is only compiled once
elsif ( defined($opt_regex) && $processes{$key}->{name} =~ /$opt_regex/o ) { $match++; }
# verify the cache's entry by doing an snmpget
if ( $match > 0 && $opt_cache != 0 ) {
my $proc = snmpget( ['hrSWRunName', $key] );
--$match if ( !$proc || $proc ne $processes{$key}->{abs_name} );
}
# get the process memory usage if requested
if ( $match > 0 && defined($opt_memory) ) {
$opt_memory += snmpget( ['hrSWRunPerfMem', $key] );
}
# get the process cpu usage if requested
if ( $match > 0 && defined($opt_cpu) ) {
$opt_cpu += snmpget( ['hrSWRunPerfCPU', $key] );
}
verbose "process '$processes{$key}->{name}' has pid $processes{$key}->{pid} and index $key\n"
if ( $match > 0 );
$ret_match += $match;
}
return $ret_match;
}
# =========================================================================== #
# =====> MAIN
# =========================================================================== #
process_options();
alarm( $TIMEOUT ); # make sure we don't hang Nagios
# intialize the cache, if it's enabled
init_cache();
# create a session for conversing with the remote SNMP agent
$snmp_session = new SNMP::Session(
DestHost => $opt_host,
Community => $opt_community,
RemotePort => $opt_port,
Version => '2c'
);
my $usage = update_cache();
my $count = check_for_matches();
# always try twice if caching is enabled - once with cache and once without
if ( $usage != 0 && $opt_cache != 0 && $count <= 0 ) {
verbose "did not find process in cache - trying a refresh\n";
%processes = ();
update_cache();
$count = check_for_matches();
}
# the default, OK message
my $message = "OK - $count process(es) found resembling '". ($opt_command || $opt_regex);
# warning, critical
if ( ($opt_warning->[0] > 0 && $opt_warning->[0] > $count)
|| ($opt_warning->[1] > 0 && $opt_warning->[1] <= $count) ) {
$message = "WARNING - no processes found resembling '". ($opt_command || $opt_regex);
$exit = $ERRORS{WARNING};
}
if ( ($opt_critical->[0] > 0 && $opt_critical->[0] > $count)
|| ($opt_critical->[1] > 0 && $opt_critical->[1] <= $count) ) {
$message = "CRITICAL - no processes found resembling '". ($opt_command || $opt_regex);
$exit = $ERRORS{CRITICAL};
}
# output the status message
print $message, "'";
# print the number of processes if statistics are requested
if ( defined($opt_stats) ) {
print "|count=$count";
if ( defined($opt_memory) ) {
print ":memory=", $opt_memory;
}
if ( defined($opt_cpu) ) {
$opt_cpu = $opt_cpu / 100;
printf ":cpu=%.2f", $opt_cpu;
}
}
# store a copy of the %processes hash if we're using caching
if ( $exit == $ERRORS{OK} && $opt_cache != 0 ) {
eval {
unlink( $cachefile ) if ( -e $cachefile );
store( \%processes, $cachefile );
};
}
print "\n";
exit $exit;

View file

@ -1,590 +0,0 @@
#!/usr/bin/perl -w
#
# check_snmp_procs.pl
# Nagios script to check processes on remote host via snmp
#
#
# Copyright (c) 2003 David Alden
#
# 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.
#
#
# History
# -------
# 02-25-2003 - Dave Alden <alden@math.ohio-state.edu>
# Initial creation
#
#
# TODO
# ----
# make it work with snmp version 3
# Suggestions???
#
#use strict;
use Getopt::Long;
use Net::SNMP qw (oid_lex_sort oid_base_match SNMP_VERSION_1);
use lib "/usr/local/nagios/libexec";
use utils qw(%ERRORS &print_revision &support &usage);
my $PROGNAME="check_snmp_procs";
my $REVISION="1.0";
#
my $opt_authprotocol;
my $opt_authpassword;
my $opt_community = 'ma4read';
my $opt_critical;
my $opt_help;
my $opt_host = 'euler';
my $opt_oidname = 'hrSWRunName';
my $opt_port = 161;
my $opt_privpassword;
my $opt_regexp = 0;
my $opt_snmp_version = '2c';
my $opt_timeout = $utils::TIMEOUT;
my $opt_username;
my $opt_verbose;
my $opt_version;
my $opt_wanted_procs;
my $opt_warning;
#
my $max_no_processes = 999999;
my $session;
my $error;
my $no_procs;
my $exit_status;
#
my @wanted_procs;
my %current_process_list;
#
my %OIDS = (hrSWRunName => '1.3.6.1.2.1.25.4.2.1.2',
hrSWRunPath => '1.3.6.1.2.1.25.4.2.1.4');
my %OIDS_L = (hrSWRunName => length($OIDS{hrSWRunName}),
hrSWRunPath => length($OIDS{hrSWRunPath}));
#
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
#
Getopt::Long::Configure('bundling');
if (GetOptions(
"a:s" => \$opt_authprotocol, "authprotocol:s" => \$opt_authprotocol,
"A:s" => \$opt_authpassword, "authpassword:s" => \$opt_authpassword,
"C:s" => \$opt_community, "community:s" => \$opt_community,
"c:s" => \$opt_critical, "critical:s" => \$opt_critical,
"h" => \$opt_help, "help" => \$opt_help,
"H:s" => \$opt_host, "hostname:s" => \$opt_host,
"o:s" => \$opt_oidname, "oidname:s" => \$opt_oidname,
"P=s" => \$opt_password, "password=s" => \$opt_password,
"p=i" => \$opt_port, "port=i" => \$opt_port,
"r" => \$opt_regexp, "regexp" => \$opt_regexp,
"S" => \$opt_snmp_version, "snmpversion" => \$opt_snmp_version,
"t=i" => \$opt_timeout, "timeout=i" => \$opt_timeout,
"U=s" => \$opt_username, "username=s" => \$opt_username,
"v" => \$opt_verbose, "verbose" => \$opt_verbose,
"V" => \$opt_version, "version" => \$opt_version,
"N=s" => \$opt_wanted_procs, "names=s" => \$opt_wanted_procs,
"w:s" => \$opt_warning, "warning:s" => \$opt_warning)
== 0) {
print_usage();
exit $ERRORS{'UNKNOWN'};
}
if ($opt_version) {
print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$");
exit $ERRORS{'OK'};
}
if ($opt_help) {
print_help();
exit $ERRORS{'OK'};
}
if (! utils::is_hostname($opt_host)){
usage();
exit $ERRORS{'UNKNOWN'};
}
($longest_wanted, @wanted_procs) = parse_wanted_procs($opt_verbose, $opt_wanted_procs, $opt_warning, $opt_critical);
$SIG{'ALRM'} = sub {
print "Timeout: No Answer from Client\n";
exit $ERRORS{'UNKNOWN'};
};
alarm($opt_timeout);
($longest_current, %current_process_list) = get_process_list($opt_verbose, $opt_host, $opt_username, $opt_privpassword, $opt_authprotocol, $opt_authpassword, $opt_community, $opt_port, $opt_oidname, $opt_snmp_version);
$exit_status = compare_process_list($opt_regexp, \%current_process_list, @wanted_procs);
if ($opt_verbose) {
print_info($longest_current, \%current_process_list, $longest_wanted, @wanted_procs);
}
exit($exit_status);
#
sub compare_process_list {
my($regexp, $current_process_list, @wanted_procs) = @_;
my($proc, $i, $no_running_procs, @warning, @critical);
my $exit = $ERRORS{'OK'};
for ($i = 0; $i <= $#wanted_procs; $i++) {
$proc = $wanted_procs[$i];
$no_running_procs = get_running_procs($regexp, $$proc{name}, $current_process_list);
$$proc{no_matches} += $no_running_procs;
if (($no_running_procs >= $$proc{warn_low}) &&
($no_running_procs <= $$proc{warn_high})) {
push(@warning, $$proc{name} . "($no_running_procs)");
if ($exit != $ERRORS{'CRITICAL'}) {
$exit = $ERRORS{'WARNING'};
}
} elsif (($no_running_procs < $$proc{minimum}) ||
($no_running_procs >= $$proc{critical_low}) &&
($no_running_procs <= $$proc{critical_high})) {
push(@critical, $$proc{name} . "($no_running_procs)");
$exit = $ERRORS{'CRITICAL'};
}
}
print "SNMPPROC ";
if ($#critical >= 0) {
print "CRITICAL:";
} elsif ($#warning >= 0) {
print "WARNING:";
} else {
print "OK";
}
foreach $i (@critical) {
print " $i";
}
if (($#critical >= 0) &&
($#warning >= 0)) {
print " WARNING:";
}
foreach $i (@warning) {
print " $i";
}
print "\n";
return $exit;
}
#
sub get_running_procs {
my($regex, $name, $process_list) = @_;
my $count = 0;
my $process;
$count = 0;
if ($regex) {
foreach $process (keys %{$process_list}) {
if ($process =~ /$name/) {
$count += $$process_list{$process};
}
}
} else {
if (!defined($count = $$process_list{$name})) {
$count = 0;
}
}
return $count;
}
#
sub get_process_list {
my($verbose, $host, $username, $privpassword, $authprotocol, $authpassword, $community, $port, $oidname, $snmp_version) = @_;
my(%process_list, %process_pid_list, $result);
my $process_list_longest = 1, $not_done = 1;
my(@args, @oids, $oid, $name);
($session, $error) = Net::SNMP->session(
-hostname => $host,
-community => $community,
-port => $port,
-version => $snmp_version,
defined($privpassword) ? (-privpassword => $privpassword) : (),
defined($authpassword) ? (-authpassword => $authpassword) : (),
defined($authprotocol) ? (-authprotocol => $authprotocol) : (),
defined($username) ? (-username => $username) : ());
if (!defined($session)) {
print ("UNKNOWN: $error\n");
exit $ERRORS{'UNKNOWN'};
}
@args = (-varbindlist => [$OIDS{$oidname}]);
if ($session->version == SNMP_VERSION_1) {
while (defined($session->get_next_request(@args))) {
$oid = (keys(%{$session->var_bind_list}))[0];
last if (!oid_base_match($OIDS{$oidname}, $oid));
$name = $session->var_bind_list->{$oid};
$process_list{$name}++;
if ($verbose && ($process_list_longest < length($name))) {
$process_list_longest = length($name);
}
@args = (-varbindlist => [$oid]);
}
} else {
push(@args, -maxrepetitions => 25);
while ($not_done && defined($session->get_bulk_request(@args))) {
@oids = oid_lex_sort(keys(%{$session->var_bind_list}));
foreach $oid (@oids) {
if (!oid_base_match($OIDS{$oidname}, $oid)) {
$not_done = 0;
} else {
$name = $session->var_bind_list->{$oid};
$process_list{$name}++;
if ($verbose && ($process_list_longest < length($name))) {
$process_list_longest = length($name);
}
if ($session->var_bind_list->{$oid} eq 'endOfMibView') {
$not_done = 0;
}
}
}
if ($not_done) {
@args = (-maxrepetitions => 25, -varbindlist => [pop(@oids)]);
}
}
}
if ($session->error() ne '') {
print ("UNKNOWN: " . $session->error() . "\n");
exit $ERRORS{'UNKNOWN'};
}
$session->close;
return($process_list_longest, %process_list);
}
#
sub parse_wanted_procs {
my($verbose, $wanted_procs, $warning, $critical) = @_;
my(@procs, $process, $i, $critical_low, $critical_high, $warn_low, $warn_high, $process_name, $process_min);
my(@process_array, @warn_array, @critical_array);
my $exit = 0;
my $longest_name = 1;
if (defined($wanted_procs)) {
@process_array = split(/,/, $wanted_procs);
}
if (defined($warning)) {
@warn_array = split(/,/, $warning);
}
if (defined($critical)) {
@critical_array = split(/,/, $critical);
}
if( defined($warning) && $#process_array != $#warn_array ) {
print "Error: Number of entries in process list($#process_array) and warn list($#warn_array) don't match\n";
exit $ERRORS{'UNKNOWN'};
}
if( defined($critical) && $#process_array != $#critical_array ) {
print "Error: Number of entries in process list and critical list don't match\n";
exit $ERRORS{'UNKNOWN'};
}
for ($i = 0; $i <= $#process_array; $i++) {
if ((($process_name, $process_min) = split(/:/, $process_array[$i])) != 2) {
$process_min = 1;
}
if ($verbose && ($longest_name < length($process_name))) {
$longest_name = length($process_name);
}
if (defined($critical_array[$i])) {
if ((($critical_low, $critical_high) = split(/:/, $critical_array[$i])) != 2) {
$critical_high = $critical_low;
} else {
if ($critical_high eq "") {
$critical_high = $max_no_processes;
}
if ($critical_low eq "") {
$critical_low = 0;
}
}
} else {
$critical_low = -1;
$critical_high = -1;
}
if (defined($warn_array[$i])) {
if ((($warn_low, $warn_high) = split(/:/, $warn_array[$i])) != 2) {
$warn_high = $warn_low;
} else {
if ($warn_high eq "") {
$warn_high = $max_no_processes;
}
if ($warn_low eq "") {
$warn_low = 0;
}
}
} else {
$warn_low = -1;
$warn_high = -1;
}
if ($critical_low > $critical_high) {
print "Error: $process_name critical low($critical_low) is larger than high($critical_high)\n";
$exit = 1;
}
if ($warn_low > $warn_high) {
print "Error: $process_name warn low($warn_low) is larger than high($warn_high)\n";
$exit = 1;
}
if (@critical_array &&
($process_min > $critical_low)) {
print "Error: $process_name minimum($process_min) is larger than critical low($critical_low)\n";
$exit = 1;
}
if (@warn_array &&
($process_min > $warn_low)) {
print "Error: $process_name minimum($process_min) is larger than warn low($warn_low)\n";
$exit = 1;
}
if (@warn_array && @critical_array &&
((($warn_low >= $critical_low) && ($warn_low <= $critical_high)) ||
(($warn_high >= $critical_low) && ($warn_high <= $critical_high)))) {
print "Error: $process_name warn levels($warn_low:$warn_high) overlap with critical levels($critical_low:$critical_high)\n";
$exit = 1;
}
push(@procs,{
name => $process_name,
critical => defined($critical),
critical_low => $critical_low,
critical_high => $critical_high,
minimum => $process_min,
warning => defined($warning),
warn_low => $warn_low,
warn_high => $warn_high});
}
if ($exit) {
exit $ERRORS{'UNKNOWN'};
}
return($longest_name, @procs);
}
#
sub print_info {
my ($longest_current, $current_process_list, $longest_wanted, @wanted_procs) = @_;
if ($longest_wanted < 7) {
$longest_wanted = 7;
} else {
$longest_wanted++;
}
printf("%s---------------------------------------------\n", "-" x $longest_wanted);
printf("|%-" . $longest_wanted . "s | | Min | Warn | Critical |\n", "Process");
printf("|%-" . $longest_wanted . "s | Qty | Procs| Low | High | Low | High |\n", "Name");
printf("%s---------------------------------------------\n", "-" x $longest_wanted);
for (my $temp=0; $temp <= $#wanted_procs; $temp++) {
printf("|%-" . $longest_wanted . "s |%6d|%6d|%6d|%6d|%6d|%6d|\n",
$wanted_procs[$temp]{name},
$wanted_procs[$temp]{no_matches},
$wanted_procs[$temp]{minimum},
$wanted_procs[$temp]{critical_low},
$wanted_procs[$temp]{critical_high},
$wanted_procs[$temp]{warn_low},
$wanted_procs[$temp]{warn_high});
}
printf("%s---------------------------------------------\n\n", "-" x $longest_wanted);
if ($longest_current < 7) {
$longest_current = 7;
} else {
$longest_current++;
}
printf("%s----------\n", "-" x $longest_current);
printf("|%-" . $longest_current . "s | Qty |\n", "Process");
printf("%s----------\n", "-" x $longest_current);
foreach my $result (sort keys %{$current_process_list}) {
printf("|%-" . $longest_current . "s |%6d|\n", $result,
$current_process_list{$result});
}
printf("%s----------\n", "-" x $longest_current);
return;
}
#
sub print_usage {
print "Usage:
$PROGNAME -H <host> [-r] [-v]
-N <processname>[:minimum][,<processname>[:minimum] ...]
[-a <authprotocol>] [-A <authpassword>]
[-U <username>] [-P <password>]
[-o <oidname>] [ -S <snmpversion> ]
[-C <snmp_community>] [-p <port>] [-t <timeout>]
[-w <low>:<high>[,<low>:<high> ...]
[-c <low>:<high>[,<low>:<high> ...]
$PROGNAME (-h | --help) for detailed help
$PROGNAME (-V | --version) for version information\n";
}
#
sub print_help {
print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$");
print "Copyright (c) 2003 David Alden
Check if processes are running on a host via snmp
";
print_usage();
print "
-a, --authprotocol=<authprotocol>
Set the authentication protocol used for authenticated SNMPv3 messages
-A, --authpassword=<authpassword>
Set the authentication pass phrase used for authenticated SNMPv3 messages
-c, --critical=<low>:<high>[,<low>:<high> ...]
exit with CRITICAL status if number of processes is between <low> and <high>
-C, --community=<snmp_community>
SNMP read community (default: $opt_community)
-h, --help
Show this help screen
-H, --host=<host>
Check processes on the indiciated host
-o, --oidname=<oidname>
Which oid tree to search, hrSWRunName or hrSWRunPath (default: $opt_oidname)
-p, --port=<port>
Make connection on the indicated port (default: $opt_port)
-N, --names=<processname>[:<minimum>][,<processname>[:<minimum>] ...]
Process names to check, (optional) minimum number of processes (default: 1)
-P, --password=<privpassword>
Set the privacy pass phrase used for encrypted SNMPv3 messages
-r, --regex
Use regular expression match for <process>
-S, --snmpversion
Use snmp version specified (values: 1|2c|3, default: $opt_snmp_version)
-t, --timeout
Plugin time out in seconds (default: $opt_timeout)
-U, --username=<securityname>
Set the securityname used for encrypted SNMPv3 messages
-v, --verbose
Print some extra debugging information (not advised for normal operation)
-V, --version
Show version and license information
-w, --warning=<low>:<high>[,<low>:<high> ...]
exit with WARNING status if number of processes is between <low> and <high>
A CRITICAL error will be indicated unless there are at least <minimum> number
of processes running (unless <minimum> is set to 0 -- useful if you don't
mind that there are none of the processes running).
If no processes are specified, the program will still connect to the remote
host and download the current list of running processes. It will then exit
with an OK (unless it wasn't able to connect) -- useful if you want to make
sure that the remote snmpd process is running and returning a list of procs.
";
support();
}

View file

@ -1,145 +0,0 @@
#! /usr/bin/perl
# ------------------------------------------------------------------------------
# File Name: check_sockets.pl
# Author: Richard Mayhew - South Africa
# Date: 2000/07/11
# Version: 1.0
# Description: This script will check to see how may open sockets
# a server has and waron respectivly
# 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'
#
# ------------------------------------------------------------------------------
# -----------------------------------------------------------------[ Require ]--
require 5.004;
# --------------------------------------------------------------------[ Uses ]--
use Socket;
use strict;
# --------------------------------------------------------------[ Enviroment ]--
$ENV{'PATH'}='/bin:/sbin:/usr/bin:/usr/sbin';
$ENV{BASH_ENV} = "";
# ------------------------------------------------------------------[ Global ]--
my $TIMEOUT = 20;
my %ERRORS = (
'UNKNOWN', '-1',
'OK', '0',
'WARNING', '1',
'CRITICAL', '2');
# --------------------------------------------------------------[ connection ]--
sub connection
{
my ($in_total,$in_warn,$in_crit,$in_high) = @_;
my $state;
my $answer;
$in_total =~ s/\ //g;
if ($in_total >= 0) {
if ($in_total > $in_crit) {
$state = "CRITICAL";
$answer = "Critical Number Of Sockets Connected : $in_total (Limit = $in_crit)\n";
} elsif ($in_total > $in_warn) {
$state = "WARNING";
$answer = "Warning Number Of Sockets Connected : $in_total (Limit = $in_warn)\n";
} else {
if ($in_high ne "") {
$answer = "Sockets OK - Current Sockets: $in_total : $in_high\n";
}
if ($in_high eq "") {
$answer = "Sockets OK - Current Sockets: $in_total\n";
}
$state = "OK";
}
} else {
$state = "UNKNOWN";
$answer = "Something is Really WRONG! Sockets Is A Negative Figure!\n";
}
print $answer;
exit $ERRORS{$state};
}
# -------------------------------------------------------------------[ usage ]--
sub usage
{
print "Minimum arguments not supplied!\n";
print "\n";
print "Perl Check Sockets plugin for Nagios\n";
print "Copyright (c) 2000 Richard Mayhew\n";
print "\n";
print "Usage: check_sockets.pl <type> <warn> <crit>\n";
print "\n";
print "<type> = TOTAL, TCP, UDP, RAW.\n";
print "<warn> = Number of sockets connected at which a warning message will be generated.[Default = 256]\n";
print "<crit> = Number of sockets connected at which a critical message will be generated.[Default = 512]\n";
exit $ERRORS{"UNKNOWN"};
}
# ====================================================================[ MAIN ]==
MAIN:
{
my $type = shift || &usage;
my $warn = shift || 256;
my $crit = shift || 512;
my $data;
my @data;
my $line;
my $data1;
my $data2;
my $data3;
my $junk;
my $total1;
my $total2;
$type = uc $type;
if ($type eq "TOTAL") {
$type = "sockets";
}
# 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"};
};
$data = `/bin/cat /proc/net/sockstat`;
@data = split("\n",$data);
alarm($TIMEOUT);
my $output = "";
my $high;
foreach $line (@data) {
if ($line =~ /$type/) {
($data1,$data2,$data3) = split(" ",$line,3);
if ($data3 =~ /highest/){
($total1,$junk,$total2) = split(" ",$data3,3);
$output = $total1;
$high = $total2;
}
else {$output = $data3;}
alarm(0);
connection($output,$warn,$crit,$high);
}
}
}

View file

@ -1,162 +0,0 @@
#!/usr/bin/perl
#
#
# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
#
# NetSaint host script to get the disk usage from NT snmp
#
# Changes and Modifications
# =========================
# 3-Aug-2000 - Xavier Dusart
# Created
# 2003 - Rainer Duffner
# Note: CPQ starts numbering sensors etc. with "1"
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
require 5.004;
use POSIX;
#use strict;
use Getopt::Std ;
use BER;
require 'SNMP_Session.pm';
use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support );
use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
getopts('H:p:C:s:w:c:hV') ;
my $ip_address=undef ;
if ($opt_h) {&help();}
if ($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]*)*)$/) {
$ip_address = $opt_H ;
}
else {
usage();
print "IP-Address format wrong\n";
exit $ERRORS{'UNKNOWN'};
}
#if ($opt_p =~ m/^[0-9]
my $port = $opt_p;
my $community = $opt_C;
my $sensor = $opt_s ;
my $warning = $opt_w;
my $critical = $opt_c;
my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,3,0,$sensor );
# not used for the moment - gives no usable output
# if reused, enter at end of list to avoid renumbering !
my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,4,0,$sensor );
my $temperature_threshold_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,5,0,$sensor );
my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,6,0,$sensor );
my $count=1 ;
my $label ;
my @r_array=();
my $q ;
my $diff ;
$warning=$warning/100 ;
$crititcal=$critical/100 ;
# get temperature, temperature_threshold bfore shutdown
my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
if ($session->get_request_response ($temperature_celsius_oid, $temperature_threshold_oid, $temperature_condition_oid, $temperature_locale_oid )) {
(my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
while ($bindings ne '') {
($binding, $bindings) = &decode_sequence ($bindings) ;
($oid,$value) = &decode_by_template ($binding,"%O%@");
$r_array[$count]=&pretty_print($value);
$count++;
}
} else {
print "No response from agent\n";
exit $ERRORS{'CRITICAL'};
}
$result_celsius=$r_array[1];
$result_threshold=$r_array[2];
$result_condition=$r_array[3];
$result_locale=$r_array[4];
if ($result_celsius < 0) {
print "Result is negative - Sensor unavailable ?\n";
exit $ERRORS{'UNKNOWN'};
}
if ($result_threshold==0) {
print "Division by zero \n";
exit $ERRORS{'CRITICAL'};
}
if ($result_condition=="2") {
$result_condition="OK";
}
else {
$result_condition=$result_condition." (other)";
}
$q=$result_celsius/$result_threshold ;
$diff=$result_threshold-$result_celsius ;
if ( $q > $critical ) {
print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
exit $ERRORS{'CRITICAL'} ;
}
elsif ( $q > $warning ) {
print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
exit $ERRORS{'WARNING'} ;
}
else {
print "Sensor " .$sensor. " (".$CPQ_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
exit $ERRORS{'OK'} ;
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> [-w <warn>] [-c <crit>]\n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1113 $\n ');
print "Copyright (c) 2003 Rainer Duffner\n ";
print_usage();
print "\n";
print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
print "<port> = SNMP-Port (normaly 161)\n";
print "<community> = SNMP v1 community\n";
print "<sensornumber> = Sensornumber (1, 2, 3 etc.)\n";
print "<warn> = report warning when more than <warn> % of the temperature is reached defaults to 80\n";
print "<crit> = report critical when more than <crit> % of the temperature is reached defaults to 90\n";
}
sub version () {
print_revision($PROGNAME,'$Revision: 1113 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

View file

@ -1,160 +0,0 @@
#!/usr/bin/perl
#
#
# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
#
# NetSaint host script to get the disk usage from NT snmp
#
# Changes and Modifications
# =========================
# 3-Aug-2000 - Xavier Dusart
# Created
# 2003 - Rainer Duffner
BEGIN {
if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
$runtimedir = $1;
$PROGNAME = $2;
}
}
require 5.004;
use POSIX;
#use strict;
use Getopt::Std ;
use BER;
require 'SNMP_Session.pm';
use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
use lib $main::runtimedir;
use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
use snmputil qw(%FSC_LOCALE %FSC_TEMP_CONDITION);
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
getopts('H:p:C:s:w:c:hV') ;
my $ip_address=undef ;
if ($opt_h) {&help();}
if ($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]*)*)$/) {
$ip_address = $opt_H ;
}
else {
usage();
print "IP-Address format wrong\n";
exit $ERRORS{'UNKNOWN'};
}
#if ($opt_p =~ m/^[0-9]
my $port = $opt_p;
my $community = $opt_C;
my $sensor = $opt_s ;
#my $warning = $opt_w;
#my $critical = $opt_c;
my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,4,0,$sensor-1 );
# not used for the moment - gives no usable output
# if reused, enter at end of list to avoid renumbering !
my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,11,0,$sensor-1 );
my $temperature_warning_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,6,0,$sensor-1 );
my $temperature_critical_oid =encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,8,0,$sensor-1 );
my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,3,0,$sensor-1 );
my $count=1 ;
my $label ;
my @r_array=();
my $q ;
my $diff ;
$warning=$warning/100 ;
$crititcal=$critical/100 ;
# get temperature, temperature_threshold bfore shutdown
my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
if ($session->get_request_response ($temperature_celsius_oid, $temperature_warning_oid, $temperature_critical_oid, $temperature_condition_oid, $temperature_locale_oid )) {
(my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
while ($bindings ne '') {
($binding, $bindings) = &decode_sequence ($bindings) ;
($oid,$value) = &decode_by_template ($binding,"%O%@");
$r_array[$count]=&pretty_print($value);
$count++;
}
} else {
print "No response from agent\n";
exit $ERRORS{'CRITICAL'};
}
$result_celsius=$r_array[1];
$result_warning=$r_array[2];
$result_critical=$r_array[3];
$result_condition=$r_array[4];
$result_locale=$r_array[5];
if ($result_celsius < 0) {
print "Result is negative - Sensor unavailable ?\n";
exit $ERRORS{'UNKNOWN'};
}
if ($result_warning==0) {
print "Division by zero \n";
exit $ERRORS{'CRITICAL'};
}
if ($result_critical==0) {
print "Division by zero \n";
exit $ERRORS{'CRITICAL'};
}
# $q=$result_celsius/$result_threshold ;
$diff=$result_critical-$result_celsius ;
if ( $result_celsius > $result_critical ) {
print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Crit-Threshold:".$result_critical." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
exit $ERRORS{'CRITICAL'} ;
}
elsif ( $result_celsius > $result_warning ) {
print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Crit-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition}."\n" ;
exit $ERRORS{'WARNING'} ;
}
else {
print "Sensor " .$sensor. " (".$FSC_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Warn-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
exit $ERRORS{'OK'} ;
}
sub print_usage () {
print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> \n";
}
sub print_help () {
print_revision($PROGNAME,'$Revision: 1113 $\n ');
print "Copyright (c) 2003 Rainer Duffner\n ";
print_usage();
print "\n";
print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
print "<port> = SNMP-Port (normaly 161)\n";
print "<community> = SNMP v1 community\n";
print "<drvnumber> = Sensornumber (1, 2, 3 etc.)\n";
}
sub version () {
print_revision($PROGNAME,'$Revision: 1113 $ ');
exit $ERRORS{'OK'};
}
sub help () {
print_help();
exit $ERRORS{'OK'};
}

Some files were not shown because too many files have changed in this diff Show more