Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/cdp: changed stats to use internal counters instead
- Loading branch information
Showing
9 changed files
with
75 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "cdp_stats.h" | ||
|
||
struct cdp_counters_h cdp_cnts_h; | ||
enum sctp_info_req { CDP_AVG_RSP }; | ||
|
||
static counter_val_t cdp_internal_stats(counter_handle_t h, void* what); | ||
|
||
counter_def_t cdp_cnt_defs[] = { | ||
{&cdp_cnts_h.timeout, "timeout", 0, 0, 0, | ||
"number of timeouts on CDP requests"}, | ||
{&cdp_cnts_h.replies_received, "replies_received", 0, 0, 0, | ||
"total number of replies received"}, | ||
{&cdp_cnts_h.replies_response_time, "replies_response_time", 0, 0, 0, | ||
"total time waiting for replies"}, | ||
{0, "average_response_time", 0, | ||
cdp_internal_stats, (void*) (long) CDP_AVG_RSP, | ||
"average response time for CDP replies"}, | ||
{0, 0, 0, 0, 0, 0} | ||
}; | ||
|
||
int cdp_init_counters() { | ||
if (counter_register_array("cdp", cdp_cnt_defs) < 0) | ||
goto error; | ||
return 0; | ||
error: | ||
return -1; | ||
} | ||
|
||
void cdp_destroy_counters() { | ||
|
||
} | ||
|
||
/** helper function for some stats (which are kept internally). | ||
*/ | ||
static counter_val_t cdp_internal_stats(counter_handle_t h, void* what) { | ||
enum sctp_info_req w; | ||
|
||
w = (int) (long) what; | ||
switch (w) { | ||
case CDP_AVG_RSP: | ||
if (counter_get_val(cdp_cnts_h.replies_received) == 0) | ||
return 0; | ||
else | ||
return counter_get_val(cdp_cnts_h.replies_response_time)/counter_get_val(cdp_cnts_h.replies_received); | ||
}; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef CDP_STATS_H | ||
#define CDP_STATS_H | ||
|
||
#include "../../counters.h" | ||
|
||
struct cdp_counters_h { | ||
counter_handle_t timeout; | ||
counter_handle_t replies_received; | ||
counter_handle_t replies_response_time; | ||
counter_handle_t avg_response_time; | ||
}; | ||
#endif /* CDP_STATS_H */ | ||
|
||
int cdp_init_counters(); | ||
void cdp_destroy_counters(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,6 @@ | |
#define _CDP__H | ||
|
||
#include "../../sr_module.h" | ||
#include "statistics.h" | ||
|
||
#define M_NAME "cdp" | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters