Commit graph

96 commits

Author SHA1 Message Date
RincewindsHat
4549a95243
Merge pull request #1654 from wolfgangkarall/master
check_procs -- exchange needle and haystack in strstr() for proper st…
2021-11-17 18:09:25 +01:00
Sven Nierlein
1738d14c0c check_procs: remove trailing whitespace 2021-11-01 13:35:11 +01:00
Wolfgang Karall-Ahlborn
8eaccee190 check_procs -- exchange needle and haystack in strstr() for proper state match 2021-01-03 11:27:44 +01:00
ChrisWi
a58ea5ec5d improve command examples for 'at least' processes 2019-03-21 14:18:37 +01:00
Sven Nierlein
edca257e20 use unknown exit code for help/version in plugins
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2015-10-04 19:24:30 +02:00
Thomas Guyot-Sionnest
11cf54ca78 Merge branch 'rename' 2014-01-21 07:59:07 -05:00
Spenser Reinhardt
66544851f7 plugins/*.c: Non-network timeout changes
Changes to non-network checks for clarity on timeout value. Adapted from pull request #1209 tracker from user awiddersheim. (Closes: #1209)
Files: check_apt.c, check_disk.c, check_procs.c, negate.c
2014-01-21 11:35:07 +01:00
Spenser Reinhardt
212575b858 plugins/*.c: Alterations for timeout messages.
.c file changes for misleading timeout messages in help functions. Solution to pull request #1209 tracker by awiddersheim.

Files: plugins/check_apt.c, plugins/check_by_ssh.c, plugins/check_dbi.c, plugins/check_dig.c, plugins/check_disk.c, plugins/check_dns.c, plugins/check_game.c, plugins/check_http.c, plugins/check_ldap.c, plugins/check_ntp.c, plugins/check_ntp_peer.c, plugins/check_ntp_time.c, plugins/check_nwstat.c, plugins/check_overcr.c, plugins/check_pgsql.c, plugins/check_ping.c, plugins/check_procs.c, plugins/check_radius.c, plugins/check_real.c, plugins/check_smtp.c, plugins/check_snmp.c, plugins/check_ssh.c, plugins/check_tcp.c, plugins/check_time.c, plugins/check_ups.c, plugins/negate.c
2014-01-21 11:33:45 +01:00
Holger Weiss
c3e756a855 Capitalize "Monitoring" when it's the first word 2014-01-20 03:12:50 +01:00
Monitoring Plugins Development Team
63734f52ab Project rename initial commit.
This is an initial take at renaming the project to Monitoring Plugins.
It's not expected to be fully complete, and it is expected to break
things (The perl module for instance). More testing will be required
before this goes mainline.
2014-01-19 14:18:47 -05:00
Anton Lofgren
77fc3548ae check_procs: ignore plugin parent process
This fixes an issue that appears when running check_procs over NRPE,
where the default shell is configured to (for example) dash, as is the
case on Debian.

dash (and tcsh, and mksh, and probably others), when invoked with -c forks an additional process
to execute the argument string. Contrast this with bash, which does not
do this, provided that the argument string simply can be exec()'d as-is.

To demonstrate:
$ bash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───pstree

versus
$ dash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───dash───pstree

The consequence of this fork is that the following invocation:
    /opt/plugins/check_procs -a init

will result in this output:

    PROCS OK: 2 processes with args 'init' | processes=2;;;0;

because the check_procs, in addition to finding the actual init process,
finds its parent shell as well.

This example is a bit contrived, but I think it illustrates the
point.

This wouldn't really be a problem, and normally isn't, if it weren't
for the fact that NRPE uses a call to popen() which does exactly the
above (executes '/bin/sh -c ...'), causing inconsistent behaviour
between distributions and much confusion for end users.

The argument may be made that the dash process spawned by NRPE is just a
process like any other, and should therefore be included in the process
count just like any other. However, this is not very intuitive, because
of the previously mentioned inconsistencies.

The argument might also well be made that we're _never_ interested in the
immediate ancestor of the plugin, and while it is unknown how many
installations have already made the necessary modifications to their
setups to make up for the fact that the plugin behaves the way it does,
it is not deemed worthwhile to entertain such workarounds.

Thus, this patch ignores the parent process.

See also these bug reports:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626913
http://sourceforge.net/p/nagiosplug/bugs/512/
https://github.com/nagios-plugins/nagios-plugins/issues/999
https://bugs.op5.com/view.php?id=4398
2013-11-19 23:57:27 +01:00
Holger Weiss
d4a781817c Fix GCC's -Wuninitialized warnings
Fix the issues found by GCC when the -Wuninitialized flag is specified.
2013-09-10 20:52:13 +02:00
Sebastian Schmidt
2f79329c41 check_procs: clarify debug message 2013-08-18 12:59:57 +02:00
Sebastian Schmidt
0efedfb77c check_procs: Assume we have stat()
stat() is in gnulib anyway, so we can safely depend on it.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
0f686d436e check_procs: Get rid of HAVE_PROC_PID_EXE
Don't check for /proc/pid/exe at compile time, it could be gone in a
build chroot or the like. Checking at runtime (once) is sufficient.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
d5677d9b42 check_procs: Ignore ENOENT when checking for myself
Previously, when a process exited between the call to /bin/ps and
stat("/proc/his/exe") was exiting it was not considered as possible
instance of check_procs. This commit makes check_procs ignore all
processes where /proc/pid/exe does not exist.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
274f3ddee2 check_procs: fix typo
Fix a typo in previous commit where st_ was missing in the mock
struct_stat_t, causing check_procs.c to not compile without sys/stat.h.
2013-08-18 12:59:57 +02:00
Sebastian Schmidt
ce7a99789d check_procs: filter out self by /proc/pid/exe
Make check_procs filter out itself in the process list by comparing the
file pointed to by /proc/pid/exe. On platforms where this is not
available or when check_procs is passed the -T flag, the old behaviour
(check whether PID equals getpid()) is retained.

This fixes some false alarms when e.g. Nagios has, for whatever reasons,
some backlog of checks to run and check_procs with -a is called more
than once in a short time, matching its sister process.
2013-08-18 12:59:57 +02:00
Richard Leitner
3931bd9500 Fixed SF.net bug #3552839, check_procs: added -k option to ignore kernel threads
This commit fixes sourceforge.net bug #3552839.
It adds a -k|--no-kthreads option to ignore kernel thread processes.
Please note: currently this feature only works for GNU/Linux systems (due to the fact I have no other systems to test/develop on)
Sorry for that, but I'm sure this can be accomplished by somebody else ;-)
2013-08-18 00:55:34 +02:00
Joerg Linge
e0eb2ebca3 Update plugins/check_procs.c
added missing longopt --user
2013-02-27 23:18:14 +01:00
Holger Weiss
92b937e49e check_procs: Remove superfluous newline character 2012-11-14 20:53:47 +01:00
Sebastian Harl
e683a8dce5 check_procs: Added performance data to plugin output. 2012-11-14 20:45:44 +01:00
Sebastian Harl
2bac48c027 check_procs: Use the range/threshold support functions from libnagiosplug.
This adds support for @<range> and makes stuff a bit simpler by removing code
duplications.

Note: Previously, the compatibility code for 'check_procs <warn> <max>'
accepted something like 'check_procs -w 10:-1 -c 10:-1 20 50' as well
(treating it as if '-w 10:20 -c 10:50' was specified). This is no longer the
case ... additional arguments are only used as warn/crit thresholds in case
-w/-c is not specified at all.
2012-11-14 20:45:44 +01:00
Anders Kaseorg
028d50d6f9 Die when asprintf fails
Fixes many instances of
warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-06-29 13:39:11 +02:00
Ton Voon
1a5a83bb82 Fix for regex input of '|', being output causing problems with Nagios' parsing of
performance data. Now replaced with ','
2011-01-21 13:14:33 +00:00
Thomas Guyot-Sionnest
eaf3cb27f4 Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
Thomas Guyot-Sionnest
884aee0667 Standardize the extra-opts notes 2010-04-21 23:29:18 -04:00
Thomas Guyot-Sionnest
25d1ee331d Fix translations when extra-opts aren't enabled
Bug #2832884 reported problem with translations outputting pot file
headers. This is caused by "" matching the header of the translation
files.

This patch moves gettext macros inside utils macros and update some
french translations.
2010-04-14 08:33:06 -04:00
Ton Voon
5324544855 Typo fixes (Jan Wagner - SF 1878971) 2009-02-20 00:00:13 +00:00
Thomas Guyot-Sionnest
6fbd14fea5 Removing CVS/SVN tags and replacing with git-based versioning
For contrib/, full tags have been imported from subversion


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2091 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-23 05:38:47 +00:00
Ton Voon
b93562e6e2 check_procs captures stderr and adds to plugin output. This is
from a merge of branch nagiosplug/branches/new_threshold_syntax 1979:1982


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2019 f882894a-f735-0410-b71e-b25c423dba1c
2008-07-08 09:31:04 +00:00
Thomas Guyot-Sionnest
44f8455b2c Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1991 f882894a-f735-0410-b71e-b25c423dba1c
2008-05-07 10:02:42 +00:00
Thomas Guyot-Sionnest
ed62784a0b --help output cleanup (plus removal of spaces on blank lines)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1984 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-27 14:35:26 +00:00
Ton Voon
a36696e454 Updated check_procs with a hidden --input-file option.
Include some sample outputs for testing


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1954 f882894a-f735-0410-b71e-b25c423dba1c
2008-03-18 01:21:54 +00:00
Ton Voon
9f3d864fd3 Reverted check_procs for solaris back to using pst3 due to truncation
for argument fields using other methods


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1937 f882894a-f735-0410-b71e-b25c423dba1c
2008-02-28 16:21:59 +00:00
Thomas Guyot-Sionnest
6c4468a728 Bump plugin/ to GPLv3 (check_overcr to check_users)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1917 f882894a-f735-0410-b71e-b25c423dba1c
2008-01-31 10:44:26 +00:00
Matthias Eble
446b89f839 Cleaned check_procs usage output (Ferenc Wagner #1862218)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1885 f882894a-f735-0410-b71e-b25c423dba1c
2008-01-04 22:10:37 +00:00
Matthias Eble
d77b785d23 Make ps column count in zombie detection less restrictive. Thanks to Andrew Elwell (#1280470)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1758 f882894a-f735-0410-b71e-b25c423dba1c
2007-07-15 15:21:51 +00:00
Ton Voon
4ad5dcce03 Use /usr/ucb/ps on Solaris in preference to pst3 (problems in 64bit mode)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1629 f882894a-f735-0410-b71e-b25c423dba1c
2007-03-06 17:29:15 +00:00
Holger Weiss
fd329a1e91 Don't try to print `optarg' (which will be a NULL pointer) if an unknown
command line option was used, as this leads to a segfault on some
systems.  The unknown option will be printed by getopt(3) anyway.  So,
simply call print_usage() and exit UNKNOWN via the new usage5() instead.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1590 f882894a-f735-0410-b71e-b25c423dba1c
2007-01-28 21:46:41 +00:00
Ton Voon
49d8064bf3 Various cleanups in the syncing with gnulib
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1581 f882894a-f735-0410-b71e-b25c423dba1c
2007-01-24 23:18:05 +00:00
Thomas Guyot-Sionnest
e4af02e9dd Fix bug #1630970 Fix for buffer overflow of check_procs procprog string
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1566 f882894a-f735-0410-b71e-b25c423dba1c
2007-01-17 05:28:22 +00:00
Benoit Mortier
bc0a22110d more localization fixes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1514 f882894a-f735-0410-b71e-b25c423dba1c
2006-10-22 22:03:31 +00:00
Benoit Mortier
082cfc29e3 first pass at cleaning localization for new release
first pass at making all the headre be the same licence, plugin, etc...


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1499 f882894a-f735-0410-b71e-b25c423dba1c
2006-10-19 00:25:16 +00:00
Ton Voon
6b9cc76d0a Using coreutils' base_name function because of portability issues with
Tru64


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1450 f882894a-f735-0410-b71e-b25c423dba1c
2006-07-13 08:54:57 +00:00
Benoit Mortier
f2d66913f9 cleaning help and usage + license
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1435 f882894a-f735-0410-b71e-b25c423dba1c
2006-06-20 11:17:03 +00:00
Benoit Mortier
cbbfed30eb cleaning up help and usage
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1433 f882894a-f735-0410-b71e-b25c423dba1c
2006-06-17 12:28:43 +00:00
Ton Voon
34cb16d283 Internal version of basename if one not found in system
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1383 f882894a-f735-0410-b71e-b25c423dba1c
2006-04-27 13:25:10 +00:00
Ton Voon
8c6126f91c Use pid_t for pids (1463853)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1368 f882894a-f735-0410-b71e-b25c423dba1c
2006-04-05 08:06:19 +00:00
M. Sean Finney
91bd5cfc68 set LC_NUMERIC to POSIX in check_procs.c
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1316 f882894a-f735-0410-b71e-b25c423dba1c
2006-02-17 06:24:53 +00:00