monitube-mgmt_config.c File Reference

Relating to loading and storing the configuration data. More...

#include <sync/common.h>
#include <ddl/dax.h>
#include <jnx/pconn.h>
#include "monitube-mgmt_config.h"
#include "monitube-mgmt_conn.h"
#include "monitube-mgmt_logging.h"

Go to the source code of this file.

Defines

#define MAX_FLOW_AGE   300
 max flow statistic age in seconds (5 mins)

Functions

static void update_address (in_addr_t addr, in_addr_t mask)
static monitor_tupdate_monitor (const char *name, uint32_t rate)
static void update_mirror (in_addr_t from, in_addr_t to)
static void delete_all_addresses (boolean notify)
static void delete_all_flowstats (monitor_t *mon)
static void delete_all_monitors (void)
static void delete_all_mirrors (void)
static void delete_address (in_addr_t addr, in_addr_t mask)
static void delete_monitor (monitor_t *mon)
static void delete_mirror (in_addr_t from)
static int parse_addresses (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static int parse_monitors (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static int parse_mirrors (dax_walk_data_t *dwd, ddl_handle_t *dop, int action, void *data)
static void age_out_flow_stat (evContext ctx __unused, void *uap, struct timespec due __unused, struct timespec inter __unused)
void init_config (evContext ctx)
void clear_config (void)
int monitube_config_read (int check)
uint8_t get_replication_interval (void)
monitor_tnext_monitor (monitor_t *data)
mirror_tnext_mirror (mirror_t *data)
address_tnext_address (monitor_t *mon, address_t *data)
flowstat_tnext_flowstat (monitor_t *mon, flowstat_t *data)
monitor_tfind_monitor (char *name)
void set_flow_stat (uint16_t fpc_slot, uint16_t pic_slot, const char *name, in_addr_t flow_addr, uint16_t flow_port, double mdi_df, uint32_t mdi_mlr)
void clear_all_flowstats (void)
int clear_flowstats (char *mon_name)

Variables

static patroot monitors_conf
 Pat. root for monitors config.
static patroot mirrors_conf
 Pat. root for mirrors config.
static monitor_tcurrent_monitor = NULL
 current monitor set while loading configuration
static uint8_t replication_interval
 replication interval
static evContext m_ctx
 event context


Detailed Description

Relating to loading and storing the configuration data.

These functions will parse and load the configuration data.

Definition in file monitube-mgmt_config.c.


Function Documentation

static void age_out_flow_stat ( evContext ctx  __unused,
void *  uap,
struct timespec due  __unused,
struct timespec inter  __unused 
) [static]

Delete the flow statistics because they have timed out

Parameters:
[in] ctx The event context for this application
[in] uap The user data for this callback
[in] due The absolute time when the event is due (now)
[in] inter The period; when this will next be called

Definition at line 800 of file monitube-mgmt_config.c.

References monitor_s::flow_stats, LOG, m_ctx, flowstat_s::mon, flowstat_s::node, and flowstat_s::timer_id.

Referenced by set_flow_stat().

void clear_all_flowstats ( void   ) 

Clear all flow statistics records

Definition at line 1157 of file monitube-mgmt_config.c.

References delete_all_flowstats(), and next_monitor().

Referenced by monitube_clear_stats().

void clear_config ( void   ) 

Clear and reset the entire configuration, freeing all memory.

Definition at line 843 of file monitube-mgmt_config.c.

References delete_all_mirrors(), and delete_all_monitors().

Referenced by monitube_config_read(), monitube_init(), and monitube_shutdown().

int clear_flowstats ( char *  mon_name  ) 

Clear all flow statistics records associated with a monitor

Parameters:
[in] mon_name Monitor's name
Returns:
0 upon success; -1 if there's no monitor configured with the given name

Definition at line 1183 of file monitube-mgmt_config.c.

References delete_all_flowstats(), and monitors_conf.

Referenced by monitube_clear_stats().

static void delete_address ( in_addr_t  addr,
in_addr_t  mask 
) [static]

Delete a given address from a monitor's config (uses current_monitor)

Parameters:
[in] addr Address
[in] mask Address mask

Definition at line 340 of file monitube-mgmt_config.c.

References monitor_s::addresses, current_monitor, LOG, monitor_s::name, address_s::node, and notify_address_delete().

Referenced by parse_addresses().

static void delete_all_addresses ( boolean  notify  )  [static]

Delete all address from a monitor's configuration

Parameters:
[in] notify Whether or not to notify the data component

Definition at line 216 of file monitube-mgmt_config.c.

References monitor_s::addresses, current_monitor, LOG, monitor_s::name, address_s::node, and notify_monitor_delete().

Referenced by delete_all_monitors(), delete_monitor(), and parse_addresses().

static void delete_all_flowstats ( monitor_t mon  )  [static]

Delete all flow statistics from a monitor's configuration

Parameters:
[in] mon The configuration for the monitor

Definition at line 250 of file monitube-mgmt_config.c.

References monitor_s::flow_stats, LOG, m_ctx, flowstat_s::node, and flowstat_s::timer_id.

Referenced by clear_all_flowstats(), clear_flowstats(), delete_all_monitors(), and delete_monitor().

static void delete_all_mirrors ( void   )  [static]

Delete all configured mirrors

Definition at line 310 of file monitube-mgmt_config.c.

References LOG, mirrors_conf, mirror_s::node, and notify_delete_all_mirrors().

Referenced by clear_config(), monitube_config_read(), and parse_mirrors().

static void delete_all_monitors ( void   )  [static]

Delete all configured monitors

Definition at line 278 of file monitube-mgmt_config.c.

References monitor_s::addresses, current_monitor, delete_all_addresses(), delete_all_flowstats(), monitor_s::flow_stats, LOG, monitors_conf, monitor_s::node, and notify_delete_all_monitors().

Referenced by clear_config(), monitube_config_read(), and parse_monitors().

static void delete_mirror ( in_addr_t  from  )  [static]

Find and delete a mirror given its from address

Parameters:
[in] from The mirror's from address

Definition at line 405 of file monitube-mgmt_config.c.

References LOG, mirrors_conf, mirror_s::node, and notify_mirror_delete().

Referenced by parse_mirrors().

static void delete_monitor ( monitor_t mon  )  [static]

Delete a monitor

Parameters:
[in] mon The monitor

Definition at line 376 of file monitube-mgmt_config.c.

References monitor_s::addresses, current_monitor, delete_all_addresses(), delete_all_flowstats(), monitor_s::flow_stats, LOG, monitors_conf, monitor_s::name, monitor_s::node, and notify_monitor_delete().

Referenced by parse_monitors().

monitor_t* find_monitor ( char *  name  ) 

Get the monitor configuration information by name

Parameters:
[in] name Monitor name
Returns:
The monitor if one exists with the matching name, o/w NULL

Definition at line 1041 of file monitube-mgmt_config.c.

References monitors_conf.

Referenced by monitube_show_stats().

uint8_t get_replication_interval ( void   ) 

Get the current replication_interval

Returns:
the replication interval

Definition at line 955 of file monitube-mgmt_config.c.

References replication_interval.

Referenced by receive_connection().

void init_config ( evContext  ctx  ) 

Init the data structures that will store configuration info

Definition at line 829 of file monitube-mgmt_config.c.

References m_ctx, MAX_MON_NAME, mirrors_conf, monitors_conf, and replication_interval.

Referenced by monitube_init().

int monitube_config_read ( int  check  ) 

Read daemon configuration from the database

Parameters:
[in] check 1 if this function being invoked because of a commit check
Returns:
SUCCESS (0) successfully loaded, EFAIL if not
Note:
Do not use ERRMSG/LOG during config check normally.

Definition at line 861 of file monitube-mgmt_config.c.

References clear_config(), delete_all_mirrors(), delete_all_monitors(), notify_replication_interval(), parse_mirrors(), parse_monitors(), process_notifications(), and replication_interval.

Referenced by main().

address_t* next_address ( monitor_t mon,
address_t data 
)

Given a monitor, get the next address in configuration given the previously returned data

Parameters:
[in] mon Monitor's configuration
[in] data previously returned data, should be NULL first time
Returns:
pointer to an address if one more exists, o/w NULL

Definition at line 1005 of file monitube-mgmt_config.c.

References monitor_s::addresses, and address_s::node.

Referenced by receive_connection().

flowstat_t* next_flowstat ( monitor_t mon,
flowstat_t data 
)

Given a monitor, get the next flowstat in configuration given the previously returned data

Parameters:
[in] mon Monitor's configuration
[in] data previously returned data, should be NULL first time
Returns:
pointer to a flowstat if one more exists, o/w NULL

Definition at line 1025 of file monitube-mgmt_config.c.

References monitor_s::flow_stats, and flowstat_s::node.

Referenced by show_monitor_stats().

mirror_t* next_mirror ( mirror_t data  ) 

Get the next mirror in configuration given the previously returned data

Parameters:
[in] data previously returned data, should be NULL first time
Returns:
pointer to a mirror if one more exists, o/w NULL

Definition at line 985 of file monitube-mgmt_config.c.

References mirrors_conf, and mirror_s::node.

Referenced by receive_connection().

monitor_t* next_monitor ( monitor_t data  ) 

Get the next monitor in configuration given the previously returned data

Parameters:
[in] data previously returned data, should be NULL first time
Returns:
pointer to a monitor if one more exists, o/w NULL

Definition at line 969 of file monitube-mgmt_config.c.

References monitors_conf, and monitor_s::node.

Referenced by clear_all_flowstats(), monitube_show_stats(), and receive_connection().

static int parse_addresses ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_walk_list to parse each configured address knob in a monnitored-networks group

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for server object
[in] action The action on the given server object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 449 of file monitube-mgmt_config.c.

References delete_address(), delete_all_addresses(), and update_address().

Referenced by parse_monitors().

static int parse_mirrors ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_walk_list to parse each configured mirror knob

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for application object
[in] action The action on the given application object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 700 of file monitube-mgmt_config.c.

References delete_all_mirrors(), delete_mirror(), and update_mirror().

Referenced by monitube_config_read().

static int parse_monitors ( dax_walk_data_t *  dwd,
ddl_handle_t *  dop,
int  action,
void *  data 
) [static]

Handler for dax_walk_list to parse each configured monitor knob

Parameters:
[in] dwd Opaque dax data
[in] dop DAX Object Pointer for application object
[in] action The action on the given application object
[in] data User data passed to handler (check flag)
Returns:
DAX_WALK_OK upon success or DAX_WALK_ABORT upon failure

Definition at line 573 of file monitube-mgmt_config.c.

References current_monitor, delete_all_monitors(), delete_monitor(), MAX_MON_NAME, monitors_conf, parse_addresses(), and update_monitor().

Referenced by monitube_config_read().

void set_flow_stat ( uint16_t  fpc_slot,
uint16_t  pic_slot,
const char *  name,
in_addr_t  flow_addr,
uint16_t  flow_port,
double  mdi_df,
uint32_t  mdi_mlr 
)

Given a monitor's name and flow address add or update its statistics record

Parameters:
[in] fpc_slot FPC slot #
[in] pic_slot PIC slot #
[in] name Monitor's name
[in] flow_addr flow address (ID)
[in] flow_port flow port (ID)
[in] mdi_df MDI delay factor
[in] mdi_mlr MDI media loss rate

Definition at line 1072 of file monitube-mgmt_config.c.

References age_out_flow_stat(), flowstat_s::flow_addr, flowstat_s::flow_port, monitor_s::flow_stats, flowstat_s::fpc_slot, flowstat_s::last_mdi_df, flowstat_s::last_mdi_mlr, LOG, m_ctx, MAX_FLOW_AGE, flowstat_s::mon, monitors_conf, flowstat_s::node, flowstat_s::pic_slot, flowstat_s::reports, STATS_BASE_WINDOW, flowstat_s::timer_id, and flowstat_s::window_position.

Referenced by receive_message().

static void update_address ( in_addr_t  addr,
in_addr_t  mask 
) [static]

Add an address to a monitor (uses current_monitor)

Parameters:
[in] addr The address of the network
[in] mask The address mask

Definition at line 84 of file monitube-mgmt_config.c.

References address_s::address, monitor_s::addresses, current_monitor, LOG, address_s::mask, monitor_s::name, address_s::node, and notify_address_update().

Referenced by parse_addresses().

static void update_mirror ( in_addr_t  from,
in_addr_t  to 
) [static]

Update or add a mirroring config

Parameters:
[in] from The mirror from address
[in] to The mirror to address

Definition at line 180 of file monitube-mgmt_config.c.

References LOG, mirrors_conf, mirror_s::node, notify_mirror_update(), mirror_s::original, and mirror_s::redirect.

Referenced by parse_mirrors().

static monitor_t* update_monitor ( const char *  name,
uint32_t  rate 
) [static]

Update or add a monitoring config

Parameters:
[in] name The monitor name
[in] rate The monitored group's bps (media) rate
Returns:
The added monitor

Definition at line 130 of file monitube-mgmt_config.c.

References monitor_s::addresses, monitor_s::flow_stats, LOG, MAX_MON_NAME, monitors_conf, monitor_s::name, monitor_s::node, notify_monitor_update(), and monitor_s::rate.

Referenced by parse_monitors().


© 2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:03 2010 for SDK Your Net Corporation Monitube IPTV Monitoring Example: monitube-mgmt 1.0 by Doxygen 1.5.1