Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
ee96ce50
N
nightingale
项目概览
DiDi
/
nightingale
11 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ee96ce50
编写于
12月 23, 2020
作者:
U
UlricQin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test port listen on 127.0.0.1 and identity.ip and ::1
上级
28d311e7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
18 deletion
+22
-18
src/modules/agent/agent.go
src/modules/agent/agent.go
+5
-6
src/modules/agent/report/report.go
src/modules/agent/report/report.go
+11
-11
src/modules/agent/sys/ports/scheduler.go
src/modules/agent/sys/ports/scheduler.go
+6
-1
未找到文件。
src/modules/agent/agent.go
浏览文件 @
ee96ce50
...
...
@@ -63,6 +63,11 @@ func main() {
loggeri
.
Init
(
config
.
Config
.
Logger
)
stats
.
Init
(
"agent"
)
if
err
:=
report
.
GatherBase
();
err
!=
nil
{
fmt
.
Println
(
"gatherBase fail: "
,
err
)
os
.
Exit
(
1
)
}
if
config
.
Config
.
Enable
.
Mon
{
monStart
()
}
...
...
@@ -76,7 +81,6 @@ func main() {
}
if
config
.
Config
.
Enable
.
Metrics
{
// 初始化 statsd服务
statsd
.
Start
()
...
...
@@ -90,11 +94,6 @@ func main() {
}
func
reportStart
()
{
if
err
:=
report
.
GatherBase
();
err
!=
nil
{
fmt
.
Println
(
"gatherBase fail: "
,
err
)
os
.
Exit
(
1
)
}
go
report
.
LoopReport
()
}
...
...
src/modules/agent/report/report.go
浏览文件 @
ee96ce50
...
...
@@ -19,9 +19,9 @@ import (
)
var
(
sn
string
ip
string
i
dent
string
SN
string
IP
string
I
dent
string
)
func
LoopReport
()
{
...
...
@@ -36,21 +36,21 @@ func LoopReport() {
func
GatherBase
()
error
{
var
err
error
sn
,
err
=
exec
(
config
.
Config
.
Report
.
SN
)
SN
,
err
=
exec
(
config
.
Config
.
Report
.
SN
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot get sn: %s"
,
err
)
}
ip
,
err
=
identity
.
GetIP
()
IP
,
err
=
identity
.
GetIP
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot get ip: %s"
,
err
)
}
if
!
str
.
IsIP
(
ip
)
{
return
fmt
.
Errorf
(
"'%s' not ip"
,
ip
)
if
!
str
.
IsIP
(
IP
)
{
return
fmt
.
Errorf
(
"'%s' not ip"
,
IP
)
}
i
dent
,
err
=
identity
.
GetIdent
()
I
dent
,
err
=
identity
.
GetIdent
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"cannot get ident: %s"
,
err
)
}
...
...
@@ -98,9 +98,9 @@ func report() error {
}
form
:=
hostRegisterForm
{
SN
:
sn
,
IP
:
ip
,
Ident
:
i
dent
,
SN
:
SN
,
IP
:
IP
,
Ident
:
I
dent
,
Name
:
name
,
Cate
:
config
.
Config
.
Report
.
Cate
,
UniqKey
:
config
.
Config
.
Report
.
UniqKey
,
...
...
src/modules/agent/sys/ports/scheduler.go
浏览文件 @
ee96ce50
...
...
@@ -11,6 +11,7 @@ import (
"github.com/didi/nightingale/src/models"
"github.com/didi/nightingale/src/modules/agent/config"
"github.com/didi/nightingale/src/modules/agent/core"
"github.com/didi/nightingale/src/modules/agent/report"
)
type
PortScheduler
struct
{
...
...
@@ -46,7 +47,11 @@ func (p *PortScheduler) Stop() {
func
PortCollect
(
p
*
models
.
PortCollect
)
{
value
:=
0
if
isListening
(
p
.
Port
)
{
if
isListen
(
p
.
Port
,
1
,
"127.0.0.1"
)
{
value
=
1
}
else
if
isListen
(
p
.
Port
,
1
,
report
.
IP
)
{
value
=
1
}
else
if
isListen
(
p
.
Port
,
1
,
"::1"
)
{
value
=
1
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录