Merge branch 'master' into master

This commit is contained in:
Lorenz Kästle 2023-09-20 08:16:11 +02:00 committed by GitHub
commit a5ba424f85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
94 changed files with 2646 additions and 5403 deletions

View file

@ -25,8 +25,9 @@
'NP_HOST_TCP_POP' => 'pop.web.de',
'NP_HOST_TCP_PROXY' => 'localhost',
'NP_HOST_TCP_SMTP' => 'localhost',
'NP_HOST_TCP_SMTP_NOTLS' => '',
'NP_HOST_TCP_SMTP_TLS' => '',
'NP_HOST_TCP_SMTP_NOSTARTTLS' => '',
'NP_HOST_TCP_SMTP_STARTTLS' => 'localhost',
'NP_HOST_TCP_SMTP_TLS' => 'localhost',
'NP_HOST_TLS_CERT' => 'localhost',
'NP_HOST_TLS_HTTP' => 'localhost',
'NP_HOST_UDP_TIME' => 'none',

View file

@ -1,3 +1,4 @@
---
version: 2
updates:
- package-ecosystem: github-actions

View file

@ -5,13 +5,18 @@ set -e
export DEBIAN_FRONTEND=noninteractive
sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
apt-get update
apt-get -y install software-properties-common
if [ $(lsb_release -is) = "Debian" ]; then
apt-add-repository non-free
apt-get update
source /etc/os-release
if [ ${ID} = "debian" ]; then
if [ -f /etc/apt/sources.list.d/debian.sources ]; then
sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
else
apt-get update
apt-get -y install software-properties-common
apt-add-repository non-free
fi
fi
apt-get update
apt-get -y install perl \
autotools-dev \
libdbi-dev \
@ -83,7 +88,7 @@ cp tools/squid.conf /etc/squid/squid.conf
service squid start
# mariadb
service mariadb start
service mariadb start || service mysql start
mysql -e "create database IF NOT EXISTS test;" -uroot
# ldap
@ -103,12 +108,7 @@ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
disown %1
# snmpd
for DIR in /usr/share/snmp/mibs /usr/share/mibs; do
rm -f $DIR/ietf/SNMPv2-PDU \
$DIR/ietf/IPSEC-SPD-MIB \
$DIR/ietf/IPATM-IPMC-MIB \
$DIR/iana/IANA-IPPM-METRICS-REGISTRY-MIB
done
service snmpd stop
mkdir -p /var/lib/snmp/mib_indexes
sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf
service snmpd start
@ -116,7 +116,11 @@ service snmpd start
# start cron, will be used by check_nagios
cron
# start postfix
# postfix
cat <<EOD >> /etc/postfix/master.cf
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
EOD
service postfix start
# start ftpd

View file

@ -1,3 +1,4 @@
---
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
@ -13,10 +14,10 @@ name: "CodeQL"
on:
push:
branches: [ master ]
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
branches: [master]
schedule:
- cron: '15 18 * * 0'
@ -32,41 +33,41 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
language: ['cpp']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Install packages
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
- name: Install packages
run: |
sudo apt update
sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
- name: Configure build
run: |
./tools/setup
./configure --enable-libtap
- name: Configure build
run: |
./tools/setup
./configure --enable-libtap
- name: Build
run: |
make
- name: Build
run: |
make
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View file

@ -1,15 +1,48 @@
---
name: Test
on:
push:
branches:
- '*'
# Run test for any PRs
pull_request:
jobs:
codespell:
name: codespell
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
with:
skip: "./.git,./.gitignore,./ABOUT-NLS,*.po,./gl,./po,./tools/squid.conf,./build-aux/ltmain.sh"
ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners
check_filenames: true
check_hidden: true
# super-linter:
# name: super-linter
# strategy:
# fail-fast: false
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Lint Code Base
# uses: github/super-linter@v5.0.0
# env:
# DEFAULT_BRANCH: master
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# macos:
# ...
linux:
needs:
- codespell
# - super-linter
runs-on: ubuntu-latest
name: Running tests on ${{ matrix.distro }}
strategy:
@ -24,7 +57,7 @@ jobs:
#...
steps:
- name: Git clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
#- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
# uses: mxschmitt/action-tmate@v3
- name: Run the tests on ${{ matrix.distro }}
@ -41,6 +74,10 @@ jobs:
/bin/sh -c '${{ matrix.prepare }} && \
tools/setup && \
./configure --enable-libtap --with-ipv6=no && \
set -x && \
tmp_dir=$(mktemp -d -t test-XXXX) && cp -a po/ $tmp_dir/ && \
cd po && make update-po && cd .. && \
diff -Nur $tmp_dir/po/*.po po/*.po | tee -a /tmp/po.diff && diff -Nur $tmp_dir/po/*.pot po/*.pot | tee -a /tmp/po.diff && if [ $(wc -l /tmp/po.diff | cut -f 1 -d" ") -gt 0 ]; then echo "Error: Translations needs to be updated with make update-po!" && exit 1; fi && \
make && \
make test'
docker container prune -f

1
.gitignore vendored
View file

@ -246,6 +246,7 @@ NP-VERSION-FILE
/plugins-scripts/check_ircd
/plugins-scripts/check_log
/plugins-scripts/check_mailq
/plugins-scripts/check_mssql
/plugins-scripts/check_ntp
/plugins-scripts/check_oracle
/plugins-scripts/check_rpc

View file

@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
Stenberg, Daniel
Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
http://curl.haxx.se/
Use of duplication of macros in m4/np_curl.m4 (slighly adapted for m4/uriparser.m4 too)
Use of duplication of macros in m4/np_curl.m4 (slightly adapted for m4/uriparser.m4 too)
Coreutils team
Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.

30
NEWS
View file

