Changeset 357

Show
Ignore:
Timestamp:
31/08/07 02:24:28 (15 months ago)
Author:
smoku
Message:

c2s and s2s packet throughput counter implemented

Location:
trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/c2s/c2s.c

    r353 r357  
    210210            /* we're counting packets */ 
    211211            sess->packet_count++; 
     212            sess->c2s->packet_count++; 
    212213 
    213214            nad = (nad_t) data; 
     
    427428    c2s_t c2s = (c2s_t) arg; 
    428429    struct sockaddr_storage sa; 
    429     int namelen = sizeof(sa), port, nbytes; 
     430    int namelen = sizeof(sa), port, nbytes, flags = 0; 
    430431 
    431432    switch(a) { 
     
    504505            xhash_put(c2s->sessions, sess->skey, (void *) sess); 
    505506 
     507            flags = SX_SASL_OFFER; 
    506508#ifdef HAVE_SSL 
    507509            /* go ssl wrappermode if they're on the ssl port */ 
    508510            if(port == c2s->local_ssl_port) 
    509                 sx_server_init(sess->s, SX_SSL_WRAPPER | SX_SASL_OFFER); 
    510             else 
    511                 sx_server_init(sess->s, SX_SASL_OFFER); 
    512 #else 
    513             sx_server_init(sess->s, SX_SASL_OFFER); 
     511                flags |= SX_SSL_WRAPPER; 
    514512#endif 
     513#ifdef HAVE_LIBZ 
     514            flags |= SX_COMPRESS_OFFER; 
     515#endif 
     516            sx_server_init(sess->s, flags); 
     517 
    515518            break; 
    516519    } 
     
    10461049                } 
    10471050 
     1051                /* we're counting packets */ 
     1052                sess->packet_count++; 
     1053                sess->c2s->packet_count++; 
     1054 
    10481055                /* remove sm specifics */ 
    10491056                nad_set_attr(nad, 1, ns, "c2s", NULL, 0); 
  • trunk/c2s/c2s.h

    r350 r357  
    2828#include "sx/sx.h" 
    2929#include "sx/ssl.h" 
     30#include "sx/compress.h" 
    3031#ifdef HEADER_MD5_H 
    3132#  define MD5_H 
     
    144145    sx_plugin_t         sx_ssl; 
    145146    sx_plugin_t         sx_sasl; 
     147    sx_plugin_t         sx_compress; 
    146148 
    147149    /** router's conn */ 
     
    165167    char                *log_facility; 
    166168    char                *log_ident; 
     169 
     170    /** packet counter */ 
     171    long long int       packet_count; 
     172    char                *packet_stats; 
    167173 
    168174    /** connect retry */ 
  • trunk/c2s/main.c

    r350 r357  
    113113        c2s->log_ident = config_get_one(c2s->config, "log.file", 0); 
    114114 
     115    c2s->packet_stats = config_get_one(c2s->config, "stats.packet", 0); 
     116 
    115117    c2s->local_ip = config_get_one(c2s->config, "local.ip", 0); 
    116118    if(c2s->local_ip == NULL) 
     
    495497    sess_t sess; 
    496498    union xhashv xhv; 
    497 #ifdef POOL_DEBUG 
    498     time_t pool_time = 0; 
    499 #endif 
     499    time_t check_time = 0; 
    500500     
    501501#ifdef HAVE_UMASK 
     
    642642    } 
    643643 
     644#ifdef HAVE_LIBZ 
     645    /* get compression up and running */ 
     646    c2s->sx_compress = sx_env_plugin(c2s->sx_env, sx_compress_init); 
     647    if(c2s->sx_compress == NULL) { 
     648        log_write(c2s->log, LOG_ERR, "failed to initialise compression"); 
     649    } 
     650#endif 
     651 
     652    /* get bind up */ 
    644653    sx_env_plugin(c2s->sx_env, bind_init, c2s); 
    645654 
     
    714723        } 
    715724 
     725        if(time(NULL) > check_time + 60) { 
    716726#ifdef POOL_DEBUG 
    717         if(time(NULL) > pool_time + 60) { 
    718727            pool_stat(1); 
    719             pool_time = time(NULL); 
    720         } 
    721 #endif 
     728#endif 
     729            if(c2s->packet_stats != NULL) { 
     730                int fd = open(c2s->packet_stats, O_TRUNC | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP); 
     731                if(fd) { 
     732                    char buf[100]; 
     733                    int len = snprintf(buf, 100, "%lld\n", c2s->packet_count); 
     734                    write(fd, buf, len); 
     735                    close(fd); 
     736                } else { 
     737                    log_write(c2s->log, LOG_ERR, "failed to write packet statistics to: %s", c2s->packet_stats); 
     738                    c2s_shutdown = 1; 
     739                } 
     740            } 
     741     
     742            check_time = time(NULL); 
     743        } 
    722744    } 
    723745 
  • trunk/etc/c2s.xml.dist.in

    r350 r357  
    264264  </io> 
    265265 
     266  <!-- Statistics --> 
     267  <stats> 
     268    <!-- file containing count of packets that went through --> 
     269    <!-- 
     270    <packet>@localstatedir@/jabberd/stats/c2s.packets</packet> 
     271    --> 
     272  </stats> 
     273 
    266274  <!-- Authentication/registration database configuration --> 
    267275  <authreg> 
  • trunk/etc/s2s.xml.dist.in

    r162 r357  
    166166  </check> 
    167167 
     168  <!-- Statistics --> 
     169  <stats> 
     170    <!-- file containing count of packets that went through --> 
     171    <!-- 
     172    <packet>@localstatedir@/jabberd/stats/s2s.packets</packet> 
     173    --> 
     174  </stats> 
     175 
    168176</s2s> 
  • trunk/s2s/in.c

    r311 r357  
    257257            /* we're counting packets */ 
    258258            in->packet_count++; 
     259            in->s2s->packet_count++; 
    259260 
    260261            nad = (nad_t) data; 
  • trunk/s2s/main.c

    r235 r357  
    110110        s2s->log_ident = config_get_one(s2s->config, "log.file", 0); 
    111111 
     112    s2s->packet_stats = config_get_one(s2s->config, "stats.packet", 0); 
     113 
    112114    s2s->local_ip = config_get_one(s2s->config, "local.ip", 0); 
    113115    if(s2s->local_ip == NULL) 
     
    381383    dnscache_t dns; 
    382384    union xhashv xhv; 
    383 #ifdef POOL_DEBUG 
    384     time_t pool_time = 0; 
    385 #endif 
     385    time_t check_time = 0; 
    386386 
    387387#ifdef HAVE_UMASK 
     
    578578        } 
    579579 
     580        if(time(NULL) > check_time + 60) { 
    580581#ifdef POOL_DEBUG 
    581         if(time(NULL) > pool_time + 60) { 
    582582            pool_stat(1); 
    583             pool_time = time(NULL); 
    584         } 
    585 #endif 
     583#endif 
     584            if(s2s->packet_stats != NULL) { 
     585                int fd = open(s2s->packet_stats, O_TRUNC | O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP); 
     586                if(fd) { 
     587                    char buf[100]; 
     588                    int len = snprintf(buf, 100, "%lld\n", s2s->packet_count); 
     589                    write(fd, buf, len); 
     590                    close(fd); 
     591                } else { 
     592                    log_write(s2s->log, LOG_ERR, "failed to write packet statistics to: %s", s2s->packet_stats); 
     593                    s2s_shutdown = 1; 
     594                } 
     595            } 
     596     
     597            check_time = time(NULL); 
     598        } 
    586599    } 
    587600 
  • trunk/s2s/out.c

    r285 r357  
    633633            /* we're counting packets */ 
    634634            out->packet_count++; 
     635            out->s2s->packet_count++; 
    635636 
    636637            nad = (nad_t) data; 
  • trunk/s2s/s2s.h

    r285 r357  
    8383    char                *log_ident; 
    8484 
     85    /** packet counter */ 
     86    long long int       packet_count; 
     87    char                *packet_stats; 
     88 
    8589    /** connect retry */ 
    8690    int                 retry_init;