Malloc info in server-status
authorDennis Schafroth <dennis@indexdata.com>
Mon, 28 Mar 2011 08:54:56 +0000 (10:54 +0200)
committerDennis Schafroth <dennis@indexdata.com>
Mon, 28 Mar 2011 08:54:56 +0000 (10:54 +0200)
etc/check-pazpar2.sh
etc/server-status-nagios.xsl
src/http_command.c

index c5d97d6..de11de4 100755 (executable)
@@ -63,6 +63,6 @@ if [ "$CRIT_LEVEL" != "" ] ; then
     fi
 fi 
 
-echo "SESSIONS $MSG $SESSIONS ($CLIENTS) | $SESSIONS;$WARN_LEVEL;$CRIT_LEVEL "
+echo "SESSIONS $MSG $SESSIONS ($CLIENTS) [$VIRT,$VIRTUSE,$AREA,$ORDBLKS,$UORDBLKS,$FORDBLKS,$KEEPCOST,$HBLKS,$HBLKHD]   | $SESSIONS;$WARN_LEVEL;$CRIT_LEVEL "
 exit $rc
 
index 56f53fa..9a2b21b 100644 (file)
@@ -8,6 +8,10 @@
       <xsl:apply-templates />
   </xsl:template>
 
+  <xsl:template match="memory">
+      <xsl:apply-templates />
+  </xsl:template>
+
   <xsl:template match="sessions">
     <xsl:text>export SESSIONS=</xsl:text><xsl:value-of select="." />
   </xsl:template>
     <xsl:text>export RESULTSETS=</xsl:text><xsl:value-of select="." />
   </xsl:template>
 
-  <xsl:template match="*">
+  <xsl:template match="arena">
+    <xsl:text>AREA=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="ordblks">
+    <xsl:text>ORDBLKS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="uordblks">
+    <xsl:text>UORDBLKS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="fordblks">
+    <xsl:text>FORDBLKS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="keepcost">
+    <xsl:text>KEEPCOST=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="hblks">
+    <xsl:text>HBLKS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="hblkhd">
+    <xsl:text>HBLKHD=</xsl:text><xsl:value-of select="." />
   </xsl:template>
 
+  <xsl:template match="virt">
+    <xsl:text>VIRT=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="virtuse">
+    <xsl:text>VIRTUSE=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="*" />
+
 </xsl:stylesheet>
index e8bba87..6acc2c3 100644 (file)
@@ -41,6 +41,29 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "settings.h"
 #include "client.h"
 
+#include <malloc.h>
+
+void print_meminfo(WRBUF wrbuf) {
+#ifdef __GNUC__
+    struct mallinfo minfo;
+    minfo = mallinfo();
+    wrbuf_printf(wrbuf, "  <memory>\n"
+                        "   <arena>%d</arena>\n" 
+                        "   <uordblks>%d</uordblks>\n"
+                        "   <fordblks>%d</fordblks>\n"
+                        "   <ordblks>%d</ordblks>\n"
+                        "   <keepcost>%d</keepcost>\n"
+                        "   <hblks>%d</hblks>\n" 
+                        "   <hblkhd>%d</hblkhd>\n"
+                        "   <virt>%d</virt>\n"
+                        "   <virtuse>%d</virtuse>\n"
+                        "  </memory>\n", 
+                 minfo.arena, minfo.uordblks, minfo.fordblks,minfo.ordblks, minfo.keepcost, minfo.hblks, minfo.hblkhd, minfo.arena + minfo.hblkhd, minfo.uordblks + minfo.hblkhd);
+
+#endif
+}
+
+
 // Update this when the protocol changes
 #define PAZPAR2_PROTOCOL_VERSION "1"
 
@@ -632,6 +655,7 @@ static void cmd_server_status(struct http_channel *c)
     wrbuf_printf(c->wrbuf, "  <clients>%u</clients>\n",   clients);
     /* Only works if yaz has been compiled with enabling of this */
     wrbuf_printf(c->wrbuf, "  <resultsets>%u</resultsets>\n",resultsets);
+    print_meminfo(c->wrbuf);
 
 /* TODO add all sessions status                         */
 /*    http_sessions_t http_sessions = c->http_sessions; */