Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system/raid metricset #5642

Merged
merged 1 commit into from
Dec 5, 2017
Merged

Conversation

ruflin
Copy link
Member

@ruflin ruflin commented Nov 20, 2017

Implements #5600.

@ruflin ruflin added in progress Pull request is currently in progress. Metricbeat Metricbeat review labels Nov 20, 2017
return m, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

Choose a reason for hiding this comment

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

exported method MetricSet.Fetch should have comment or be unexported

fs procfs.FS
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

Choose a reason for hiding this comment

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

exported function New should have comment or be unexported

}
}

type MetricSet struct {

Choose a reason for hiding this comment

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

exported type MetricSet should have comment or be unexported

return m, nil
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

Choose a reason for hiding this comment

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

exported method MetricSet.Fetch should have comment or be unexported

fs procfs.FS
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

Choose a reason for hiding this comment

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

exported function New should have comment or be unexported

}
}

type MetricSet struct {

Choose a reason for hiding this comment

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

exported type MetricSet should have comment or be unexported

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would be worth modifying the generator to add comments for all these.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tsg We actually have pretty extensive comments in the generator which tell you what to do: https://github.com/elastic/beats/blob/master/metricbeat/scripts/module/metricset/metricset.go.tmpl#L17 I removed all of them manually to not have the boiler plate ...

@tsg
Copy link
Contributor

tsg commented Nov 20, 2017

LGTM, but it would be good to have some sort of testing on it.

"activity_state": stat.ActivityState,
"disks": common.MapStr{
"active": stat.DisksActive,
"total": stat.DisksTotal,
Copy link
Member

Choose a reason for hiding this comment

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

Usage question: How would I figure out how many available spares there are? Is spares = total - active? Or does total include the number of failed disks still in the array?

Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewkroh Based on https://raid.wiki.kernel.org/index.php/Mdstat I think what you state is correct.

}

mountPoint := filepath.Join(systemModule.HostFS, procfs.DefaultMountPoint)
fs, err := procfs.NewFS(mountPoint)
Copy link
Member

Choose a reason for hiding this comment

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

For testing purposes I'd make it possible to fully define the proc dir location so that you can create testdata/proc/mdstat and read it.

Copy link
Member

Choose a reason for hiding this comment

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

)

func TestData(t *testing.T) {

Copy link
Member

Choose a reason for hiding this comment

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

Consider removing this newline for me 😄 . (BTW I have a tool for this at nonewlines)

Copy link
Member Author

Choose a reason for hiding this comment

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

@andrewkroh You should add this tool to our make fmt part so CI can bug us in the future instead of requiring the krohcompiler. Like this you can also go on vacation :-D

Copy link
Member

Choose a reason for hiding this comment

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

It will be part of gofmt in Go 1.10. I'm just trying to prepare you in advance.

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to check if it was you that contributed it to Go 1.10 :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

BTW: Probably worth adding the script it will take some time until we are on 1.10 (lots of newlines to come until then)

@ruflin
Copy link
Member Author

ruflin commented Nov 20, 2017

@andrewkroh I added some basic tests (still WIP). It works with the file from the procfs repo but not the one I got from our servers. The error I get:

        Error:          Received unexpected error "error parsing _meta/test/proc/mdstat: unexpected statusline:       497754112 blocks super 1.2 512k chunks"

The content of the file looks as following:

Personalities : [raid0] [raid1] [linear] [multipath] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb1[1] sda1[0]
      1047552 blocks super 1.2 [2/2] [UU]

md1 : active raid0 sdb2[1] sda2[0]
      497754112 blocks super 1.2 512k chunks

unused devices: <none>

Probably an issue we have to solve in procfs (didn't look into it yet).

@@ -0,0 +1,8 @@
Personalities : [raid0] [raid1] [linear] [multipath] [raid6] [raid5] [raid4] [raid10]
Copy link
Member

Choose a reason for hiding this comment

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

I recommend storing this under system/raid/testdata/[testname]/proc/mdstat. Using testdata seems to be conventional to Go; we have it in a few places. And keeping the proc/mdstat ensures that we don't have to mess with temporary files which eliminates code and potential problems. To switch between test cases you just change the raid.mount_point between testdata/scenarioA and testdata/scenarioB.

The "[testname]" could be anything "hostA", "scenarioA", "ubuntu16".

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it to just /proc/mdstats inside testdata as I realised one mdstat file should be enough and we can just add more lines. I kept the testdata directory inside _meta as we do for other metricsets too to not conflict with package and and "automatic logic to gather files" we have around metricbeat. Like this only the _meta directory has to be ignored from all these logics.

@ruflin
Copy link
Member Author

ruflin commented Nov 27, 2017

@andrewkroh I for now skipped the special raid data I have pasted above as this has to be fixed in procfs. I wanted to open an issue there for it but it seems there is no issue tab? https://github.com/elastic/procfs Is that intentional?

@andrewkroh
Copy link
Member

I think issues are turned off by default for forks to encourage using the parent's issue tracker. But you can turn issues on in the project's settings IIRC.

@ruflin
Copy link
Member Author

ruflin commented Nov 27, 2017

@andrewkroh How close are we still to the "parent project". I actually don't have access rights to turn on the issue tracker :-)

@ruflin
Copy link
Member Author

ruflin commented Nov 28, 2017

@plinde @andrewkroh I suggest we get this in as is and start to iterate on top of it?

@ruflin
Copy link
Member Author

ruflin commented Nov 28, 2017

jenkins, retest it

@ruflin ruflin removed the in progress Pull request is currently in progress. label Nov 28, 2017
@ruflin ruflin force-pushed the raid-metricset branch 2 times, most recently from 2c37869 to caf62d4 Compare November 30, 2017 05:30
@andrewkroh andrewkroh merged commit 6536115 into elastic:master Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants