Add 44_check_snmp_perfdata.dpatch to fix regression related perfdata

This commit is contained in:
Jan Wagner 2010-04-01 07:17:31 +00:00
parent 6e922d4d8f
commit 5c04a14b72
3 changed files with 43 additions and 0 deletions

1
debian/changelog vendored
View file

@ -6,6 +6,7 @@ nagios-plugins (1.4.14-4) UNRELEASED; urgency=low
- Provide package specific documentation with the packages - Provide package specific documentation with the packages
- Provide symlinks from other packages - Provide symlinks from other packages
* Remove debian/TODO cause it't totally outdated * Remove debian/TODO cause it't totally outdated
* Add 44_check_snmp_perfdata.dpatch to fix regression related perfdata
-- Jan Wagner <waja@cyconet.org> Wed, 24 Mar 2010 20:24:51 +0100 -- Jan Wagner <waja@cyconet.org> Wed, 24 Mar 2010 20:24:51 +0100

View file

@ -19,3 +19,4 @@
41_check_ping_detect_args.dpatch 41_check_ping_detect_args.dpatch
42_check_linux_raid_fix_r10.dpatch 42_check_linux_raid_fix_r10.dpatch
43_check_http_large_pages_mleak.dpatch 43_check_http_large_pages_mleak.dpatch
44_check_snmp_perfdata.dpatch

View file

@ -0,0 +1,41 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 44_check_snmp_perfdata.dpatch
## From: Thomas Guyot-Sionnest <dermoth@aei.ca>
## Date: Wed, 31 Mar 2010 06:45:45 +0000 (02:45 -0400)
## Subject: [PATCH] Fix regression introduced in #1867716 where partially valid performance strings would not be printed anymore
## X-Git-Url: http://repo.or.cz/w/nagiosplugins.git/blobdiff/e7e9a99117d7e0a7189393b3a04366393620efab..e5690e3ddaebdd98bfd96c2303453e4e0d7ed318:/plugins/check_snmp.c
##
## DP: Fix regression introduced in #1867716
@DPATCH@
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index dcb3138..fdb5819 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -117,7 +117,7 @@ int needmibs = FALSE;
int
main (int argc, char **argv)
{
- int i;
+ int i, len;
int iresult = STATE_UNKNOWN;
int result = STATE_UNKNOWN;
int return_code = 0;
@@ -351,10 +351,14 @@ main (int argc, char **argv)
if (nunits > (size_t)0 && (size_t)i < nunits && unitv[i] != NULL)
asprintf (&outbuff, "%s %s", outbuff, unitv[i]);
- if (is_numeric(show)) {
+ /* Write perfdata with whatever can be parsed by strtod, if possible */
+ ptr = NULL;
+ strtod(show, &ptr);
+ if (ptr > show) {
strncat(perfstr, oidname, sizeof(perfstr)-strlen(perfstr)-1);
strncat(perfstr, "=", sizeof(perfstr)-strlen(perfstr)-1);
- strncat(perfstr, show, sizeof(perfstr)-strlen(perfstr)-1);
+ len = sizeof(perfstr)-strlen(perfstr)-1;
+ strncat(perfstr, show, len>ptr-show ? ptr-show : len);
if (type)
strncat(perfstr, type, sizeof(perfstr)-strlen(perfstr)-1);