diff options
author | Dwayne M. Hubbard <dwayne.hubbard@gmail.com> | 2007-04-11 19:11:32 +0000 |
---|---|---|
committer | Dwayne M. Hubbard <dwayne.hubbard@gmail.com> | 2007-04-11 19:11:32 +0000 |
commit | 62256ee410915750eb4bbf249af1d418e0c0540e (patch) | |
tree | 82d331cb2b230277ba0c9e9b1a28128beb005c3c /main/pbx.c | |
parent | 6fc5c73f78be23df3b5660e2b60047ff8d299b98 (diff) |
added option_minmemfree for use in asterisk.conf to specify the amount of minimum free memory prior to accepting calls. added CLI 'core show sysinfo' to display system information
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61539 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/main/pbx.c b/main/pbx.c index ef9567850..0f82e9a56 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include <time.h> #include <sys/time.h> #include <limits.h> +#include <sys/sysinfo.h> #include "asterisk/lock.h" #include "asterisk/cli.h" @@ -2447,11 +2448,14 @@ static int __ast_pbx_run(struct ast_channel *c) return 0; } -/* Returns 0 on success, non-zero if call limit was reached */ +/* Returns 0 on success, non-zero if a configured limit (maxcalls, maxload, minmemfree) was reached */ static int increase_call_count(const struct ast_channel *c) { int failed = 0; double curloadavg; + long curfreemem; + struct sysinfo sys_info; + ast_mutex_lock(&maxcalllock); if (option_maxcalls) { if (countcalls >= option_maxcalls) { @@ -2466,6 +2470,19 @@ static int increase_call_count(const struct ast_channel *c) failed = -1; } } + if (option_minmemfree) { + if (!sysinfo(&sys_info)) { + /* make sure that the free system memory is above the configured low watermark + * convert the amount of freeram from mem_units to MB */ + curfreemem = sys_info.freeram / sys_info.mem_unit; + curfreemem /= 1024*1024; + if (curfreemem < option_minmemfree) { + ast_log(LOG_WARNING, "Available system memory (~%ldMB) is below the configured low watermark (%ldMB)\n", curfreemem, option_minmemfree); + failed = -1; + } + } + } + if (!failed) countcalls++; ast_mutex_unlock(&maxcalllock); |