@ -9,12 +9,12 @@ This file documents the major additions and syntax changes between releases.
check_http/check_curl: add chunked encoding test
check_log: Added --exclude to exclude patterns
check_log: Add tests
check_disk: Clarify usage possibilites
check_disk: Clarify usage possibilities
FIXES
fixed two PRId64 to PRIu64 in perfdata_uint64
check_pgsql: Removing is_pg_dbname alltogether,using postgres API.
check_http: Remove superflous CRLF in HTTP-Requests
check_pgsql: Removing is_pg_dbname altogether,using postgres API.
check_http: Remove superfluous CRLF in HTTP-Requests
check_curl: detect ipv6
check_icmp: fix parsing help/version long options
check_http: fix test plan
@ -40,7 +40,7 @@ This file documents the major additions and syntax changes between releases.
2.3.2 20th Oct 2022
GENERAL
Use netcat-openbsd for debian explicitely (by @RincewindsHat #1704)
Use netcat-openbsd for debian explicitly (by @RincewindsHat #1704)
Replace egrep with grep -E (by @RincewindsHat #1791)
Use silent automake by default (by @RincewindsHat #1747)
@ -123,7 +123,7 @@ This file documents the major additions and syntax changes between releases.
check_log: Modernize check log (by @RincewindsHat #1692)
check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
check_pgsql: Using snprintf which honors the buffers size and guarantees null temination. (Closes: #1601) (by @waja #1663)
check_pgsql: Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601) (by @waja #1663)
check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
@ -165,7 +165,7 @@ This file documents the major additions and syntax changes between releases.
check_apt: adding packages-warning option
check_load: Adding top consuming processes option
check_http: Adding Proxy-Authorization and extra headers
check_snmp: make calcualtion of timeout value in help output more clear
check_snmp: make calculation of timeout value in help output more clear
check_uptime: new plugin for checking uptime to see how long the system is running
check_curl: check_http replacement based on libcurl
check_http: Allow user to specify HTTP method after proxy CONNECT
@ -195,7 +195,7 @@ This file documents the major additions and syntax changes between releases.
check_procs: improve command examples for 'at least' processes
check_swap: repaired "-n" behaviour
check_disk: include -P switch in help
check_mailq: restore accidentially removed options
check_mailq: restore accidentally removed options
2.2 29th November 2016
ENHANCEMENTS
@ -236,7 +236,7 @@ This file documents the major additions and syntax changes between releases.
check_ssh now returns CRITICAL for protocol/version errors
If a plugin is invoked with -h/--help or -V/--version, the exit status
is now UNKNOWN
The superseeded check_ntp.pl was removed, please use check_ntp_peer or
The superseded check_ntp.pl was removed, please use check_ntp_peer or
check_ntp_time instead
2.1.2 16th October 2015
@ -263,7 +263,7 @@ This file documents the major additions and syntax changes between releases.
New check_mysql -n option to ignore authentication failures
Added IP and port or socket name to error messages
New check_ntp_time -o option to add expected offset
check_disk shows now troubled partions in verbose mode
check_disk shows now troubled partitions in verbose mode
check_dig has now support for drill and dig
check_dig has now support for -6 option
Add performance data to check_file_age
@ -357,10 +357,10 @@ This file documents the major additions and syntax changes between releases.
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
Let check_mysql add performance 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
New check_snmp --offset option to allow for adding/subtracting an offset value to sensor data
Let check_snmp support an arbitrary number of OIDs
Let check_ide_smart support NetBSD
@ -375,7 +375,7 @@ This file documents the major additions and syntax changes between releases.
Fix deprecated imports of check_nmap.py
WARNINGS
check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead.
check_http behaviour of -k/--header changed since it does not separate multiple headers by semicolons anymore. Use multiple -k switches instead.
check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
The contrib directory has been removed from this distribution
@ -526,7 +526,7 @@ This file documents the major additions and syntax changes between releases.
check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
check_mysql and check_mysql_query now support sockets explicitely (-s, --socket)
check_mysql and check_mysql_query now support sockets explicitly (-s, --socket)
negate now has the ability to replace the status text as well (-s, --substitute)
Added performance data to check_ping
Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
@ -566,7 +566,7 @@ This file documents the major additions and syntax changes between releases.
New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
Thus accessibility of remote filesystems can be checked without any threshold comparison.
Check_disk's --help now prints some examples for the new features introduced in 1.4.8
New check_disk -i/-I option to ignore pathes/partitions based on regular expressions
New check_disk -i/-I option to ignore paths/partitions based on regular expressions
New check_disk -A option to select all filesystems explicitly
WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
Passing -E after -p or -r results in UNKNOWN state, now
@ -615,7 +615,7 @@ This file documents the major additions and syntax changes between releases.
Fixed MKINSTALLDIRS problem in po/
./configure now detects if possible to compile check_mysql
Fixed broken HELO in check_smtp
check_icmp now allows to set a minimum number of hosts required for successs (-m)
check_icmp now allows to set a minimum number of hosts required for success (-m)
check_icmp fix for *BSD when running for long time
check_ping times out 1 second quicker if host is unreachable
Root plugins installed with world executable

View file

@ -151,14 +151,14 @@ of testing against a set of desired exit status values.
=item *
Firstly, if C<$desiredExitStatus> is a reference to an array of exit
stati, if the actual exit status of the command is present in the
statuses, if the actual exit status of the command is present in the
array, it is used in the call to C<Test::ok(...)> when testing the
exit status.
=item *
Alternatively, if C<$desiredExitStatus> is a reference to a hash of
exit stati (mapped to the strings "continue" or "skip"), similar
exit statuses(mapped to the strings "continue" or "skip"), similar
processing to the above occurs with the side affect of determining if
any generated output testing should proceed. Note: only the string
"skip" will result in generated output testing being skipped.
@ -207,7 +207,7 @@ under the same terms as the Monitoring Plugins release.
my( %CACHE ) = ();
# I'm not really sure wether to house a site-specific cache inside
# I'm not really sure whether to house a site-specific cache inside
# or outside of the extracted source / build tree - lets default to outside
my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";

14
ROADMAP
View file

@ -7,7 +7,7 @@ With that done, it's time to figure out what we are doing for release
1.3 development. I have a few ideas. Maybe others do as well.
DOCUMENTATION:
We pretty much have decieded that we will doing something along
We pretty much have decided that we will doing something along
the lines of a literate programming model. So far, we have site
documentation in DocBook. I have some ideas here, which I will
discuss in a separate thread.
@ -39,9 +39,9 @@ inconsistent mess and I'd love to ditch it. I only created it to
satisfy people that wanted reverse compatibility and did not have
GNU getopt.
Bu I would like to urge that all standard plugins contain
But I would like to urge that all standard plugins contain
validate_arguments(). I think this will help convey the idea that
validations hould be done, even if we don't insist on the specific
validations should be done, even if we don't insist on the specific
extent that each plugin must do that validation.
This is the set of standard options I envision:
@ -59,7 +59,7 @@ Reserved:
-F, --file = STRING (usually input)
-O, --output = STRING (output file)
Recommended, but not reserverd:
Recommended, but not reserved:
-I, --ipaddress = STRING
-C, --community = STRING
@ -69,7 +69,7 @@ Recommended, but not reserverd:
-P, --port = INT
-u, --url = STRING (also --username if --url is not needed)
I am suggesting that port alway be '-P' (uppercase) -- we are
I am suggesting that port always be '-P' (uppercase) -- we are
currently inconsistent in that regard.
I am also adding '-q' for silent running. This is totally self
@ -87,12 +87,12 @@ Programming:
length character assignments, at least to the extent possible,
from the C-based plugins. To that end, I have made strscpy and
friends in utils.c -- I'd like to deploy them. I have comments
that there is alot of duplicated code, and techniques used that
that there is a lot of duplicated code, and techniques used that
should be cleaned up. Details in a separate thread.
Remote checks:
I have a proposal in hand to incorporate ssh check into spopen()
so that remote machine checks can be seemless. A nice idea, but
so that remote machine checks can be seamless. A nice idea, but
complex enough to require discussion. Another thread.
I also have a wish list, and I'm sure I've forgot some items. I'll

View file

@ -405,3 +405,4 @@ Robert Bohne
Wolfgang Nieder
andrew bezella
Lorenz Gruenwald
John Morrissey

View file

@ -189,7 +189,7 @@ func_basename ()
# to NONDIR_REPLACEMENT.
# value returned in "$func_dirname_result"
# basename: Compute filename of FILE.
# value retuned in "$func_basename_result"
# value returned in "$func_basename_result"
# Implementation must be kept synchronized with func_dirname
# and func_basename. For efficiency, we do not delegate to
# those functions but instead duplicate the functionality here.
@ -522,7 +522,7 @@ func_mkdir_p ()
# While some portion of DIR does not yet exist...
while test ! -d "$my_directory_path"; do
# ...make a list in topmost first order. Use a colon delimited
# list incase some portion of path contains whitespace.
# list in case some portion of path contains whitespace.
my_dir_list="$my_directory_path:$my_dir_list"
# If the last portion added has no slash in it, the list is done
@ -4394,7 +4394,7 @@ EOF
{
/* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
namespace, but it is not one of the ones we know about and
have already dealt with, above (inluding dump-script), then
have already dealt with, above (including dump-script), then
report an error. Otherwise, targets might begin to believe
they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
namespace. The first time any user complains about this, we'll

View file

@ -30,7 +30,7 @@ int main(){
/* pipefd[1] is for writing to the pipe. We want the output
* that used to go to the standard output (file descriptor 1)
* to be written to the pipe. The following command does this,
* creating a new file descripter 1 (the lowest available)
* creating a new file descriptor 1 (the lowest available)
* that writes where pipefd[1] goes. */
dup (pipefd[1]); /* points pipefd at file descriptor */
/* the child isn't going to read from the pipe, so

View file

@ -328,6 +328,25 @@ AS_IF([test "x$with_ldap" != "xno"], [
LIBS="$_SAVEDLIBS"
])
AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
dnl Check for libsystemd
AS_IF([test "x$with_systemd" != "xno"], [
_SAVEDLIBS="$LIBS"
AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
SYSTEMDLIBS="-lsystemd"
SYSTEMDINCLUDE=""
AC_SUBST(SYSTEMDLIBS)
AC_SUBST(SYSTEMDINCLUDE)
else
AC_MSG_WARN([Skipping systemd support])
fi
LIBS="$_SAVEDLIBS"
])
dnl Check for headers used by check_ide_smart
case $host in
*linux*)
@ -932,7 +951,7 @@ elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
then
ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
# There must be no space between the %s and %n due to a wierd problem in sscanf where
# There must be no space between the %s and %n due to a weird problem in sscanf where
# it will return %n as longer than the line length
ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
ac_cv_ps_cols=9
@ -1552,7 +1571,7 @@ if test -n "$PATH_TO_SUDO"
then
AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
else
AC_MSG_WARN([Could not find sudo or eqivalent])
AC_MSG_WARN([Could not find sudo or equivalent])
fi
AC_PATH_PROG(PATH_TO_MAILQ,mailq)
@ -1563,7 +1582,7 @@ if test -n "$PATH_TO_MAILQ"
then
AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
else
AC_MSG_WARN([Could not find mailq or eqivalent])
AC_MSG_WARN([Could not find mailq or equivalent])
fi
AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
@ -1574,7 +1593,7 @@ if test -n "$PATH_TO_QMAIL_QSTAT"
then
AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
else
AC_MSG_WARN([Could not find qmail-qstat or eqivalent])
AC_MSG_WARN([Could not find qmail-qstat or equivalent])
fi
dnl SWAP info required is amount allocated/available and amount free
@ -1592,13 +1611,13 @@ then
grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
>/dev/null]
then
ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"]
ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
ac_cv_swap_conv=2048
AC_MSG_RESULT([using IRIX format swap])
elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
then
ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"]
ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
ac_cv_swap_conv=2048
AC_MSG_RESULT([using Unixware format swap])
else
@ -1622,7 +1641,7 @@ then
if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
then
ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_format=["%*s %lu %*d %lu"]
ac_cv_swap_conv=1024
AC_MSG_RESULT([using FreeBSD format swapinfo])
fi
@ -1631,7 +1650,7 @@ elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE"
then
ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
ac_cv_swap_format=["%*s %f %*d %f"]
ac_cv_swap_format=["%*s %lu %*d %lu"]
ac_cv_swap_conv=1024
AC_MSG_RESULT([using HP-UX format swapinfo])
fi
@ -1646,7 +1665,7 @@ if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
then
ac_cv_have_swap=yes
ac_cv_swap_command="$PATH_TO_LSPS -a"
ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"]
ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
ac_cv_swap_conv=1
AC_MSG_RESULT([using AIX lsps])
fi
@ -1832,7 +1851,7 @@ AM_GNU_GETTEXT([external], [need-ngettext])
AM_GNU_GETTEXT_VERSION(0.15)
dnl Check for Redhat spopen problem
dnl Wierd problem where ECHILD is returned from a wait call in error
dnl Weird problem where ECHILD is returned from a wait call in error
dnl Only appears to affect nslookup and dig calls. Only affects redhat around
dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
dnl We patch plugins/popen.c

View file

@ -31,7 +31,7 @@
<preface id="preface"><title>Preface</title>
<para>The purpose of this guidelines is to provide a reference for
the plugin developers and encourage the standarization of the
the plugin developers and encourage the standardization of the
different kind of plugins: C, shell, perl, python, etc.</para>
<para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013
@ -374,7 +374,7 @@
<listitem><para>s - seconds (also us, ms)</para></listitem>
<listitem><para>% - percentage</para></listitem>
<listitem><para>B - bytes (also KB, MB, TB)</para></listitem>
<listitem><para>c - a continous counter (such as bytes
<listitem><para>c - a continuous counter (such as bytes
transmitted on an interface)</para></listitem>
</orderedlist>
</listitem>
@ -397,7 +397,7 @@
<section><title>Don't execute system commands without specifying their
full path</title>
<para>Don't use exec(), popen(), etc. to execute external
commands without explicity using the full path of the external
commands without explicitly using the full path of the external
program.</para>
<para>Doing otherwise makes the plugin vulnerable to hijacking
@ -655,7 +655,7 @@
<para>If possible when writing lists, use tokens to make the
list easy to remember and non-order dependent - so
check_disk uses '-c 10000,10%' so that it is clear which is
the precentage and which is the KB values (note that due to
the percentage and which is the KB values (note that due to
my own lack of foresight, that used to be '-c 10000:10%' but
such constructs should all be changed for consistency,
though providing reverse compatibility is fairly
@ -686,7 +686,7 @@ all the current tests and report an overall success rate.
<para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t".
</para>
<para>There will somtimes be failures seen in this output which are known failures that
<para>There will sometimes be failures seen in this output which are known failures that
need to be fixed. As long as the return code is 0, it will be reported as "test pass".
(If you have a fix so that the specific test passes, that will be gratefully received!)
</para>
@ -733,12 +733,9 @@ setup the tests. Run "make test" to run all the tests.
<para>Variables should be declared at the beginning of code blocks and
not inline because of portability with older compilers.</para>
<para>You should use /* */ for comments and not // as some compilers
do not handle the latter form.</para>
<para>You should also avoid using the type "bool" and its values
"true" and "false". Instead use the "int" type and the plugins' own
"TRUE"/"FALSE" values to keep the code uniformly.</para>
<para>You should use the type "bool" and its values
"true" and "false" instead of the "int" type for booleans.
</para>
</section>
<section><title>Crediting sources</title>
@ -846,7 +843,7 @@ setup the tests. Run "make test" to run all the tests.
<para>It is determined to be not redundant (for instance, we would not
add a new version of check_disk just because someone had provide
a plugin that had perf checking - we would incorporate the features
into an exisiting plugin)</para>
into an existing plugin)</para>
</listitem>
<listitem>
<para>One of the developers has had the time to audit the code and declare

View file

@ -78,7 +78,7 @@ static char *default_file_in_path(void);
/*
* Parse_locator decomposes a string of the form
* [stanza][@filename]
* into its seperate parts.
* into its separate parts.
*/
static void
parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
@ -169,7 +169,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
if (isspace(c))
continue;
switch (c) {
/* globble up coment lines */
/* globble up comment lines */
case ';':
case '#':
GOBBLE_TO(f, c, '\n');

View file

@ -176,14 +176,14 @@ main (int argc, char **argv)
ok (result == UNSET, "(initialised) Checking exit code is reset");
command = (char *)malloc(COMMAND_LINE);
strcpy(command, "/bin/echo3456 non-existant command");
strcpy(command, "/bin/echo3456 non-existent command");
result = cmd_run (command, &chld_out, &chld_err, 0);
ok (chld_out.lines == 0,
"Non existant command, so no output");
"Non existent command, so no output");
ok (chld_err.lines == 0,
"No stderr either");
ok (result == 3, "Get return code 3 (?) for non-existant command");
ok (result == 3, "Get return code 3 (?) for non-existent command");
/* ensure everything is empty again */
@ -192,14 +192,14 @@ main (int argc, char **argv)
result = UNSET;
command = (char *)malloc(COMMAND_LINE);
strcpy(command, "/bin/sh non-existant-file");
strcpy(command, "/bin/sh non-existent-file");
result = cmd_run (command, &chld_out, &chld_err, 0);
ok (chld_out.lines == 0,
"/bin/sh returns no stdout when file is missing...");
ok (chld_err.lines == 1,
"...but does give an error line");
ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message");
ok (strstr(chld_err.line[0],"non-existent-file") != NULL, "And missing filename is in error message");
ok (result != 0, "Get non-zero return code from /bin/sh");
@ -219,11 +219,11 @@ main (int argc, char **argv)
result = UNSET;
command = (char *)malloc(COMMAND_LINE);
strcpy(command, "/bin/non-existant-command");
strcpy(command, "/bin/non-existent-command");
result = cmd_run (command, &chld_out, &chld_err, 0);
ok (chld_out.lines == 0,
"/bin/non-existant-command returns no stdout...");
"/bin/non-existent-command returns no stdout...");
ok (chld_err.lines == 0,
"...and no stderr output either");
ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist");

View file

@ -88,10 +88,10 @@ main (int argc, char **argv)
cflags, 3,strdup("regex on dev names:"));
np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"),
cflags, 0,
strdup("regex on non existant dev/path:"));
strdup("regex on non existent dev/path:"));
np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"),
cflags | REG_ICASE,0,
strdup("regi on non existant dev/path:"));
strdup("regi on non existent dev/path:"));
np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"),
cflags, 3,
strdup("partial devname regex match:"));

View file

