-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
return m, nil | ||
} | ||
|
||
func (m *MetricSet) Fetch() ([]common.MapStr, error) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ...
377cef5
to
ae80d6d
Compare
LGTM, but it would be good to have some sort of testing on it. |
ae80d6d
to
e8e7aa2
Compare
"activity_state": stat.ActivityState, | ||
"disks": common.MapStr{ | ||
"active": stat.DisksActive, | ||
"total": stat.DisksTotal, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's some sample data for testing: https://github.com/elastic/procfs/blob/master/fixtures/mdstat
) | ||
|
||
func TestData(t *testing.T) { | ||
|
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :-)
There was a problem hiding this comment.
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)
@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:
The content of the file looks as following:
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] |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
37c9c7a
to
bafa4cf
Compare
@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? |
8ef1b88
to
31950e5
Compare
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. |
@andrewkroh How close are we still to the "parent project". I actually don't have access rights to turn on the issue tracker :-) |
31950e5
to
2257685
Compare
@plinde @andrewkroh I suggest we get this in as is and start to iterate on top of it? |
jenkins, retest it |
2c37869
to
caf62d4
Compare
caf62d4
to
46c2691
Compare
Implements #5600.