Store socket and fwmark in the stats file.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 15 Apr 2013 22:39:17 +0000 (00:39 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 15 Apr 2013 22:39:17 +0000 (00:39 +0200)
client.cpp
client.h
stats.cpp

index bb2d26c..5871da1 100644 (file)
@@ -67,6 +67,7 @@ Client::Client(const ClientProto &serialized, Stream *stream)
                if (fwmark != 0) {
                        log_perror("setsockopt(SO_MARK)");
                }
+               fwmark = 0;
        }
 }
 
@@ -92,6 +93,8 @@ ClientStats Client::get_stats() const
 {
        ClientStats stats;
        stats.stream_id = stream_id;
+       stats.sock = sock;
+       stats.fwmark = fwmark;
        stats.remote_addr = remote_addr;
        stats.connect_time = connect_time;
        stats.bytes_sent = bytes_sent;
index db1fea5..d511698 100644 (file)
--- a/client.h
+++ b/client.h
@@ -13,6 +13,8 @@ struct Stream;
 // Digested statistics for writing to logs etc.
 struct ClientStats {
        std::string stream_id;
+       int sock;
+       int fwmark;
        std::string remote_addr;
        time_t connect_time;
        size_t bytes_sent;
index 71fb485..fa483bf 100644 (file)
--- a/stats.cpp
+++ b/stats.cpp
@@ -53,8 +53,10 @@ void StatsThread::do_work()
                now = time(NULL);
                client_stats = servers->get_client_stats();
                for (size_t i = 0; i < client_stats.size(); ++i) {
-                       fprintf(fp, "%s %s %d %llu %llu %llu\n",
+                       fprintf(fp, "%s %d %d %s %d %llu %llu %llu\n",
                                client_stats[i].remote_addr.c_str(),
+                               client_stats[i].sock,
+                               client_stats[i].fwmark,
                                client_stats[i].stream_id.c_str(),
                                int(now - client_stats[i].connect_time),
                                (long long unsigned)(client_stats[i].bytes_sent),