From d32a72bcc10af5aadf8ec6611254392f2291067a Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Mon, 2 Jul 2012 11:49:42 -0500
Subject: [PATCH] show current process stack size from status command where
 supported

---
 .../applications/mod_commands/mod_commands.c  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c
index 65518dc0d3..dd29136dca 100644
--- a/src/mod/applications/mod_commands/mod_commands.c
+++ b/src/mod/applications/mod_commands/mod_commands.c
@@ -1721,6 +1721,14 @@ SWITCH_STANDARD_API(lan_addr_function)
 	return SWITCH_STATUS_SUCCESS;
 }
 
+#include "switch_private.h"
+#ifndef WIN32
+#ifdef HAVE_SETRLIMIT
+#include <sys/resource.h>
+#endif
+#endif
+
+
 SWITCH_STANDARD_API(status_function)
 {
 	uint8_t html = 0;
@@ -1728,6 +1736,11 @@ SWITCH_STANDARD_API(status_function)
 	char *http = NULL;
 	int sps = 0, last_sps = 0;
 	const char *var;
+#ifdef HAVE_SETRLIMIT
+	struct rlimit rlp;
+#endif
+
+
 
 	switch_core_measure_time(switch_core_uptime(), &duration);
 
@@ -1764,6 +1777,14 @@ SWITCH_STANDARD_API(status_function)
 	stream->write_function(stream, "%d session(s) max\n", switch_core_session_limit(0));
 	stream->write_function(stream, "min idle cpu %0.2f/%0.2f\n", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu());
 
+#ifdef HAVE_SETRLIMIT
+	memset(&rlp, 0, sizeof(rlp));
+	getrlimit(RLIMIT_STACK, &rlp);
+
+	stream->write_function(stream, "Current Stack Size/Max %ldK/%ldK\n", rlp.rlim_cur / 1024, rlp.rlim_max / 1024);
+#endif
+
+
 	if (html) {
 		stream->write_function(stream, "</b>\n");
 	}