Commit a8a5fe7a authored by Node- 门 忠鑫's avatar Node- 门 忠鑫

# 添加部分数据

parent 4c8a82af
...@@ -5,20 +5,27 @@ import ( ...@@ -5,20 +5,27 @@ import (
"fmt" "fmt"
"git.quantgroup.cn/DevOps/enoch/service/end_points" "git.quantgroup.cn/DevOps/enoch/service/end_points"
"github.com/influxdata/influxdb/client/v2" "github.com/influxdata/influxdb/client/v2"
"math/big"
"net"
"time" "time"
) )
var sysNameIndex = make(map[int64]bool)
func AgentMsgProcess(msg string) { func AgentMsgProcess(msg string) {
chunkMsg := enn_points.ChunkMsg{} chunkMsg := end_points.ChunkMsg{}
err := json.Unmarshal([]byte(msg), &chunkMsg) err := json.Unmarshal([]byte(msg), &chunkMsg)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
buildMetricsInfluxMsg(chunkMsg) buildMetricsInfluxMsg(chunkMsg)
} }
func buildMetricsInfluxMsg(chunkMsg enn_points.ChunkMsg) { func buildMetricsInfluxMsg(chunkMsg end_points.ChunkMsg) {
var ip = inetAtoN(chunkMsg.Ip)
println("ip:%d", ip)
sysNameIndex[ip] = true
var sysNameCount = len(sysNameIndex)
for _, p := range chunkMsg.EndPoints { for _, p := range chunkMsg.EndPoints {
tags := make(map[string]string, ) tags := make(map[string]string, )
tags["sys_name"] = chunkMsg.AppName tags["sys_name"] = chunkMsg.AppName
...@@ -62,15 +69,24 @@ func buildMetricsInfluxMsg(chunkMsg enn_points.ChunkMsg) { ...@@ -62,15 +69,24 @@ func buildMetricsInfluxMsg(chunkMsg enn_points.ChunkMsg) {
fields["gc_concurrent_mark_sweep"] = metrics.GcConcurrentmarksweepCount fields["gc_concurrent_mark_sweep"] = metrics.GcConcurrentmarksweepCount
fields["gc_concurrent_mark_time"] = metrics.GcConcurrentmarksweepTime fields["gc_concurrent_mark_time"] = metrics.GcConcurrentmarksweepTime
fields["processors"] = metrics.Processors fields["uptime"] = metrics.Uptime
fields["instance_uptime"] = metrics.InstanceUptime
fields["system_load_average"] = metrics.SystemloadAverage
unix := time.Unix(0, p.Timestamp) unix := time.Unix(0, p.Timestamp*1000000)
if (len(pointSlice) == batchSize) { println(p.Timestamp)
if len(pointSlice) >= sysNameCount {
go batchWrite(pointSlice) go batchWrite(pointSlice)
pointSlice = make([]*client.Point, 0, batchSize) pointSlice = make([]*client.Point, 0, batchSize)
} }
println(len(pointSlice))
point, _ := client.NewPoint("machine_info", tags, fields, unix) point, _ := client.NewPoint("machine_info", tags, fields, unix)
pointSlice = append(pointSlice, point) pointSlice = append(pointSlice, point)
} }
}
func inetAtoN(ip string) int64 {
ret := big.NewInt(0)
ret.SetBytes(net.ParseIP(ip).To4())
return ret.Int64()
} }
package enn_points package end_points
type ChunkMsg struct { type ChunkMsg struct {
AppName string `json:"appName"` AppName string `json:"appName"`
Ip string `json:"ip"` Ip string `json:"ip"`
EndPoints []EndPoint `json:"end_points"` EndPoints []EndPoint `json:"endPoints"`
} }
type EndPoint struct { type EndPoint struct {
...@@ -18,7 +18,7 @@ type Health struct { ...@@ -18,7 +18,7 @@ type Health struct {
} }
type Detail struct { type Detail struct {
DiskSpace DiskInfo `json:"disk_space"` DiskSpace DiskInfo `json:"diskSpace"`
Redis RedisInfo `json:"redis"` Redis RedisInfo `json:"redis"`
Db interface{} `json:"db"` Db interface{} `json:"db"`
} }
...@@ -82,80 +82,80 @@ type MetricsInfo struct { ...@@ -82,80 +82,80 @@ type MetricsInfo struct {
GcParnewTime int `json:"gc.parnew.time"` GcParnewTime int `json:"gc.parnew.time"`
GcConcurrentmarksweepCount int `json:"gc.concurrentmarksweep.count"` GcConcurrentmarksweepCount int `json:"gc.concurrentmarksweep.count"`
GcConcurrentmarksweepTime int `json:"gc.concurrentmarksweep.time"` GcConcurrentmarksweepTime int `json:"gc.concurrentmarksweep.time"`
CounterStatus200AddReduceApply int `json:"counter.status.200.addReduceApply"` //CounterStatus200AddReduceApply int `json:"counter.status.200.addReduceApply"`
CounterStatus200OwnerList int `json:"counter.status.200.ownerList"` //CounterStatus200OwnerList int `json:"counter.status.200.ownerList"`
CounterStatus200ShowReport int `json:"counter.status.200.showReport"` //CounterStatus200ShowReport int `json:"counter.status.200.showReport"`
GaugeResponseShowReduceApplyList int `json:"gauge.response.showReduceApplyList"` //GaugeResponseShowReduceApplyList int `json:"gauge.response.showReduceApplyList"`
CounterStatus200ShowOwnerReduceApplyList int `json:"counter.status.200.showOwnerReduceApplyList"` //CounterStatus200ShowOwnerReduceApplyList int `json:"counter.status.200.showOwnerReduceApplyList"`
GaugeResponseQueryPreciseCallRecordList int `json:"gauge.response.queryPreciseCallRecordList"` //GaugeResponseQueryPreciseCallRecordList int `json:"gauge.response.queryPreciseCallRecordList"`
GaugeResponseQueryUserPhoneRemarkList int `json:"gauge.response.queryUserPhoneRemarkList"` //GaugeResponseQueryUserPhoneRemarkList int `json:"gauge.response.queryUserPhoneRemarkList"`
CounterStatus200FindCreditReport int `json:"counter.status.200.findCreditReport"` //CounterStatus200FindCreditReport int `json:"counter.status.200.findCreditReport"`
GaugeResponseAddUserPhoneRemark int `json:"gauge.response.addUserPhoneRemark"` //GaugeResponseAddUserPhoneRemark int `json:"gauge.response.addUserPhoneRemark"`
CounterStatus200DisperseCase int `json:"counter.status.200.disperseCase"` //CounterStatus200DisperseCase int `json:"counter.status.200.disperseCase"`
CounterStatus200QueryDispatcherParam int `json:"counter.status.200.queryDispatcherParam"` //CounterStatus200QueryDispatcherParam int `json:"counter.status.200.queryDispatcherParam"`
CounterStatus200CheckReduceApply int `json:"counter.status.200.checkReduceApply"` //CounterStatus200CheckReduceApply int `json:"counter.status.200.checkReduceApply"`
GaugeResponseQueryRepayOrderList int `json:"gauge.response.queryRepayOrderList"` //GaugeResponseQueryRepayOrderList int `json:"gauge.response.queryRepayOrderList"`
GaugeResponseAddReduceApply int `json:"gauge.response.addReduceApply"` //GaugeResponseAddReduceApply int `json:"gauge.response.addReduceApply"`
GaugeResponseOwnerList int `json:"gauge.response.ownerList"` //GaugeResponseOwnerList int `json:"gauge.response.ownerList"`
GaugeResponsePhoneBook int `json:"gauge.response.phoneBook"` //GaugeResponsePhoneBook int `json:"gauge.response.phoneBook"`
CounterStatus200ViewCaseDetail int `json:"counter.status.200.viewCaseDetail"` //CounterStatus200ViewCaseDetail int `json:"counter.status.200.viewCaseDetail"`
GaugeResponseUserInfo int `json:"gauge.response.userInfo"` //GaugeResponseUserInfo int `json:"gauge.response.userInfo"`
GaugeResponseFindAlipayInfo int `json:"gauge.response.findAlipayInfo"` //GaugeResponseFindAlipayInfo int `json:"gauge.response.findAlipayInfo"`
CounterStatus200MenuTree int `json:"counter.status.200.menuTree"` //CounterStatus200MenuTree int `json:"counter.status.200.menuTree"`
GaugeResponseCheckReduceApply int `json:"gauge.response.checkReduceApply"` //GaugeResponseCheckReduceApply int `json:"gauge.response.checkReduceApply"`
CounterStatus200QueryPreciseCallRecordList int `json:"counter.status.200.queryPreciseCallRecordList"` //CounterStatus200QueryPreciseCallRecordList int `json:"counter.status.200.queryPreciseCallRecordList"`
CounterStatus200PhoneBook int `json:"counter.status.200.phoneBook"` //CounterStatus200PhoneBook int `json:"counter.status.200.phoneBook"`
GaugeResponseAutoAssignReceiveRelation int `json:"gauge.response.autoAssign.receiveRelation"` //GaugeResponseAutoAssignReceiveRelation int `json:"gauge.response.autoAssign.receiveRelation"`
CounterStatus200SaveCall int `json:"counter.status.200.saveCall"` //CounterStatus200SaveCall int `json:"counter.status.200.saveCall"`
CounterStatus200QueryRepayOrderList int `json:"counter.status.200.queryRepayOrderList"` //CounterStatus200QueryRepayOrderList int `json:"counter.status.200.queryRepayOrderList"`
CounterStatus200AutoAssignReceiveRelation int `json:"counter.status.200.autoAssign.receiveRelation"` //CounterStatus200AutoAssignReceiveRelation int `json:"counter.status.200.autoAssign.receiveRelation"`
CounterStatus200RemoveCallRecord int `json:"counter.status.200.removeCallRecord"` //CounterStatus200RemoveCallRecord int `json:"counter.status.200.removeCallRecord"`
GaugeResponseOrganizationList int `json:"gauge.response.organizationList"` //GaugeResponseOrganizationList int `json:"gauge.response.organizationList"`
CounterStatus200QueryCasePackPage int `json:"counter.status.200.queryCasePackPage"` //CounterStatus200QueryCasePackPage int `json:"counter.status.200.queryCasePackPage"`
GaugeResponseShowOwnerReduceApplyList int `json:"gauge.response.showOwnerReduceApplyList"` //GaugeResponseShowOwnerReduceApplyList int `json:"gauge.response.showOwnerReduceApplyList"`
GaugeResponseHandleCollectionReduce int `json:"gauge.response.handleCollectionReduce"` //GaugeResponseHandleCollectionReduce int `json:"gauge.response.handleCollectionReduce"`
CounterStatus200Logout int `json:"counter.status.200.logout"` //CounterStatus200Logout int `json:"counter.status.200.logout"`
CounterStatus200QueryCasePage int `json:"counter.status.200.queryCasePage"` //CounterStatus200QueryCasePage int `json:"counter.status.200.queryCasePage"`
GaugeResponseSelectList int `json:"gauge.response.selectList"` //GaugeResponseSelectList int `json:"gauge.response.selectList"`
CounterStatus200HandleCollectionReduce int `json:"counter.status.200.handleCollectionReduce"` //CounterStatus200HandleCollectionReduce int `json:"counter.status.200.handleCollectionReduce"`
CounterStatus200FindAlipayInfo int `json:"counter.status.200.findAlipayInfo"` //CounterStatus200FindAlipayInfo int `json:"counter.status.200.findAlipayInfo"`
GaugeResponseFundingList int `json:"gauge.response.fundingList"` //GaugeResponseFundingList int `json:"gauge.response.fundingList"`
GaugeResponseTechHealthCheck int `json:"gauge.response.tech.health.check"` //GaugeResponseTechHealthCheck int `json:"gauge.response.tech.health.check"`
CounterStatus200Login int `json:"counter.status.200.login"` //CounterStatus200Login int `json:"counter.status.200.login"`
CounterStatus200HaveUnCheckedApply int `json:"counter.status.200.haveUnCheckedApply"` //CounterStatus200HaveUnCheckedApply int `json:"counter.status.200.haveUnCheckedApply"`
GaugeResponseSaveCall int `json:"gauge.response.saveCall"` //GaugeResponseSaveCall int `json:"gauge.response.saveCall"`
GaugeResponseQueryDispatcherParam int `json:"gauge.response.queryDispatcherParam"` //GaugeResponseQueryDispatcherParam int `json:"gauge.response.queryDispatcherParam"`
CounterStatus200OrganizationList int `json:"counter.status.200.organizationList"` //CounterStatus200OrganizationList int `json:"counter.status.200.organizationList"`
GaugeResponseQueryOrganizationList int `json:"gauge.response.queryOrganizationList"` //GaugeResponseQueryOrganizationList int `json:"gauge.response.queryOrganizationList"`
CounterStatus200ShowReduceApplyList int `json:"counter.status.200.showReduceApplyList"` //CounterStatus200ShowReduceApplyList int `json:"counter.status.200.showReduceApplyList"`
CounterStatus200QueryDisperseParam int `json:"counter.status.200.queryDisperseParam"` //CounterStatus200QueryDisperseParam int `json:"counter.status.200.queryDisperseParam"`
CounterStatus200AgingList int `json:"counter.status.200.agingList"` //CounterStatus200AgingList int `json:"counter.status.200.agingList"`
CounterStatus200UserInfo int `json:"counter.status.200.userInfo"` //CounterStatus200UserInfo int `json:"counter.status.200.userInfo"`
GaugeResponseQueryUserPage int `json:"gauge.response.queryUserPage"` //GaugeResponseQueryUserPage int `json:"gauge.response.queryUserPage"`
GaugeResponseDisperseCase int `json:"gauge.response.disperseCase"` //GaugeResponseDisperseCase int `json:"gauge.response.disperseCase"`
CounterStatus200SelectList int `json:"counter.status.200.selectList"` //CounterStatus200SelectList int `json:"counter.status.200.selectList"`
GaugeResponsePackageStatus int `json:"gauge.response.packageStatus"` //GaugeResponsePackageStatus int `json:"gauge.response.packageStatus"`
CounterStatus200AddUserPhoneRemark int `json:"counter.status.200.addUserPhoneRemark"` //CounterStatus200AddUserPhoneRemark int `json:"counter.status.200.addUserPhoneRemark"`
GaugeResponseShowReport int `json:"gauge.response.showReport"` //GaugeResponseShowReport int `json:"gauge.response.showReport"`
GaugeResponseQueryCasePage int `json:"gauge.response.queryCasePage"` //GaugeResponseQueryCasePage int `json:"gauge.response.queryCasePage"`
CounterStatus200QueryUserPhoneRemarkList int `json:"counter.status.200.queryUserPhoneRemarkList"` //CounterStatus200QueryUserPhoneRemarkList int `json:"counter.status.200.queryUserPhoneRemarkList"`
CounterStatus200TechHealthCheck int `json:"counter.status.200.tech.health.check"` //CounterStatus200TechHealthCheck int `json:"counter.status.200.tech.health.check"`
GaugeResponseLogin int `json:"gauge.response.login"` //GaugeResponseLogin int `json:"gauge.response.login"`
CounterStatus200RoleList int `json:"counter.status.200.roleList"` //CounterStatus200RoleList int `json:"counter.status.200.roleList"`
GaugeResponseLogout int `json:"gauge.response.logout"` //GaugeResponseLogout int `json:"gauge.response.logout"`
GaugeResponseAgingList int `json:"gauge.response.agingList"` //GaugeResponseAgingList int `json:"gauge.response.agingList"`
GaugeResponseRoleList int `json:"gauge.response.roleList"` //GaugeResponseRoleList int `json:"gauge.response.roleList"`
GaugeResponseViewCaseDetail int `json:"gauge.response.viewCaseDetail"` //GaugeResponseViewCaseDetail int `json:"gauge.response.viewCaseDetail"`
GaugeResponseMenuTree int `json:"gauge.response.menuTree"` //GaugeResponseMenuTree int `json:"gauge.response.menuTree"`
CounterStatus200QueryUserPage int `json:"counter.status.200.queryUserPage"` //CounterStatus200QueryUserPage int `json:"counter.status.200.queryUserPage"`
GaugeResponseFindCreditReport int `json:"gauge.response.findCreditReport"` //GaugeResponseFindCreditReport int `json:"gauge.response.findCreditReport"`
GaugeResponseHaveUnCheckedApply int `json:"gauge.response.haveUnCheckedApply"` //GaugeResponseHaveUnCheckedApply int `json:"gauge.response.haveUnCheckedApply"`
GaugeResponseQueryDisperseParam int `json:"gauge.response.queryDisperseParam"` //GaugeResponseQueryDisperseParam int `json:"gauge.response.queryDisperseParam"`
GaugeResponseQueryCasePackPage int `json:"gauge.response.queryCasePackPage"` //GaugeResponseQueryCasePackPage int `json:"gauge.response.queryCasePackPage"`
CounterStatus200FundingList int `json:"counter.status.200.fundingList"` //CounterStatus200FundingList int `json:"counter.status.200.fundingList"`
CounterStatus200PackageStatus int `json:"counter.status.200.packageStatus"` //CounterStatus200PackageStatus int `json:"counter.status.200.packageStatus"`
GaugeResponseRemoveCallRecord int `json:"gauge.response.removeCallRecord"` //GaugeResponseRemoveCallRecord int `json:"gauge.response.removeCallRecord"`
CounterStatus200QueryOrganizationList int `json:"counter.status.200.queryOrganizationList"` //CounterStatus200QueryOrganizationList int `json:"counter.status.200.queryOrganizationList"`
HttpsessionsMax int `json:"httpsessions.max"` HttpsessionsMax int `json:"httpsessions.max"`
HttpsessionsActive int `json:"httpsessions.active"` HttpsessionsActive int `json:"httpsessions.active"`
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment