Commit graph

33 commits

Author SHA1 Message Date
Sven Nierlein
024d268386 check_snmp: fix performance thresholds when using multiple oids
when using check_snmp with multiple oids it simply printed the unparsed content
from -w/-c into the thresholds for each oid. So each oid contained the hole -w
from all oids.

./check_snmp ... -o iso.3.6.1.2.1.25.1.3.0,iso.3.6.1.2.1.25.1.5.0 -w '1,2' -c '3,4'

before:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1,2;3,4 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;1,2;3,4

after:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1;3 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;2;4

This also applies to fixed thresholds since check_snmp translates negative infinities from: '~:-1' to '@-1:~'
2021-11-17 14:04:09 +01:00
Sven Nierlein
7cafb0e845 check_by_ssh: fix child process leak on timeouts
When check_by_ssh runs into a timeout it simply exits keeping all child processes running.
Simply adopting the kill loop from runcmd_timeout_alarm_handler() fixes this.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-02-15 10:36:28 +01:00
Guido Falsi
c76f59bcc0 Avoid passing NULL to vprintf(). 2018-09-29 16:22:44 +02:00
Holger Weiss
f40fc650f7 Revert "Make use of xasprintf instead of asprintf"
This reverts commit a143739ed2.

Our current setup doesn't allow lib/*.c files to call functions defined
in plugins/utils.[ch].
2014-10-06 22:09:10 +02:00
Jan Wagner
a143739ed2 Make use of xasprintf instead of asprintf
---
Closes #1278
2014-07-30 14:53:07 +02:00
Ricardo Maraschini
15d14d28bb lib/utils_base.c: if asprintf fails, string is undefined
if asprintf fails, string content becomes invalid. we need
to check if it ran OK by checking the returned value.

in case of fail, asprintf returns -1, otherwise the number
of writen bytes is returned.

also, on ubuntu 13.10 i've receiving a lot of warnings:

"warning: ignoring return value of ‘asprintf’"

this patches fixes some of them

Signed-off-by: Ricardo Maraschini <ricardo.maraschini@gmail.com>
---
Closes #1227
2014-07-30 14:48:09 +02:00
Jan Wagner
ba21e26443 check_icmp/check_dhcp: disable check, if we are root
As it is possible to use capabilities(7) on linux or solaris
privileges for example, it is not necessary in all cases to
have those binaries making use of setuid.
2014-07-06 13:29:24 +02:00
Holger Weiss
eb85a612a3 Add UID to state retention file path
Add the UID of the invoking user to the state retention file path.  This
helps solving permission issues when different users run the same
plugin.
2014-06-21 15:15:44 +02:00
Thomas Guyot-Sionnest
8fc9e5ac4b Move negate' translate_state() to utils_base.h mp_translate_state()
Also use strcasecmp imported from gnulib for simplicity
2014-01-29 03:20:23 -05:00
Thomas Guyot-Sionnest
189e2aa344 Rename MP_STATE_DIRECTORY to MP_STATE_PATH 2014-01-27 08:35:23 -05:00
Thomas Guyot-Sionnest
4a10a9493a And release notes for previous change (MP_STATE_DIRECTORY)
The change has also been updated in
https://www.monitoring-plugins.org/doc/state-retention.html
2014-01-27 02:18:06 -05:00
Thomas Guyot-Sionnest
68fe713335 Ignore MP_STATE_DIRECTORY in suid plugins
If a plugin still has suid privileges at the time np_enable_state() is
called, the MP_STATE_DIRECTORY environment will be ignored.

There is no need for a NEWS entry as no suid plugins use np_enable_state
yet.
2014-01-25 04:22:09 -05:00
Thomas Guyot-Sionnest
4caf4ce4fe Rename ENV variable, keep backward compatibility
Rename NAGIOS_PLUGIN_STATE_DIRECTORY to MP_STATE_DIRECTORY
2014-01-25 03:35:46 -05: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
Holger Weiss
b48cb1f130 Fix GCC's -Wimplicit-function-declaration warnings
Fix the issues found by GCC when the -Wimplicit-function-declaration
flag is specified.
2013-09-10 22:29:46 +02:00
Sven Nierlein
4083622f86 added missing header to fix build on freebsd 2013-08-20 17:02:02 +02:00
Andreas Ericsson
364ce21b10 lib/utils_base.c: Stop dumping core on bad args to check_snmp
Since the state patch introduction, we've been freeing uninitialized
memory in lib/utils_base.c::np_cleanup(), which caused coredumps
with check_snmp when illegal threshold ranges (for example) were
passed, or when we called 'die' without having read any state.

