5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-26 07:11:40 +00:00

Show information about individual active queues

This commit is contained in:
Neil Alexander 2018-09-27 12:14:55 +01:00
parent 2674e1cb8b
commit b530916044
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
4 changed files with 27 additions and 3 deletions

View File

@ -527,7 +527,17 @@ func (a *admin) getData_getSwitchQueues() admin_nodeInfo {
var peerInfos admin_nodeInfo var peerInfos admin_nodeInfo
switchTable := a.core.switchTable switchTable := a.core.switchTable
getSwitchQueues := func() { getSwitchQueues := func() {
queues := make([]map[string]interface{}, 0)
for k, v := range switchTable.queues.bufs {
queue := map[string]interface{}{
"queue_id": k,
"queue_size": v.size,
"queue_packets": len(v.packets),
}
queues = append(queues, queue)
}
peerInfos = admin_nodeInfo{ peerInfos = admin_nodeInfo{
{"queues", queues},
{"queues_count", len(switchTable.queues.bufs)}, {"queues_count", len(switchTable.queues.bufs)},
{"queues_size", switchTable.queues.size}, {"queues_size", switchTable.queues.size},
{"max_queues_count", switchTable.queues.maxbufs}, {"max_queues_count", switchTable.queues.maxbufs},

View File

@ -699,12 +699,12 @@ func (t *switchTable) doWorker() {
if t.queues.size > t.queues.maxsize { if t.queues.size > t.queues.maxsize {
t.queues.maxsize = t.queues.size t.queues.maxsize = t.queues.size
} }
t.queues.bufs[streamID] = buf
if !bufExists { if !bufExists {
if len(t.queues.bufs) > t.queues.maxbufs { if len(t.queues.bufs) > t.queues.maxbufs {
t.queues.maxbufs = len(t.queues.bufs) t.queues.maxbufs = len(t.queues.bufs)
} }
} }
t.queues.bufs[streamID] = buf
t.queues.cleanup(t) t.queues.cleanup(t)
} }
case port := <-t.idleIn: case port := <-t.idleIn:

View File

@ -197,6 +197,20 @@ func main() {
if maxqueuesize, ok := v["max_queues_size"].(float64); ok { if maxqueuesize, ok := v["max_queues_size"].(float64); ok {
fmt.Printf("Maximum queue size: %d\n", uint(maxqueuesize)) fmt.Printf("Maximum queue size: %d\n", uint(maxqueuesize))
} }
if queues, ok := v["queues"].([]interface{}); ok {
if len(queues) == 0 {
fmt.Println("No active queues")
return
} else {
fmt.Println("Active queues:")
for k, v := range queues {
fmt.Printf("[%d] - Queue '%v', size: %d, packets: %d\n", k+1,
v.(map[string]interface{})["queue_id"].([]byte),
uint(v.(map[string]interface{})["queue_size"].(float64)),
uint(v.(map[string]interface{})["queue_packets"].(float64)))
}
}
}
case "addpeer", "removepeer", "addallowedencryptionpublickey", "removeallowedencryptionpublickey": case "addpeer", "removepeer", "addallowedencryptionpublickey", "removeallowedencryptionpublickey":
if _, ok := res["added"]; ok { if _, ok := res["added"]; ok {
for _, v := range res["added"].([]interface{}) { for _, v := range res["added"].([]interface{}) {