New CLI command "Core show settings" to list some core settings

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@54464 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Olle Johansson
2007-02-14 20:22:20 +00:00
parent daa5f504ec
commit 8ac0fb2bc3
7 changed files with 106 additions and 8 deletions

View File

@@ -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); 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 /*! \brief Allocate a CDR record
* Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure) * Returns a malloc'd ast_cdr structure, returns NULL on error (malloc failure)
*/ */

View File

@@ -155,6 +155,9 @@ int ast_update_realtime(const char *family, const char *keyfield, const char *lo
*/ */
int ast_check_realtime(const char *family); 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 /*! \brief Free variable list
* \param var the linked list of variables to free * \param var the linked list of variables to free
* This function frees a list of variables. * This function frees a list of variables.

View File

@@ -62,6 +62,7 @@
/* Manager Helper Function */ /* Manager Helper Function */
typedef int (*manager_hook_t)(int, const char *, char *); typedef int (*manager_hook_t)(int, const char *, char *);
struct manager_custom_hook { struct manager_custom_hook {
/*! Identifier */ /*! Identifier */
char *file; char *file;
@@ -71,6 +72,12 @@ struct manager_custom_hook {
AST_RWLIST_ENTRY(manager_custom_hook) list; 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 */ /*! Add a custom hook to be called when an event is fired */
/*! \param hook struct manager_custom_hook object to add /*! \param hook struct manager_custom_hook object to add
*/ */

View File

@@ -160,6 +160,7 @@ int option_debug; /*!< Debug level */
double option_maxload; /*!< Max load avg on system */ double option_maxload; /*!< Max load avg on system */
int option_maxcalls; /*!< Max number of active calls */ 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[]) static int handle_show_threads(int fd, int argc, char *argv[])
{ {
int count = 0; int count = 0;
@@ -1547,6 +1607,10 @@ static struct ast_cli_entry cli_asterisk[] = {
handle_show_profile, "Display profiling info", handle_show_profile, "Display profiling info",
NULL }, NULL },
{ { "core", "show", "settings", NULL },
handle_show_settings, "Show some core settings",
NULL },
{ { "core", "clear", "profile", NULL }, { { "core", "clear", "profile", NULL },
handle_show_profile, "Clear profiling info", handle_show_profile, "Clear profiling info",
NULL }, NULL },
@@ -2320,7 +2384,8 @@ static void ast_readconfig(void)
} }
/* Set the maximum amount of open files */ /* Set the maximum amount of open files */
} else if (!strcasecmp(v->name, "maxfiles")) { } 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 */ /* What user to run as */
} else if (!strcasecmp(v->name, "runuser")) { } else if (!strcasecmp(v->name, "runuser")) {
ast_copy_string(ast_config_AST_RUN_USER, v->value, sizeof(ast_config_AST_RUN_USER)); ast_copy_string(ast_config_AST_RUN_USER, v->value, sizeof(ast_config_AST_RUN_USER));

View File

@@ -88,7 +88,7 @@ static pthread_t cdr_thread = AST_PTHREADT_NULL;
#define BATCH_SCHEDULER_ONLY_DEFAULT 0 #define BATCH_SCHEDULER_ONLY_DEFAULT 0
#define BATCH_SAFE_SHUTDOWN_DEFAULT 1 #define BATCH_SAFE_SHUTDOWN_DEFAULT 1
static int enabled; static int enabled; /*! Is the CDR subsystem enabled ? */
static int batchmode; static int batchmode;
static int batchsize; static int batchsize;
static int batchtime; static int batchtime;
@@ -101,6 +101,10 @@ AST_MUTEX_DEFINE_STATIC(cdr_batch_lock);
AST_MUTEX_DEFINE_STATIC(cdr_pending_lock); AST_MUTEX_DEFINE_STATIC(cdr_pending_lock);
static ast_cond_t cdr_pending_cond; static ast_cond_t cdr_pending_cond;
int check_cdr_enabled()
{
return enabled;
}
/*! Register a CDR driver. Each registered CDR driver generates a CDR /*! Register a CDR driver. Each registered CDR driver generates a CDR
\return 0 on success, -1 on failure \return 0 on success, -1 on failure

View File

@@ -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 *ast_load_realtime_multientry(const char *family, ...)
{ {
struct ast_config_engine *eng; struct ast_config_engine *eng;

View File

@@ -109,6 +109,8 @@ static AST_LIST_HEAD_STATIC(all_events, eventqent);
static int displayconnects = 1; static int displayconnects = 1;
static int timestampevents; static int timestampevents;
static int httptimeout = 60; static int httptimeout = 60;
static int manager_enabled = 0;
static int webmanager_enabled = 0;
static int block_sockets; static int block_sockets;
static int num_sessions; static int num_sessions;
@@ -239,6 +241,16 @@ static void UNLOCK_SESS(void)
} }
#endif #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. * Grab a reference to the last event, update usecount as needed.
* Can handle a NULL pointer. * Can handle a NULL pointer.
@@ -2934,8 +2946,6 @@ int init_manager(void)
struct ast_config *cfg = NULL; struct ast_config *cfg = NULL;
const char *val; const char *val;
char *cat = NULL; char *cat = NULL;
int webenabled = 0;
int enabled = 0;
int newhttptimeout = 60; int newhttptimeout = 60;
int have_sslbindaddr = 0; int have_sslbindaddr = 0;
struct hostent *hp; struct hostent *hp;
@@ -3015,11 +3025,11 @@ int init_manager(void)
free(ami_tls_cfg.cipher); free(ami_tls_cfg.cipher);
ami_tls_cfg.cipher = ast_strdup(val); ami_tls_cfg.cipher = ast_strdup(val);
} else if (!strcasecmp(var->name, "enabled")) { } else if (!strcasecmp(var->name, "enabled")) {
enabled = ast_true(val); manager_enabled = ast_true(val);
} else if (!strcasecmp(var->name, "block-sockets")) { } else if (!strcasecmp(var->name, "block-sockets")) {
block_sockets = ast_true(val); block_sockets = ast_true(val);
} else if (!strcasecmp(var->name, "webenabled")) { } else if (!strcasecmp(var->name, "webenabled")) {
webenabled = ast_true(val); webmanager_enabled = ast_true(val);
} else if (!strcasecmp(var->name, "port")) { } else if (!strcasecmp(var->name, "port")) {
ami_desc.sin.sin_port = htons(atoi(val)); ami_desc.sin.sin_port = htons(atoi(val));
} else if (!strcasecmp(var->name, "bindaddr")) { } 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; ami_desc.sin.sin_family = AF_INET;
if (!have_sslbindaddr) if (!have_sslbindaddr)
amis_desc.sin.sin_addr = ami_desc.sin.sin_addr; amis_desc.sin.sin_addr = ami_desc.sin.sin_addr;
@@ -3128,7 +3138,7 @@ int init_manager(void)
ast_config_destroy(cfg); ast_config_destroy(cfg);
if (webenabled && enabled) { if (webmanager_enabled && manager_enabled) {
if (!webregged) { if (!webregged) {
ast_http_uri_link(&rawmanuri); ast_http_uri_link(&rawmanuri);
ast_http_uri_link(&manageruri); ast_http_uri_link(&manageruri);