diff options
Diffstat (limited to 'ot_stats.c')
| -rw-r--r-- | ot_stats.c | 25 | 
1 files changed, 21 insertions, 4 deletions
| @@ -24,6 +24,8 @@ static unsigned long long ot_overall_tcp_successfulannounces = 0; | |||
| 24 | static unsigned long long ot_overall_udp_successfulannounces = 0; | 24 | static unsigned long long ot_overall_udp_successfulannounces = 0; | 
| 25 | static unsigned long long ot_overall_tcp_successfulscrapes = 0; | 25 | static unsigned long long ot_overall_tcp_successfulscrapes = 0; | 
| 26 | static unsigned long long ot_overall_udp_successfulscrapes = 0; | 26 | static unsigned long long ot_overall_udp_successfulscrapes = 0; | 
| 27 | static unsigned long long ot_overall_tcp_connects = 0; | ||
| 28 | static unsigned long long ot_overall_udp_connects = 0; | ||
| 27 | static unsigned long long ot_full_scrape_count = 0; | 29 | static unsigned long long ot_full_scrape_count = 0; | 
| 28 | static unsigned long long ot_full_scrape_size = 0; | 30 | static unsigned long long ot_full_scrape_size = 0; | 
| 29 | 31 | ||
| @@ -171,11 +173,11 @@ static size_t stats_connections_mrtg( char * reply ) { | |||
| 171 | return sprintf( reply, | 173 | return sprintf( reply, | 
| 172 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", | 174 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker connections, %lu conns/s :: %lu success/s.", | 
| 173 | ot_overall_tcp_connections+ot_overall_udp_connections, | 175 | ot_overall_tcp_connections+ot_overall_udp_connections, | 
| 174 | ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, | 176 | ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, | 
| 175 | (int)t, | 177 | (int)t, | 
| 176 | (int)(t / 3600), | 178 | (int)(t / 3600), | 
| 177 | events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), | 179 | events_per_time( ot_overall_tcp_connections+ot_overall_udp_connections, t ), | 
| 178 | events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, t ) | 180 | events_per_time( ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces+ot_overall_udp_connects, t ) | 
| 179 | ); | 181 | ); | 
| 180 | } | 182 | } | 
| 181 | 183 | ||
| @@ -184,11 +186,11 @@ static size_t stats_udpconnections_mrtg( char * reply ) { | |||
| 184 | return sprintf( reply, | 186 | return sprintf( reply, | 
| 185 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.", | 187 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker udp4 stats, %lu conns/s :: %lu success/s.", | 
| 186 | ot_overall_udp_connections, | 188 | ot_overall_udp_connections, | 
| 187 | ot_overall_udp_successfulannounces, | 189 | ot_overall_udp_successfulannounces+ot_overall_udp_connects, | 
| 188 | (int)t, | 190 | (int)t, | 
| 189 | (int)(t / 3600), | 191 | (int)(t / 3600), | 
| 190 | events_per_time( ot_overall_udp_connections, t ), | 192 | events_per_time( ot_overall_udp_connections, t ), | 
| 191 | events_per_time( ot_overall_udp_successfulannounces, t ) | 193 | events_per_time( ot_overall_udp_successfulannounces+ot_overall_udp_connects, t ) | 
| 192 | ); | 194 | ); | 
| 193 | } | 195 | } | 
| 194 | 196 | ||
| @@ -205,6 +207,17 @@ static size_t stats_tcpconnections_mrtg( char * reply ) { | |||
| 205 | ); | 207 | ); | 
| 206 | } | 208 | } | 
| 207 | 209 | ||
| 210 | static size_t stats_scrape_mrtg( char * reply ) { | ||
| 211 | time_t t = time( NULL ) - ot_start_time; | ||
| 212 | return sprintf( reply, | ||
| 213 | "%llu\n%llu\n%i seconds (%i hours)\nopentracker scrape stats, %lu scrape/s (tcp and udp)", | ||
| 214 | ot_overall_tcp_successfulscrapes, | ||
| 215 | ot_overall_udp_successfulscrapes, | ||
| 216 | (int)t, | ||
| 217 | (int)(t / 3600), | ||
| 218 | events_per_time( (ot_overall_tcp_successfulscrapes+ot_overall_udp_successfulscrapes), t ) | ||
| 219 | ); | ||
| 220 | } | ||
| 208 | 221 | ||
| 209 | static size_t stats_fullscrapes_mrtg( char * reply ) { | 222 | static size_t stats_fullscrapes_mrtg( char * reply ) { | 
| 210 | ot_time t = time( NULL ) - ot_start_time; | 223 | ot_time t = time( NULL ) - ot_start_time; | 
| @@ -244,6 +257,8 @@ size_t return_stats_for_tracker( char *reply, int mode, int format ) { | |||
| 244 | switch( mode ) { | 257 | switch( mode ) { | 
| 245 | case TASK_STATS_CONNS: | 258 | case TASK_STATS_CONNS: | 
| 246 | return stats_connections_mrtg( reply ); | 259 | return stats_connections_mrtg( reply ); | 
| 260 | case TASK_STATS_SCRAPE: | ||
| 261 | return stats_scrape_mrtg( reply ); | ||
| 247 | case TASK_STATS_UDP: | 262 | case TASK_STATS_UDP: | 
| 248 | return stats_udpconnections_mrtg( reply ); | 263 | return stats_udpconnections_mrtg( reply ); | 
| 249 | case TASK_STATS_TCP: | 264 | case TASK_STATS_TCP: | 
| @@ -271,6 +286,8 @@ void stats_issue_event( ot_status_event event, int is_tcp, size_t event_data ) { | |||
| 271 | break; | 286 | break; | 
| 272 | case EVENT_SCRAPE: | 287 | case EVENT_SCRAPE: | 
| 273 | if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++; | 288 | if( is_tcp ) ot_overall_tcp_successfulscrapes++; else ot_overall_udp_successfulscrapes++; | 
| 289 | case EVENT_CONNECT: | ||
| 290 | if( is_tcp ) ot_overall_tcp_connects++; else ot_overall_udp_connects++; | ||
| 274 | case EVENT_FULLSCRAPE: | 291 | case EVENT_FULLSCRAPE: | 
| 275 | ot_full_scrape_count++; | 292 | ot_full_scrape_count++; | 
| 276 | ot_full_scrape_size += event_data; | 293 | ot_full_scrape_size += event_data; | 
