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

import (
黄孟柱 已提交
4 5 6 7
	. "github.com/eolinker/goku-api-gateway/common/version"
	"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 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
)

func GetGatewayMonitorSummaryByPeriod(clientId int, beginTime, endTime string, period int) (bool, *SystemInfo, error) {

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

	values, e := dao_monitor.GetGateway(clientId, startHour, endHour)
	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
	info.BaseInfo.ApiCount = apiCount
	info.BaseInfo.StrategyCount = strategyCount
	activeRedisCount, redisErrorCount := console_mysql.GetRedisCount()
	info.BaseInfo.RedisCount = activeRedisCount + redisErrorCount
	info.BaseInfo.Version = Version
	info.BaseInfo.ClusterCount = cluster.GetClusterCount()
	//dao_monitor.GetGatewayMonitorSummaryByPeriod(beginTime, endTime, period)
	return true, info, nil

}