aboutsummaryrefslogtreecommitdiff
path: root/lib/utils_base.c
AgeCommit message (Collapse)Author
2021-11-17check_snmp: fix performance thresholds when using multiple oidsGravatar Sven Nierlein
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:~'
2019-02-15check_by_ssh: fix child process leak on timeoutsGravatar Sven Nierlein
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>
2018-09-29Avoid passing NULL to vprintf().Gravatar Guido Falsi
2014-10-06Revert "Make use of xasprintf instead of asprintf"Gravatar Holger Weiss
This reverts commit a143739ed286cf9ae003792dbb1ce26ce43f3312. Our current setup doesn't allow lib/*.c files to call functions defined in plugins/utils.[ch].
2014-07-30Make use of xasprintf instead of asprintfGravatar Jan Wagner
--- Closes #1278
2014-07-30lib/utils_base.c: if asprintf fails, string is undefinedGravatar Ricardo Maraschini
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-06check_icmp/check_dhcp: disable check, if we are rootGravatar Jan Wagner
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-06-21Add UID to state retention file pathGravatar Holger Weiss
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-01-29Move negate' translate_state() to utils_base.h mp_translate_state()Gravatar Thomas Guyot-Sionnest
Also use strcasecmp imported from gnulib for simplicity
2014-01-27Rename MP_STATE_DIRECTORY to MP_STATE_PATHGravatar Thomas Guyot-Sionnest
2014-01-27And release notes for previous change (MP_STATE_DIRECTORY)Gravatar Thomas Guyot-Sionnest
The change has also been updated in https://www.monitoring-plugins.org/doc/state-retention.html
2014-01-25Ignore MP_STATE_DIRECTORY in suid pluginsGravatar Thomas Guyot-Sionnest
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-25Rename ENV variable, keep backward compatibilityGravatar Thomas Guyot-Sionnest
Rename NAGIOS_PLUGIN_STATE_DIRECTORY to MP_STATE_DIRECTORY
2014-01-19Project rename initial commit.Gravatar Monitoring Plugins Development Team
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.
2013-09-10Fix GCC's -Wimplicit-function-declaration warningsGravatar Holger Weiss
Fix the issues found by GCC when the -Wimplicit-function-declaration flag is specified.
2013-08-20added missing header to fix build on freebsdGravatar Sven Nierlein
2012-11-02lib/utils_base.c: Stop dumping core on bad args to check_snmpGravatar Andreas Ericsson
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>
2010-06-24Cleanup some warnings displayed from IRIX tinderbox serverGravatar Ton Voon
2010-06-23Added state retention APIs. Implemented for check_snmp with --rate option.Gravatar Ton Voon
See http://nagiosplugin.org/c-api-private for more details on the API. Also updated check_snmp -l option to change the perfdata label.
2009-06-02Fix the memory allocation for the thresholds dataGravatar Holger Weiss
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-01-26Make extract_value more generic:Gravatar Thomas Guyot-Sionnest
Add a separator argument passed using defines.
2009-01-21Move check_ntp's extract_value to utils_base.c.Gravatar Thomas Guyot-Sionnest
This function can also be used to parse performance data strings which could be useful in the future.
2008-11-23Removing CVS/SVN tags and replacing with git-based versioningGravatar Thomas Guyot-Sionnest
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-19Bulk EOL cleanupGravatar Thomas Guyot-Sionnest
$ 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-03-11Fixed link -m64 problems on pst3 for solaris. Fixed _FILE_OFFSET_BITSGravatar Ton Voon
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-02-13set_thresholds now let the user free the thresolds. (P.S.: When you set ↵Gravatar Thomas Guyot-Sionnest
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-01-30Bump /lib to GPLv3Gravatar Thomas Guyot-Sionnest
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1913 f882894a-f735-0410-b71e-b25c423dba1c
2007-07-29Don't use C++ style comments.Gravatar Holger Weiss
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1768 f882894a-f735-0410-b71e-b25c423dba1c
2007-05-27added functions to utils_base:Gravatar M. Sean Finney
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-01-27Change the variable names `true' and `false' (which are keywords in C99)Gravatar Holger Weiss
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
2006-10-18Cater for different errors when setting thresholdsGravatar Ton Voon
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1496 f882894a-f735-0410-b71e-b25c423dba1c
2006-07-14Missing header filesGravatar Ton Voon
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1454 f882894a-f735-0410-b71e-b25c423dba1c
2006-07-13Major fixes to check_disk. Now should return same data as dfGravatar Ton Voon
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1452 f882894a-f735-0410-b71e-b25c423dba1c