This commit is contained in:
chowyu08
2017-09-09 16:04:40 +08:00
parent f3b2924b07
commit c85ba76f8f

View File

@@ -2,6 +2,7 @@ package broker
import (
"crypto/tls"
"fmt"
"hmq/lib/acl"
"hmq/packets"
"net"
@@ -13,6 +14,7 @@ import (
"golang.org/x/net/websocket"
log "github.com/cihub/seelog"
"github.com/shirou/gopsutil/mem"
)
type Broker struct {
@@ -77,6 +79,17 @@ func (b *Broker) Start() {
if len(b.config.Cluster.Routes) > 0 {
b.ConnectToRouters()
}
}
func StateMonitor() {
v, _ := mem.VirtualMemory()
timeSticker := time.NewTicker(time.Second * 5)
for {
select {
case <-timeSticker:
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
}
}
}
func (b *Broker) StartWebsocketListening() {