@ -10,7 +10,7 @@ if (! -e "./test_ini3") {
# array of argument arrays
# - First value is the expected return code
# - 2nd value is the NAGIOS_CONFIG_PATH
# TODO: looks like we look in default path after looking trough this variable - shall we?
# TODO: looks like we look in default path after looking through this variable - shall we?
# - 3rd value is the plugin name
# - 4th is the ini locator
my @TESTS = (

View file

@ -10,7 +10,7 @@ if (! -e "./test_opts3") {
# array of argument arrays
# - First value is the expected return code
# - 2nd value is the NAGIOS_CONFIG_PATH
# TODO: looks like we look in default path after looking trough this variable - shall we?
# TODO: looks like we look in default path after looking through this variable - shall we?
# - 3rd value is the plugin name
# - 4th and up are arguments
my @TESTS = (

View file

@ -395,7 +395,7 @@ main (int argc, char **argv)
ok( temp_state_data==NULL, "Older data version gives NULL" );
temp_state_key->data_version=54;
temp_state_key->_filename="var/nonexistant";
temp_state_key->_filename="var/nonexistent";
temp_state_data = np_state_read();
ok( temp_state_data==NULL, "Missing file gives NULL" );
ok( this_monitoring_plugin->state->state_data==NULL, "No state information" );

View file

@ -24,7 +24,7 @@
*
*****************************************************************************/
#include "common.h"
#include "../plugins/common.h"
#include <stdarg.h>
#include "utils_base.h"
#include <ctype.h>
@ -319,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
while (1) {
/* Strip any leading space */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (strncmp(name, varlist, strlen(name)) == 0) {
varlist += strlen(name);
/* strip trailing spaces */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (varlist[0] == '=') {
/* We matched the key, go past the = sign */
varlist++;
/* strip leading spaces */
for (varlist; isspace(varlist[0]); varlist++);
for (; isspace(varlist[0]); varlist++);
if (tmp = index(varlist, sep)) {
/* Value is delimited by a comma */

View file

@ -118,10 +118,6 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
int i = 0;
/* if no command was passed, return with no error */
if (argv == NULL)
return -1;
if (!_cmd_pids)
CMD_INIT;
@ -161,7 +157,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
}
/* parent picks up execution here */
/* close childs descriptors in our address space */
/* close children descriptors in our address space */
close (pfd[1]);
close (pfderr[1]);

View file

@ -147,24 +147,25 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
/* set best match if path name exactly matches a mounted device name */
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
if (strcmp(me->me_devname, d->name)==0)
best_match = me;
if (strcmp(me->me_devname, d->name)==0) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
best_match = me;
}
}
}
/* set best match by directory name if no match was found by devname */
if (! best_match) {
for (me = mount_list; me; me = me->me_next) {
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
continue; /* skip if permissions do not suffice for accessing device */
size_t len = strlen (me->me_mountdir);
if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
(len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
|| (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
{
best_match = me;
best_match_len = len;
if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
best_match = me;
best_match_len = len;
}
}
}
}

View file

@ -81,7 +81,7 @@ AC_DEFUN([np_check_lib_mariadbclient],
], [with_mysql=no], [$np_mysql_libs])
])
dnl Will take $1, find last occurrance of -LDIR and add DIR to LD_RUN_PATH
dnl Will take $1, find last occurrence of -LDIR and add DIR to LD_RUN_PATH
AC_DEFUN([np_add_to_runpath],
[
dnl Need [[ ]] so autoconf gives us just one set

View file

@ -1,4 +1,4 @@
# (this check is rougly based on and inspired libcurl.m4)
# (this check is roughly based on and inspired libcurl.m4)
# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION],
# [ACTION-IF-YES], [ACTION-IF-NO])
# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to

View file

@ -229,7 +229,7 @@ struct in_addr requested_address;
int process_arguments(int, char **);
int call_getopt(int, char **);
int validate_arguments(int, int);
int validate_arguments(int);
void print_usage(void);
void print_help(void);
@ -470,10 +470,6 @@ int send_dhcp_discover(int sock){
packet_xid=random();
discover_packet.xid=htonl(packet_xid);
/**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/
/* downright bizzarre... */
ntohl(discover_packet.xid);
/*discover_packet.secs=htons(65535);*/
discover_packet.secs=0xFF;
@ -1059,8 +1055,8 @@ int process_arguments(int argc, char **argv){
return ERROR;
arg_index = call_getopt(argc,argv);
return validate_arguments(argc,arg_index);
}
return validate_arguments(argc);
}
@ -1158,13 +1154,13 @@ int call_getopt(int argc, char **argv){
}
int validate_arguments(int argc, int arg_index){
int validate_arguments(int argc){
if(argc-optind > 0)
if(argc - optind > 0)
usage(_("Got unexpected non-option argument"));
return OK;
}
}
#if defined(__sun__) || defined(__solaris__) || defined(__hpux__)

View file

@ -274,7 +274,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code)
break;
case ICMP_TIMXCEED:
/* really 'out of reach', or non-existant host behind a router serving
/* really 'out of reach', or non-existent host behind a router serving
* two different subnets */
switch(icmp_code) {
case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break;
@ -1432,15 +1432,20 @@ get_ip_address(const char *ifname)
{
// TODO: Rewrite this so the function return an error and we exit somewhere else
struct sockaddr_in ip;
ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy
#if defined(SIOCGIFADDR)
struct ifreq ifr;
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1)
crash("Cannot determine IP address of interface %s", ifname);
memcpy(&ip, &ifr.ifr_addr, sizeof(ip));
#else
(void) ifname;
errno = 0;
crash("Cannot get interface IP address on this platform.");
#endif

View file

@ -257,6 +257,6 @@ void usage() {
printf("\tRSS - Real memory usage (kilobytes)\n");
printf("\t%%CPU - CPU usage\n");
printf("\tCOMMAND - Command being run\n");
printf("\tARGS - Full command line with arguements\n");
printf("\tARGS - Full command line with arguments\n");
return;
}

View file

@ -92,5 +92,5 @@ like( $res->output, $successOutput, "Output OK" );
$res = NPTest->testCmd(
"$sudo ./check_icmp -H $host_responsive -b 65507"
);
is( $res->return_code, 0, "Try max paket size" );
is( $res->return_code, 0, "Try max packet size" );
like( $res->output, $successOutput, "Output OK - Didn't overflow" );

View file

@ -16,13 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/
libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
check_log check_oracle check_rpc check_sensors check_wave \
check_ifstatus check_ifoperstatus check_mailq check_file_age \
check_uptime \
check_uptime check_mssql \
utils.sh utils.pm
EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
check_uptime.pl \
check_uptime.pl check_mssql.pl \
utils.sh.in utils.pm.in t
EDIT = sed \

View file

@ -14,8 +14,9 @@ sub print_help ();
sub print_usage ();
$ENV{'PATH'}='@TRUSTED_PATH@';
$ENV{'BASH_ENV'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$ENV{'CDPATH'}='';
Getopt::Long::Configure('bundling');
GetOptions

View file

@ -28,7 +28,7 @@ use FindBin;
use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# make us session leader which makes all childs exit if we do
# make us session leader which makes all children exit if we do
setsid;
sub print_help ();

View file

@ -134,7 +134,7 @@ if (defined $ifdescr || defined $iftype) {
}
if ($status==0) {
$state = "UNKNOWN";
printf "$state: could not retrive ifdescr/iftype snmpkey - $status-$snmpkey\n";
printf "$state: could not retrieve ifdescr/iftype snmpkey - $status-$snmpkey\n";
$session->close;
exit $ERRORS{$state};
}
@ -187,7 +187,7 @@ if (defined $ifXTable) {
$name = $response->{$snmpIfDescr} ;
}
## if AdminStatus is down - some one made a consious effort to change config
## if AdminStatus is down - some one made a conscious effort to change config
##
if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
$answer = "Interface $name (index $snmpkey) is administratively down.";
@ -286,7 +286,7 @@ sub print_usage() {
printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n";
printf "Copyright (C) 2000 Christoph Kron\n";
printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n";
printf "This programm is licensed under the terms of the ";
printf "This program is licensed under the terms of the ";
printf "GNU General Public License\n(check source code for details)\n";
printf "\n\n";
}
@ -424,7 +424,7 @@ sub process_arguments() {
if (defined $seclevel && defined $secname) {
$session_opts{'-username'} = $secname;
# Must define a security level even though defualt is noAuthNoPriv
# Must define a security level even though default is noAuthNoPriv
unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
usage("Must define a valid security level even though default is noAuthNoPriv");
}

View file

@ -370,7 +370,7 @@ sub process_arguments() {
if (defined $seclevel && defined $secname) {
$session_opts{'-username'} = $secname;
# Must define a security level even though defualt is noAuthNoPriv
# Must define a security level even though default is noAuthNoPriv
unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
usage("Must define a valid security level even though default is noAuthNoPriv");
}

View file

@ -60,7 +60,7 @@ sub print_usage ();
sub connection ($$$$);
sub bindRemote ($$);
# -------------------------------------------------------------[ Enviroment ]--
# -------------------------------------------------------------[ Environment ]--
$ENV{'PATH'}='@TRUSTED_PATH@';
$ENV{'BASH_ENV'}='';
@ -208,7 +208,7 @@ MAIN:
# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
exit $ERRORS{"UNKNOWN"};
};

View file

@ -105,11 +105,11 @@ while test -n "$1"; do
case "$1" in
-h | --help)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-V | --version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-F | --filename)
logfile=$2

View file

@ -4,7 +4,7 @@
# transmittal.
#
# Initial version support sendmail's mailq command
# Support for mutiple sendmail queues (Carlos Canau)
# Support for multiple sendmail queues (Carlos Canau)
# Support for qmail (Benjamin Schmid)
# License Information:
@ -149,7 +149,26 @@ if ($mailq eq "sendmail") {
##/var/spool/mqueue/qF/df is empty
## Total Requests: 1
# separate submission/transport queues, empty
## MSP Queue status...
## /var/spool/mqueue-client is empty
## Total requests: 0
## MTA Queue status...
## /var/spool/mqueue is empty
## Total requests: 0
# separate submission/transport queues: 1
## MSP Queue status...
## /var/spool/mqueue-client (1 request)
## -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
## oAJEfhdW014123 5 Fri Nov 19 14:41 jwm
## (Deferred: Connection refused by [127.0.0.1])
## root
## Total requests: 1
## MTA Queue status...
## /var/spool/mqueue is empty
## Total requests: 0
my $this_msg_q = 0;
while (<MAILQ>) {
# match email addr on queue listing
@ -189,13 +208,18 @@ if ($mailq eq "sendmail") {
#
# single queue: first line
# multi queue: one for each queue. overwrite on multi queue below
$msg_q = $1 ;
$this_msg_q = $1 ;
$msg_q += $1 ;
}
} elsif (/^\s+Total\sRequests:\s(\d+)$/i) {
print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
#
# multi queue: last line
$msg_q = $1 ;
if ($this_msg_q) {
$this_msg_q = 0 ;
} else {
print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
#
# multi queue: last line
$msg_q += $1 ;
}
}
}

View file

@ -86,20 +86,20 @@ esac
# Information options
case "$cmd" in
--help)
print_help
exit "$STATE_OK"
print_help
exit "$STATE_UNKNOWN"
;;
-h)
print_help
exit "$STATE_OK"
print_help
exit "$STATE_UNKNOWN"
;;
--version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_UNKNOWN"
;;
-V)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_UNKNOWN"
;;
esac

View file

@ -5,7 +5,7 @@
# usage:
# check_rpc host service
#
# Check if an rpc serice is registered and running
# Check if an rpc service is registered and running
# using rpcinfo - $proto $host $prognum 2>&1 |";
#
# Use these hosts.cfg entries as examples

View file

@ -26,19 +26,19 @@ print_help() {
case "$1" in
--help)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-h)
print_help
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
--version)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
-V)
print_revision "$PROGNAME" "$REVISION"
exit "$STATE_OK"
exit "$STATE_UNKNOWN"
;;
*)
sensordata=$(sensors 2>&1)

View file

@ -110,7 +110,7 @@ $pretty_uptime .= sprintf( "%d week%s, ", $weeks, $weeks == 1 ? "" : "s" ) if
$pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days;
$pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours;
$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins;
# Replace last occurence of comma with "and"
# Replace last occurrence of comma with "and"
$pretty_uptime =~ s/, $/ and /;
# Always print the seconds (though it may be 0 seconds)
$pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" );

View file

@ -19,6 +19,7 @@ sub print_usage ();
$ENV{'PATH'}='@TRUSTED_PATH@';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
$ENV{'CDPATH'}='';
Getopt::Long::Configure('bundling');
GetOptions
@ -50,34 +51,34 @@ my $critical = $1 if ($opt_c =~ /([0-9]+)/);
($opt_w) || ($opt_w = shift) || ($opt_w = 60);
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
$low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
$low1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
@test = split(/ /,$low1);
$low1 = $test[2];
$med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
$med1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
@test = split(/ /,$med1);
$med1 = $test[2];
$high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
$high1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
@test = split(/ /,$high1);
$high1 = $test[2];
sleep(2);
$snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
$snr = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
@test = split(/ /,$snr);
$snr = $test[2];
$snr = int($snr*25);
$low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
$low2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
@test = split(/ /,$low2);
$low2 = $test[2];
$med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
$med2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
@test = split(/ /,$med2);
$med2 = $test[2];
$high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
$high2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
@test = split(/ /,$high2);
$high2 = $test[2];

View file

@ -23,6 +23,7 @@ $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";
$PATH_TO_SNMPGET = "@PATH_TO_SNMPGET@";
## common variables
$TIMEOUT = 15;

View file

@ -112,7 +112,7 @@ check_tcp_LDADD = $(SSLOBJS)
check_time_LDADD = $(NETLIBS)
check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
check_ups_LDADD = $(NETLIBS)
check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS)
check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) $(SYSTEMDLIBS)
check_by_ssh_LDADD = $(NETLIBS)
check_ide_smart_LDADD = $(BASEOBJS)
negate_LDADD = $(BASEOBJS)

View file

@ -55,6 +55,7 @@ const char *email = "devel@monitoring-plugins.org";
#include "uriparser/Uri.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#if defined(HAVE_SSL) && defined(USE_OPENSSL)
#include <openssl/opensslv.h>
@ -243,7 +244,7 @@ void curlhelp_freewritebuffer (curlhelp_write_curlbuf*);
int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t);
int curlhelp_buffer_read_callback (void *, size_t , size_t , void *);
void curlhelp_freereadbuffer (curlhelp_read_curlbuf *);
curlhelp_ssl_library curlhelp_get_ssl_library (CURL*);
curlhelp_ssl_library curlhelp_get_ssl_library ();
const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library);
int net_noopenssl_check_certificate (cert_ptr_union*, int, int);
@ -296,6 +297,7 @@ main (int argc, char **argv)
int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
{
(void) preverify_ok;
/* TODO: we get all certificates of the chain, so which ones
* should we test?
* TODO: is the last certificate always the server certificate?
@ -320,6 +322,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
{
(void) curl; // ignore unused parameter
(void) parm; // ignore unused parameter
SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
return CURLE_OK;
@ -374,8 +378,12 @@ void
handle_curl_option_return_code (CURLcode res, const char* option)
{
if (res != CURLE_OK) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Error while setting cURL option '%s': cURL returned %d - %s"),
option, res, curl_easy_strerror(res));
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Error while setting cURL option '%s': cURL returned %d - %s"),
option,
res,
curl_easy_strerror(res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
}
@ -384,8 +392,11 @@ int
lookup_host (const char *host, char *buf, size_t buflen)
{
struct addrinfo hints, *res, *result;
char addrstr[100];
size_t addrstr_len;
int errcode;
void *ptr;
size_t buflen_remaining = buflen - 1;
memset (&hints, 0, sizeof (hints));
hints.ai_family = address_family;
@ -395,26 +406,40 @@ lookup_host (const char *host, char *buf, size_t buflen)
errcode = getaddrinfo (host, NULL, &hints, &result);
if (errcode != 0)
return errcode;
strcpy(buf, "");
res = result;
while (res) {
inet_ntop (res->ai_family, res->ai_addr->sa_data, buf, buflen);
switch (res->ai_family) {
case AF_INET:
ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
break;
case AF_INET6:
ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
break;
switch (res->ai_family) {
case AF_INET:
ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
break;
case AF_INET6:
ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
break;
}
inet_ntop (res->ai_family, ptr, buf, buflen);
if (verbose >= 1)
inet_ntop (res->ai_family, ptr, addrstr, 100);
if (verbose >= 1) {
printf ("* getaddrinfo IPv%d address: %s\n",
res->ai_family == PF_INET6 ? 6 : 4, buf);
res->ai_family == PF_INET6 ? 6 : 4, addrstr);
}
// Append all IPs to buf as a comma-separated string
addrstr_len = strlen(addrstr);
if (buflen_remaining > addrstr_len + 1) {
if (buf[0] != '\0') {
strncat(buf, ",", buflen_remaining);
buflen_remaining -= 1;
}
strncat(buf, addrstr, buflen_remaining);
buflen_remaining -= addrstr_len;
}
res = res->ai_next;
}
freeaddrinfo(result);
return 0;
@ -445,7 +470,7 @@ check_http (void)
int i;
char *force_host_header = NULL;
struct curl_slist *host = NULL;
char addrstr[100];
char addrstr[DEFAULT_BUFFER_SIZE/2];
char dnscache[DEFAULT_BUFFER_SIZE];
/* initialize curl */
@ -497,10 +522,14 @@ check_http (void)
// fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
if(use_ssl && host_name != NULL) {
if ( (res=lookup_host (server_address, addrstr, 100)) != 0) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
server_address, res, gai_strerror (res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
if ( (res=lookup_host (server_address, addrstr, DEFAULT_BUFFER_SIZE/2)) != 0) {
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
server_address,
res,
gai_strerror (res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr);
host = curl_slist_append(NULL, dnscache);
@ -524,7 +553,7 @@ check_http (void)
/* compose URL: use the address we want to connect to, set Host: header later */
snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
use_ssl ? "https" : "http",
use_ssl & host_name != NULL ? host_name : server_address,
( use_ssl & ( host_name != NULL ) ) ? host_name : server_address,
server_port,
server_url
);
@ -600,7 +629,7 @@ check_http (void)
#ifdef LIBCURL_FEATURE_SSL
/* set SSL version, warn about unsecure or unsupported versions */
/* set SSL version, warn about insecure or unsupported versions */
if (use_ssl) {
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLVERSION, ssl_version), "CURLOPT_SSLVERSION");
}
@ -628,7 +657,7 @@ check_http (void)
}
/* detect SSL library used by libcurl */
ssl_library = curlhelp_get_ssl_library (curl);
ssl_library = curlhelp_get_ssl_library ();
/* try hard to get a stack of certificates to verify against */
if (check_cert) {
@ -792,12 +821,19 @@ check_http (void)
/* free header and server IP resolve lists, we don't need it anymore */
curl_slist_free_all (header_list); header_list = NULL;
curl_slist_free_all (server_ips); server_ips = NULL;
if (host) {
curl_slist_free_all (host); host = NULL;
}
/* Curl errors, result in critical Nagios state */
if (res != CURLE_OK) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
server_port, res, errbuf[0] ? errbuf : curl_easy_strerror(res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
server_port,
res,
errbuf[0] ? errbuf : curl_easy_strerror(res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
/* certificate checks */
@ -840,15 +876,19 @@ check_http (void)
}
GOT_FIRST_CERT:
if (!raw_cert) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
BIO* cert_BIO = BIO_new (BIO_s_mem());
BIO_write (cert_BIO, raw_cert, strlen(raw_cert));
cert = PEM_read_bio_X509 (cert_BIO, NULL, NULL, NULL);
if (!cert) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot read certificate from CERTINFO information - BIO error"));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Cannot read certificate from CERTINFO information - BIO error"));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
BIO_free (cert_BIO);
result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
@ -865,9 +905,12 @@ GOT_FIRST_CERT:
}
#endif /* USE_OPENSSL */
} else {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates - cURL returned %d - %s"),
res, curl_easy_strerror(res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
snprintf (msg,
DEFAULT_BUFFER_SIZE,
_("Cannot retrieve certificates - cURL returned %d - %s"),
res,
curl_easy_strerror(res));
die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
}
}
}
@ -906,8 +949,11 @@ GOT_FIRST_CERT:
/* get status line of answer, check sanity of HTTP code */
if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) {
snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n",
total_time, perfstring);
snprintf (msg,
DEFAULT_BUFFER_SIZE,
"Unparsable status line in %.3g seconds response time|%s\n",
total_time,
perfstring);
/* we cannot know the major/minor version here for sure as we cannot parse the first line */
die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg);
}
@ -927,9 +973,16 @@ GOT_FIRST_CERT:
/* make sure the status line matches the response we are looking for */
if (!expected_statuscode(status_line.first_line, server_expect)) {
if (server_port == HTTP_PORT)
snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host: %s\n"), status_line.first_line);
snprintf(msg,
DEFAULT_BUFFER_SIZE,
_("Invalid HTTP response received from host: %s\n"),
status_line.first_line);
else
snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: %s\n"), server_port, status_line.first_line);
snprintf(msg,
DEFAULT_BUFFER_SIZE,
_("Invalid HTTP response received from host on port %d: %s\n"),
server_port,
status_line.first_line);
die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg,
show_body ? "\n" : "",
show_body ? body_buf.buf : "");
@ -965,7 +1018,7 @@ GOT_FIRST_CERT:
}
} else {
/* this is a specific code in the command line to
* be returned when a redirection is encoutered
* be returned when a redirection is encountered
*/
}
result = max_state_alt (onredirect, result);
@ -1002,23 +1055,55 @@ GOT_FIRST_CERT:
if (strlen (header_expect)) {
if (!strstr (header_buf.buf, header_expect)) {
strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
if(output_header_search[sizeof(output_header_search)-1]!='\0') {
bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
}
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
result = STATE_CRITICAL;
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp,
DEFAULT_BUFFER_SIZE,
_("%sheader '%s' not found on '%s://%s:%d%s', "),
msg,
output_header_search,
use_ssl ? "https" : "http",
host_name ? host_name : server_address,
server_port,
server_url);
strcpy(msg, tmp);
result = STATE_CRITICAL;
}
}
if (strlen (string_expect)) {
if (!strstr (body_buf.buf, string_expect)) {
strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
if(output_string_search[sizeof(output_string_search)-1]!='\0') {
bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
}
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
result = STATE_CRITICAL;
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp,
DEFAULT_BUFFER_SIZE,
_("%sstring '%s' not found on '%s://%s:%d%s', "),
msg,
output_string_search,
use_ssl ? "https" : "http",
host_name ? host_name : server_address,
server_port,
server_url);
strcpy(msg, tmp);
result = STATE_CRITICAL;
}
}
@ -1029,27 +1114,48 @@ GOT_FIRST_CERT:
result = max_state_alt(STATE_OK, result);
}
else if ((errcode == REG_NOMATCH && !invert_regex) || (errcode == 0 && invert_regex)) {
if (!invert_regex)
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
else
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
result = STATE_CRITICAL;
}
else {
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
result = STATE_UNKNOWN;
}
if (!invert_regex) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
strcpy(msg, tmp);
} else {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
strcpy(msg, tmp);
}
result = STATE_CRITICAL;
} else {
regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
strcpy(msg, tmp);
result = STATE_UNKNOWN;
}
}
/* make sure the page is of an appropriate size */
if ((max_page_len > 0) && (page_len > max_page_len)) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
result = max_state_alt(STATE_WARNING, result);
} else if ((min_page_len > 0) && (page_len < min_page_len)) {
snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
result = max_state_alt(STATE_WARNING, result);
}
if ((max_page_len > 0) && (page_len > max_page_len)) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
strcpy(msg, tmp);
result = max_state_alt(STATE_WARNING, result);
} else if ((min_page_len > 0) && (page_len < min_page_len)) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
strcpy(msg, tmp);
result = max_state_alt(STATE_WARNING, result);
}
/* -w, -c: check warning and critical level */
result = max_state_alt(get_status(total_time, thlds), result);
@ -1633,6 +1739,7 @@ process_arguments (int argc, char **argv)
break;
case 'R': /* regex */
cflags |= REG_ICASE;
// fall through
case 'r': /* regex */
strncpy (regexp, optarg, MAX_RE_SIZE - 1);
regexp[MAX_RE_SIZE - 1] = 0;
@ -2030,7 +2137,7 @@ print_usage (void)
printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>] [-D]\n");
printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport|curl>]\n");
printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport|curl>]\n");
printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
@ -2196,11 +2303,10 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
if( strchr( p, '.' ) != NULL ) {
/* HTTP 1.x case */
char *ppp;
ppp = strtok( p, "." );
strtok( p, "." );
status_line->http_major = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( first_line_buf ); return -1; }
ppp = strtok( NULL, " " );
strtok( NULL, " " );
status_line->http_minor = (int)strtol( p, &pp, 10 );
if( *pp != '\0' ) { free( first_line_buf ); return -1; }
p += 4; /* 1.x SP */
@ -2287,37 +2393,67 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
server_date = get_header_value (headers, nof_headers, "date");
document_date = get_header_value (headers, nof_headers, "last-modified");
if (!server_date || !*server_date) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
date_result = max_state_alt(STATE_UNKNOWN, date_result);
} else if (!document_date || !*document_date) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
date_result = max_state_alt(STATE_CRITICAL, date_result);
if (!server_date || !*server_date) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_UNKNOWN, date_result);
} else if (!document_date || !*document_date) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else {
time_t srv_data = curl_getdate (server_date, NULL);
time_t doc_data = curl_getdate (document_date, NULL);
if (verbose >= 2)
printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data);
if (srv_data <= 0) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data <= 0) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data > srv_data + 30) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data < srv_data - maximum_age) {
int n = (srv_data - doc_data);
if (n > (60 * 60 * 24 * 2)) {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else {
snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
date_result = max_state_alt(STATE_CRITICAL, date_result);
}
}
}
if (srv_data <= 0) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data <= 0) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data > srv_data + 30) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else if (doc_data < srv_data - maximum_age) {
int n = (srv_data - doc_data);
if (n > (60 * 60 * 24 * 2)) {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
} else {
char tmp[DEFAULT_BUFFER_SIZE];
snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
strcpy(*msg, tmp);
date_result = max_state_alt(STATE_CRITICAL, date_result);
}
}
}
if (server_date) free (server_date);
if (document_date) free (document_date);
@ -2359,7 +2495,7 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
/* TODO: is there a better way in libcurl to check for the SSL library? */
curlhelp_ssl_library
curlhelp_get_ssl_library (CURL* curl)
curlhelp_get_ssl_library ()
{
curl_version_info_data* version_data;
char *ssl_version;

View file

@ -141,21 +141,28 @@ main (int argc, char **argv)
if (verbose > 2)
printf ("Initializing DBI\n");
if (dbi_initialize (NULL) < 0) {
dbi_inst *instance_p;
if (dbi_initialize_r(NULL, instance_p) < 0) {
printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n");
return STATE_UNKNOWN;
}
if (instance_p == NULL) {
printf ("UNKNOWN - failed to initialize DBI.\n");
return STATE_UNKNOWN;
}
if (verbose)
printf ("Opening DBI driver '%s'\n", np_dbi_driver);
driver = dbi_driver_open (np_dbi_driver);
driver = dbi_driver_open_r(np_dbi_driver, instance_p);
if (! driver) {
printf ("UNKNOWN - failed to open DBI driver '%s'; possibly it's not installed.\n",
np_dbi_driver);
printf ("Known drivers:\n");
for (driver = dbi_driver_list (NULL); driver; driver = dbi_driver_list (driver)) {
for (driver = dbi_driver_list_r(NULL, instance_p); driver; driver = dbi_driver_list_r(driver, instance_p)) {
printf (" - %s\n", dbi_driver_get_name (driver));
}
return STATE_UNKNOWN;
@ -426,6 +433,7 @@ process_arguments (int argc, char **argv)
else
timeout_interval = atoi (optarg);
break;
case 'H': /* host */
if (!is_host (optarg))
usage2 (_("Invalid hostname/address"), optarg);

View file

@ -131,9 +131,6 @@ bool stat_path (struct parameter_list *p);
void get_stats (struct parameter_list *p, struct fs_usage *fsp);
void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
double w_dfp = -1.0;
double c_dfp = -1.0;
char *path;
char *exclude_device;
char *units;
uintmax_t mult = 1024 * 1024;
@ -587,7 +584,7 @@ process_arguments (int argc, char **argv)
/* Awful mistake where the range values do not make sense. Normally,
you alert if the value is within the range, but since we are using
freespace, we have to alert if outside the range. Thus we artifically
freespace, we have to alert if outside the range. Thus we artificially
force @ at the beginning of the range, so that it is backwards compatible
*/
case 'c': /* critical threshold */
@ -626,21 +623,36 @@ process_arguments (int argc, char **argv)
if (! strcasecmp (optarg, "bytes")) {
mult = (uintmax_t)1;
units = strdup ("B");
} else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) {
} else if (!strcmp(optarg, "KiB")) {
mult = (uintmax_t)1024;
units = strdup ("kiB");
} else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) {
units = strdup ("KiB");
} else if (! strcmp (optarg, "kB")) {
mult = (uintmax_t)1000;
units = strdup ("kB");
} else if (!strcmp(optarg, "MiB")) {
mult = (uintmax_t)1024 * 1024;
units = strdup ("MiB");
} else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) {
} else if (! strcmp (optarg, "MB")) {
mult = (uintmax_t)1000 * 1000;
units = strdup ("MB");
} else if (!strcmp(optarg, "GiB")) {
mult = (uintmax_t)1024 * 1024 * 1024;
units = strdup ("GiB");
} else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) {
} else if (! strcmp (optarg, "GB")){
mult = (uintmax_t)1000 * 1000 * 1000;
units = strdup ("GB");
} else if (!strcmp(optarg, "TiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
units = strdup ("TiB");
} else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) {
} else if (! strcmp (optarg, "TB")) {
mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
units = strdup ("TB");
} else if (!strcmp(optarg, "PiB")) {
mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
units = strdup ("PiB");
} else if (! strcmp (optarg, "PB")){
mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
units = strdup ("PB");
} else {
die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
}
@ -874,7 +886,7 @@ process_arguments (int argc, char **argv)
if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c]))
crit_usedspace_percent = argv[c++];
if (argc > c && path == NULL) {
if (argc > c) {
se = np_add_parameter(&path_select_list, strdup(argv[c++]));
path_selected = TRUE;
set_all_thresholds(se);
@ -1115,7 +1127,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
p->available_to_root = fsp->fsu_bfree;
p->used = fsp->fsu_blocks - fsp->fsu_bfree;
if (freespace_ignore_reserved) {
/* option activated : we substract the root-reserved space from the total */
/* option activated : we subtract the root-reserved space from the total */
p->total = fsp->fsu_blocks - p->available_to_root + p->available;
} else {
/* default behaviour : take all the blocks into account */
@ -1130,7 +1142,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */
p->inodes_used = fsp->fsu_files - fsp->fsu_ffree;
if (freespace_ignore_reserved) {
/* option activated : we substract the root-reserved inodes from the total */
/* option activated : we subtract the root-reserved inodes from the total */
/* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */
/* for others, fsp->fsu_ffree == fsp->fsu_favail */
p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free;

View file

@ -75,7 +75,7 @@ main (int argc, char **argv)
{
char *command_line = NULL;
char input_buffer[MAX_INPUT_BUFFER];
char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */
char *address = NULL; /* comma separated str with addrs/ptrs (sorted) */
char **addresses = NULL;
int n_addresses = 0;
char *msg = NULL;

View file

@ -73,7 +73,7 @@ int wrta_p = FALSE;
int
main (int argc, char **argv)
{
/* normaly should be int result = STATE_UNKNOWN; */
/* normally should be int result = STATE_UNKNOWN; */
int status = STATE_UNKNOWN;
int result = 0;
@ -354,6 +354,7 @@ process_arguments (int argc, char **argv)
break;
case 'I': /* sourceip */
sourceif = strscpy (sourceif, optarg);
break;
case '4': /* IPv4 only */
address_family = AF_INET;
break;

View file

@ -353,6 +353,7 @@ process_arguments (int argc, char **argv)
usage2 (_("Port must be a positive short integer"), optarg);
else
port = atoi(optarg);
break;
case 'D': /* disable paper out check*/
check_paper_out = 0;
break;

View file

@ -198,7 +198,7 @@ test_file (char *path)
/*
* process command-line arguments
* returns true on succes, false otherwise
* returns true on success, false otherwise
*/
bool process_arguments (int argc, char **argv)
{
@ -498,6 +498,7 @@ bool process_arguments (int argc, char **argv)
break;
case 'R': /* regex */
cflags |= REG_ICASE;
// fall through
case 'r': /* regex */
strncpy (regexp, optarg, MAX_RE_SIZE - 1);
regexp[MAX_RE_SIZE - 1] = 0;
@ -1278,7 +1279,7 @@ check_http (void)
regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
if (regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
if (!no_body && regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
if (verbose) {
printf("Found chunked content\n");
}
@ -1391,7 +1392,6 @@ char *unchunk_content(const char *content) {
// https://en.wikipedia.org/wiki/Chunked_transfer_encoding
// https://www.rfc-editor.org/rfc/rfc7230#section-4.1
char *result = NULL;
size_t content_length = strlen(content);
char *start_of_chunk;
char* end_of_chunk;
long size_of_chunk;
@ -1885,7 +1885,7 @@ print_usage (void)
printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
printf (" [-J <client certificate file>] [-K <private key>]\n");
printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n");
printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport>]\n");
printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
printf (" [-A string] [-k string] [-S <version>] [--sni]\n");

View file

@ -222,7 +222,7 @@ main (int argc, char *argv[])
/* reset the alarm handler */
alarm (0);
/* calcutate the elapsed time and compare to thresholds */
/* calculate the elapsed time and compare to thresholds */
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;

View file

@ -107,7 +107,7 @@ main (int argc, char **argv)
int i;
long numcpus;
double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */
double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about uninitialized arrays */
#ifndef HAVE_GETLOADAVG
char input_buffer[MAX_INPUT_BUFFER];
# ifdef HAVE_PROC_LOADAVG

View file

@ -34,7 +34,7 @@ const char *progname = "check_mysql";
const char *copyright = "1999-2011";
const char *email = "devel@monitoring-plugins.org";
#define SLAVERESULTSIZE 70
#define SLAVERESULTSIZE 96
#include "common.h"
#include "utils.h"
@ -89,6 +89,8 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
"Uptime"
};
#define MYSQLDUMP_THREADS_QUERY "SELECT COUNT(1) mysqldumpThreads FROM information_schema.processlist WHERE info LIKE 'SELECT /*!40001 SQL_NO_CACHE */%'"
thresholds *my_threshold = NULL;
int process_arguments (int, char **);
@ -108,7 +110,7 @@ main (int argc, char **argv)
char *result = NULL;
char *error = NULL;
char slaveresult[SLAVERESULTSIZE];
char slaveresult[SLAVERESULTSIZE] = { 0 };
char* perf;
perf = strdup ("");
@ -138,7 +140,10 @@ main (int argc, char **argv)
mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
/* establish a connection to the server and error checking */
if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR)
/* Depending on internally-selected auth plugin MySQL might return */
/* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */
/* Semantically these errors are the same. */
if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR))
{
printf("MySQL OK - Version: %s (protocol %d)\n",
mysql_get_server_info(&mysql),
@ -275,11 +280,30 @@ main (int argc, char **argv)
/* Save slave status in slaveresult */
snprintf (slaveresult, SLAVERESULTSIZE, "Slave IO: %s Slave SQL: %s Seconds Behind Master: %s", row[slave_io_field], row[slave_sql_field], seconds_behind_field!=-1?row[seconds_behind_field]:"Unknown");
/* Raise critical error if SQL THREAD or IO THREAD are stopped */
/* Raise critical error if SQL THREAD or IO THREAD are stopped, but only if there are no mysqldump threads running */
if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) {
mysql_free_result (res);
mysql_close (&mysql);
die (STATE_CRITICAL, "%s\n", slaveresult);
MYSQL_RES *res_mysqldump;
MYSQL_ROW row_mysqldump;
unsigned int mysqldump_threads = 0;
if (mysql_query (&mysql, MYSQLDUMP_THREADS_QUERY) == 0) {
/* store the result */
if ( (res_mysqldump = mysql_store_result (&mysql)) != NULL) {
if (mysql_num_rows(res_mysqldump) == 1) {
if ( (row_mysqldump = mysql_fetch_row (res_mysqldump)) != NULL) {
mysqldump_threads = atoi(row_mysqldump[0]);
}
}
/* free the result */
mysql_free_result (res_mysqldump);
}
mysql_close (&mysql);
}
if (mysqldump_threads == 0) {
die (STATE_CRITICAL, "%s\n", slaveresult);
} else {
strncat(slaveresult, " Mysqldump: in progress", SLAVERESULTSIZE-1);
}
}
if (verbose >=3) {
@ -291,7 +315,7 @@ main (int argc, char **argv)
}
/* Check Seconds Behind against threshold */
if ((seconds_behind_field != -1) && (strcmp (row[seconds_behind_field], "NULL") != 0)) {
if ((seconds_behind_field != -1) && (row[seconds_behind_field] != NULL && strcmp (row[seconds_behind_field], "NULL") != 0)) {
double value = atof(row[seconds_behind_field]);
int status;
@ -551,7 +575,7 @@ print_help (void)
printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds"));
printf (" %s\n", _("behind master"));
printf (" %s\n", "-l, --ssl");
printf (" %s\n", _("Use ssl encryptation"));
printf (" %s\n", _("Use ssl encryption"));
printf (" %s\n", "-C, --ca-cert=STRING");
printf (" %s\n", _("Path to CA signing the cert"));
printf (" %s\n", "-a, --cert=STRING");

View file

@ -341,7 +341,7 @@ int main(int argc, char **argv){
2) If the counter you're going to measure is percent-based, the code will detect
the percent sign in its name and will attribute minimum (0%) and maximum (100%)
values automagically, as well the ¨%" sign to graph units.
values automagically, as well the "%" sign to graph units.
3) OTOH, if the counter is "absolute", you'll have to provide the following
the counter unit - that is, the dimensions of the counter you're getting. Examples:

View file

@ -10,7 +10,7 @@
*
* This file contains the check_ntp plugin
*
* This plugin to check ntp servers independant of any commandline
* This plugin to check ntp servers independent of any commandline
* programs or external libraries.
*
*
@ -79,7 +79,7 @@ typedef struct {
/* this structure holds data about results from querying offset from a peer */
typedef struct {
time_t waiting; /* ts set when we started waiting for a response */
int num_responses; /* number of successfully recieved responses */
int num_responses; /* number of successfully received responses */
uint8_t stratum; /* copied verbatim from the ntp_message */
double rtdelay; /* converted from the ntp_message */
double rtdisp; /* converted from the ntp_message */
@ -100,7 +100,7 @@ typedef struct {
/* NB: not necessarily NULL terminated! */
} ntp_control_message;
/* this is an association/status-word pair found in control packet reponses */
/* this is an association/status-word pair found in control packet responses */
typedef struct {
uint16_t assoc;
uint16_t status;
@ -575,7 +575,7 @@ double jitter_request(int *status){
}
}
}
if(verbose) printf("%d candiate peers available\n", num_candidates);
if(verbose) printf("%d candidate peers available\n", num_candidates);
if(verbose && syncsource_found) printf("synchronization source found\n");
if(! syncsource_found){
*status = STATE_UNKNOWN;
@ -597,7 +597,7 @@ double jitter_request(int *status){
/* By spec, putting the variable name "jitter" in the request
* should cause the server to provide _only_ the jitter value.
* thus reducing net traffic, guaranteeing us only a single
* datagram in reply, and making intepretation much simpler
* datagram in reply, and making interpretation much simpler
*/
/* Older servers doesn't know what jitter is, so if we get an
* error on the first pass we redo it with "dispersion" */

View file

@ -86,7 +86,7 @@ typedef struct {
/* NB: not necessarily NULL terminated! */
} ntp_control_message;
/* this is an association/status-word pair found in control packet reponses */
/* this is an association/status-word pair found in control packet responses */
typedef struct {
uint16_t assoc;
uint16_t status;
@ -189,7 +189,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
}
/* This function does all the actual work; roughly here's what it does
* beside setting the offest, jitter and stratum passed as argument:
* beside setting the offset, jitter and stratum passed as argument:
* - offset can be negative, so if it cannot get the offset, offset_result
* is set to UNKNOWN, otherwise OK.
* - jitter and stratum are set to -1 if they cannot be retrieved so any
@ -199,7 +199,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
* status is pretty much useless as syncsource_found is a global variable
* used later in main to check is the server was synchronized. It works
* so I left it alone */
int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
int conn=-1, i, npeers=0, num_candidates=0;
double tmp_offset = 0;
int min_peer_sel=PEER_INCLUDED;
@ -306,7 +306,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
/* Putting the wanted variable names in the request
* cause the server to provide _only_ the requested values.
* thus reducing net traffic, guaranteeing us only a single
* datagram in reply, and making intepretation much simpler
* datagram in reply, and making interpretation much simpler
*/
/* Older servers doesn't know what jitter is, so if we get an
* error on the first pass we redo it with "dispersion" */
@ -585,8 +585,8 @@ int main(int argc, char *argv[]){
/* set socket timeout */
alarm (socket_timeout);
/* This returns either OK or WARNING (See comment preceeding ntp_request) */
result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum, &num_truechimers);
/* This returns either OK or WARNING (See comment preceding ntp_request) */
result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers);
if(offset_result == STATE_UNKNOWN) {
/* if there's no sync peer (this overrides ntp_request output): */

View file

@ -81,7 +81,7 @@ typedef struct {
/* this structure holds data about results from querying offset from a peer */
typedef struct {
time_t waiting; /* ts set when we started waiting for a response */
int num_responses; /* number of successfully recieved responses */
int num_responses; /* number of successfully received responses */
uint8_t stratum; /* copied verbatim from the ntp_message */
double rtdelay; /* converted from the ntp_message */
double rtdisp; /* converted from the ntp_message */

View file

@ -1668,7 +1668,7 @@ void print_help(void)
printf ("\n");
printf ("%s\n", _("Notes:"));
printf (" %s\n", _("- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"));
printf (" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"));
printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));

View file

@ -93,7 +93,7 @@ int verbose = 0;
/******************************************************************************
The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
tags in the comments. With in the tags, the XML is assembled sequentially.
You can define entities in tags. You also have all the #defines available as
entities.
@ -517,7 +517,10 @@ print_help (void)
printf (" %s\n", _("connecting to the server. The result from the query has to be numeric."));
printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result "));
printf (" %s\n", _("of the last command is taken into account only. The value of the first"));
printf (" %s\n\n", _("column in the first row is used as the check result."));
printf (" %s\n", _("column in the first row is used as the check result. If a second column is"));
printf (" %s\n", _("present in the result set, this is added to the plugin output with a"));
printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system"));
printf (" %s\n\n", _("executing the plugin."));
printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
@ -557,6 +560,7 @@ do_query (PGconn *conn, char *query)
PGresult *res;
char *val_str;
char *extra_info;
double value;
char *endptr = NULL;
@ -621,6 +625,12 @@ do_query (PGconn *conn, char *query)
printf ("|query=%f;%s;%s;;\n", value,
query_warning ? query_warning : "",
query_critical ? query_critical : "");
if (PQnfields (res) > 1) {
extra_info = PQgetvalue (res, 0, 1);
if (extra_info != NULL) {
printf ("Extra Info: %s\n", extra_info);
}
}
return my_status;
}

View file

@ -70,6 +70,7 @@ int options = 0; /* bitmask of filter criteria to test against */
#define PCPU 256
#define ELAPSED 512
#define EREG_ARGS 1024
#define EXCLUDE_PROGS 2048
#define KTHREAD_PARENT "kthreadd" /* the parent process of kernel threads:
ppid of procs are compared to pid of this proc*/
@ -93,6 +94,9 @@ int rss;
float pcpu;
char *statopts;
char *prog;
char *exclude_progs;
char **exclude_progs_arr = NULL;
char exclude_progs_counter = 0;
char *args;
char *input_filename = NULL;
regex_t re_args;
@ -250,7 +254,26 @@ main (int argc, char **argv)
continue;
}
/* filter kernel threads (childs of KTHREAD_PARENT)*/
/* Ignore excluded processes by name */
if(options & EXCLUDE_PROGS) {
int found = 0;
int i = 0;
for(i=0; i < (exclude_progs_counter); i++) {
if(!strcmp(procprog, exclude_progs_arr[i])) {
found = 1;
}
}
if(found == 0) {
resultsum |= EXCLUDE_PROGS;
} else
{
if(verbose >= 3)
printf("excluding - by ignorelist\n");
}
}
/* filter kernel threads (children of KTHREAD_PARENT)*/
/* TODO adapt for other OSes than GNU/Linux
sorry for not doing that, but I've no other OSes to test :-( */
if (kthread_filter == 1) {
@ -409,6 +432,7 @@ process_arguments (int argc, char **argv)
{"input-file", required_argument, 0, CHAR_MAX+2},
{"no-kthreads", required_argument, 0, 'k'},
{"traditional-filter", no_argument, 0, 'T'},
{"exclude-process", required_argument, 0, 'X'},
{0, 0, 0, 0}
};
@ -417,7 +441,7 @@ process_arguments (int argc, char **argv)
strcpy (argv[c], "-t");
while (1) {
c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T",
c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T:X:",
longopts, &option);
if (c == -1 || c == EOF)
@ -490,6 +514,23 @@ process_arguments (int argc, char **argv)
prog);
options |= PROG;
break;
case 'X':
if(exclude_progs)
break;
else
exclude_progs = optarg;
xasprintf (&fmt, _("%s%sexclude progs '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
exclude_progs);
char *p = strtok(exclude_progs, ",");
while(p){
exclude_progs_arr = realloc(exclude_progs_arr, sizeof(char*) * ++exclude_progs_counter);
exclude_progs_arr[exclude_progs_counter-1] = p;
p = strtok(NULL, ",");
}
options |= EXCLUDE_PROGS;
break;
case 'a': /* args (full path name with args) */
/* TODO: allow this to be passed in with --metric */
if (args)
@ -745,6 +786,8 @@ print_help (void)
printf (" %s\n", _("Only scan for processes with args that contain the regex STRING."));
printf (" %s\n", "-C, --command=COMMAND");
printf (" %s\n", _("Only scan for exact matches of COMMAND (without path)."));
printf (" %s\n", "-X, --exclude-process");
printf (" %s\n", _("Exclude processes which match this comma separated list"));
printf (" %s\n", "-k, --no-kthreads");
printf (" %s\n", _("Only scan for non kernel threads (works on Linux only)."));
@ -786,5 +829,5 @@ print_usage (void)
printf ("%s\n", _("Usage:"));
printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname);
printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n");
printf (" [-C command] [-k] [-t timeout] [-v]\n");
printf (" [-C command] [-X process_to_exclude] [-k] [-t timeout] [-v]\n");
}

View file

@ -97,7 +97,7 @@ int verbose = FALSE;
/******************************************************************************
The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
tags in the comments. With in the tags, the XML is assembled sequentially.
You can define entities in tags. You also have all the #defines available as
entities.
@ -155,7 +155,11 @@ main (int argc, char **argv)
{
struct sockaddr_storage ss;
char name[HOST_NAME_MAX];
#ifdef RC_BUFFER_LEN
char msg[RC_BUFFER_LEN];
#else
char msg[BUFFER_LEN];
#endif
SEND_DATA data;
int result = STATE_UNKNOWN;
uint32_t client_id, service;
@ -377,7 +381,7 @@ print_help (void)
printf ("\n");
printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections."));
printf ("%s\n", _("The server to test must be specified in the invocation, as well as a user"));
printf ("%s\n", _("name and password. A configuration file may also be present. The format of"));
printf ("%s\n", _("name and password. A configuration file must be present. The format of"));
printf ("%s\n", _("the configuration file is described in the radiusclient library sources."));
printf ("%s\n", _("The password option presents a substantial security issue because the"));
printf ("%s\n", _("password can possibly be determined by careful watching of the command line"));

View file

@ -178,7 +178,7 @@ main (int argc, char **argv)
/* watch for the REAL connection string */
result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
buffer[result] = '\0'; /* null terminate recieved buffer */
buffer[result] = '\0'; /* null terminate received buffer */
/* return a CRITICAL status if we couldn't read any data */
if (result == -1) {
@ -436,7 +436,7 @@ print_help (void)
printf ("\n");
printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host."));
printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"));
printf ("%s\n", _("but incorrect response messages from the host result in STATE_WARNING return"));
printf ("%s\n", _("values."));

View file

@ -3,7 +3,7 @@
* Monitoring check_smtp plugin
*
* License: GPL
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
* Copyright (c) 2000-2023 Monitoring Plugins Development Team
*
* Description:
*
@ -42,16 +42,18 @@ const char *email = "devel@monitoring-plugins.org";
#ifdef HAVE_SSL
int check_cert = FALSE;
int days_till_exp_warn, days_till_exp_crit;
# define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
# define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
# define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
# define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
#else /* ifndef HAVE_SSL */
# define my_recv(buf, len) read(sd, buf, len)
# define my_send(buf, len) send(sd, buf, len, 0)
#endif
enum {
SMTP_PORT = 25
SMTP_PORT = 25,
SMTPS_PORT = 465
};
#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n"
#define SMTP_EXPECT "220"
#define SMTP_HELO "HELO "
#define SMTP_EHLO "EHLO "
@ -82,6 +84,7 @@ int eflags = 0;
int errcode, excode;
int server_port = SMTP_PORT;
int server_port_option = 0;
char *server_address = NULL;
char *server_expect = NULL;
char *mail_command = NULL;
@ -102,6 +105,9 @@ double critical_time = 0;
int check_critical_time = FALSE;
int verbose = 0;
int use_ssl = FALSE;
int use_starttls = FALSE;
int use_sni = FALSE;
short use_proxy_prefix = FALSE;
short use_ehlo = FALSE;
short use_lhlo = FALSE;
short ssl_established = 0;
@ -183,6 +189,26 @@ main (int argc, char **argv)
result = my_tcp_connect (server_address, server_port, &sd);
if (result == STATE_OK) { /* we connected */
/* If requested, send PROXY header */
if (use_proxy_prefix) {
if (verbose)
printf ("Sending header %s\n", PROXY_PREFIX);
my_send(PROXY_PREFIX, strlen(PROXY_PREFIX));
}
#ifdef HAVE_SSL
if (use_ssl) {
result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
if (result != STATE_OK) {
printf (_("CRITICAL - Cannot create SSL context.\n"));
close(sd);
np_net_ssl_cleanup();
return STATE_CRITICAL;
} else {
ssl_established = 1;
}
}
#endif
/* watch for the SMTP connection string and */
/* return a WARNING status if we couldn't read any data */
@ -195,7 +221,7 @@ main (int argc, char **argv)
xasprintf(&server_response, "%s", buffer);
/* send the HELO/EHLO command */
send(sd, helocmd, strlen(helocmd), 0);
my_send(helocmd, strlen(helocmd));
/* allow for response to helo command to reach us */
if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
@ -208,14 +234,14 @@ main (int argc, char **argv)
}
}
if(use_ssl && ! supports_tls){
if(use_starttls && ! supports_tls){
printf(_("WARNING - TLS not supported by server\n"));
smtp_quit();
return STATE_WARNING;
}
#ifdef HAVE_SSL
if(use_ssl) {
if(use_starttls) {
/* send the STARTTLS command */
send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0);
@ -225,7 +251,7 @@ main (int argc, char **argv)
smtp_quit();
return STATE_UNKNOWN;
}
result = np_net_ssl_init(sd);
result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
if(result != STATE_OK) {
printf (_("CRITICAL - Cannot create SSL context.\n"));
close(sd);
@ -454,6 +480,10 @@ process_arguments (int argc, char **argv)
int c;
char* temp;
enum {
SNI_OPTION
};
int option = 0;
static struct option longopts[] = {
{"hostname", required_argument, 0, 'H'},
@ -475,9 +505,13 @@ process_arguments (int argc, char **argv)
{"use-ipv6", no_argument, 0, '6'},
{"help", no_argument, 0, 'h'},
{"lmtp", no_argument, 0, 'L'},
{"ssl", no_argument, 0, 's'},
{"tls", no_argument, 0, 's'},
{"starttls",no_argument,0,'S'},
{"sni", no_argument, 0, SNI_OPTION},
{"certificate",required_argument,0,'D'},
{"ignore-quit-failure",no_argument,0,'q'},
{"proxy",no_argument,0,'r'},
{0, 0, 0, 0}
};
@ -494,7 +528,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
c = getopt_long (argc, argv, "+hVv46Lt:p:f:e:c:w:H:C:R:SD:F:A:U:P:q",
c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:sSD:F:A:U:P:q",
longopts, &option);
if (c == -1 || c == EOF)
@ -511,7 +545,7 @@ process_arguments (int argc, char **argv)
break;
case 'p': /* port */
if (is_intpos (optarg))
server_port = atoi (optarg);
server_port_option = atoi (optarg);
else
usage4 (_("Port must be a positive integer"));
break;
@ -616,11 +650,26 @@ process_arguments (int argc, char **argv)
#else
usage (_("SSL support not available - install OpenSSL and recompile"));
#endif
case 's':
/* ssl */
use_ssl = TRUE;
server_port = SMTPS_PORT;
break;
case 'S':
/* starttls */
use_ssl = TRUE;
use_starttls = TRUE;
use_ehlo = TRUE;
break;
case SNI_OPTION:
#ifdef HAVE_SSL
use_sni = TRUE;
#else
usage (_("SSL support not available - install OpenSSL and recompile"));
#endif
break;
case 'r':
use_proxy_prefix = TRUE;
break;
case 'L':
use_lhlo = TRUE;
break;
@ -667,6 +716,14 @@ process_arguments (int argc, char **argv)
if (from_arg==NULL)
from_arg = strdup(" ");
if (use_starttls && use_ssl) {
usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
}
if (server_port_option != 0) {
server_port = server_port_option;
}
return validate_arguments ();
}
@ -819,11 +876,18 @@ print_help (void)
printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
printf (" %s\n", "-F, --fqdn=STRING");
printf (" %s\n", _("FQDN used for HELO"));
printf (" %s\n", "-r, --proxy");
printf (" %s\n", _("Use PROXY protocol prefix for the connection."));
#ifdef HAVE_SSL
printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
printf (" %s\n", "-s, --ssl, --tls");
printf (" %s\n", _("Use SSL/TLS for the connection."));
printf (_(" Sets default port to %d.\n"), SMTPS_PORT);
printf (" %s\n", "-S, --starttls");
printf (" %s\n", _("Use STARTTLS for the connection."));
printf (" %s\n", "--sni");
printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
#endif
printf (" %s\n", "-A, --authtype=STRING");
@ -844,7 +908,7 @@ print_help (void)
printf (UT_VERBOSE);
printf("\n");
printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"));
printf ("%s\n", _("connects, but incorrect response messages from the host result in"));
printf ("%s\n", _("STATE_WARNING return values."));
@ -860,6 +924,6 @@ print_usage (void)
printf ("%s\n", _("Usage:"));
printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-v] \n");
printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n");
}

View file

@ -46,6 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
#define DEFAULT_PRIV_PROTOCOL "DES"
#define DEFAULT_DELIMITER "="
#define DEFAULT_OUTPUT_DELIMITER " "
#define DEFAULT_BUFFER_SIZE 100
#define mark(a) ((a)!=0?"*":"")
@ -64,6 +65,7 @@ const char *email = "devel@monitoring-plugins.org";
#define L_RATE_MULTIPLIER CHAR_MAX+2
#define L_INVERT_SEARCH CHAR_MAX+3
#define L_OFFSET CHAR_MAX+4
#define L_IGNORE_MIB_PARSING_ERRORS CHAR_MAX+5
/* Gobble to string - stop incrementing c when c[0] match one of the
* characters in s */
@ -157,6 +159,9 @@ int perf_labels = 1;
char* ip_version = "";
double multiplier = 1.0;
char *fmtstr = "";
bool fmtstr_set = false;
char buffer[DEFAULT_BUFFER_SIZE];
bool ignore_mib_parsing_errors = false;
static char *fix_snmp_range(char *th)
{
@ -304,42 +309,55 @@ main (int argc, char **argv)
}
/* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */
command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
command_line[0] = snmpcmd;
command_line[1] = strdup ("-Le");
command_line[2] = strdup ("-t");
xasprintf (&command_line[3], "%d", timeout_interval);
command_line[4] = strdup ("-r");
xasprintf (&command_line[5], "%d", retries);
command_line[6] = strdup ("-m");
command_line[7] = strdup (miblist);
command_line[8] = "-v";
command_line[9] = strdup (proto);
unsigned index = 0;
command_line = calloc (11 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
command_line[index++] = snmpcmd;
command_line[index++] = strdup ("-Le");
command_line[index++] = strdup ("-t");
xasprintf (&command_line[index++], "%d", timeout_interval);
command_line[index++] = strdup ("-r");
xasprintf (&command_line[index++], "%d", retries);
command_line[index++] = strdup ("-m");
command_line[index++] = strdup (miblist);
command_line[index++] = "-v";
command_line[index++] = strdup (proto);
xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s",
snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto);
if (ignore_mib_parsing_errors) {
command_line[index++] = "-Pe";
xasprintf(&cl_hidden_auth, "%s -Pe", cl_hidden_auth);
}
for (i = 0; i < numcontext; i++) {
command_line[10 + i] = contextargs[i];
command_line[index++] = contextargs[i];
}
for (i = 0; i < numauthpriv; i++) {
command_line[10 + numcontext + i] = authpriv[i];
command_line[index++] = authpriv[i];
}
xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port);
xasprintf (&command_line[index++], "%s:%s", server_address, port);
/* This is just for display purposes, so it can remain a string */
xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s",
snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]",
server_address, port);
xasprintf(&cl_hidden_auth, "%s [context] [authpriv] %s:%s",
cl_hidden_auth,
server_address,
port);
for (i = 0; i < numoids; i++) {
command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i];
command_line[index++] = oids[i];
xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
}
command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL;
command_line[index++] = NULL;
if (verbose)
if (verbose) {
printf ("%s\n", cl_hidden_auth);
}
/* Set signal handling and alarm */
if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
@ -420,7 +438,8 @@ main (int argc, char **argv)
}
else if (strstr (response, "INTEGER: ")) {
show = multiply (strstr (response, "INTEGER: ") + 9);
if (fmtstr != "") {
if (fmtstr_set) {
conv = fmtstr;
}
}
@ -594,8 +613,9 @@ main (int argc, char **argv)
len = sizeof(perfstr)-strlen(perfstr)-1;
strncat(perfstr, show, len>ptr-show ? ptr-show : len);
if (type)
if (strcmp(type, "") != 0) {
strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);
}
if (warning_thresholds) {
strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
@ -706,6 +726,7 @@ process_arguments (int argc, char **argv)
{"ipv6", no_argument, 0, '6'},
{"multiplier", required_argument, 0, 'M'},
{"fmtstr", required_argument, 0, 'f'},
{"ignore-mib-parsing-errors", no_argument, false, L_IGNORE_MIB_PARSING_ERRORS},
{0, 0, 0, 0}
};
@ -853,6 +874,7 @@ process_arguments (int argc, char **argv)
break;
case 'R': /* regex */
cflags = REG_ICASE;
// fall through
case 'r': /* regex */
cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
strncpy (regex_expect, optarg, sizeof (regex_expect) - 1);
@ -969,8 +991,11 @@ process_arguments (int argc, char **argv)
case 'f':
if (multiplier != 1.0) {
fmtstr=optarg;
fmtstr_set = true;
}
break;
case L_IGNORE_MIB_PARSING_ERRORS:
ignore_mib_parsing_errors = true;
}
}
@ -1169,33 +1194,33 @@ multiply (char *str)
double val;
char *conv = "%f";
if(multiplier == 1)
return(str);
if(verbose>2)
printf(" multiply input: %s\n", str);
val = strtod (str, &endptr);
if ((val == 0.0) && (endptr == str)) {
if(multiplier != 1) {
die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
}
return str;
die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
}
if(verbose>2)
printf(" multiply extracted double: %f\n", val);
val *= multiplier;
if (fmtstr != "") {
if (fmtstr_set) {
conv = fmtstr;
}
if (val == (int)val) {
sprintf(str, "%.0f", val);
snprintf(buffer, DEFAULT_BUFFER_SIZE, "%.0f", val);
} else {
if(verbose>2)
printf(" multiply using format: %s\n", conv);
sprintf(str, conv, val);
snprintf(buffer, DEFAULT_BUFFER_SIZE, conv, val);
}
if(verbose>2)
printf(" multiply result: %s\n", str);
return str;
printf(" multiply result: %s\n", buffer);
return buffer;
}
@ -1272,7 +1297,7 @@ print_help (void)
printf (" %s\n", "--rate-multiplier");
printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute"));
printf (" %s\n", "--offset=OFFSET");
printf (" %s\n", _("Add/substract the specified OFFSET to numeric sensor data"));
printf (" %s\n", _("Add/subtract the specified OFFSET to numeric sensor data"));
/* Tests Against Strings */
printf (" %s\n", "-s, --string=STRING");
@ -1304,6 +1329,9 @@ print_help (void)
printf (" %s\n", "-O, --perf-oids");
printf (" %s\n", _("Label performance data with OIDs instead of --label's"));
printf (" %s\n", "--ignore-mib-parsing-errors");
printf (" %s\n", _("Tell snmpget to not print errors encountered when parsing MIB files"));
printf (UT_VERBOSE);
printf ("\n");