This patch fixes it by replacing the malloc() calls in there (all of
them, since using malloc() is almost always an error) with calloc().

malloc() either doesn't initialize the memory at all, or taints it
with a special marker so it can tell us when we're free()'ing memory
that hasn't been initialized. calloc() explicitly initializes the
allocated memory to nul bytes, which is a zero-cost operation when
we get the memory from the kernel (which alread does that) and almost
always desirable everywhere else.

Signed-off-by: Andreas Ericsson <ae@op5.se>
2012-11-02 22:25:37 -04:00
Ton Voon
2ad344a47b Cleanup some warnings displayed from IRIX tinderbox server 2010-06-24 10:08:13 +01:00
Ton Voon
18f6835eda Added state retention APIs. Implemented for check_snmp with --rate option.
See http://nagiosplugin.org/c-api-private for more details on the API.

Also updated check_snmp -l option to change the perfdata label.
2010-06-23 13:30:34 +00:00
Holger Weiss
9eabd8d054 Fix the memory allocation for the thresholds data
Allocate the appropriate amount of memory for storing the thresholds
data.  Before, we allocated the amount of memory required for storing a
_pointer_ to the thresholds data.  This crashed (at least) check_mysql
when using its "-S" option on FreeBSD/amd64 (as reported and analyzed by
Nikita Kalabukhov - 2797757).

Signed-off-by: Holger Weiss <holger@zedat.fu-berlin.de>
2009-06-02 01:11:19 +02:00
Thomas Guyot-Sionnest
ba132e9e52 Make extract_value more generic:
Add a separator argument passed using defines.
2009-01-26 02:05:21 -05:00
Thomas Guyot-Sionnest
a4647be424 Move check_ntp's extract_value to utils_base.c.
This function can also be used to parse performance data strings which
could be useful in the future.
2009-01-21 01:27:40 -05: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
Thomas Guyot-Sionnest
caa8bd6423 Bulk EOL cleanup
$ git diff --ignore-space-change|diffstat
 0 files changed


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2087 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-19 06:45:18 +00:00
Ton Voon
dc2ec71d22 Fixed link -m64 problems on pst3 for solaris. Fixed _FILE_OFFSET_BITS
redefinition warnings. Fixed helper ar error in ./configure


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1938 f882894a-f735-0410-b71e-b25c423dba1c
2008-03-11 00:10:23 +00:00
Thomas Guyot-Sionnest
fe2e5f4aec set_thresholds now let the user free the thresolds. (P.S.: When you set twice the thresholds for a path in check disk (like using -C followed by -p ) it overrides them. All new elements are created with np_add_parameter which initialises the thresholds to NULL.)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1930 f882894a-f735-0410-b71e-b25c423dba1c
2008-02-13 11:05:44 +00:00
Thomas Guyot-Sionnest
fafb8ead9d Bump /lib to GPLv3
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1913 f882894a-f735-0410-b71e-b25c423dba1c
2008-01-30 09:33:43 +00:00
Holger Weiss
d18b8f5d94 Don't use C++ style comments.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1768 f882894a-f735-0410-b71e-b25c423dba1c
2007-07-29 12:42:05 +00:00
M. Sean Finney
bf9f0e9f89 added functions to utils_base:
np_check_if_root() - returns nonzero if geteuid()==0
  np_warn_if_not_root() - uses the above to print an informative warning
added uses of these functions to check_dhcp and check_icmp.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1718 f882894a-f735-0410-b71e-b25c423dba1c
2007-05-27 13:46:32 +00:00
Holger Weiss
35fcc425a6 Change the variable names true' and false' (which are keywords in C99)
to `yes' and `no'.  Fixes compilation when using SGI's MIPSpro c99(1).


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1588 f882894a-f735-0410-b71e-b25c423dba1c
2007-01-27 17:49:08 +00:00
Ton Voon
c56c42b9c9 Cater for different errors when setting thresholds
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1496 f882894a-f735-0410-b71e-b25c423dba1c
2006-10-18 12:03:10 +00:00
Ton Voon
426ef84181 Missing header files
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1454 f882894a-f735-0410-b71e-b25c423dba1c
2006-07-14 09:47:25 +00:00
Ton Voon
5912398b97 Major fixes to check_disk. Now should return same data as df
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1452 f882894a-f735-0410-b71e-b25c423dba1c
2006-07-13 23:58:00 +00:00