Commit graph

158 commits

Author SHA1 Message Date
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
Thomas Guyot-Sionnest
485f306868 Return UNKNOWN if none of the default files can be found.
It makes no sense to return unknown if an implicit section is not found, but
go on if the file is missing
2009-01-22 02:24:39 -05:00
Thomas Guyot-Sionnest
bf4abd5395 Add die tests for extra-opts 2009-01-22 02:04:31 -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
81871eaa82 Accidentally included built executables - also updated .gitignore 2009-01-21 01:25:06 -05:00
Thomas Guyot-Sionnest
3b69f13467 Some platform are missing setenv
Instead of adding the gnulib module for solving tests only I split the test
in two, setting environment from Perl for the later.
2009-01-20 23:58:02 -05:00
Thomas Guyot-Sionnest
26bf63a5bb Fix (or try at least) for IRIX compile to tap tests
Gnulib says: "$(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise"
Everywhere else we use LTLIBINTL so I assume the tests should use it as well.
2009-01-20 22:28:30 -05:00
Thomas Guyot-Sionnest
82674792c7 Re-apply "Cleanup; fix the way libraries are linked; Make-It-Simple(tm)"
This reverts commit 7449b16b17.
2009-01-18 16:26:58 -05:00
Thomas Guyot-Sionnest
09f9ddd18d Typo 2009-01-15 06:12:04 -05:00
Thomas Guyot-Sionnest
301871bd6f Make /lib before /lib/tests to satisfy dependencies (building tests fails on IRIX) 2009-01-13 04:31:30 -05:00
Thomas Guyot-Sionnest
f8c6d8b52e Fix test from last commit 2009-01-09 08:16:52 -05:00
Thomas Guyot-Sionnest
4d5eb82a47 basename check in test_utils.c was accidentaly added again.
In 538b97c I reverted a serie of libtap patch by Ton Voon; it included
the removal of the useless basename check.

Relevant portion of the changelog from which it was removed (f31cd40):

  Removed basename test as we should use base_name from GNUlib which is
	tested separately
2009-01-09 02:44:36 -05:00
Thomas Guyot-Sionnest
7449b16b17 Revert "Cleanup; fix the way libraries are linked; Make-It-Simple(tm)"
Trying to see if this has any relation to the tinderbox failure. I doubt it
and will revert back as soon as it's tested.

This reverts commit a97e5fbda2.
2009-01-09 02:27:02 -05:00
Thomas Guyot-Sionnest
254baca111 Try to make IRIX happy (this fixes a similar warning in Solaris) 2009-01-08 08:14:19 -05:00
Thomas Guyot-Sionnest
a97e5fbda2 Cleanup; fix the way libraries are linked; Make-It-Simple(tm)
lib/Makefile.am       |    2 +-
 lib/tests/Makefile.am |   37 ++++---------------------------------
 2 files changed, 5 insertions(+), 34 deletions(-)
2009-01-07 04:41:54 -05:00
Thomas Guyot-Sionnest
2bbf2e6967 Add Libtap as a bundled library (does not change any behaviour without --enable-libtap)
Detects system library as pre-1.4.13 and does not install the built-in library anymore

Tested on:
  - Linux x86_64, with and without local libtap (System libtap installed)
	- Linux x86, with and without local libtap (System libtap NOT installed)
  - Solaris SPARC, with and without local libtap, with and without system libtap installed
2008-11-29 04:38:54 -05:00
Thomas Guyot-Sionnest
538b97cea6 Revert inclusion of libtap into nagiosplugins
(except for the NEWS file)

This reverts the following commits (latest first): f3e0909, 9f16b54, be8df51, f31cd40, 5270c7d, a25083f, f1bfe40, c503d85 and 6c476db
2008-11-28 03:22:39 -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
Thomas Guyot-Sionnest
5305852212 check_disk: rerpopulate the mount list after doing a stat() on paths specified with -p for better automount support.
NB: There's a memory leak here - properly freeing the mount list would invlove
    much more work - there's many other places where leaks can happen so it
    should be a project on its own.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2085 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-19 05:59:22 +00:00
Ton Voon
a688e9338a Need to add in the libgnu.la for Solaris and other platforms
where missing functions have been replaced by GNUlib


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2071 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-05 17:07:40 +00:00
Thomas Guyot-Sionnest
3011838fe9 Fix calculation of extra-opts parameters.
By reading the current list instead of the additional one when counting parameters, extra-opts calculation was allocating insuficient space for the final array if later sections contained more arguments than the sum of all previously parsed sections.


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2069 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-05 16:15:59 +00:00
Thomas Guyot-Sionnest
cca36dc245 Fixed the test (not the bug yet) and added similar one to test_ini (that one works)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2066 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-04 21:52:45 +00:00
Thomas Guyot-Sionnest
83ec9f2694 Corrected test_opts plan
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2065 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-04 21:31:10 +00:00
Thomas Guyot-Sionnest
5847c4eb83 Adding extra-opts check that crash on my prod servers (*** glibc detected *** malloc(): memory corruption: 0x0804e248 ***)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2064 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-04 21:29:36 +00:00
Thomas Guyot-Sionnest
51ec51a8dc Make extra-opts (C plugins) behave more like N::P:
N::P allows both '#' and ';' for comments. Extra-opts used to allow only '#', it now allows both (';' is the standard for ini files)
  Extra-opts does not allow trailing comments anymore (like N::P)



git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2063 f882894a-f735-0410-b71e-b25c423dba1c
2008-11-04 17:41:53 +00:00
Ton Voon
f31cd40f7a Correctly link to included libtap. Simplify invoking test scripts.
Removed basename test as we should use base_name from GNUlib which is
tested separately


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2042 f882894a-f735-0410-b71e-b25c423dba1c
2008-08-21 15:18:58 +00:00
Thomas Guyot-Sionnest
77362a18ba Typos in comments
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2035 f882894a-f735-0410-b71e-b25c423dba1c
2008-08-21 04:17:25 +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
Ton Voon
f1bfe40afb Use tap.h from the libtap directory
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2017 f882894a-f735-0410-b71e-b25c423dba1c
2008-07-02 20:07:00 +00:00
Ton Voon
6c476db6dc Adding libtap into distribution to help run C based tests
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2013 f882894a-f735-0410-b71e-b25c423dba1c
2008-06-26 22:00:08 +00:00
Thomas Guyot-Sionnest
2a4640f671 make parse_ini die like in N::P if section isn't found
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1976 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-04 10:11:22 +00:00
Thomas Guyot-Sionnest
815fbd802f Delete obsolete files
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1974 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-02 09:19:26 +00:00
Thomas Guyot-Sionnest
0d13deb0e4 - Add --enable-extra-opts configure option for compiling extra-opts support
- Auto-update po/pot files


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1973 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-02 09:11:44 +00:00
Thomas Guyot-Sionnest
63897a4179 fix the obvious...
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1972 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-01 09:38:37 +00:00
Thomas Guyot-Sionnest
d001e08133 np_extra_opts now retain pointers from argv so that plugins can still overwrite sensitive options
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1971 f882894a-f735-0410-b71e-b25c423dba1c
2008-04-01 09:31:27 +00:00
Thomas Guyot-Sionnest
d043862c15 Fix bug with --extra-opts as last argument with no value
Fix problem with duplicate function name (function should eventually move to /lib)


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1969 f882894a-f735-0410-b71e-b25c423dba1c
2008-03-31 07:04:07 +00:00