Added information about current node in tinc's top
The information is of grate value when monitoring multiple nodes in one window. Without it the user is forced to quit top, exit tinc and go back to shell to refresh his memory about which node is in what window.
This commit is contained in:
parent
970283c148
commit
ce1c957e87
2 changed files with 12 additions and 4 deletions
|
@ -209,8 +209,8 @@ bool dump_nodes(connection_t *c) {
|
||||||
|
|
||||||
bool dump_traffic(connection_t *c) {
|
bool dump_traffic(connection_t *c) {
|
||||||
for splay_each(node_t, n, node_tree)
|
for splay_each(node_t, n, node_tree)
|
||||||
send_request(c, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, CONTROL, REQ_DUMP_TRAFFIC,
|
send_request(c, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %d", CONTROL, REQ_DUMP_TRAFFIC,
|
||||||
n->name, n->in_packets, n->in_bytes, n->out_packets, n->out_bytes);
|
n->name, n->in_packets, n->in_bytes, n->out_packets, n->out_bytes, n == myself ? 1 : 0);
|
||||||
|
|
||||||
return send_request(c, "%d %d", CONTROL, REQ_DUMP_TRAFFIC);
|
return send_request(c, "%d %d", CONTROL, REQ_DUMP_TRAFFIC);
|
||||||
}
|
}
|
||||||
|
|
12
src/top.c
12
src/top.c
|
@ -43,6 +43,7 @@ typedef struct nodestats_t {
|
||||||
float out_packets_rate;
|
float out_packets_rate;
|
||||||
float out_bytes_rate;
|
float out_bytes_rate;
|
||||||
bool known;
|
bool known;
|
||||||
|
bool myself;
|
||||||
} nodestats_t;
|
} nodestats_t;
|
||||||
|
|
||||||
static const char *const sortname[] = {
|
static const char *const sortname[] = {
|
||||||
|
@ -85,17 +86,18 @@ static bool update(int fd) {
|
||||||
uint64_t in_bytes;
|
uint64_t in_bytes;
|
||||||
uint64_t out_packets;
|
uint64_t out_packets;
|
||||||
uint64_t out_bytes;
|
uint64_t out_bytes;
|
||||||
|
bool myself;
|
||||||
|
|
||||||
for list_each(nodestats_t, ns, &node_list)
|
for list_each(nodestats_t, ns, &node_list)
|
||||||
ns->known = false;
|
ns->known = false;
|
||||||
|
|
||||||
while(recvline(fd, line, sizeof line)) {
|
while(recvline(fd, line, sizeof line)) {
|
||||||
int n = sscanf(line, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes);
|
int n = sscanf(line, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64" %d", &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes, &myself);
|
||||||
|
|
||||||
if(n == 2)
|
if(n == 2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(n != 7)
|
if(n != 8)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
nodestats_t *found = NULL;
|
nodestats_t *found = NULL;
|
||||||
|
@ -119,6 +121,7 @@ static bool update(int fd) {
|
||||||
if(!found) {
|
if(!found) {
|
||||||
found = xzalloc(sizeof *found);
|
found = xzalloc(sizeof *found);
|
||||||
found->name = xstrdup(name);
|
found->name = xstrdup(name);
|
||||||
|
found->myself = myself;
|
||||||
list_insert_tail(&node_list, found);
|
list_insert_tail(&node_list, found);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -234,6 +237,11 @@ static void redraw(void) {
|
||||||
else
|
else
|
||||||
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
|
mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f",
|
||||||
node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale);
|
node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale);
|
||||||
|
|
||||||
|
if (node->myself) {
|
||||||
|
attrset(A_NORMAL);
|
||||||
|
mvprintw(1, 0, "Node: %-16s", node->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
attrset(A_NORMAL);
|
attrset(A_NORMAL);
|
||||||
|
|
Loading…
Reference in a new issue