[nagiosplug] Counter increments were incorrect; remove the ...

"Nagios Plugin Development" <[email protected]> Sun, 18 Aug 2013 16:50:17 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
    Module: nagiosplug
    Branch: master
    Commit: 7bbd155a72eb439efd338f2e217b47332460a250
    Author: Tim Laszlo <[email protected]>
 Committer: Holger Weiss <[email protected]>
      Date: Tue Nov 20 12:31:18 2012 -0600
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=7bbd155

Counter increments were incorrect; remove the leading space from perfdata

---

 plugins/check_mysql.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 212910d..8d1f99a 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -166,21 +166,24 @@ main (int argc, char **argv)
 		while ( (row = mysql_fetch_row (res)) != NULL) {
 			int i;
 
-			for(i = 0; i < LENGTH_METRIC_UNIT - 1; i++) {
+			for(i = 0; i < LENGTH_METRIC_UNIT; i++) {
 				if (strcmp(row[0], metric_unit[i]) == 0) {
-					xasprintf(&perf, "%s %s", perf, perfdata(metric_unit[i],
+					xasprintf(&perf, "%s%s ", perf, perfdata(metric_unit[i],
 						atol(row[1]), "", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0));
 					continue;
 				}
 			}
-			for(i = 0; i < LENGTH_METRIC_COUNTER - 1; i++) {
+			for(i = 0; i < LENGTH_METRIC_COUNTER; i++) {
 				if (strcmp(row[0], metric_counter[i]) == 0) {
-					xasprintf(&perf, "%s %s", perf, perfdata(metric_counter[i],
+					xasprintf(&perf, "%s%s ", perf, perfdata(metric_counter[i],
 						atol(row[1]), "c", FALSE, 0, FALSE, 0, FALSE, 0, FALSE, 0));
 					continue;
 				}
 			}
 		}
+		/* remove trailing space */
+                if (strlen(perf) > 0)
+                    perf[strlen(perf) - 1] = '\0';
 	}
 
 	if(check_slave) {


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk