Navigation


Changeset 1381:f374d3f8f7d3 in freeDiameter


Ignore:
Timestamp:
Jun 27, 2019, 1:11:36 AM (5 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

test_ccload: add statistics for received messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/test_ccload/test_ccload.c

    r1375 r1381  
    6767        uint64_t error;
    6868        time_t first;
     69        time_t first_reply;
    6970        time_t last;
     71        time_t last_reply;
    7072} statistics;
    7173
    7274void print_statistics(void) {
    73         uint64_t missing;
     75        uint64_t missing, received;
    7476
    7577        if (statistics.first == 0 || statistics.last == 0 || statistics.last == statistics.first) {
     
    7779        }
    7880
    79         missing = statistics.sent - statistics.error - statistics.success;
    80 
    81         fd_log_error("%s: %lld CCR messages sent in %llds (%.2f messages/second), %lld success (%.2f%%), %lld errors (%.2f%%), %lld missing (%.2f%%)",
     81        received = statistics.error + statistics.success;
     82        missing = statistics.sent - received;
     83
     84        fd_log_error("%s: %lld CCR messages sent in %llds (%.2f messages/second), %lld CCA messages received in %llds (%.2f messages/second), %lld success (%.2f%%), %lld errors (%.2f%%), %lld missing (%.2f%%)",
    8285                     fd_g_config->cnf_diamid,
    8386                     (long long)statistics.sent, (long long)(statistics.last-statistics.first), (float)statistics.sent / (statistics.last-statistics.first),
     87                     (long long)received, (long long)(statistics.last_reply-statistics.first_reply), (float)received / (statistics.last_reply-statistics.first_reply),
    8488                     (long long)statistics.success,
    8589                     100*(float)statistics.success/statistics.sent, (long long)statistics.error, 100*(float)statistics.error/statistics.sent,
     
    104108        }
    105109
     110        if (statistics.first_reply == 0) {
     111                statistics.first_reply = time(NULL);
     112        }
    106113        /* Answer received, check it */
    107114        if (fd_msg_search_avp(*msg, rc_avp_do, &rc) < 0 || rc == NULL) {
     
    114121                return -1;
    115122        }
     123        statistics.last_reply = time(NULL);
    116124        fd_log_debug("Credit-Control-Answer with Result-Code %d received", ahdr->avp_value->i32);
    117125        switch (ahdr->avp_value->i32/1000) {
     
    122130                statistics.error++;
    123131                break;
     132        }
     133        if (statistics.sent - statistics.error - statistics.success == 0) {
     134                print_statistics();
    124135        }
    125136
Note: See TracChangeset for help on using the changeset viewer.