Commit graph

194 commits

Author SHA1 Message Date
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
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
Matthias Eble
77f2c84d2f Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603)
Various values (dused_pct, dfree_pct, inodes_free, inodes_total, ...) are now carried in
the parameter_list structure. Assignments have been moved to a subroutine preventing
code redundancies.
Group metrics are now calculated based on units rather than blocks. This fixes freespace calculation
when blocksizes differ within a group.
2010-11-15 23:59:35 +01:00
Thomas Guyot-Sionnest
cf2bcf6c7a Fix cmd_run overwriting the environment
Some commands need the environment to function properly. One such
example is check_ssh and check_by_ssh when a SOCKS proxy is required.

This patch use setenv and extern char **environ to alter and pass the
new environment to the child process Those modules have been added to
Gnulib for portability.
2010-07-02 12:55:19 -04:00
tonvoon
f324f5b94f Add test file directory 2010-06-25 07:52:59 +00: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
Thomas Guyot-Sionnest
6e5d12b5d0 Use a more "natural" way of writing argument lists in extra-opts tests. 2009-06-11 00:14:23 -04: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
7cb3ae0933 check_snmp: Make use of standard threshold functions
This patch makes use of standard threshold functions. This allows using
	doubles as thresholds.

	Since SNMP supports only integers, double precision numbers are only
	printed when parsed from a STRING type.

	In addition, support for printing properly Timeticks type has been added,
	and the code has been thoroughly cleaned.
2009-05-28 08:10:49 -04: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
0a74b6fda0 Remove the commented out blocks
The die tests are implemented in the test_*3.t files
2009-01-24 07:41:45 -05:00
Thomas Guyot-Sionnest
1b1dc7a48b Fix paths in test_ini tests 2009-01-24 00:41:00 -05:00
Thomas Guyot-Sionnest
8b103c0c77 Add die tests for parse_ini 2009-01-23 02:43:59 -05:00