Hi,

I tried to set kMG option as in example in documentation
(http://oss.oetiker.ch/mrtg/doc/mrtg-reference.en.html),
but the mrtg failed then with:

# env LANG=C mrtg /etc/mrtg/mrtg.cfg
Monday, 16 May 2011 at 6:48: ERROR: Skipping webupdates because rateup 
did not return anything sensible
Monday, 16 May 2011 at 6:48: WARNING: rateup died from Signal 11
  with Exit Value 0 when doing router 'localhost_2'
  Signal was 11, Returncode was 0

("kMG[localhost_2]: n,u,m,,k,M,G,T,P" in mrtg.cfg file)

Proposed patch fixing the issue follows.

Please let me know what do you think about it.

Best regards
Vitezslav Crhonek

--- rateup.c.test       2011-02-20 23:33:38.000000000 +0100
+++ rateup.c    2011-05-16 17:02:06.935338826 +0200
@@ -111,7 +111,7 @@

  char *short_si_def[] = { "", "k", "M", "G", "T" };
  int kMGnumber = 4;
-char **short_si = short_si_def;
+char **short_si;
  char *longup = NULL;
  char *shortup = NULL;
  char *pngtitle = NULL;
@@ -484,19 +484,22 @@

    if (kMG)
      {
-      if (short_si[0] != kMG)
+      short_si = calloc (strlen(kMG), sizeof(char *)); /* allocated 
more than enough */
+      short_si_out = kMG;
+      kMGnumber = 0;
+      short_si[0] = kMG;
+      while ((short_si_out = strchr (short_si_out, ',')) != NULL)
          {
-          short_si_out = kMG;
-          kMGnumber = 0;
-         short_si[0] = kMG;
-          while ((short_si_out = strchr (short_si_out, ',')) != NULL)
-           {
-             short_si_out[0] = '\0';
-             short_si_out++;
-              short_si[++kMGnumber] = short_si_out;
-           }
-        }
+          short_si_out[0] = '\0';
+          short_si_out++;
+          short_si[++kMGnumber] = short_si_out;
+       }
       }
+  else
+    {
+      short_si = short_si_def;
+      kMGnumber = 4;
+    }

    /* mangle the 0.25*maxv value so, that we get a number with either */
    /* one or two digits != 0 and these digits should be at the  */
@@ -1125,6 +1128,8 @@
    gdImageDestroy (brush_outp);
    free (lhist);
    free (graph_label);
+  if (kMG)
+    free(short_si); /* I'm not sure if this is ideal place for freeing */

  #ifdef WIN32
    /* got to remove the target under win32

_______________________________________________
mrtg-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg-developers

Reply via email to