View file

@ -34,9 +34,6 @@ const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "popen.h"
#include "utils.h"
#include <string.h>
#include <math.h>
#include <libintl.h>
#ifdef HAVE_DECL_SWAPCTL
# ifdef HAVE_SYS_PARAM_H
@ -181,7 +178,7 @@ main (int argc, char **argv)
# ifdef _AIX
if (!allswaps) {
xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
xasprintf(&swap_format, "%s", "%f%*s %f");
xasprintf(&swap_format, "%s", "%lu%*s %lu");
conv_factor = 1;
}
# endif
@ -208,9 +205,9 @@ main (int argc, char **argv)
temp_buffer = strtok (input_buffer, " \n");
while (temp_buffer) {
if (strstr (temp_buffer, "blocks"))
sprintf (str, "%s %s", str, "%f");
sprintf (str, "%s %s", str, "%lu");
else if (strstr (temp_buffer, "dskfree"))
sprintf (str, "%s %s", str, "%f");
sprintf (str, "%s %s", str, "%lu");
else
sprintf (str, "%s %s", str, "%*s");
temp_buffer = strtok (NULL, " \n");
@ -555,7 +552,7 @@ validate_arguments (void)
}
else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
/* This is NOT triggered if warn and crit are different units, e.g warn is percentage
* and crit is absolut. We cannot determine the condition at this point since we
* and crit is absolute. We cannot determine the condition at this point since we
* dont know the value of total swap yet
*/
usage4(_("Warning should be more than critical"));

View file

@ -128,7 +128,7 @@ main (int argc, char **argv)
SERVICE[i] = toupper(SERVICE[i]);
}
/* set up a resonable buffer at first (will be realloc()'ed if
/* set up a reasonable buffer at first (will be realloc()'ed if
* user specifies other options) */
server_expect = calloc(sizeof(char *), 2);

View file

@ -89,7 +89,7 @@ char *ups_status;
int temp_output_c = 0;
int determine_status (void);
int get_ups_variable (const char *, char *, size_t);
int get_ups_variable (const char *, char *);
int process_arguments (int, char **);
int validate_arguments (void);
@ -189,7 +189,7 @@ main (int argc, char **argv)
}
/* get the ups utility voltage if possible */
res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer));
res=get_ups_variable ("input.voltage", temp_buffer);
if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
else if (res != OK)
return STATE_CRITICAL;
@ -224,7 +224,7 @@ main (int argc, char **argv)
}
/* get the ups battery percent if possible */
res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer));
res=get_ups_variable ("battery.charge", temp_buffer);
if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
else if ( res != OK)
return STATE_CRITICAL;
@ -253,7 +253,7 @@ main (int argc, char **argv)
}
/* get the ups load percent if possible */
res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer));
res=get_ups_variable ("ups.load", temp_buffer);
if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
else if ( res != OK)
return STATE_CRITICAL;
@ -282,7 +282,7 @@ main (int argc, char **argv)
}
/* get the ups temperature if possible */
res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer));
res=get_ups_variable ("ups.temperature", temp_buffer);
if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
else if ( res != OK)
return STATE_CRITICAL;
@ -342,7 +342,7 @@ determine_status (void)
char *ptr;
int res;
res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
res=get_ups_variable ("ups.status", recv_buffer);
if (res == NOSUCHVAR) return OK;
if (res != STATE_OK) {
printf ("%s\n", _("Invalid response received from host"));
@ -388,7 +388,7 @@ determine_status (void)
/* gets a variable value for a specific UPS */
int
get_ups_variable (const char *varname, char *buf, size_t buflen)
get_ups_variable (const char *varname, char *buf)
{
/* char command[MAX_INPUT_BUFFER]; */
char temp_buffer[MAX_INPUT_BUFFER];
@ -507,7 +507,7 @@ process_arguments (int argc, char **argv)
usage2 (_("Invalid hostname/address"), optarg);
}
break;
case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */
case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Fahrenheit) */
temp_output_c = 1;
break;
case 'u': /* ups name */

