34 #if defined(HAVE_SYSINFO)
35 #include <sys/sysinfo.h>
92 static int sysinfo_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
93 char *buf,
size_t len)
95 #if defined(HAVE_SYSINFO)
96 struct sysinfo sys_info;
97 if (sysinfo(&sys_info)) {
98 ast_log(LOG_ERROR,
"FAILED to retrieve system information\n");
102 if (ast_strlen_zero(data)) {
103 ast_log(LOG_WARNING,
"Syntax: ${SYSINFO(<parameter>)} - missing argument!)\n");
105 }
else if (!strcasecmp(
"loadavg", data)) {
107 getloadavg(&curloadavg, 1);
108 snprintf(buf, len,
"%f", curloadavg);
109 }
else if (!strcasecmp(
"numcalls", data)) {
112 #if defined(HAVE_SYSINFO)
113 else if (!strcasecmp(
"uptime", data)) {
114 snprintf(buf, len,
"%ld", sys_info.uptime/3600);
115 }
else if (!strcasecmp(
"totalram", data)) {
116 snprintf(buf, len,
"%lu",(sys_info.totalram * sys_info.mem_unit)/1024);
117 }
else if (!strcasecmp(
"freeram", data)) {
118 snprintf(buf, len,
"%lu",(sys_info.freeram * sys_info.mem_unit)/1024);
119 }
else if (!strcasecmp(
"bufferram", data)) {
120 snprintf(buf, len,
"%lu",(sys_info.bufferram * sys_info.mem_unit)/1024);
121 }
else if (!strcasecmp(
"totalswap", data)) {
122 snprintf(buf, len,
"%lu",(sys_info.totalswap * sys_info.mem_unit)/1024);
123 }
else if (!strcasecmp(
"freeswap", data)) {
124 snprintf(buf, len,
"%lu",(sys_info.freeswap * sys_info.mem_unit)/1024);
125 }
else if (!strcasecmp(
"numprocs", data)) {
126 snprintf(buf, len,
"%d", sys_info.procs);
130 ast_log(LOG_ERROR,
"Unknown sysinfo parameter type '%s'.\n", data);
139 .read = sysinfo_helper,
143 static int unload_module(
void)
148 static int load_module(
void)
153 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"System information related functions");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_active_calls(void)
Retrieve the number of active calls.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Data structure associated with a custom dialplan function.
Core PBX routines and definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_custom_function_register(acf)
Register a custom function.