[Xymon] Patch: AIX memory actual

Stef Coene stef.coene at docum.org
Thu Feb 11 09:47:55 CET 2016


Hi,

On AIX, the actual memory is reported.
And it can also be bigger then 100% .

This patch will get the actual memory for AIX and allows for memact > 100%.


Stef
-------------- next part --------------
diff -Naur xymon-4.3.25.ori/xymond/client/aix.c xymon-4.3.25/xymond/client/aix.c
--- xymon-4.3.25.ori/xymond/client/aix.c  2016-02-02 21:16:19.000000000 +0100
+++ xymon-4.3.25/xymond/client/aix.c   2016-02-11 08:48:07.297215950 +0100
@@ -76,10 +76,12 @@

   if (realmemstr && freememstr && swapmemstr) {
      long memphystotal = 0, memphysfree = 0, memswaptotal = 0, memswappct = 0;
+     long memactused = 0;
      char *p;

      if (strncmp(realmemstr, "realmem ", 8) == 0) memphystotal = atol(realmemstr+8) / 1024L;
      if (sscanf(freememstr, "%*d %*d %*d %ld", &memphysfree) == 1) memphysfree /= 256L;
+     if (sscanf(freememstr, "%*d %*d %ld", &memactused) == 1) memactused /= 256;

      p = strchr(swapmemstr, '\n'); if (p) p++;
      if (p && (sscanf(p, " %ldMB %ld%%", &memswaptotal, &memswappct) != 2)) {
@@ -88,7 +90,7 @@

      unix_memory_report(hostname, clienttype, os, hinfo, fromline, timestr,
            memphystotal, (memphystotal - memphysfree),
-           -1L, -1L,
+           memphystotal, memactused,
            memswaptotal, ((memswaptotal * memswappct) / 100L));
   }

diff -Naur xymon-4.3.25.ori/xymond/rrd/do_memory.c xymon-4.3.25/xymond/rrd/do_memory.c
--- xymon-4.3.25.ori/xymond/rrd/do_memory.c  2012-08-08 12:24:34.000000000 +0200
+++ xymon-4.3.25/xymond/rrd/do_memory.c   2016-02-11 08:42:14.241435824 +0100
@@ -45,7 +45,8 @@
   snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, swapval);
   create_and_update_rrd(hostname, testname, classname, pagepaths, memory_params, memory_tpl);

-  if ((actval >= 0) && (actval <= 100)) {
+  // if ((actval >= 0) && (actval <= 100)) {
+  if (actval >= 0) {
      setupfn2("%s.%s.rrd", "memory", "actual");
      snprintf(rrdvalues, sizeof(rrdvalues), "%d:%d", (int)tstamp, actval);
      create_and_update_rrd(hostname, testname, classname, pagepaths, memory_params, memory_tpl);
diff -Naur xymon-4.3.25.ori/xymond/xymond_client.c xymon-4.3.25/xymond/xymond_client.c
--- xymon-4.3.25.ori/xymond/xymond_client.c  2016-02-02 21:16:19.000000000 +0100
+++ xymon-4.3.25/xymond/xymond_client.c   2016-02-11 08:49:10.599146510 +0100
@@ -942,11 +942,11 @@
   else invaliddata = 1;

   if (memactused != -1) memactpct = (memacttotal > 0) ? ((100 * memactused) / memacttotal) : 0;
-  if (memactpct <= 100) {
+  //if (memactpct <= 100) {
      if (memactpct  > actyellow)  actcolor  = COL_YELLOW;
      if (memactpct  > actred)     actcolor  = COL_RED;
-  }
-  else invaliddata = 1;
+  //}
+  //else invaliddata = 1;

   if ((physcolor == COL_RED) || (swapcolor == COL_RED) || (actcolor == COL_RED)) {
      memorycolor = COL_RED;
@@ -981,12 +981,12 @@
   addtostatus(msgline);

   if (memactused != -1) {
-     if (memactpct <= 100)
+     //if (memactpct <= 100)
         sprintf(msgline, "&%s %-16s%11ldM%11ldM%11ld%%\n",
-           colorname(actcolor), "Actual/Virtual", memactused, memacttotal, memactpct);
-     else
-        sprintf(msgline, "&%s %-16s%11ldM%11ldM%11ld%% - invalid data\n", 
-           colorname(COL_YELLOW), "Actual/Virtual", memactused, memacttotal, 0L);
+     //    colorname(actcolor), "Actual/Virtual", memactused, memacttotal, memactpct);
+     //else
+     // sprintf(msgline, "&%s %-16s%11ldM%11ldM%11ld%% - invalid data\n", 
+     //    colorname(COL_YELLOW), "Actual/Virtual", memactused, memacttotal, 0L);

      addtostatus(msgline);
   }



More information about the Xymon mailing list