View file

@ -1,33 +1,33 @@
/*****************************************************************************
*
*
* Monitoring check_users plugin
*
*
* License: GPL
* Copyright (c) 2000-2012 Monitoring Plugins Development Team
*
*
* Description:
*
*
* This file contains the check_users plugin
*
*
* This plugin checks the number of users currently logged in on the local
* system and generates an error if the number exceeds the thresholds
* specified.
*
*
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*
*
*****************************************************************************/
const char *progname = "check_users";
@ -48,6 +48,11 @@ const char *email = "devel@monitoring-plugins.org";
# include "popen.h"
#endif
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-daemon.h>
#include <systemd/sd-login.h>
#endif
#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
int process_arguments (int, char **);
@ -85,6 +90,11 @@ main (int argc, char **argv)
users = 0;
#ifdef HAVE_LIBSYSTEMD
if (sd_booted () > 0)
users = sd_get_sessions (NULL);
else {
#endif
#if HAVE_WTSAPI32_H
if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
0, 1, &wtsinfo, &wtscount)) {
@ -156,6 +166,9 @@ main (int argc, char **argv)
if (spclose (child_process))
result = possibly_set (result, STATE_UNKNOWN);
#endif
#ifdef HAVE_LIBSYSTEMD
}
#endif
/* check the user count against warning and critical thresholds */
result = get_status((double)users, thlds);
@ -163,7 +176,7 @@ main (int argc, char **argv)
if (result == STATE_UNKNOWN)
printf ("%s\n", _("Unable to read output"));
else {
printf (_("USERS %s - %d users currently logged in |%s\n"),
printf (_("USERS %s - %d users currently logged in |%s\n"),
state_text(result), users,
sperfdata_int("users", users, "", warning_range,
critical_range, TRUE, 0, FALSE, 0));

View file

@ -400,7 +400,7 @@ int phr_parse_request(const char *buf_start, size_t len, const char **method, si
*num_headers = 0;
/* if last_len != 0, check if the request is complete (a fast countermeasure
againt slowloris */
against slowloris */
if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
return r;
}
@ -435,7 +435,7 @@ static const char *parse_response(const char *buf, const char *buf_end, int *maj
}
PARSE_INT_3(status);
/* get message includig preceding space */
/* get message including preceding space */
if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
return NULL;
}

View file

@ -14,7 +14,7 @@
* FILE * spopen(const char *);
* int spclose(FILE *);
*
* Code taken with liitle modification from "Advanced Programming for the Unix
* Code taken with little modification from "Advanced Programming for the Unix
* Environment" by W. Richard Stevens
*
* This is considered safe in that no shell is spawned, and the environment

View file

@ -44,6 +44,8 @@
# include <sys/wait.h>
#endif
#include "./utils.h"
/** macros **/
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@ -114,10 +116,6 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
env[0] = strdup("LC_ALL=C");
env[1] = '\0';
/* if no command was passed, return with no error */
if (cmdstring == NULL)
return -1;
/* make copy of command string so strtok() doesn't silently modify it */
/* (the calling program may want to access it later) */
cmdlen = strlen(cmdstring);
@ -203,7 +201,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
}
/* parent picks up execution here */
/* close childs descriptors in our address space */
/* close children descriptors in our address space */
close(pfd[1]);
close(pfderr[1]);

View file

