// Gather gathers system utilization data. func Gather(config Config, lg logger.Logger) *Data { uDat := Data{ MetadataVersion: metadataVersion, Vendors: &vendors{}, LogicalProcessors: runtime.NumCPU(), } if config.DetectDocker { id, err := sysinfo.DockerID() if err != nil && err != sysinfo.ErrDockerUnsupported && err != sysinfo.ErrDockerNotFound { lg.Warn("error gathering Docker information", map[string]interface{}{ "error": err.Error(), }) } else if id != "" { uDat.Vendors.Docker = &vendor{ID: id} } } if config.DetectAWS { aws, err := getAWS() if nil == err { uDat.Vendors.AWS = aws } else if isAWSValidationError(err) { lg.Warn("AWS validation error", map[string]interface{}{ "error": err.Error(), }) } } if uDat.Vendors.AWS == nil && uDat.Vendors.Docker == nil { uDat.Vendors = nil } host, err := sysinfo.Hostname() if nil == err { uDat.Hostname = host } else { lg.Warn("error getting hostname", map[string]interface{}{ "error": err.Error(), }) } bts, err := sysinfo.PhysicalMemoryBytes() if nil == err { mib := sysinfo.BytesToMebibytes(bts) uDat.RAMMib = &mib } else { lg.Warn("error getting memory", map[string]interface{}{ "error": err.Error(), }) } uDat.Config = overrideFromConfig(config) return &uDat }
ParameterizedQuery string QueryParameters map[string]interface{} Host string PortPathOrID string Database string } const ( unknownDatastoreHost = "unknown" unknownDatastorePortPathOrID = "unknown" ) var ( // ThisHost is the system hostname. ThisHost = func() string { if h, err := sysinfo.Hostname(); nil == err { return h } return unknownDatastoreHost }() hostsToReplace = map[string]struct{}{ "localhost": struct{}{}, "127.0.0.1": struct{}{}, "0.0.0.0": struct{}{}, "0:0:0:0:0:0:0:1": struct{}{}, "::1": struct{}{}, "0:0:0:0:0:0:0:0": struct{}{}, "::": struct{}{}, } )