#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_t * | update_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_t * | next_monitor (monitor_t *data) |
mirror_t * | next_mirror (mirror_t *data) |
address_t * | next_address (monitor_t *mon, address_t *data) |
flowstat_t * | next_flowstat (monitor_t *mon, flowstat_t *data) |
monitor_t * | find_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_t * | current_monitor = NULL |
current monitor set while loading configuration | |
static uint8_t | replication_interval |
replication interval | |
static evContext | m_ctx |
event context |
These functions will parse and load the configuration data.
Definition in file monitube-mgmt_config.c.
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
[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
[in] | mon_name | Monitor's 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
)
[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
[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
[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
[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
[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
[in] | name | Monitor name |
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
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
[in] | check | 1 if this function being invoked because of a commit check |
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().
Given a monitor, get the next address in configuration given the previously returned data
[in] | mon | Monitor's configuration |
[in] | data | previously returned data, should be NULL first time |
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
[in] | mon | Monitor's configuration |
[in] | data | previously returned data, should be NULL first time |
Definition at line 1025 of file monitube-mgmt_config.c.
References monitor_s::flow_stats, and flowstat_s::node.
Referenced by show_monitor_stats().
Get the next mirror in configuration given the previously returned data
[in] | data | previously returned data, should be NULL first time |
Definition at line 985 of file monitube-mgmt_config.c.
References mirrors_conf, and mirror_s::node.
Referenced by receive_connection().
Get the next monitor in configuration given the previously returned data
[in] | data | previously returned data, should be NULL first time |
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
[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) |
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
[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) |
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
[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) |
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
[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
)
[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
[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
[in] | name | The monitor name |
[in] | rate | The monitored group's bps (media) rate |
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().