aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-14 20:22:20 +0000
committeroej <oej@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-14 20:22:20 +0000
commit18b268814d2574f5330818b6a2b87176c7c71dd7 (patch)
treee555dc0a32c9ad1121e13d0ac88f2ab05905a38a
parent21a2f91b3e8f9f685e22705409cc8a6d8f10403a (diff)
New CLI command "Core show settings" to list some core settings
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@54464 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/cdr.h3
-rw-r--r--include/asterisk/config.h3
-rw-r--r--include/asterisk/manager.h7
-rw-r--r--main/asterisk.c67
-rw-r--r--main/cdr.c6
-rw-r--r--main/config.c6
-rw-r--r--main/manager.c22
7 files changed, 106 insertions, 8 deletions
diff --git a/include/asterisk/cdr.h b/include/asterisk/cdr.h
index 35f20e6b1..9c081718d 100644
--- a/include/asterisk/cdr.h
+++ b/include/asterisk/cdr.h
@@ -102,6 +102,9 @@ int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr);
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)
*/
diff --git a/include/asterisk/config.h b/include/asterisk/config.h
index 7ee51d32a..c9b684cb6 100644
--- a/include/asterisk/config.h
+++ b/include/asterisk/config.h
@@ -155,6 +155,9 @@ int ast_update_realtime(const char *family, const char *keyfield, const char *lo
*/
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.
diff --git a/include/asterisk/manager.h b/include/asterisk/manager.h
index 0f0eb79f5..189130f3f 100644
--- a/include/asterisk/manager.h
+++ b/include/asterisk/manager.h
@@ -62,6 +62,7 @@
/* Manager Helper Function */
typedef int (*manager_hook_t)(int, const char *, char *);
+
struct manager_custom_hook {
/*! Identifier */
char *file;
@@ -71,6 +72,12 @@ struct manager_custom_hook {
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
*/
diff --git a/main/asterisk.c b/main/asterisk.c
index de01bbe5a..379668c6f 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -160,6 +160,7 @@ int option_debug; /*!< Debug level */
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) */
/*! @} */
@@ -327,6 +328,65 @@ void ast_unregister_thread(void *id)
}
}
+#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[])
{
int count = 0;
@@ -1547,6 +1607,10 @@ static struct ast_cli_entry cli_asterisk[] = {
handle_show_profile, "Display profiling info",
NULL },
+ { { "core", "show", "settings", NULL },
+ handle_show_settings, "Show some core settings",
+ NULL },
+
{ { "core", "clear", "profile", NULL },
handle_show_profile, "Clear profiling info",
NULL },
@@ -2320,7 +2384,8 @@ static void ast_readconfig(void)
}
/* 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));
diff --git a/main/cdr.c b/main/cdr.c
index 33f326b86..9c56f0fdd 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -88,7 +88,7 @@ static pthread_t cdr_thread = AST_PTHREADT_NULL;
#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_batch_lock);
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
diff --git a/main/config.c b/main/config.c
index 9889e639e..023be5fb5 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1384,6 +1384,12 @@ int ast_check_realtime(const char *family)
}
+/*! \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;
diff --git a/main/manager.c b/main/manager.c
index decc65e13..bdb17f8f9 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -109,6 +109,8 @@ static AST_LIST_HEAD_STATIC(all_events, eventqent);
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;
@@ -239,6 +241,16 @@ static void UNLOCK_SESS(void)
}
#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.
* Can handle a NULL pointer.
@@ -2934,8 +2946,6 @@ int init_manager(void)
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 @@ int init_manager(void)
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 @@ int init_manager(void)
}
}
- 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 @@ int init_manager(void)
ast_config_destroy(cfg);
- if (webenabled && enabled) {
+ if (webmanager_enabled && manager_enabled) {
if (!webregged) {
ast_http_uri_link(&rawmanuri);
ast_http_uri_link(&manageruri);