Added creation and periodic update of a file called "status" in the home directory that contains peer link status. Useful for debugging and statistics. Send it SIGHUP to force an update now. Otherwise it updates every 120 seconds.
This commit is contained in:
parent
68cc5ea523
commit
7c85a638b0
7 changed files with 120 additions and 15 deletions
|
@ -28,6 +28,8 @@
|
|||
#ifndef _ZT_TOPOLOGY_HPP
|
||||
#define _ZT_TOPOLOGY_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <list>
|
||||
|
@ -292,6 +294,35 @@ public:
|
|||
std::vector< SharedPtr<Peer> > &_v;
|
||||
};
|
||||
|
||||
/**
|
||||
* Dump peer I/O statistics to an open FILE (for status reporting and debug)
|
||||
*/
|
||||
class DumpPeerStatistics
|
||||
{
|
||||
public:
|
||||
DumpPeerStatistics(FILE *out) :
|
||||
_out(out),
|
||||
_now(Utils::now())
|
||||
{
|
||||
fprintf(_out,"Peer Direct IPv4 Direct IPv6 Latency(ms)"ZT_EOL_S);
|
||||
}
|
||||
|
||||
inline void operator()(Topology &t,const SharedPtr<Peer> &p)
|
||||
{
|
||||
InetAddress v4(p->ipv4ActivePath(_now));
|
||||
InetAddress v6(p->ipv6ActivePath(_now));
|
||||
fprintf(_out,"%-10s %-21s %-51s %u"ZT_EOL_S,
|
||||
p->address().toString().c_str(),
|
||||
((v4) ? v4.toString().c_str() : "(none)"),
|
||||
((v6) ? v6.toString().c_str() : "(none)"),
|
||||
p->latency());
|
||||
}
|
||||
|
||||
private:
|
||||
FILE *_out;
|
||||
uint64_t _now;
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void main()
|
||||
throw();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue