#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/pbx.h"
Go to the source code of this file.
Functions | |
| AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"System information related functions") | |
| 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_custom_function | sysinfo_function |
SYSINFO function to return various system data.
Definition in file func_sysinfo.c.
| AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
| "System information related functions" | ||||
| ) |
| static int load_module | ( | void | ) | [static] |
Definition at line 110 of file func_sysinfo.c.
References ast_custom_function_register.
00111 { 00112 return ast_custom_function_register(&sysinfo_function); 00113 }
| 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.
00041 { 00042 #if defined(HAVE_SYSINFO) 00043 struct sysinfo sys_info; 00044 if (sysinfo(&sys_info)) { 00045 ast_log(LOG_ERROR, "FAILED to retrieve system information\n"); 00046 return -1; 00047 } 00048 #endif 00049 if (ast_strlen_zero(data)) { 00050 ast_log(LOG_WARNING, "Syntax: ${SYSINFO(<parameter>)} - missing argument!)\n"); 00051 return -1; 00052 } else if (!strcasecmp("loadavg", data)) { 00053 double curloadavg; 00054 getloadavg(&curloadavg, 1); 00055 snprintf(buf, len, "%f", curloadavg); 00056 } else if (!strcasecmp("numcalls", data)) { 00057 snprintf(buf, len, "%d", ast_active_calls()); 00058 } 00059 #if defined(HAVE_SYSINFO) 00060 else if (!strcasecmp("uptime", data)) { /* in hours */ 00061 snprintf(buf, len, "%ld", sys_info.uptime/3600); 00062 } else if (!strcasecmp("totalram", data)) { /* in KiB */ 00063 snprintf(buf, len, "%ld",(sys_info.totalram * sys_info.mem_unit)/1024); 00064 } else if (!strcasecmp("freeram", data)) { /* in KiB */ 00065 snprintf(buf, len, "%ld",(sys_info.freeram * sys_info.mem_unit)/1024); 00066 } else if (!strcasecmp("bufferram", data)) { /* in KiB */ 00067 snprintf(buf, len, "%ld",(sys_info.bufferram * sys_info.mem_unit)/1024); 00068 } else if (!strcasecmp("totalswap", data)) { /* in KiB */ 00069 snprintf(buf, len, "%ld",(sys_info.totalswap * sys_info.mem_unit)/1024); 00070 } else if (!strcasecmp("freeswap", data)) { /* in KiB */ 00071 snprintf(buf, len, "%ld",(sys_info.freeswap * sys_info.mem_unit)/1024); 00072 } else if (!strcasecmp("numprocs", data)) { 00073 snprintf(buf, len, "%d", sys_info.procs); 00074 } 00075 #endif 00076 else { 00077 ast_log(LOG_ERROR, "Unknown sysinfo parameter type '%s'.\n", data); 00078 return -1; 00079 } 00080 00081 return 0; 00082 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 105 of file func_sysinfo.c.
References ast_custom_function_unregister().
00106 { 00107 return ast_custom_function_unregister(&sysinfo_function); 00108 }
struct ast_custom_function sysinfo_function [static] |
Definition at line 84 of file func_sysinfo.c.
1.6.1