[Asterisk-cvs] asterisk asterisk.8, 1.2, 1.3 asterisk.c, 1.184, 1.185 asterisk.sgml, 1.4, 1.5 pbx.c, 1.289, 1.290

markster markster
Wed Oct 26 00:05:39 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv12704

Modified Files:
	asterisk.8 asterisk.c asterisk.sgml pbx.c 
Log Message:
Allow limitation by loadavg not just calls (should be BSD friendly)...


Index: asterisk.8
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.8,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- asterisk.8	18 Oct 2005 21:06:38 -0000	1.2
+++ asterisk.8	26 Oct 2005 03:58:32 -0000	1.3
@@ -3,7 +3,7 @@
 .\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
 .\" Please send any bug reports, improvements, comments, patches, 
 .\" etc. to Steve Cheng <steve at ggi-project.org>.
-.TH "ASTERISK" "8" "18 October 2005" "asterisk 1.2" ""
+.TH "ASTERISK" "8" "25 October 2005" "asterisk 1.2" ""
 
 .SH NAME
 asterisk \- All-purpose telephony server.
@@ -80,6 +80,11 @@
 Prompt user to intialize any encrypted private keys for IAX2
 secure authentication during startup.
 .TP
+\fB-L \fIloadaverage\fB\fR
+Limits the maximum load average before rejecting new calls.  This can
+be useful to prevent a system from being brought down by terminating
+too many simultaneous calls.
+.TP
 \fB-M \fIvalue\fB\fR
 Limits the maximum number of calls to the specified value.  This can
 be useful to prevent a system from being brought down by terminating

Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- asterisk.c	24 Oct 2005 20:12:04 -0000	1.184
+++ asterisk.c	26 Oct 2005 03:58:32 -0000	1.185
@@ -143,6 +143,7 @@
 int option_reconnect = 0;
 int option_transcode_slin = 1;
 int option_maxcalls = 0;
+double option_maxload = 0.0;
 int option_dontwarn = 0;
 int option_priority_jumping = 1;
 int fully_booted = 0;
@@ -1872,6 +1873,10 @@
 			if ((sscanf(v->value, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0)) {
 				option_maxcalls = 0;
 			}
+		} else if (!strcasecmp(v->name, "maxload")) {
+			if ((sscanf(v->value, "%lf", &option_maxload) != 1) || (option_maxload < 0.0)) {
+				option_maxload = 0.0;
+			}
 		}
 		v = v->next;
 	}
@@ -1930,7 +1935,7 @@
 	}
 	*/
 	/* Check for options */
-	while((c=getopt(argc, argv, "tThfdvVqprRgcinx:U:G:C:M:")) != -1) {
+	while((c=getopt(argc, argv, "tThfdvVqprRgcinx:U:G:C:L:M:")) != -1) {
 		switch(c) {
 		case 'd':
 			option_debug++;
@@ -1966,6 +1971,10 @@
 			if ((sscanf(optarg, "%d", &option_maxcalls) != 1) || (option_maxcalls < 0))
 				option_maxcalls = 0;
 			break;
+		case 'L':
+			if ((sscanf(optarg, "%lf", &option_maxload) != 1) || (option_maxload < 0.0))
+				option_maxload = 0.0;
+			break;
 		case 'q':
 			option_quiet++;
 			break;

Index: asterisk.sgml
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.sgml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- asterisk.sgml	18 Oct 2005 21:06:38 -0000	1.4
+++ asterisk.sgml	26 Oct 2005 03:58:32 -0000	1.5
@@ -153,6 +153,16 @@
 		</listitem>
 	</varlistentry>
 	<varlistentry>
+		<term>-L <replaceable class="parameter">loadaverage</replaceable></term>
+		<listitem>
+			<para>
+			Limits the maximum load average before rejecting new calls.  This can
+			be useful to prevent a system from being brought down by terminating
+			too many simultaneous calls.
+			</para>
+		</listitem>
+	</varlistentry>
+	<varlistentry>
 		<term>-M <replaceable class="parameter">value</replaceable></term>
 		<listitem>
 			<para>

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.289
retrieving revision 1.290
diff -u -d -r1.289 -r1.290
--- pbx.c	24 Oct 2005 20:12:05 -0000	1.289
+++ pbx.c	26 Oct 2005 03:58:32 -0000	1.290
@@ -2477,7 +2477,7 @@
 static int increase_call_count(const struct ast_channel *c)
 {
 	int failed = 0;
-
+	double curloadavg;
 	ast_mutex_lock(&maxcalllock);
 	if (option_maxcalls) {
 		if (countcalls >= option_maxcalls) {
@@ -2485,6 +2485,13 @@
 			failed = -1;
 		}
 	}
+	if (option_maxload) {
+		getloadavg(&curloadavg, 1);
+		if (curloadavg >= option_maxload) {
+			ast_log(LOG_NOTICE, "Maximum loadavg limit of %lf load exceeded by '%s' (currently %f)!\n", option_maxload, c->name, curloadavg);
+			failed = -1;
+		}
+	}
 	if (!failed)
 		countcalls++;	
 	ast_mutex_unlock(&maxcalllock);




More information about the svn-commits mailing list