gateway.go 1.4 KB
Newer Older
E
eoLinker API Management 已提交
1 2 3
package monitor

import (
Y
Your Name 已提交
4
	v "github.com/eolinker/goku-api-gateway/common/version"
黄孟柱 已提交
5 6 7
	"github.com/eolinker/goku-api-gateway/server/cluster"
	console_mysql "github.com/eolinker/goku-api-gateway/server/dao/console-mysql"
	dao_monitor "github.com/eolinker/goku-api-gateway/server/dao/console-mysql/dao-monitor"
E
eoLinker API Management 已提交
8 9
)

Y
Your Name 已提交
10 11
//GetGatewayMonitorSummaryByPeriod 获取网关监控概况
func GetGatewayMonitorSummaryByPeriod(clientID int, beginTime, endTime string, period int) (bool, *SystemInfo, error) {
E
eoLinker API Management 已提交
12 13 14

	startHour, endHour := genHour(beginTime, endTime, period)

Y
Your Name 已提交
15
	values, e := dao_monitor.GetGateway(clientID, startHour, endHour)
E
eoLinker API Management 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29
	if e != nil {
		return false, nil, e
	}

	nodeStartCount, nodeStopCount, projectCount, apiCount, strategyCount, e := dao_monitor.GetGatewayInfo()
	if e != nil {
		return false, nil, e
	}
	info := new(SystemInfo)
	info.GatewayRequestInfo.read(values)
	info.ProxyInfo.read(values)

	info.BaseInfo.NodeCount = nodeStartCount + nodeStopCount
	info.BaseInfo.ProjectCount = projectCount
Y
Your Name 已提交
30
	info.BaseInfo.APICount = apiCount
E
eoLinker API Management 已提交
31 32 33
	info.BaseInfo.StrategyCount = strategyCount
	activeRedisCount, redisErrorCount := console_mysql.GetRedisCount()
	info.BaseInfo.RedisCount = activeRedisCount + redisErrorCount
Y
Your Name 已提交
34
	info.BaseInfo.Version = v.Version
E
eoLinker API Management 已提交
35 36 37 38 39
	info.BaseInfo.ClusterCount = cluster.GetClusterCount()
	//dao_monitor.GetGatewayMonitorSummaryByPeriod(beginTime, endTime, period)
	return true, info, nil

}