Commit graph

207 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
RincewindsHat
50fc9b73a2 Switch to uint64_t 2021-10-26 17:07:09 +02:00
Sven Nierlein
555559fd30
Merge pull request #1567 from vdanjean/master
[check_disk] add support to display inodes usage in perfdata
2019-02-19 21:49:13 +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
Vincent Danjean
270e7cba38 [check_disk] add support to display inodes usage in perfdata
This is not enabled by default
It can be enabled with the -P (--iperfdata) option
2018-12-08 22:44:42 +01:00
Guido Falsi
c76f59bcc0 Avoid passing NULL to vprintf(). 2018-09-29 16:22:44 +02:00
Sven Nierlein
7660540c31 make constants from maxfd values (#1300)
its good practice to use constants instead of (random) values.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2014-11-28 15:25:43 +01:00
nafets
6bb5e1db52 avoid a segfault, if ulimit is set to unlimited 2014-11-28 15:21:23 +01: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
Spenser Reinhardt
9123f6146c lib/utils_cmd.c - Free file descriptor
Coverity 66502 - File descriptor fd in cmd_file_read is never closed, and thus file is left open after usage throughout runtime. - SR
2014-06-28 18:24:46 +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
Holger Weiss
dc0f25cf76 lib/parse_ini.c: Print proper read error message
Print a useful error message if opening the configuration file fails.
2014-06-18 23:42:57 +02:00
Holger Weiss
48025ff39c lib/parse_ini.c: Drop privileges for reading file
Read the configuration file with privileges temporarily dropped if the
code is used by a setuid plugin.
2014-06-18 23:22:12 +02:00
Holger Weiss
2bf7647be6 lib/parse_ini.c: Add newline to die() calls
Our die() function doesn't append a newline character to the message.
2014-06-18 23:15:21 +02:00
Holger Weiss
b81c10e00c lib/parse_ini.c: Cosmetic change
Replace an "if" with the ternary operator.
2014-06-18 23:09:02 +02:00
Holger Weiss
f0b22b37f9 lib/parse_ini.c: Search for INI file in subdirs
Add two path names to the list of default INI file locations, as some
users/distributions prefer to put configuration files into
subdirectories.
2014-06-18 18:39:32 +02:00
Holger Weiss
6da7dba782 lib/parse_ini.c: Add comment on NAGIOS_CONFIG_PATH
We might want to spit out a warning when NAGIOS_CONFIG_PATH is used.

While at it, move the function that handles this environment variable to
the bottom.
2014-06-18 10:53:44 +02:00
Holger Weiss
1890cfccdf lib/parse_ini.c: Cosmetic changes to comments 2014-06-18 10:52:09 +02:00
Holger Weiss
f627b3f33b lib/parse_ini.c: Fix Clang warnings 2014-06-18 10:45:14 +02:00
Holger Weiss
11bfb0def2 lib/parse_ini.[ch]: Change code formatting
Change the indentation and formatting of the code in lib/parse_ini.c.
This breaks patches against that file and makes it harder to track its
history, but it (hopefully) improves readability a lot.
2014-06-18 10:37:10 +02:00
Holger Weiss
e2b8169869 lib/parse_ini.c: Don't cast malloc(3) result
There's no need to cast malloc(3)'s return value.
2014-06-18 01:21:31 +02:00
Holger Weiss
95ed0a996c lib/parse_ini.c: Remove outdated comment and code
The lib/parse_ini.c:np_get_defaults() function now dies if no
configuration file is found.
2014-06-18 00:50:48 +02:00
Holger Weiss
fbe13d8f32 lib/parse_ini.c: Read $MP_CONFIG_FILE
Read $MP_CONFIG_FILE if that variable is set in the environment.
2014-06-18 00:47:35 +02:00
Holger Weiss
f94e95785c lib/parse_ini.c: Read "monitoring-plugins.ini"
Read "monitoring-plugins.ini" if that file exists, but fall back to
reading "plugins.ini" or "nagios-plugins.ini" for backward
compatibility.
2014-06-18 00:39:38 +02:00
Holger Weiss
f02b3f6b28 lib/parse_ini.[ch]: Simplify code
Rewrite the code that looks up the INI configuration file path (used by
the Extra-Opts feature) in order to improve readability.  The behaviour
should not have changed.
2014-06-18 00:37:45 +02:00
Davide Madrisan
546e15a8e8 build - avoid deprecated INCLUDES
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
2014-03-09 11:02:18 +01:00
Stephane Lapie
35811848da Handle negative values properly with check_snmp
check_snmp becomes capable of evaluating negative values properly,
but it might be returning CRITICALs where it used to return OK and was ignored,
if a negative value turns out to actually be a valid value.
If negative values are valid, this can be worked around,
by adding "~:" to the warning/critical threshold : 100 -> ~:100
2014-01-31 00:49:18 -05:00
Thomas Guyot-Sionnest
bc92b93920 Add tests for negative thresholds in test_utils 2014-01-31 00:04:23 -05:00
Thomas Guyot-Sionnest
7310030ae7 Add tests for mp_translate_state() 2014-01-29 22:03:04 -05: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
25a289f307 Clean up parse_ini error messages, add missing newlines 2014-01-25 04:13:32 -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
Thomas Guyot-Sionnest
c2c24bc564 Use access() instead of stat() in parse_ini.c 2014-01-24 08:30:57 -05:00
Thomas Guyot-Sionnest
f1e9ebd037 Update comments
1. libtab is now bundled, so suggest to enable it rather than install it
2. "parse-ini" feature has been called "extra-opts"
2014-01-24 02:32:45 -05:00
Holger Weiss
01e570f4a4 Capitalize "Monitoring Plugins"
"Monitoring Plugins" is a name.
2014-01-21 16:19:20 +01:00
Holger Weiss
a8c9b696f4 Minor fixes to be amended into "rename" commit 2014-01-20 03:01:55 +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
Holger Weiss
7573aa1616 Minor cosmetic changes 2013-09-12 21:50:18 +02:00
Holger Weiss
e8044713d4 check_tcp: Properly deal will partial recv(3)s
The np_expect_match() function now returns one of three possible states
instead of just TRUE or FALSE:

- NP_MATCH_SUCCESS
- NP_MATCH_FAILURE
- NP_MATCH_RETRY

The NP_MATCH_RETRY state indicates that matching might succeed if
np_expect_match() is called with a longer input string.  This allows
check_tcp to decide whether it makes sense to wait for additional data
from the server.
2013-09-12 21:37:20 +02:00
Holger Weiss
662997251d Improve interface of np_expect_match() function
Replace the three boolean parameters of lib/utils_tcp.c's
np_expect_match() function with a single "flags" parameter.
2013-09-12 17:42:10 +02: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
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
Sven Nierlein
4083622f86 added missing header to fix build on freebsd 2013-08-20 17:02:02 +02:00
Dominique Broeglin
30bf8025d2 Adding tests for range @1:1 2013-08-17 17:19:34 +02:00