mirror of
git://erdgeist.org/opentracker
synced 2025-03-12 13:41:12 +00:00
Allow logging of completed events to syslog
This commit is contained in:
parent
b1bf030f92
commit
f4409df68a
1
Makefile
1
Makefile
@ -35,6 +35,7 @@ BINDIR?=$(PREFIX)/bin
|
|||||||
#FEATURES+=-DWANT_LOG_NUMWANT
|
#FEATURES+=-DWANT_LOG_NUMWANT
|
||||||
#FEATURES+=-DWANT_MODEST_FULLSCRAPES
|
#FEATURES+=-DWANT_MODEST_FULLSCRAPES
|
||||||
#FEATURES+=-DWANT_SPOT_WOODPECKER
|
#FEATURES+=-DWANT_SPOT_WOODPECKER
|
||||||
|
#FEATURES+=-DWANT_SYSLOGS
|
||||||
FEATURES+=-DWANT_FULLSCRAPE
|
FEATURES+=-DWANT_FULLSCRAPE
|
||||||
|
|
||||||
#FEATURES+=-D_DEBUG_HTTPERROR
|
#FEATURES+=-D_DEBUG_HTTPERROR
|
||||||
|
17
ot_stats.c
17
ot_stats.c
@ -14,6 +14,9 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#ifdef WANT_SYSLOGS
|
||||||
|
#include <syslog.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Libowfat */
|
/* Libowfat */
|
||||||
#include "byte.h"
|
#include "byte.h"
|
||||||
@ -637,6 +640,13 @@ void stats_issue_event( ot_status_event event, PROTO_FLAG proto, uintptr_t event
|
|||||||
if( proto == FLAG_TCP ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
|
if( proto == FLAG_TCP ) ot_overall_tcp_connects++; else ot_overall_udp_connects++;
|
||||||
break;
|
break;
|
||||||
case EVENT_COMPLETED:
|
case EVENT_COMPLETED:
|
||||||
|
#ifdef WANT_SYSLOGS
|
||||||
|
if( event_data) {
|
||||||
|
char hex_out[42];
|
||||||
|
to_hex( hex_out, (uint8_t*)event_data );
|
||||||
|
syslog( LOG_INFO, "event=completed info_hash=%s", hex_out );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
ot_overall_completed++;
|
ot_overall_completed++;
|
||||||
break;
|
break;
|
||||||
case EVENT_SCRAPE:
|
case EVENT_SCRAPE:
|
||||||
@ -715,10 +725,17 @@ static pthread_t thread_id;
|
|||||||
void stats_init( ) {
|
void stats_init( ) {
|
||||||
ot_start_time = g_now_seconds;
|
ot_start_time = g_now_seconds;
|
||||||
pthread_create( &thread_id, NULL, stats_worker, NULL );
|
pthread_create( &thread_id, NULL, stats_worker, NULL );
|
||||||
|
#ifdef WANT_SYSLOGS
|
||||||
|
openlog( "opentracker", 0, LOG_USER );
|
||||||
|
setlogmask(LOG_UPTO(LOG_INFO));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void stats_deinit( ) {
|
void stats_deinit( ) {
|
||||||
pthread_cancel( thread_id );
|
pthread_cancel( thread_id );
|
||||||
|
#ifdef WANT_SYSLOGS
|
||||||
|
closelog();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *g_version_stats_c = "$Source$: $Revision$\n";
|
const char *g_version_stats_c = "$Source$: $Revision$\n";
|
||||||
|
@ -138,7 +138,7 @@ size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_
|
|||||||
torrent->peer_list->peer_count++;
|
torrent->peer_list->peer_count++;
|
||||||
if( OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) {
|
if( OT_PEERFLAG(peer) & PEER_FLAG_COMPLETED ) {
|
||||||
torrent->peer_list->down_count++;
|
torrent->peer_list->down_count++;
|
||||||
stats_issue_event( EVENT_COMPLETED, 0, 0 );
|
stats_issue_event( EVENT_COMPLETED, 0, (uintptr_t)torrent->hash );
|
||||||
}
|
}
|
||||||
if( OT_PEERFLAG(peer) & PEER_FLAG_SEEDING )
|
if( OT_PEERFLAG(peer) & PEER_FLAG_SEEDING )
|
||||||
torrent->peer_list->seed_count++;
|
torrent->peer_list->seed_count++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user