[asterisk-commits] oej: trunk r54464 - in /trunk: include/asterisk/ main/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Feb 14 13:22:20 MST 2007


Author: oej
Date: Wed Feb 14 14:22:20 2007
New Revision: 54464

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54464
Log:
New CLI command "Core show settings" to list some core settings

Modified:
    trunk/include/asterisk/cdr.h
    trunk/include/asterisk/config.h
    trunk/include/asterisk/manager.h
    trunk/main/asterisk.c
    trunk/main/cdr.c
    trunk/main/config.c
    trunk/main/manager.c

Modified: trunk/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/cdr.h?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/include/asterisk/cdr.h (original)
+++ trunk/include/asterisk/cdr.h Wed Feb 14 14:22:20 2007
@@ -102,6 +102,9 @@
 
 typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
 
+/*! \brief Return TRUE if CDR subsystem is enabled */
+int check_cdr_enabled(void);
+
 /*! \brief Allocate a CDR record 
  * Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
  */

Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Wed Feb 14 14:22:20 2007
@@ -155,6 +155,9 @@
 */
 int ast_check_realtime(const char *family);
 
+/*! \brief Check if there's any realtime engines loaded */
+int ast_realtime_enabled(void);
+
 /*! \brief Free variable list 
  * \param var the linked list of variables to free
  * This function frees a list of variables.

Modified: trunk/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/manager.h?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/include/asterisk/manager.h (original)
+++ trunk/include/asterisk/manager.h Wed Feb 14 14:22:20 2007
@@ -62,6 +62,7 @@
 /* Manager Helper Function */
 typedef int (*manager_hook_t)(int, const char *, char *); 
 
+
 struct manager_custom_hook {
 	/*! Identifier */
 	char *file;
@@ -70,6 +71,12 @@
 	/*! Linked list information */
 	AST_RWLIST_ENTRY(manager_custom_hook) list;
 };
+
+/*! \brief Check if AMI is enabled */
+int check_manager_enabled(void);
+
+/*! \brief Check if AMI/HTTP is enabled */
+int check_webmanager_enabled(void);
 
 /*! Add a custom hook to be called when an event is fired */
 /*! \param hook struct manager_custom_hook object to add

Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Feb 14 14:22:20 2007
@@ -160,6 +160,7 @@
 
 double option_maxload;				/*!< Max load avg on system */
 int option_maxcalls;				/*!< Max number of active calls */
+int option_maxfiles;				/*!< Max number of open file handles (files, sockets) */
 
 /*! @} */
 
@@ -326,6 +327,65 @@
 		free(x);
 	}
 }
+
+#if !defined(LOW_MEMORY)
+/*! \brief Give an overview of core settings */
+static int handle_show_settings(int fd, int argc, char *argv[])
+{
+	char buf[BUFSIZ];
+	struct tm tm;
+
+	ast_cli(fd, "\nPBX Core settings\n");
+	ast_cli(fd, "-----------------\n");
+	if (option_maxcalls)
+		ast_cli(fd, "  Max. calls:                  %d (Current %d)\n", option_maxcalls, ast_active_channels());
+	else
+		ast_cli(fd, "  Max. calls:                  Not set\n");
+	if (option_maxfiles)
+		ast_cli(fd, "  Max. open file handles:      %d\n", option_maxfiles); 
+	else
+		ast_cli(fd, "  Max. open file handles:      Not set\n");
+	ast_cli(fd, "  Verbosity:                   %d\n", option_verbose);
+	ast_cli(fd, "  Debug level:                 %d\n", option_debug);
+	ast_cli(fd, "  Max load avg:                %lf\n", option_maxload);
+	if (localtime_r(&ast_startuptime, &tm)) {
+		strftime(buf, sizeof(buf), "%H:%M:%S", &tm);
+		ast_cli(fd, "  Startup time:                %s\n", buf);
+	}
+	if (localtime_r(&ast_lastreloadtime, &tm)) {
+		strftime(buf, sizeof(buf), "%H:%M:%S", &tm);
+		ast_cli(fd, "  Last reload time:            %s\n", buf);
+	}
+	ast_cli(fd, "  System:                      %s/%s built by %s on %s %s\n", ast_build_os, ast_build_kernel, ast_build_user, ast_build_machine, ast_build_date);
+	ast_cli(fd, "  System name:                 %s\n", ast_config_AST_SYSTEM_NAME);
+	ast_cli(fd, "  Default language:            %s\n", defaultlanguage);
+	ast_cli(fd, "  Language prefix:             %s\n", ast_language_is_prefix ? "Enabled" : "Disabled");
+	ast_cli(fd, "  User name and group:         %s/%s\n", ast_config_AST_RUN_USER, ast_config_AST_RUN_GROUP);
+	ast_cli(fd, "  Executable includes:         %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES) ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Transcode via SLIN:          %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN) ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Internal timing:             %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Transmit silence during rec: %s\n", ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING) ? "Enabled" : "Disabled");
+
+	ast_cli(fd, "\n* Subsystems\n");
+	ast_cli(fd, "  -------------\n");
+	ast_cli(fd, "  Manager (AMI):               %s\n", check_manager_enabled() ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Web Manager (AMI/HTTP):      %s\n", check_webmanager_enabled() ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Call data records:           %s\n", check_cdr_enabled() ? "Enabled" : "Disabled");
+	ast_cli(fd, "  Realtime Architecture (ARA): %s\n", ast_realtime_enabled() ? "Enabled" : "Disabled");
+
+	/*! \todo we could check musiconhold, voicemail, smdi, adsi, queues  */
+
+	ast_cli(fd, "\n* Directories\n");
+	ast_cli(fd, "  -------------\n");
+	ast_cli(fd, "  Configuration file:          %s\n", ast_config_AST_CONFIG_FILE);
+	ast_cli(fd, "  Configuration directory:     %s\n", ast_config_AST_CONFIG_DIR);
+	ast_cli(fd, "  Module directory:            %s\n", ast_config_AST_MODULE_DIR);
+	ast_cli(fd, "  Spool directory:             %s\n", ast_config_AST_SPOOL_DIR);
+	ast_cli(fd, "  Log directory:               %s\n", ast_config_AST_LOG_DIR);
+	ast_cli(fd, "\n\n");
+	return 0;
+}
+#endif
 
 static int handle_show_threads(int fd, int argc, char *argv[])
 {
@@ -1545,6 +1605,10 @@
 
 	{ { "core", "show", "profile", NULL },
 	handle_show_profile, "Display profiling info",
+	NULL },
+
+	{ { "core", "show", "settings", NULL },
+	handle_show_settings, "Show some core settings",
 	NULL },
 
 	{ { "core", "clear", "profile", NULL },
@@ -2320,7 +2384,8 @@
 			}
 		/* Set the maximum amount of open files */
 		} else if (!strcasecmp(v->name, "maxfiles")) {
-			set_ulimit(atoi(v->value));
+			option_maxfiles = atoi(v->value);
+			set_ulimit(option_maxfiles);
 		/* What user to run as */
 		} else if (!strcasecmp(v->name, "runuser")) {
 			ast_copy_string(ast_config_AST_RUN_USER, v->value, sizeof(ast_config_AST_RUN_USER));

Modified: trunk/main/cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cdr.c?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Wed Feb 14 14:22:20 2007
@@ -88,7 +88,7 @@
 #define BATCH_SCHEDULER_ONLY_DEFAULT 0
 #define BATCH_SAFE_SHUTDOWN_DEFAULT 1
 
-static int enabled;
+static int enabled;		/*! Is the CDR subsystem enabled ? */
 static int batchmode;
 static int batchsize;
 static int batchtime;
@@ -101,6 +101,10 @@
 AST_MUTEX_DEFINE_STATIC(cdr_pending_lock);
 static ast_cond_t cdr_pending_cond;
 
+int check_cdr_enabled()
+{
+	return enabled;
+}
 
 /*! Register a CDR driver. Each registered CDR driver generates a CDR 
 	\return 0 on success, -1 on failure 

Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Wed Feb 14 14:22:20 2007
@@ -1384,6 +1384,12 @@
 
 }
 
+/*! \brief Check if there's any realtime engines loaded */
+int ast_realtime_enabled()
+{
+	return config_maps ? 1 : 0;
+}
+
 struct ast_config *ast_load_realtime_multientry(const char *family, ...)
 {
 	struct ast_config_engine *eng;

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=54464&r1=54463&r2=54464
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Feb 14 14:22:20 2007
@@ -109,6 +109,8 @@
 static int displayconnects = 1;
 static int timestampevents;
 static int httptimeout = 60;
+static int manager_enabled = 0;
+static int webmanager_enabled = 0;
 
 static int block_sockets;
 static int num_sessions;
@@ -238,6 +240,16 @@
 	AST_LIST_UNLOCK(&sessions);
 }
 #endif
+
+int check_manager_enabled()
+{
+	return manager_enabled;
+}
+
+int check_webmanager_enabled()
+{
+	return (webmanager_enabled && manager_enabled);
+}
 
 /*!
  * Grab a reference to the last event, update usecount as needed.
@@ -2934,8 +2946,6 @@
 	struct ast_config *cfg = NULL;
 	const char *val;
 	char *cat = NULL;
-	int webenabled = 0;
-	int enabled = 0;
 	int newhttptimeout = 60;
 	int have_sslbindaddr = 0;
 	struct hostent *hp;
@@ -3015,11 +3025,11 @@
 			free(ami_tls_cfg.cipher);
 			ami_tls_cfg.cipher = ast_strdup(val);
 		} else if (!strcasecmp(var->name, "enabled")) {
-			enabled = ast_true(val);
+			manager_enabled = ast_true(val);
 		} else if (!strcasecmp(var->name, "block-sockets")) {
 			block_sockets = ast_true(val);
 		} else if (!strcasecmp(var->name, "webenabled")) {
-			webenabled = ast_true(val);
+			webmanager_enabled = ast_true(val);
 		} else if (!strcasecmp(var->name, "port")) {
 			ami_desc.sin.sin_port = htons(atoi(val));
 		} else if (!strcasecmp(var->name, "bindaddr")) {
@@ -3041,7 +3051,7 @@
 		}	
 	}
 
-	if (enabled)
+	if (manager_enabled)
 		ami_desc.sin.sin_family = AF_INET;
 	if (!have_sslbindaddr)
 		amis_desc.sin.sin_addr = ami_desc.sin.sin_addr;
@@ -3128,7 +3138,7 @@
 
 	ast_config_destroy(cfg);
 
-	if (webenabled && enabled) {
+	if (webmanager_enabled && manager_enabled) {
 		if (!webregged) {
 			ast_http_uri_link(&rawmanuri);
 			ast_http_uri_link(&manageruri);



More information about the asterisk-commits mailing list