Functions | Variables

snmpstats.c File Reference

SNMP statistic module

More...

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/wait.h>
#include "snmpstats.h"
#include "snmpstats_globals.h"
#include "../../timer.h"
#include "../../cfg/cfg_struct.h"
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "../../lib/kcore/statistics.h"
#include "../../sr_module.h"
#include "../../dprint.h"
#include "../../error.h"
#include "../../ut.h"
#include "../../script_cb.h"
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "snmpSIPRegUserTable.h"
#include "snmpSIPContactTable.h"
#include "interprocess_buffer.h"
#include "hashTable.h"
#include "alarm_checks.h"
#include "utilities.h"
#include "sub_agent.h"
Include dependency graph for snmpstats.c:

Go to the source code of this file.

Functions

Variables


Detailed Description

Definition in file snmpstats.c.


Function Documentation

static int mod_child_init ( int  rank  )  [static]

It is at this point that we want to create our AgentX sub-agent process, and register a handler for any state changes of our child.

Definition at line 362 of file snmpstats.c.

References agentx_child(), fork_process(), PROC_MAIN, PROC_NOCHLDINIT, and spawn_sysUpTime_child().

Here is the call graph for this function:

static void mod_destroy ( void   )  [static]

When this happens, we log a useful message and kill the AgentX Sub-Agent child process

Definition at line 393 of file snmpstats.c.

static int mod_init ( void   )  [static]

This call must always return a value as soon as possible. If it were not to return, then Kamailio would not be able to initialize any of the other modules.

Definition at line 310 of file snmpstats.c.

References initInterprocessBuffers(), register_message_code_statistics(), and run_alarm_check().

Here is the call graph for this function:

int set_snmp_community ( modparam_t  type,
void *  val 
)

Definition at line 585 of file snmpstats.c.

References stringHandlerSanityCheck().

Here is the call graph for this function:

int set_snmpget_path ( modparam_t  type,
void *  val 
)

Handles setting of the path to the snmpget binary.

The function will set the snmpget_path parameter.

Definition at line 573 of file snmpstats.c.

References stringHandlerSanityCheck().

Here is the call graph for this function:

static void sigchld_handler ( int  signal  )  [static]

We need a customized handler to catch and ignore its SIGCHLD when it terminates. We also need to make sure to forward other processes SIGCHLD's to Kamailio's usual SIGCHLD handler. We do this by resetting back Kamailio's own signal handlers after we caught our appropriate SIGCHLD.

Definition at line 408 of file snmpstats.c.

References old_sigchld_handler.

static int spawn_sysUpTime_child ( void   )  [static]

This function will spawn a child that retrieves the sysUpTime and stores the result in a file.

See the function definition below for a full description.

This file will be read by the AgentX Sub-agent process to supply the openserSIPServiceStartTime time. This function never returns, but it will generated a SIGCHLD when it terminates. There must a SIGCHLD handler to ignore the SIGCHLD for only this process. (See sigchld_handler above).

Note:
sysUpTime is a scalar provided by netsnmp. It is not the same thing as a normal system uptime. Support for this has been provided to try to match the IETF Draft SIP MIBs as closely as possible.

Definition at line 457 of file snmpstats.c.

References old_sigchld_handler.

Referenced by mod_child_init().

Here is the caller graph for this function:


Variable Documentation

Initial value:
 
{
        "100_in", "180_in", "181_in", "182_in", "183_in", 
        
        "200_in", "202_in", 
        
        "300_in", "301_in", "302_in", "305_in", "380_in",
        
        "400_in", "401_in", "402_in", "403_in", "404_in", "405_in", "406_in", 
        "407_in", "408_in", "410_in", "413_in", "414_in", "415_in", "416_in", 
        "420_in", "421_in", "423_in", "480_in", "481_in", "482_in", "483_in", 
        "484_in", "485_in", "486_in", "487_in", "488_in", "491_in", "492_in",   
        "494_in", 
        
        "500_in", "501_in", "502_in", "503_in", "504_in", "505_in", "513_in",
        "600_in", "603_in", "604_in", "606_in"
}

http://en.wikipedia.org/wiki/SIP_Responses

If there are more message codes added at a later time, they should be added here, and to out_message_code_names below.

The array is used to register the statistics keeping track of the number of messages received with the response code X.

Definition at line 216 of file snmpstats.c.

stat_var** in_message_code_stats = NULL

Definition at line 265 of file snmpstats.c.

struct sigaction old_sigchld_handler [static]

This structure holds the old handler so we can call and restore Kamailio's usual handler when appropriate

Definition at line 204 of file snmpstats.c.

Referenced by sigchld_handler(), and spawn_sysUpTime_child().

Initial value:
 
{
        "100_out", "180_out", "181_out", "182_out", "183_out", 
        
        "200_out", "202_out", 
        
        "300_out", "301_out", "302_out", "305_out", "380_out",
        
        "400_out", "401_out", "402_out", "403_out", "404_out", "405_out", "406_out", 
        "407_out", "408_out", "410_out", "413_out", "414_out", "415_out", "416_out", 
        "420_out", "421_out", "423_out", "480_out", "481_out", "482_out", "483_out", 
        "484_out", "485_out", "486_out", "487_out", "488_out", "491_out", "492_out",    
        "494_out", 
        
        "500_out", "501_out", "502_out", "503_out", "504_out", "505_out", "513_out",
        "600_out", "603_out", "604_out", "606_out"
}

http://en.wikipedia.org/wiki/SIP_Responses

If there are more message codes added at a later time, they should be added here, and to in_message_code_names above.

The array is used to register the statistics keeping track of the number of messages send out with the response code X.

Definition at line 244 of file snmpstats.c.

char* snmpget_path = NULL

The parameters are used to define what happens with the sysUpTime child.

Definition at line 196 of file snmpstats.c.

volatile pid_t sysUpTime_pid

We need a customized handler to ignore the SIGCHLD when the execve() finishes. We keep around the child process's pid for the customized handler.

Specifically, If the process that generated the SIGCHLD doesn't match this pid, we call Kamailio's default handlers. Otherwise, we just ignore SIGCHLD.

Definition at line 188 of file snmpstats.c.