#include "asterisk.h"
#include <sys/sysinfo.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 | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "System information related functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | sysinfo_function |
Definition in file func_sysinfo.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 151 of file func_sysinfo.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 151 of file func_sysinfo.c.
static int load_module | ( | void | ) | [static] |
Definition at line 146 of file func_sysinfo.c.
References ast_custom_function_register, and sysinfo_function.
00147 { 00148 return ast_custom_function_register(&sysinfo_function); 00149 }
static int sysinfo_helper | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 90 of file func_sysinfo.c.
References ast_active_calls(), ast_log(), ast_strlen_zero(), getloadavg(), LOG_ERROR, and LOG_WARNING.
00092 { 00093 #if defined(HAVE_SYSINFO) 00094 struct sysinfo sys_info; 00095 if (sysinfo(&sys_info)) { 00096 ast_log(LOG_ERROR, "FAILED to retrieve system information\n"); 00097 return -1; 00098 } 00099 #endif 00100 if (ast_strlen_zero(data)) { 00101 ast_log(LOG_WARNING, "Syntax: ${SYSINFO(<parameter>)} - missing argument!)\n"); 00102 return -1; 00103 } else if (!strcasecmp("loadavg", data)) { 00104 double curloadavg; 00105 getloadavg(&curloadavg, 1); 00106 snprintf(buf, len, "%f", curloadavg); 00107 } else if (!strcasecmp("numcalls", data)) { 00108 snprintf(buf, len, "%d", ast_active_calls()); 00109 } 00110 #if defined(HAVE_SYSINFO) 00111 else if (!strcasecmp("uptime", data)) { /* in hours */ 00112 snprintf(buf, len, "%ld", sys_info.uptime/3600); 00113 } else if (!strcasecmp("totalram", data)) { /* in KiB */ 00114 snprintf(buf, len, "%ld",(sys_info.totalram * sys_info.mem_unit)/1024); 00115 } else if (!strcasecmp("freeram", data)) { /* in KiB */ 00116 snprintf(buf, len, "%ld",(sys_info.freeram * sys_info.mem_unit)/1024); 00117 } else if (!strcasecmp("bufferram", data)) { /* in KiB */ 00118 snprintf(buf, len, "%ld",(sys_info.bufferram * sys_info.mem_unit)/1024); 00119 } else if (!strcasecmp("totalswap", data)) { /* in KiB */ 00120 snprintf(buf, len, "%ld",(sys_info.totalswap * sys_info.mem_unit)/1024); 00121 } else if (!strcasecmp("freeswap", data)) { /* in KiB */ 00122 snprintf(buf, len, "%ld",(sys_info.freeswap * sys_info.mem_unit)/1024); 00123 } else if (!strcasecmp("numprocs", data)) { 00124 snprintf(buf, len, "%d", sys_info.procs); 00125 } 00126 #endif 00127 else { 00128 ast_log(LOG_ERROR, "Unknown sysinfo parameter type '%s'.\n", data); 00129 return -1; 00130 } 00131 00132 return 0; 00133 }
static int unload_module | ( | void | ) | [static] |
Definition at line 141 of file func_sysinfo.c.
References ast_custom_function_unregister(), and sysinfo_function.
00142 { 00143 return ast_custom_function_unregister(&sysinfo_function); 00144 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "System information related functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 151 of file func_sysinfo.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 151 of file func_sysinfo.c.
struct ast_custom_function sysinfo_function [static] |
Initial value:
{ .name = "SYSINFO", .read = sysinfo_helper, .read_max = 22, }
Definition at line 135 of file func_sysinfo.c.
Referenced by load_module(), and unload_module().