Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
6e10ab4b
N
nightingale
项目概览
DiDi
/
nightingale
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
6e10ab4b
编写于
5月 10, 2020
作者:
U
Ulric Qin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mount ignore refactor
上级
04e6f36c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
35 addition
and
33 deletion
+35
-33
etc/collector.yml
etc/collector.yml
+10
-3
src/modules/collector/collector.go
src/modules/collector/collector.go
+4
-1
src/modules/collector/sys/config.go
src/modules/collector/sys/config.go
+14
-10
src/modules/collector/sys/funcs/dfstat.go
src/modules/collector/sys/funcs/dfstat.go
+4
-16
src/modules/collector/sys/funcs/fsstat.go
src/modules/collector/sys/funcs/fsstat.go
+3
-3
未找到文件。
etc/collector.yml
浏览文件 @
6e10ab4b
...
...
@@ -2,6 +2,7 @@ logger:
dir
:
logs/collector
level
:
WARNING
keepHours
:
2
identity
:
specify
:
"
"
shell
:
ifconfig `route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|awk -F ':' '{print $NF}'|head -n
1
...
...
@@ -18,12 +19,18 @@ sys:
timeout
:
1000
interval
:
20
plugin
:
./plugin
# monitor nic which filtered by prefix
ifacePrefix
:
-
eth
-
em
mountPoint
:
[]
mountIgnorePrefix
:
# ignore disk mount point
mountIgnore
:
prefix
:
-
/var/lib
# collect anyway
exclude
:
[]
ignoreMetrics
:
-
cpu.core.idle
...
...
src/modules/collector/collector.go
浏览文件 @
6e10ab4b
...
...
@@ -28,7 +28,10 @@ import (
"github.com/toolkits/pkg/runner"
)
const
version
=
1
// changelog:
// 1: init project
// 2: mount ignore refactor
const
version
=
2
var
(
vers
*
bool
...
...
src/modules/collector/sys/config.go
浏览文件 @
6e10ab4b
...
...
@@ -2,8 +2,7 @@ package sys
type
SysSection
struct
{
IfacePrefix
[]
string
`yaml:"ifacePrefix"`
MountPoint
[]
string
`yaml:"mountPoint"`
MountIgnorePrefix
[]
string
`yaml:"mountIgnorePrefix"`
MountIgnore
MountIgnoreSection
`yaml:"mountIgnore"`
IgnoreMetrics
[]
string
`yaml:"ignoreMetrics"`
IgnoreMetricsMap
map
[
string
]
struct
{}
`yaml:"-"`
NtpServers
[]
string
`yaml:"ntpServers"`
...
...
@@ -13,6 +12,11 @@ type SysSection struct {
Timeout
int
`yaml:"timeout"`
}
type
MountIgnoreSection
struct
{
Prefix
[]
string
`yaml:"prefix"`
Exclude
[]
string
`yaml:"exclude"`
}
var
Config
SysSection
func
Init
(
s
SysSection
)
{
...
...
src/modules/collector/sys/funcs/dfstat.go
浏览文件 @
6e10ab4b
...
...
@@ -9,6 +9,7 @@ import (
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/nux"
"github.com/toolkits/pkg/slice"
)
func
DeviceMetrics
()
[]
*
dataobj
.
MetricValue
{
...
...
@@ -21,26 +22,11 @@ func DeviceMetrics() []*dataobj.MetricValue {
return
ret
}
var
myMountPoints
=
make
(
map
[
string
]
bool
)
if
len
(
sys
.
Config
.
MountPoint
)
>
0
{
for
_
,
mp
:=
range
sys
.
Config
.
MountPoint
{
myMountPoints
[
mp
]
=
true
}
}
ignoreMountPointsPrefix
:=
sys
.
Config
.
MountIgnorePrefix
var
diskTotal
uint64
=
0
var
diskUsed
uint64
=
0
for
idx
:=
range
mountPoints
{
fsSpec
,
fsFile
,
fsVfstype
:=
mountPoints
[
idx
][
0
],
mountPoints
[
idx
][
1
],
mountPoints
[
idx
][
2
]
if
len
(
myMountPoints
)
>
0
{
if
_
,
ok
:=
myMountPoints
[
fsFile
];
!
ok
{
logger
.
Debug
(
"mount point not matched with config"
,
fsFile
,
"ignored."
)
continue
}
}
if
_
,
exists
:=
fsFileFilter
[
fsFile
];
exists
{
logger
.
Debugf
(
"mount point %s was collected"
,
fsFile
)
...
...
@@ -49,7 +35,9 @@ func DeviceMetrics() []*dataobj.MetricValue {
fsFileFilter
[
fsFile
]
=
struct
{}{}
}
if
hasIgnorePrefix
(
fsFile
,
ignoreMountPointsPrefix
)
{
// 注意: 虽然前缀被忽略了,但是被忽略的这部分分区里边有些仍然是需要采集的
if
hasIgnorePrefix
(
fsFile
,
sys
.
Config
.
MountIgnore
.
Prefix
)
&&
!
slice
.
ContainsString
(
sys
.
Config
.
MountIgnore
.
Exclude
,
fsFile
)
{
continue
}
...
...
src/modules/collector/sys/funcs/fsstat.go
浏览文件 @
6e10ab4b
...
...
@@ -13,6 +13,7 @@ import (
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/nux"
"github.com/toolkits/pkg/slice"
)
func
FsRWMetrics
()
[]
*
dataobj
.
MetricValue
{
...
...
@@ -26,8 +27,6 @@ func FsRWMetrics() []*dataobj.MetricValue {
fsFileFilter
:=
make
(
map
[
string
]
struct
{})
//过滤 /proc/mounts 出现重复的fsFile
ignoreMountPointsPrefix
:=
sys
.
Config
.
MountIgnorePrefix
for
idx
:=
range
mountPoints
{
var
du
*
nux
.
DeviceUsage
du
,
err
=
nux
.
BuildDeviceUsage
(
mountPoints
[
idx
][
0
],
mountPoints
[
idx
][
1
],
mountPoints
[
idx
][
2
])
...
...
@@ -36,7 +35,8 @@ func FsRWMetrics() []*dataobj.MetricValue {
continue
}
if
hasIgnorePrefix
(
mountPoints
[
idx
][
1
],
ignoreMountPointsPrefix
)
{
if
hasIgnorePrefix
(
du
.
FsFile
,
sys
.
Config
.
MountIgnore
.
Prefix
)
&&
!
slice
.
ContainsString
(
sys
.
Config
.
MountIgnore
.
Exclude
,
du
.
FsFile
)
{
continue
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录