@ -19,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic
plan tests => 42;
# Some random check strings/response
my @responce = ('OK: Everything is fine',
my @response = ('OK: Everything is fine',
'WARNING: Hey, pick me, pick me',
'CRITICAL: Shit happens',
'UNKNOWN: What can I do for ya',
'WOOPS: What did I smoke',
);
my @responce_re;
my @response_re;
my @check;
for (@responce) {
for (@response) {
push(@check, "echo $_");
my $re_str = $_;
$re_str =~ s{(.)} { "\Q$1" }ge;
push(@responce_re, $re_str);
push(@response_re, $re_str);
}
my $result;
@ -47,7 +47,7 @@ for (my $i=0; $i<4; $i++) {
"./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'"
);
cmp_ok($result->return_code, '==', $i, "Exit with return code $i");
is($result->output, $responce[$i], "Status text is correct for check $i");
is($result->output, $response[$i], "Status text is correct for check $i");
}
$result = NPTest->testCmd(
@ -84,7 +84,7 @@ $result = NPTest->testCmd(
"./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'"
);
cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)");
is($result->output, $responce[4], "Return proper status text even with unknown status codes");
is($result->output, $response[4], "Return proper status text even with unknown status codes");
$result = NPTest->testCmd(
"./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'"
@ -108,7 +108,7 @@ my %linemap = (
foreach my $line (0, 2, 4, 6) {
my $code = $linemap{$line};
my $statline = $line+1;
is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line");
is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line");
is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line");
}
@ -124,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!");
cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed');
for (0) {
if ($pasv[$_]) {
like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check');
like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check');
} else {
fail('proper result for passive check');
}
@ -144,7 +144,7 @@ for (0, 1, 2, 3, 4) {
if ($pasv[$_]) {
my $ret = $_;
$ret = 9 if ($_ == 4);
like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_");
like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_");
} else {
fail("proper result for passive check $_");
}

View file

@ -326,19 +326,19 @@ cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free meg
$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
# regex: exit unknown if given regex is not compileable
# regex: exit unknown if given regex is not compilable
$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable");
cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compilable");
# ignore: exit unknown, if all pathes are deselected using -i
# ignore: exit unknown, if all paths are deselected using -i
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
# ignore: exit unknown, if all pathes are deselected using -I
# ignore: exit unknown, if all paths are deselected using -I
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
# ignore: exit unknown, if all pathes are deselected using -i
# ignore: exit unknown, if all paths are deselected using -i
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
@ -347,7 +347,7 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mo
like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
# ignore: test if all pathes are listed when ignore regex doesn't match
# ignore: test if all paths are listed when ignore regex doesn't match
$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");

View file

@ -178,13 +178,13 @@ SKIP: {
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302");
is( $res->return_code, 0, "Proxy HTTP works");
like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent");
like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficient");
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT");
is( $res->return_code, 0, "Proxy HTTP CONNECT works");
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent");
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
$res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD");
is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method");
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent");
like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
}

View file

@ -5,7 +5,7 @@
#
#
# These are the database permissions required for this test:
# GRANT SELECT ON $db.* TO $user@$host INDENTIFIED BY '$password';
# GRANT SELECT ON $db.* TO $user@$host IDENTIFIED BY '$password';
# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host;
# Check with:
# mysql -u$user -p$password -h$host $db
@ -23,9 +23,9 @@ plan tests => 15;
my $bad_login_output = '/Access denied for user /';
my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest");
my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest");
my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup");
my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest");
my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest");
my $result;

View file

@ -31,7 +31,7 @@ $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver $
cmp_ok( $result->return_code, '==', 0, "Can run query");
$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details");
cmp_ok( $result->return_code, '==', 3, "Missing query parmeter");
cmp_ok( $result->return_code, '==', 3, "Missing query parameter");
like( $result->output, "/Must specify a SQL query to run/", "Missing query error message");
$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql");

View file

@ -36,7 +36,7 @@ cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" );
like ( $result->output, $warningOutput, "Output for warning correct" );
my $now = time;
# This substitution is dependant on the testcase
# This substitution is dependent on the testcase
system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
$result = NPTest->testCmd(

View file

@ -8,12 +8,14 @@ use strict;
use Test::More;
use NPTest;
my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP",
my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP",
"A host providing an SMTP Service (a mail server)", "mailhost");
my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS",
my $host_tcp_smtp_starttls = getTestParameter( "NP_HOST_TCP_SMTP_STARTTLS",
"A host providing SMTP with STARTTLS", $host_tcp_smtp);
my $host_tcp_smtp_nostarttls = getTestParameter( "NP_HOST_TCP_SMTP_NOSTARTTLS",
"A host providing SMTP without STARTTLS", "");
my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS",
"A host providing SMTP with TLS", $host_tcp_smtp);
my $host_tcp_smtp_notls = getTestParameter( "NP_HOST_TCP_SMTP_NOTLS",
"A host providing SMTP without TLS", "");
my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
"The hostname of system not responsive to network requests", "10.0.0.1" );
@ -22,7 +24,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
"An invalid (not known to DNS) hostname", "nosuchhost" );
my $res;
plan tests => 10;
plan tests => 16;
SKIP: {
skip "No SMTP server defined", 4 unless $host_tcp_smtp;
@ -42,22 +44,38 @@ SKIP: {
local $TODO = "Output is over two lines";
like ( $res->output, qr/^SMTP WARNING/, "Correct error message" );
}
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" );
is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" );
like ($res->output, qr/^CRITICAL - Cannot make SSL connection\./, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port");
}
SKIP: {
skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls;
# SSL connection for TLS
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p 25 -S" );
skip "No SMTP server with STARTTLS defined", 1 unless $host_tcp_smtp_starttls;
# SSL connection for STARTTLS
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_starttls -p 25 -S" );
is ($res->return_code, 0, "OK, with STARTTLS" );
}
SKIP: {
skip "No SMTP server without TLS defined", 2 unless $host_tcp_smtp_notls;
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_notls -p 25 -S" );
is ($res->return_code, 1, "OK, got warning from server without TLS");
skip "No SMTP server without STARTTLS defined", 2 unless $host_tcp_smtp_nostarttls;
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_nostarttls -p 25 -S" );
is ($res->return_code, 1, "OK, got warning from server without STARTTLS");
is ($res->output, "WARNING - TLS not supported by server", "Right error message" );
}
SKIP: {
skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls;
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" );
is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" );
like ($res->output, qr/^SMTP OK - /, "Check output of connecting to $host_tcp_smtp_tls with TLS" );
my $unused_port = 4465;
$res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" );
is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port" );
like ($res->output, qr/^connect to address $host_tcp_smtp_tls and port $unused_port: Connection refused/, "Check output of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port");
}
$res = NPTest->testCmd( "./check_smtp $host_nonresponsive" );
is ($res->return_code, 2, "CRITICAL - host non responding" );

View file

@ -26,22 +26,22 @@ $res = NPTest->testCmd( "./check_snmp -t 1" );
is( $res->return_code, 3, "No host name" );
is( $res->output, "No host specified" );
$res = NPTest->testCmd( "./check_snmp -H fakehostname" );
$res = NPTest->testCmd( "./check_snmp -H fakehostname --ignore-mib-parsing-errors" );
is( $res->return_code, 3, "No OIDs specified" );
is( $res->output, "No OIDs specified" );
$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" );
$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3 -U not_a_user --seclevel=rubbish" );
is( $res->return_code, 3, "Invalid seclevel" );
like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3c" );
$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3c" );
is( $res->return_code, 3, "Invalid protocol" );
like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
SKIP: {
skip "no snmp host defined", 50 if ( ! $host_snmp );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK");
$res->output =~ /^SNMP OK - (\d+)/;
@ -51,111 +51,111 @@ SKIP: {
# some more threshold tests
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1");
cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:");
cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c ~:1");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c ~:1");
cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:10");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:10");
cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c \@1:10");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c \@1:10");
cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 10:1");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 10:1");
cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" );
like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" );
unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0,system.sysDescr.0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0,system.sysDescr.0");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" );
like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" );
like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" );
like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:");
cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " );
like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0");
cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" );
like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2");
cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" );
like($res->output, "/^SNMP OK - 2 1/", "Got two values back" );
like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2");
cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" );
like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" );
like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:");
cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses");
like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0");
cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds");
like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3");
$res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/;
my $lower = $1 - 0.05;
my $higher = $1 + 0.05;
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher");
cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2");
cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold");
like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''");
cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2");
cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check");
like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,");
cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds");
like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'");
cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold");
like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0");
cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1");
cmp_ok( $res->return_code, '==', 0, "snmp response without datatype");
like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" );
}
SKIP: {
skip "no SNMP user defined", 1 if ( ! $user_snmp );
$res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
$res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
}
@ -163,14 +163,14 @@ SKIP: {
# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
SKIP: {
skip "no non responsive host defined", 2 if ( ! $host_nonresponsive );
$res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" );
like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem");
}
SKIP: {
skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
$res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
$res = NPTest->testCmd( "./check_snmp -H $hostname_invalid --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host)/', "String matches invalid host");
like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host).*/s', "String matches invalid host");
}

View file

@ -84,7 +84,7 @@ foreach my $current_state (keys(%state)) {
foreach my $new_state (keys(%state)) {
$res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" );
is( $res->output, uc($new_state).": Fake $new_state", "Substitued fake $new_state output");
is( $res->output, uc($new_state).": Fake $new_state", "Substituted fake $new_state output");
}
}

View file

@ -8,7 +8,7 @@ use Test::More;
use NPTest;
if (-x "./check_procs") {
plan tests => 52;
plan tests => 54;
} else {
plan skip_all => "No check_procs compiled";
}
@ -34,9 +34,13 @@ is( $result->return_code, 0, "Checking no threshold breeched" );
is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
$result = NPTest->testCmd( "$command -C launchd -c 5" );
is( $result->return_code, 2, "Checking processes filtered by command name" );
is( $result->return_code, 2, "Checking processes matched by command name" );
is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
$result = NPTest->testCmd( "$command -X bash -c 5" );
is( $result->return_code, 2, "Checking processes excluded by command name" );
is( $result->output, "PROCS CRITICAL: 95 processes with exclude progs 'bash' | procs=95;;5;0;", "Output correct" );
SKIP: {
skip 'user with uid 501 required', 4 unless getpwuid(501);

View file

@ -53,7 +53,7 @@ if ($pid) {
#print "child\n";
print "Please contact SNMP at: $port_snmp\n";
close(STDERR); # Coment out to debug snmpd problems (most errors sent there are OK)
close(STDERR); # Comment out to debug snmpd problems (most errors sent there are OK)
exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
}
@ -227,7 +227,7 @@ is($res->output, 'SNMP OK - "555\"I said\"" | ', "Check string with a double quo
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" );
is($res->return_code, 0, "String check should check whole string, not a parsed number" );
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string");
is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check with numbers returns whole string");
$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
is($res->return_code, 0, "Negative integer check OK" );

View file

@ -7,7 +7,7 @@
/* The purpose of this package is to provide safer alternatives to C
functions that might otherwise be vulnerable to hacking. This
currently includes a standard suite of validation routines to be sure
that an string argument acually converts to its intended type and a
that an string argument actually converts to its intended type and a
suite of string handling routine that do their own memory management
in order to resist overflow attacks. In addition, a few functions are
provided to standardize version and error reporting across the entire

View file

@ -8,7 +8,7 @@ subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format --no-location
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding

2243
po/de.po

File diff suppressed because it is too large Load diff

2125
po/fr.po

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -291,7 +291,7 @@ always returns 0.
.Xc
.El
.Pp
For maximum compatability your test program should return a particular
For maximum compatibility your test program should return a particular
exit code. This is calculated by
.Fn exit_status
so it is sufficient to always return from
@ -309,7 +309,7 @@ directory in the source distribution contains numerous tests of
functionality, written using
.Nm .
Examine them for examples of how to construct test suites.
.Sh COMPATABILITY
.Sh COMPATIBILITY
.Nm
strives to be compatible with the Perl Test::More and Test::Harness
modules. The test suite verifies that

View file

@ -25,7 +25,7 @@
*/
/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
and requires the caller to add the final comma if they've ommitted
and requires the caller to add the final comma if they've omitted
the optional arguments */
#ifdef __GNUC__
# define ok(e, test, ...) ((e) ? \

View file

@ -140,7 +140,7 @@ my $libs = "$destdir/$prefix/lib:$destdir/$prefix/lib/$Config{archname}";
my $topdir = cwd();
# set an initial value if there isnt one already
# set an initial value if there isn't one already
# Need to use PERL5LIB to ensure we get pre-installed mods from earlier
# tags in the install_order file
$ENV{PERL5LIB} ||= q{};
@ -149,8 +149,8 @@ $ENV{PERL5LIB} ||= q{};
$ENV{PERL_AUTOINSTALL} = "--skipdeps";
# keep a record of how many times a module build is done. This is so they may
# be built a second time to include optional prereq's that couldnt
# previously be built due to circular dependancies
# be built a second time to include optional prereq's that couldn't
# previously be built due to circular dependencies
my %built_modules;
foreach my $tarball (@tarballs) {
( my $dir = $tarball ) =~ s/\.(?:tgz|tar.gz)$//;

View file

@ -2,7 +2,7 @@
#
# Hacked version of the sample code from the perlembedded doco.
#
# Only major changes are to separate the compiling and cacheing from
# Only major changes are to separate the compiling and caching from
# the execution so that the cache can be kept in "non-volatile" parent
# process while the execution is done from "volatile" child processes
# and that STDOUT is redirected to a file by means of a tied filehandle

View file

@ -138,7 +138,7 @@ sub BuildIt {
# interprets that as the end of the mail, and truncates the log before
# it gets to Tinderbox. (terry weismann, chris yeh)
#
# This was replaced by a perl 'port' of the above, writen by
# This was replaced by a perl 'port' of the above, written by
# preed@netscape.com; good things: no need for system() call, and now it's
# all in perl, so we don't have to do OS checking like before.