summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarper Mann <harpermann@users.sourceforge.net>2004-12-22 23:02:10 +0000
committerHarper Mann <harpermann@users.sourceforge.net>2004-12-22 23:02:10 +0000
commit5315de2b9ebb1e8d5dc63da3280ee7990d152a47 (patch)
tree3973f041aa8e5ecf40e19d6db26050852b94341d
parentc0a999cfed9172f4837a0966b5c861c1602a5abe (diff)
downloadmonitoring-plugins-5315de2b9ebb1e8d5dc63da3280ee7990d152a47.tar.gz
Added check for "%" in COUNTER <description>. If it exists, <description> is used as an arg to asprintf. If it doesn't exist, <description> is used as a label. If the formatting is wrong, the program will segv.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1053 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_nt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index f76a52a6..fa93fce7 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -356,7 +356,12 @@ int main(int argc, char **argv){
356 { 356 {
357 /* Let's format the output string, finally... */ 357 /* Let's format the output string, finally... */
358 358
359 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit); 359 if (strstr(description, "%") == NULL) {
360 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
361 } else {
362 /* has formatting, will segv if wrong */
363 asprintf (&output_message, description, counter_value);
364 }
360 output_message = strcat (output_message, "|"); 365 output_message = strcat (output_message, "|");
361 output_message = strcat (output_message, 366 output_message = strcat (output_message,
362 fperfdata (description, counter_value, counter_unit, 367 fperfdata (description, counter_value, counter_unit,
@@ -672,7 +677,8 @@ Windows NT/2000/XP/2003 server.\n\n"));
672 Request a -l parameters with the following syntax:\n\ 677 Request a -l parameters with the following syntax:\n\
673 -l \"\\\\<performance object>\\\\counter\",\"<description>\n\ 678 -l \"\\\\<performance object>\\\\counter\",\"<description>\n\
674 The <description> parameter is optional and \n\ 679 The <description> parameter is optional and \n\
675 is given to a printf output command which require a float parameters.\n\ 680 is given to a printf output command which requires a float parameter.\n\
681 If <description> does not include \"%%\", it is used as a label.\n\
676 Some examples:\n\ 682 Some examples:\n\
677 \"Paging file usage is %%.2f %%%%\"\n\ 683 \"Paging file usage is %%.2f %%%%\"\n\
678 \"%%.f %%%% paging file used.\"\n")); 684 \"%%.f %%%% paging file used.\"\n"));