Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
9082abfb
Commit
9082abfb
authored
Dec 04, 2019
by
jingbo.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
服务健康状态报表第一版完成(只报总表),分表后续实现,告警后续实现,砍掉无效的对外api,砍掉redis缓存模块部分
parent
61958889
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
14 deletions
+32
-14
main.go
main.go
+22
-12
global.go
pkg/global/global.go
+9
-0
regular_report.go
pkg/report-form/regular_report.go
+1
-2
No files found.
main.go
View file @
9082abfb
...
@@ -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)
func
runApiServer
()
{
http
.
HandleFunc
(
"/tech/health/check"
,
func
(
writer
http
.
ResponseWriter
,
request
*
http
.
Request
)
{
http
.
HandleFunc
(
"/tech/health/check"
,
func
(
writer
http
.
ResponseWriter
,
request
*
http
.
Request
)
{
writer
.
WriteHeader
(
http
.
StatusOK
)
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
)
}
}
*/
}()
}
}
pkg/global/global.go
View file @
9082abfb
...
@@ -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
{
...
...
pkg/report-form/regular_report.go
View file @
9082abfb
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment