Repository navigation
add some metrics - #563
Merged
Merged
add some metrics#563
Conversation
wonderflow
suggested changes
Jun 22, 2018
| } | ||
| for _, inter := range interfaces { | ||
| flags := inter.Flags.String() | ||
| if strings.Contains(flags, "up") && strings.Contains(flags, "broadcast") { |
Contributor
There was a problem hiding this comment.
flags == interface.FlagUP
| return -1 | ||
| } | ||
| mounts, err := diskMetrics().Collect() | ||
| mountsNum := len(mounts) |
Contributor
There was a problem hiding this comment.
上面这部分可以做到defer里面,如果defer的num是0或者返回了错误之类的,才去collect
| mountsNum := len(mounts) | ||
| diskUtil, err := exec.LookPath("/usr/sbin/diskutil") | ||
| if err != nil { | ||
| log.Errorf(err.Error()) |
| KeySystemNDisks: getNumDisk(), | ||
| KeySystemNServices: getNumService(), | ||
| } | ||
| datas = append(datas, data) |
Contributor
There was a problem hiding this comment.
这里怎么会是append,datas明明是nil,直接构造就好了。
| return -1 | ||
| } | ||
| mounts, err := diskMetrics().Collect() | ||
| mountsNum := len(mounts) |
Contributor
There was a problem hiding this comment.
同上,放到defer里,没必要的时候不要collect
| out, err := exec.Command("which", "supervisorctl").Output() | ||
| if err != nil { | ||
| log.Errorf(err.Error()) | ||
| return -1 |
Contributor
There was a problem hiding this comment.
拿不到的时候return 0比较好,不然很奇怪
| } | ||
|
|
||
| func getNumService() int { | ||
| out, err := exec.Command("which", "supervisorctl").Output() |
| return -1 | ||
| } | ||
| mounts, err := diskMetrics().Collect() | ||
| mountsNum := len(mounts) |
| } | ||
| mounts, err := diskMetrics().Collect() | ||
| mountsNum := len(mounts) | ||
| out, err := exec.Command("diskpart", "/S", "diskpart.txt").Output() |
Contributor
Author
There was a problem hiding this comment.
C:/Windows/System32/diskpart.exe
| @@ -0,0 +1 @@ | |||
|
|
|||
wonderflow
approved these changes
Jun 22, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add metrics of disks,network cards and services