Db/system both rebase#351
Conversation
…up disk changes, at least in the manner tested.
fe36c70 to
c7b4989
Compare
c7b4989 to
b58e66c
Compare
| Datadog.SetDefault("check_runners", int64(4)) | ||
| Datadog.SetDefault("forwarder_timeout", 20) | ||
| // Dogstatsd | ||
| Datadog.SetDefault("device_blacklist_re", "") |
There was a problem hiding this comment.
We decided device_blacklist_re was meant to be a check level (init_conf as I implemented it) configuration element. So we should remove it from here.
| if !ENV["USE_SYSTEM_PY"] | ||
| env["PKG_CONFIG_LIBDIR"] = "#{PKG_CONFIG_LIBDIR}" | ||
| libdir = `PKG_CONFIG_LIBDIR="#{PKG_CONFIG_LIBDIR}" pkg-config --variable=libdir python-2.7`.strip | ||
| ENV["PKG_CONFIG_LIBDIR"] = "#{PKG_CONFIG_LIBDIR}" |
There was a problem hiding this comment.
Do we really need to add PKG_CONFIG_LIBDIR to the global environment? I take it prepending the environment variable won't work on windows...
There was a problem hiding this comment.
yes, it doesn't work on windows. This solution is definitely sub-optimal, and I'd be open to anything else, but the existing rakefile won't build on windows.
| core.RegisterCheck("iowin", wmiioFactory) | ||
| } | ||
|
|
||
| func wmiioFactory() check.Check { |
There was a problem hiding this comment.
nit: should probably be wmiIoFactory
There was a problem hiding this comment.
Do we really need two different factories? They both do the same thing:
func ioFactory() check.Check {
c := &IOCheck{}
return c
}
Similarly, I think we can probably have a single init block for the two implementations (and leave the initialization of hz in its own separate init block):
init() {
core.RegisterCheck("io", ioFactory)
}
| } | ||
|
|
||
| func init() { | ||
| core.RegisterCheck("iowin", wmiioFactory) |
There was a problem hiding this comment.
nit: the check can probably be called io - not sure we need to differentiate between platforms in the check name.
There was a problem hiding this comment.
You're right. This is supposed to be "io". But, I have an associated problem on windows which is that when I call it "io", it fails to load, because the python loader fails loading the module "io"; this was supposed to be a temporary workaround. Will fix it.
| return err | ||
| } | ||
|
|
||
| blacklistRe := config.Datadog.GetString("device_blacklist_re") |
There was a problem hiding this comment.
As mentioned in pkg/config we decided to not have this as a global configuration element, so you can probably remove this entire block. We already initialize the regexp expression in commonConfigure().
|
|
||
| drivebuf := make([]byte, 256) | ||
|
|
||
| r, _, err := ProcGetLogicalDriveStringsW.Call( |
There was a problem hiding this comment.
maybe a comment here with a link to: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364975(v=vs.85).aspx ?
| } | ||
| for _, v := range drivebuf { | ||
| // between 'A' & 'Z' | ||
| if v >= 65 && v <= 90 { |
There was a problem hiding this comment.
Any scenario on windows where the drive would not be a single letter? Network drives, for instance? Maybe something like this might be safer?
drives := bytes.Split(drivebuff, []byte{0})
for _, v := range drives {
drive := string(v)
// do whatever we need to do with the drive string.
}
| tagbuff.WriteString("device:") | ||
| tagbuff.WriteString(drive) | ||
| tags := []string{tagbuff.String()} | ||
| if len(c.drivemap[d.Name].Name) != 0 { |
There was a problem hiding this comment.
Are we just checking if the value was already in the drivemap? The more idiomatic way of doing this would be:
if prev, ok := m["route"]; ok {
metrics, err := computeValue(prev, &d)
}
| err := c.commonConfigure(data, initConfig) | ||
| return err | ||
| } | ||
| func (c *IOCheck) nixIO() error { |
There was a problem hiding this comment.
Note to self (and totally on me): We may be assuming way too many things about how this will work out on Darwin...
| } | ||
|
|
||
| // Run executes the check | ||
| func (c *IOCheck) Run() error { |
There was a problem hiding this comment.
Although right now this it's probably unnecessary to have Run() just call nixIO(), it might actually come in handy in case we need to do different things for Darwin or other GOOS variants.
There was a problem hiding this comment.
My intent was, once we get to doing darwin, it should be split out at compile time (the way I did with windows), not at runtime. That's more a preference thing, though one we probably ought to standardize on one way or the other.
* adds upstart file to centos6 * adds upstart file to rpm * changes conditional * enables alternative python
truthbk
left a comment
There was a problem hiding this comment.
Logic looks good to me. There's a few things I commented on, but I'll let you decide if/when you want to address those.
|
|
||
| variables: | ||
| DOCKER_REGISTRY: gitlab.datad0g.com:4567 | ||
| DOCKER_REGISTRY: 727006795293.dkr.ecr.us-east-1.amazonaws.com |
There was a problem hiding this comment.
Could this be a problem once the repo goes public? Or is it only accessible from within a VPC or whatever?
There was a problem hiding this comment.
I took this from master, to get it to pass ci: https://github.com/DataDog/datadog-agent/blob/master/.gitlab-ci.yml#L9. TBH, I'm not sure of the impact
| # Linux | ||
| if linux? | ||
| if debian? | ||
| if debian? || redhat? |
There was a problem hiding this comment.
If we don't do anything different for redhat vs debian we can maybe remove this if? Or are you accounting here for SuSE?
There was a problem hiding this comment.
This is also on master; I had to pull in this change to get CI to function
2a22841#diff-6510f031d77235eab2fc2392e0be89abR110
|
|
||
| if debian? | ||
| mkdir "/etc/init/" | ||
| if debian? || redhat? |
There was a problem hiding this comment.
Similarly, do we need this if condition, we're doing the same thing for both major distros... Is it because of SuSE?
There was a problem hiding this comment.
ditto here (same change as above)
| retstrings = append(retstrings, "") | ||
| continue | ||
| } | ||
| retstrings[rsindex] += string(rune(winput[i])) |
There was a problem hiding this comment.
Unfortunately this is the most inefficient way to concatenate strings in go (by far)... This is going to get called pretty often, and although it's going to work on a short list, with short strings - it might be preferable to use a string buffer instead. I'll let you decide if you want to implement this differently.
byte buffer to do the original conversion, rather than appending a character on to the string for each pass.
byte buffer to do the original conversion, rather than appending a character on to the string for each pass.
What does this PR do?
Implements the IO/disk check for windows. This version uses WMI, to match agent5. Have an eventual PR that uses PDH.
Moves platform specific code to conditionally compiled rather than runtime evaluation.
Note that this does NOT detect insertion of drives, at least as tested. Is same behavior as agent5.
(Tested using virtualbox, and using Disk Manager to mount & unmount drives).