#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/pbx.h"
Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | sysinfo_helper (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "System information related functions" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_custom_function | sysinfo_function |
SYSINFO function to return various system data.
Definition in file func_sysinfo.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 115 of file func_sysinfo.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 115 of file func_sysinfo.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 110 of file func_sysinfo.c.
References ast_custom_function_register.
{
return ast_custom_function_register(&sysinfo_function);
}
| static int sysinfo_helper | ( | struct ast_channel * | chan, |
| const char * | cmd, | ||
| char * | data, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | [static] |
Definition at line 39 of file func_sysinfo.c.
References ast_active_calls(), ast_log(), ast_strlen_zero(), getloadavg(), LOG_ERROR, and LOG_WARNING.
{
#if defined(HAVE_SYSINFO)
struct sysinfo sys_info;
if (sysinfo(&sys_info)) {
ast_log(LOG_ERROR, "FAILED to retrieve system information\n");
return -1;
}
#endif
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Syntax: ${SYSINFO(<parameter>)} - missing argument!)\n");
return -1;
} else if (!strcasecmp("loadavg", data)) {
double curloadavg;
getloadavg(&curloadavg, 1);
snprintf(buf, len, "%f", curloadavg);
} else if (!strcasecmp("numcalls", data)) {
snprintf(buf, len, "%d", ast_active_calls());
}
#if defined(HAVE_SYSINFO)
else if (!strcasecmp("uptime", data)) { /* in hours */
snprintf(buf, len, "%ld", sys_info.uptime/3600);
} else if (!strcasecmp("totalram", data)) { /* in KiB */
snprintf(buf, len, "%ld",(sys_info.totalram * sys_info.mem_unit)/1024);
} else if (!strcasecmp("freeram", data)) { /* in KiB */
snprintf(buf, len, "%ld",(sys_info.freeram * sys_info.mem_unit)/1024);
} else if (!strcasecmp("bufferram", data)) { /* in KiB */
snprintf(buf, len, "%ld",(sys_info.bufferram * sys_info.mem_unit)/1024);
} else if (!strcasecmp("totalswap", data)) { /* in KiB */
snprintf(buf, len, "%ld",(sys_info.totalswap * sys_info.mem_unit)/1024);
} else if (!strcasecmp("freeswap", data)) { /* in KiB */
snprintf(buf, len, "%ld",(sys_info.freeswap * sys_info.mem_unit)/1024);
} else if (!strcasecmp("numprocs", data)) {
snprintf(buf, len, "%d", sys_info.procs);
}
#endif
else {
ast_log(LOG_ERROR, "Unknown sysinfo parameter type '%s'.\n", data);
return -1;
}
return 0;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 105 of file func_sysinfo.c.
References ast_custom_function_unregister().
{
return ast_custom_function_unregister(&sysinfo_function);
}
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "System information related functions" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 115 of file func_sysinfo.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 115 of file func_sysinfo.c.
struct ast_custom_function sysinfo_function [static] |
Definition at line 84 of file func_sysinfo.c.