|
@@ -113,11 +113,17 @@ func (t *T) task() {
|
|
|
fmt.Println("eq1", eq1)
|
|
|
|
|
|
rangeQuery := es.NewRangeQuery("id").Gte(st1).Lt(et1)
|
|
|
- termsQuery := es.NewTermsQuery("site", "元博网(采购与招标网)", "中国招标与采购网")
|
|
|
+ //竞品网站统计
|
|
|
+ termsQuery := es.NewTermsQuery("site", "元博网(采购与招标网)", "中国招标与采购网", "北京隆道网络科技有限公司", "友云采")
|
|
|
countQuery := es.NewBoolQuery().
|
|
|
Must(rangeQuery)
|
|
|
-
|
|
|
+ //竞品网站总量
|
|
|
count1Query := es.NewBoolQuery().Must(rangeQuery).Filter(termsQuery)
|
|
|
+ //元博网(采购与招标网),竞品网站数量统计
|
|
|
+ countComptetQuery1 := es.NewBoolQuery().Must(rangeQuery).Filter(es.NewTermQuery("site", "元博网(采购与招标网)"))
|
|
|
+ countComptetQuery2 := es.NewBoolQuery().Must(rangeQuery).Filter(es.NewTermQuery("site", "中国招标与采购网"))
|
|
|
+ countComptetQuery3 := es.NewBoolQuery().Must(rangeQuery).Filter(es.NewTermQuery("site", "北京隆道网络科技有限公司"))
|
|
|
+ countComptetQuery4 := es.NewBoolQuery().Must(rangeQuery).Filter(es.NewTermQuery("site", "友云采"))
|
|
|
|
|
|
es2 := elastic.Elastic{S_esurl: esAddr2, I_size: 2, Username: username, Password: password}
|
|
|
es2.InitElasticSize()
|
|
@@ -125,21 +131,29 @@ func (t *T) task() {
|
|
|
es3 := elastic.Elastic{S_esurl: esAddr3, I_size: 5, Username: username3, Password: password3}
|
|
|
es3.InitElasticSize()
|
|
|
|
|
|
- count := int(es2.Count(esIndex2, countQuery)) //公司 es集群 数量统计
|
|
|
- count1 := int(es2.Count(esIndex, count1Query)) //竞品网站 数量统计
|
|
|
+ count := int(es2.Count(esIndex2, countQuery)) //公司 es集群 数量统计
|
|
|
+ count1 := int(es2.Count(esIndex, count1Query)) //竞品网站 数量统计
|
|
|
+ //元博网(采购与招标网)
|
|
|
+ countComptet1 := int(es2.Count(esIndex, countComptetQuery1))
|
|
|
+ //中国招标与采购网
|
|
|
+ countComptet2 := int(es2.Count(esIndex, countComptetQuery2))
|
|
|
+ //北京隆道网络科技有限公司
|
|
|
+ countComptet3 := int(es2.Count(esIndex, countComptetQuery3))
|
|
|
+ //友云采
|
|
|
+ countComptet4 := int(es2.Count(esIndex, countComptetQuery4))
|
|
|
countNew := int(es3.Count(esIndex3, countQuery)) //华为云 新集群
|
|
|
- fmt.Println("count", count)
|
|
|
- fmt.Println("count1", count1)
|
|
|
- fmt.Println("countNew", countNew)
|
|
|
-
|
|
|
+ log.Println("count", count)
|
|
|
+ log.Println("count1", count1)
|
|
|
+ log.Println("countNew", countNew)
|
|
|
+ report := ""
|
|
|
switch t.Type {
|
|
|
case "alert":
|
|
|
if count < t.Min || count > t.Max || countNew < t.Min || countNew > t.Max {
|
|
|
- report := fmt.Sprintf("告警%s,最小%d,最大%d,统计结果:%d", t.Name, t.Min, t.Max, count)
|
|
|
+ report = fmt.Sprintf("告警%s,最小%d,最大%d,统计结果:%d", t.Name, t.Min, t.Max, count)
|
|
|
t.SendMail(report)
|
|
|
}
|
|
|
case "report":
|
|
|
- report := fmt.Sprintf("统计报告%s,【统计结果】,es库数量:%d", t.Name, count)
|
|
|
+ report = fmt.Sprintf("统计报告%s,【统计结果】,es库数量:%d", t.Name, count)
|
|
|
if len(t.Mgo) > 5 {
|
|
|
fs := strings.Split(t.Mgo, "|")
|
|
|
fmgo := mongodb.NewMgoWithUser(fs[0], fs[3], fs[1], fs[2], 1)
|
|
@@ -184,10 +198,32 @@ func (t *T) task() {
|
|
|
var pc_diff30 int64
|
|
|
var pc_diff301 int64
|
|
|
|
|
|
+ var competCount1 int
|
|
|
+ var competCount2 int
|
|
|
+ var competCount3 int
|
|
|
+ var competCount4 int
|
|
|
+ competeReal1 := 0
|
|
|
+ competeReal2 := 0
|
|
|
+ competeReal3 := 0
|
|
|
+ competeReal4 := 0
|
|
|
+
|
|
|
query := sess.DB(fs[3]).C(fs[4]).Find(mq).Select(fd).Iter()
|
|
|
for tmp := make(map[string]interface{}); query.Next(tmp); count2++ {
|
|
|
- if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" || util.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" || util.ObjToString(tmp["site"]) == "中国招标与采购网" || util.ObjToString(tmp["site"]) == "北京隆道网络科技有限公司" || util.ObjToString(tmp["site"]) == "友云采" {
|
|
|
count4++
|
|
|
+ if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" {
|
|
|
+ competCount1++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ competCount2++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "北京隆道网络科技有限公司" {
|
|
|
+ competCount3++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "友云采" {
|
|
|
+ competCount4++
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if util.IntAll(tmp["extracttype"]) != -1 && util.ObjToString(tmp["sensitive"]) != "测试" && util.IntAll(tmp["dataging"]) != 1 && util.Float64All(tmp["infoformat"]) != 3 {
|
|
|
count3++
|
|
@@ -248,8 +284,20 @@ func (t *T) task() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" || util.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" || util.ObjToString(tmp["site"]) == "中国招标与采购网" || util.ObjToString(tmp["site"]) == "北京隆道网络科技有限公司" || util.ObjToString(tmp["site"]) == "友云采" {
|
|
|
count5++
|
|
|
+ if util.ObjToString(tmp["site"]) == "元博网(采购与招标网)" {
|
|
|
+ competeReal1++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ competeReal2++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "北京隆道网络科技有限公司" {
|
|
|
+ competeReal3++
|
|
|
+ }
|
|
|
+ if util.ObjToString(tmp["site"]) == "友云采" {
|
|
|
+ competeReal4++
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -264,9 +312,14 @@ func (t *T) task() {
|
|
|
if noFileCount > 0 {
|
|
|
no_file_avgltime = no_file_totaltime / int64(noFileCount)
|
|
|
}
|
|
|
+ report += `,mgo统计:` + fmt.Sprint(count3) + `,差值:` + fmt.Sprint(count3-count) + `,mgo总入库量:` + fmt.Sprint(count2) +
|
|
|
+ `<br>竟品统计结果_es统计:` + strconv.Itoa(count1) + `,mgo统计:` + fmt.Sprint(count5) + `,差值:` + fmt.Sprint(count5-count1) + `,mgo总入库量` + fmt.Sprint(count4) +
|
|
|
+ `<br>元博网_es统计:` + strconv.Itoa(countComptet1) + `,mgo统计:` + fmt.Sprint(competeReal1) + `,差值:` + fmt.Sprint(competeReal1-countComptet1) + `,mgo总入库量` + fmt.Sprint(competCount1) +
|
|
|
+ `<br>中国招标与采购网_es统计` + strconv.Itoa(countComptet2) + `,mgo统计:` + fmt.Sprint(competeReal2) + `,差值:` + fmt.Sprint(competeReal2-countComptet2) + `,mgo总入库量` + fmt.Sprint(competCount2) +
|
|
|
+ `<br>北京隆道网络科技有限公司_es统计` + strconv.Itoa(countComptet3) + `,mgo统计:` + fmt.Sprint(competeReal3) + `,差值:` + fmt.Sprint(competeReal3-countComptet3) + `,mgo总入库量` + fmt.Sprint(competCount3) +
|
|
|
+ `<br>友云采_es统计` + strconv.Itoa(countComptet4) + `,mgo统计:` + fmt.Sprint(competeReal4) + `,差值:` + fmt.Sprint(competeReal4-countComptet4) + `,mgo总入库量` + fmt.Sprint(competCount4) +
|
|
|
+ `<br>新集群统计结果_es数量:` + strconv.Itoa(countNew) + `,mgo统计:` + fmt.Sprint(count3) + `,差值:` + fmt.Sprint(count3-countNew)
|
|
|
|
|
|
- report += ",mgo统计:" + fmt.Sprint(count3) + ",差值:" + fmt.Sprint(count3-count) + ",mgo总入库量:" + fmt.Sprint(count2)
|
|
|
- report += "<br>" + "【竟品统计结果】:" + strconv.Itoa(count1) + ",mgo统计:" + fmt.Sprint(count5) + ",差值:" + fmt.Sprint(count5-count1) + ",mgo总入库量" + fmt.Sprint(count4) + "<br>【新集群统计结果】es数量:" + strconv.Itoa(countNew) + ",mgo统计:" + fmt.Sprint(count3) + ",差值:" + fmt.Sprint(count3-countNew)
|
|
|
//存入数据库
|
|
|
yesterday := now.AddDate(0, 0, -1)
|
|
|
insert := map[string]interface{}{
|