Commit 9082abfb authored by jingbo.wang's avatar jingbo.wang

服务健康状态报表第一版完成(只报总表),分表后续实现,告警后续实现,砍掉无效的对外api,砍掉redis缓存模块部分

parent 61958889
...@@ -6,13 +6,15 @@ import ( ...@@ -6,13 +6,15 @@ import (
"git.quantgroup.cn/DevOps/enoch/pkg/global" "git.quantgroup.cn/DevOps/enoch/pkg/global"
"git.quantgroup.cn/DevOps/enoch/pkg/glog" "git.quantgroup.cn/DevOps/enoch/pkg/glog"
"git.quantgroup.cn/DevOps/enoch/pkg/points" "git.quantgroup.cn/DevOps/enoch/pkg/points"
report_form "git.quantgroup.cn/DevOps/enoch/pkg/report-form" "git.quantgroup.cn/DevOps/enoch/pkg/report-form"
"github.com/Shopify/sarama" "github.com/Shopify/sarama"
_ "github.com/mkevac/debugcharts" _ "github.com/mkevac/debugcharts"
"net/http" "net/http"
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"runtime/debug"
"strconv"
"strings" "strings"
"syscall" "syscall"
"time" "time"
...@@ -103,6 +105,7 @@ func main() { ...@@ -103,6 +105,7 @@ func main() {
} }
}() }()
//主节点:刷新连续查询、健康状态报表、告警策略
if isMaster() { if isMaster() {
//初始化数据库(创建DB,创建连续查询) //初始化数据库(创建DB,创建连续查询)
dao.DbInit() dao.DbInit()
...@@ -113,20 +116,27 @@ func main() { ...@@ -113,20 +116,27 @@ func main() {
//TODO 告警策略 //TODO 告警策略
} }
//对外api ?? //对外api
runApiServer()
//处理消息(阻塞) //处理消息(阻塞)
handlerKafkaMsg() handlerKafkaMsg()
/* }
http.HandleFunc("/duration", service.DurationInterface)
http.HandleFunc("/tech/health/check", func(writer http.ResponseWriter, request *http.Request) { func runApiServer() {
writer.WriteHeader(http.StatusOK) http.HandleFunc("/tech/health/check", func(writer http.ResponseWriter, request *http.Request) {
}) writer.WriteHeader(http.StatusOK)
http.HandleFunc("/counter", service.CounterInterface) })
err = http.ListenAndServe(":"+port, nil) go func() {
defer func() {
if err := recover(); err != nil {
glog.Error(err, debug.Stack())
}
}()
err := http.ListenAndServe(":"+strconv.Itoa(global.HttpPort), nil)
if err != nil { if err != nil {
log.Fatalln("服务启动失败", err) glog.Error(err)
} }
*/ }()
} }
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/vrg0/go-common/util" "github.com/vrg0/go-common/util"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"os" "os"
"strconv"
"strings" "strings"
) )
...@@ -47,6 +48,7 @@ var ( ...@@ -47,6 +48,7 @@ var (
ConsulDc = "" ConsulDc = ""
ConsulAddress = "" ConsulAddress = ""
ReportFormDir = "" ReportFormDir = ""
HttpPort = 9091
) )
type EosResult struct { type EosResult struct {
...@@ -107,6 +109,13 @@ func init() { ...@@ -107,6 +109,13 @@ func init() {
//InfluxDbAddress = "http://172.20.6.33:8086" //InfluxDbAddress = "http://172.20.6.33:8086"
DaoFileCacheDir = Config.GetOrDefault(NamespaceApplication, "dao.file.cache.dir", "/var") DaoFileCacheDir = Config.GetOrDefault(NamespaceApplication, "dao.file.cache.dir", "/var")
ReportFormDir = Config.GetOrDefault(NamespaceApplication, "report.form.dir", "/var") ReportFormDir = Config.GetOrDefault(NamespaceApplication, "report.form.dir", "/var")
httpPortStr := Config.GetOrDefault(NamespaceTechDeploy, "http_port", "9091")
port, err := strconv.Atoi(httpPortStr)
if err != nil {
Logger.Error("a to i http_port err:", httpPortStr)
} else {
HttpPort = port
}
//初始化registry //初始化registry
if consulDc, ok := Config.Get(NamespaceApplication, "consul.datacenter"); !ok { if consulDc, ok := Config.Get(NamespaceApplication, "consul.datacenter"); !ok {
......
...@@ -46,8 +46,7 @@ func RegularReport(dir string) { ...@@ -46,8 +46,7 @@ func RegularReport(dir string) {
fileNamePrefix := now.Format("2006-01-02") fileNamePrefix := now.Format("2006-01-02")
//周表 //周表
// if now.Weekday() == time.Monday { if now.Weekday() == time.Monday {
if now.Weekday() == time.Wednesday {
fileName := dir + "/" + fileNamePrefix + "_week.txt" fileName := dir + "/" + fileNamePrefix + "_week.txt"
if !util.Exists(fileName) { if !util.Exists(fileName) {
body := GeneralTableRun(7) body := GeneralTableRun(7)
......
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