#599 check_nt COUNTER overenthusiatic isPercent test

Rod Payne

Plugin Version (-V output): check_nt v1991 (nagios-plugins 1.4.13)
Plugin Name: check_nt
Plugin Commandline showing issues: -l "\\PhysicalDisk(_Total)\\Avg. Disk sec/Transfer","Seconds/transfer = %.6f","seconds" -w 1.000000 -c 2.000000

This returns performance data like: 'Seconds/transfer = %.6f&'=0.000044%;1.000000;2.000000
Note the percent sign (%) after the counter value. This confuses the graph programs. (%.6f is being specified because with just a clear description/label field, only two decimal places are displayed, and for this counter it mostly shows "Second/transfer = 0.00 seconds".)

Whenever the description is formated for printf substitution ("Seconds/transfer = %.6f") in this example, the isPercent test finds the % in the description, overriding whatever may have been specified in counter_unit. It should be looking for a % in the perfmon counter name only.

Alternately, allow the user to specify the counter_unit and override the isPercent test. Alternately, allow the user to specify the number of decimal places in the result.

Code: (looking at line numbers in https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins/check_nt.c\)
----- insert after 93 -----
char *counter_name = NULL;
----- replace 339-341 -----
isPercent = (strchr (value_list, '%') != NULL);
strtok (value_list, "&"); /* burn the first parameters */
----- with -----
counter_name = strtok (value_list, "&");
isPercent = (strchr (counter_name, '%') != NULL);


  • Rod Payne

    Rod Payne - 2013-08-13

    Also, the help text does not have a closing quote and mention the counter_unit:

    ----- replace 736 -----
    printf (" %s\n", _("-l \"\\\\&lt;performance object>\\\\counter\",\"<description>"));
    ----- with -----
    printf (" %s\n", _("-l \"\\\\&lt;performance object>\\\\counter\",\"<description>\",\"<counter units>\""));


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks