nfs-ganesha 1.4
Functions | Variables

libdaemon.c File Reference

libdaemon.c : snmp_adm API More...

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <pthread.h>
#include <unistd.h>
#include "snmp_adm.h"
#include "register.h"
#include "get_set_proc.h"
#include "parse_type.h"
#include "config_daemon.h"

Go to the source code of this file.

Functions

int snmp_adm_config_daemon (char *agent_x_socket, char *filelog, int prod_id)
int snmp_adm_register_scalars (int branch, register_scal *tab, int len)
int snmp_adm_register_get_set_function (int branch, register_get_set *tab, int len)
int snmp_adm_register_procedure (register_proc *tab, int len)
int snmp_adm_unregister (char *label)
void snmp_adm_send_trap (unsigned char type, snmp_adm_type_union value)
int snmp_adm_register_poll_trap (unsigned int second, trap_test test_fct, void *args, unsigned char type, snmp_adm_type_union value)
void snmp_adm_close ()
int snmp_adm_start ()
void snmp_adm_log (char *format,...)

Variables

register_inforegister_info_list = NULL
pthread_t * polling_threads = NULL
polling_argpolling_args = NULL
int polling_list_size = 0
oid * root_oid = NULL
int root_oid_len = 0
int branch_num [NUM_BRANCH]

Detailed Description

libdaemon.c : snmp_adm API

Author:
Cédric CABESSA

Definition in file libdaemon.c.


Function Documentation

void snmp_adm_close ( )

Close the snmp thread.

Definition at line 711 of file libdaemon.c.

int snmp_adm_config_daemon ( char *  agent_x_socket,
char *  filelog,
int  prod_id 
)

Configure daemon. Should be called before registering values.

Parameters:
agent_x_socketagentX socket name (eg:"/tmp/agentx/master" or "tcp:192.168.67.19:31415"). This parametre should be set according to the snmpd config.
prod_idproduct id, unique identifier of this daemon.
filelogfile to record log messages or "syslog".
Returns:
0 on success.

Definition at line 426 of file libdaemon.c.

void snmp_adm_log ( char *  format,
  ... 
)

Log a message.

See also:
init_daemon.

Definition at line 794 of file libdaemon.c.

int snmp_adm_register_get_set_function ( int  branch,
register_get_set tab,
int  len 
)

Register get/set functions. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe functions to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 515 of file libdaemon.c.

int snmp_adm_register_poll_trap ( unsigned int  second,
trap_test  test_fct,
void *  args,
unsigned char  type,
snmp_adm_type_union  value 
)

Register a polling fonction.

Parameters:
secondpolling time.
test_fctfonction called each "second", send a trap if return 1.
argsarguments of test_fct.
typetype of the variable.
valuevalue of the variable.

Definition at line 661 of file libdaemon.c.

int snmp_adm_register_procedure ( register_proc tab,
int  len 
)

Register procedures. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
tabthe procedures to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 547 of file libdaemon.c.

int snmp_adm_register_scalars ( int  branch,
register_scal tab,
int  len 
)

Register scalars. Note for strings : string provided in code MUST be readonly (ACCESS_RO). string MUST be allocated with SNMP_ADM_MAX_STR. Note for label & desc in register_scal* : they are copied in the library own memory, so user can safely free them or reuse them after this call.

Parameters:
branchthe branch number (STAT_OID or CONF_OID).
tabthe values to register.
lenthe array's length.
Returns:
0 on success.

Definition at line 485 of file libdaemon.c.

void snmp_adm_send_trap ( unsigned char  type,
snmp_adm_type_union  value 
)

Send a SNMPv2 trap.

Parameters:
typetype of the variable.
valuevalue of the variable.

Definition at line 607 of file libdaemon.c.

int snmp_adm_start ( )

Launch the thread. FIXME after this, nothing should be registered, net-snmp bug?

Returns:
1: nothing was recorded. 2: daemon not configured, or problem with snmpd. 3: cannot create the thread.

Definition at line 763 of file libdaemon.c.

int snmp_adm_unregister ( char *  label)

Unregister an instance.

Parameters:
labelname of the instance.
Returns:
0 on success.

Definition at line 572 of file libdaemon.c.


Variable Documentation

int branch_num[NUM_BRANCH]

Definition at line 169 of file libdaemon.c.

array of polling arg

See also:
polling_arg

Definition at line 42 of file libdaemon.c.

sizeof polling_thread and polling_args

Definition at line 44 of file libdaemon.c.

pthread_t* polling_threads = NULL

array of thread id for polling

Definition at line 40 of file libdaemon.c.

linked list of registred objects

Definition at line 38 of file libdaemon.c.

oid* root_oid = NULL

Definition at line 46 of file libdaemon.c.

int root_oid_len = 0

Definition at line 47 of file libdaemon.c.