Skip to content

add some metrics - #563

Merged
wonderflow merged 9 commits into
qiniu:masterfrom
mockerzzz:master
Jun 22, 2018
Merged

wonderflow merged 9 commits into
qiniu:masterfrom
mockerzzz:master

Conversation

@mockerzzz

Copy link
Copy Markdown
Contributor

add metrics of disks,network cards and services

Comment thread metric/system/system.go Outdated
}
for _, inter := range interfaces {
flags := inter.Flags.String()
if strings.Contains(flags, "up") && strings.Contains(flags, "broadcast") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么包含up和braodcast的才算哈?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flags == interface.FlagUP

Comment thread metric/system/system_darwin.go Outdated
return -1
}
mounts, err := diskMetrics().Collect()
mountsNum := len(mounts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面这部分可以做到defer里面,如果defer的num是0或者返回了错误之类的,才去collect

Comment thread metric/system/system_darwin.go Outdated
mountsNum := len(mounts)
diskUtil, err := exec.LookPath("/usr/sbin/diskutil")
if err != nil {
log.Errorf(err.Error())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考下其他的error怎么写的

Comment thread metric/system/system_linux.go Outdated
KeySystemNDisks: getNumDisk(),
KeySystemNServices: getNumService(),
}
datas = append(datas, data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里怎么会是append,datas明明是nil,直接构造就好了。

Comment thread metric/system/system_linux.go Outdated
return -1
}
mounts, err := diskMetrics().Collect()
mountsNum := len(mounts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,放到defer里,没必要的时候不要collect

Comment thread metric/system/system_linux.go Outdated
out, err := exec.Command("which", "supervisorctl").Output()
if err != nil {
log.Errorf(err.Error())
return -1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拿不到的时候return 0比较好,不然很奇怪

}

func getNumService() int {
out, err := exec.Command("which", "supervisorctl").Output()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个直接Output会有panic的可能吗

Comment thread metric/system/system_windows.go Outdated
return -1
}
mounts, err := diskMetrics().Collect()
mountsNum := len(mounts)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,defer处理

}
mounts, err := diskMetrics().Collect()
mountsNum := len(mounts)
out, err := exec.Command("diskpart", "/S", "diskpart.txt").Output()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个diskpart是什么哈?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C:/Windows/System32/diskpart.exe

Comment thread mgr/TestTailxCleaner/b/b.log Outdated
@@ -0,0 +1 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这三个测试文件删掉,单测结束的时候注意清理

@wonderflow
wonderflow merged commit d3dbe42 into qiniu:master Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants