Index: doc/asterisk-mib.txt =================================================================== --- doc/asterisk-mib.txt (revision 71655) +++ doc/asterisk-mib.txt (working copy) @@ -11,7 +11,7 @@ FROM DIGIUM-MIB; asterisk MODULE-IDENTITY - LAST-UPDATED "200606081626Z" + LAST-UPDATED "200706251750Z" ORGANIZATION "Digium, Inc." CONTACT-INFO "Mark A. Spencer @@ -32,6 +32,9 @@ DESCRIPTION "Asterisk is an Open Source PBX. This MIB defined objects for managing Asterisk instances." + REVISION "200706251750Z" + DESCRIPTION + "Add total and current call counter statistics." REVISION "200603061840Z" DESCRIPTION "Change audio codec identification from 3kAudio to @@ -104,6 +107,23 @@ "The control socket for giving Asterisk commands." ::= { asteriskConfiguration 4 } +astConfigPid OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of calls currently on the Asterisk PBX." + ::= { asteriskConfiguration 5 } + +astConfigPid OBJECT-TYPE + SYNTAX Integer32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The total number of calls placed through the Asterisk PBX since last + restart." + ::= { asteriskConfiguration 6 } + -- asteriskModules astNumModules OBJECT-TYPE Index: include/asterisk/pbx.h =================================================================== --- include/asterisk/pbx.h (revision 71655) +++ include/asterisk/pbx.h (working copy) @@ -849,6 +849,11 @@ * \brief Retrieve the number of active calls */ int ast_active_calls(void); + +/*! + * \brief Retrieve the total number of calls run through the PBX since last restart + */ +int ast_total_calls(void); /*! * \brief executes a read operation on a function Index: main/cli.c =================================================================== --- main/cli.c (revision 71655) +++ main/cli.c (working copy) @@ -556,8 +556,10 @@ ast_cli(fd, "%d of %d max active call%s (%5.2f%% of capacity)\n", ast_active_calls(), option_maxcalls, ESS(ast_active_calls()), ((double)ast_active_calls() / (double)option_maxcalls) * 100.0); - else + else { ast_cli(fd, "%d active call%s\n", ast_active_calls(), ESS(ast_active_calls())); + ast_cli(fd, "%d call%s placed\n", ast_total_calls(), ESS(ast_total_calls())); + } } return CLI_SUCCESS; Index: main/pbx.c =================================================================== --- main/pbx.c (revision 71655) +++ main/pbx.c (working copy) @@ -278,6 +278,7 @@ AST_MUTEX_DEFINE_STATIC(maxcalllock); static int countcalls; +static int totalcalls; static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function); @@ -2567,8 +2568,10 @@ } #endif - if (!failed) + if (!failed) { countcalls++; + totalcalls++; + } ast_mutex_unlock(&maxcalllock); return failed; @@ -2651,6 +2654,11 @@ return countcalls; } +int ast_total_calls(void) +{ + return totalcalls; +} + int pbx_set_autofallthrough(int newval) { int oldval = autofallthrough; Index: res/snmp/agent.c =================================================================== --- res/snmp/agent.c (revision 71655) +++ res/snmp/agent.c (working copy) @@ -67,6 +67,8 @@ #define ASTCONFRELOADTIME 2 #define ASTCONFPID 3 #define ASTCONFSOCKET 4 +#define ASTCONFCURRENTCALLS 5 +#define ASTCONFTOTALCALLS 6 #define ASTMODULES 3 #define ASTMODCOUNT 1 @@ -590,6 +592,12 @@ case ASTCONFSOCKET: *var_len = strlen(ast_config_AST_SOCKET); return (u_char *)ast_config_AST_SOCKET; + case ASTCONFCURRENTCALLS: + long_ret = ast_current_calls(); + return (u_char *)&long_ret; + case ASTCONFTOTALCALLS: + long_ret = ast_total_calls(); + return (u_char *)&long_ret; default: break; } @@ -721,6 +729,8 @@ {ASTCONFRELOADTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFRELOADTIME}}, {ASTCONFPID, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPID}}, {ASTCONFSOCKET, ASN_OCTET_STR, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFSOCKET}}, + {ASTCONFCURRENTCALLS, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFCURRENTCALLS}}, + {ASTCONFTOTALCALLS, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFTOTALCALLS}}, {ASTMODCOUNT, ASN_INTEGER, RONLY, ast_var_Modules , 2, {ASTMODULES, ASTMODCOUNT}}, {ASTINDCOUNT, ASN_INTEGER, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCOUNT}}, {ASTINDCURRENT, ASN_OCTET_STR, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCURRENT}},