id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
128,300 | influxdata/telegraf | selfstat/selfstat.go | Metrics | func Metrics() []telegraf.Metric {
registry.mu.Lock()
now := time.Now()
metrics := make([]telegraf.Metric, len(registry.stats))
i := 0
for _, stats := range registry.stats {
if len(stats) > 0 {
var tags map[string]string
var name string
fields := map[string]interface{}{}
j := 0
for fieldname, stat... | go | func Metrics() []telegraf.Metric {
registry.mu.Lock()
now := time.Now()
metrics := make([]telegraf.Metric, len(registry.stats))
i := 0
for _, stats := range registry.stats {
if len(stats) > 0 {
var tags map[string]string
var name string
fields := map[string]interface{}{}
j := 0
for fieldname, stat... | [
"func",
"Metrics",
"(",
")",
"[",
"]",
"telegraf",
".",
"Metric",
"{",
"registry",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
"\n",
"metrics",
":=",
"make",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
... | // Metrics returns all registered stats as telegraf metrics. | [
"Metrics",
"returns",
"all",
"registered",
"stats",
"as",
"telegraf",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/selfstat/selfstat.go#L91-L121 |
128,301 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | Gather | func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
if c.statFilter == nil {
var err error
// Set config level filter (won't change throughout life of plugin).
c.statFilter, err = filter.NewIncludeExcludeFilter(c.StatisticInclude, c.StatisticExclude)
if err != nil {
return err
}
}
if c.client... | go | func (c *CloudWatch) Gather(acc telegraf.Accumulator) error {
if c.statFilter == nil {
var err error
// Set config level filter (won't change throughout life of plugin).
c.statFilter, err = filter.NewIncludeExcludeFilter(c.StatisticInclude, c.StatisticExclude)
if err != nil {
return err
}
}
if c.client... | [
"func",
"(",
"c",
"*",
"CloudWatch",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"c",
".",
"statFilter",
"==",
"nil",
"{",
"var",
"err",
"error",
"\n",
"// Set config level filter (won't change throughout life of plugin).",
... | // Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval". | [
"Gather",
"takes",
"in",
"an",
"accumulator",
"and",
"adds",
"the",
"metrics",
"that",
"the",
"Input",
"gathers",
".",
"This",
"is",
"called",
"every",
"interval",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L167-L236 |
128,302 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | getFilteredMetrics | func getFilteredMetrics(c *CloudWatch) ([]filteredMetric, error) {
if c.metricCache != nil && c.metricCache.isValid() {
return c.metricCache.metrics, nil
}
fMetrics := []filteredMetric{}
// check for provided metric filter
if c.Metrics != nil {
for _, m := range c.Metrics {
metrics := []*cloudwatch.Metric... | go | func getFilteredMetrics(c *CloudWatch) ([]filteredMetric, error) {
if c.metricCache != nil && c.metricCache.isValid() {
return c.metricCache.metrics, nil
}
fMetrics := []filteredMetric{}
// check for provided metric filter
if c.Metrics != nil {
for _, m := range c.Metrics {
metrics := []*cloudwatch.Metric... | [
"func",
"getFilteredMetrics",
"(",
"c",
"*",
"CloudWatch",
")",
"(",
"[",
"]",
"filteredMetric",
",",
"error",
")",
"{",
"if",
"c",
".",
"metricCache",
"!=",
"nil",
"&&",
"c",
".",
"metricCache",
".",
"isValid",
"(",
")",
"{",
"return",
"c",
".",
"me... | // getFilteredMetrics returns metrics specified in the config file or metrics listed from Cloudwatch. | [
"getFilteredMetrics",
"returns",
"metrics",
"specified",
"in",
"the",
"config",
"file",
"or",
"metrics",
"listed",
"from",
"Cloudwatch",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L263-L342 |
128,303 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | fetchNamespaceMetrics | func (c *CloudWatch) fetchNamespaceMetrics() ([]*cloudwatch.Metric, error) {
metrics := []*cloudwatch.Metric{}
var token *string
params := &cloudwatch.ListMetricsInput{
Namespace: aws.String(c.Namespace),
Dimensions: []*cloudwatch.DimensionFilter{},
NextToken: token,
MetricName: nil,
}
for {
resp, er... | go | func (c *CloudWatch) fetchNamespaceMetrics() ([]*cloudwatch.Metric, error) {
metrics := []*cloudwatch.Metric{}
var token *string
params := &cloudwatch.ListMetricsInput{
Namespace: aws.String(c.Namespace),
Dimensions: []*cloudwatch.DimensionFilter{},
NextToken: token,
MetricName: nil,
}
for {
resp, er... | [
"func",
"(",
"c",
"*",
"CloudWatch",
")",
"fetchNamespaceMetrics",
"(",
")",
"(",
"[",
"]",
"*",
"cloudwatch",
".",
"Metric",
",",
"error",
")",
"{",
"metrics",
":=",
"[",
"]",
"*",
"cloudwatch",
".",
"Metric",
"{",
"}",
"\n\n",
"var",
"token",
"*",
... | // fetchNamespaceMetrics retrieves available metrics for a given CloudWatch namespace. | [
"fetchNamespaceMetrics",
"retrieves",
"available",
"metrics",
"for",
"a",
"given",
"CloudWatch",
"namespace",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L345-L371 |
128,304 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | gatherMetrics | func (c *CloudWatch) gatherMetrics(
params *cloudwatch.GetMetricDataInput,
) ([]*cloudwatch.MetricDataResult, error) {
results := []*cloudwatch.MetricDataResult{}
for {
resp, err := c.client.GetMetricData(params)
if err != nil {
return nil, fmt.Errorf("failed to get metric data: %v", err)
}
results = ap... | go | func (c *CloudWatch) gatherMetrics(
params *cloudwatch.GetMetricDataInput,
) ([]*cloudwatch.MetricDataResult, error) {
results := []*cloudwatch.MetricDataResult{}
for {
resp, err := c.client.GetMetricData(params)
if err != nil {
return nil, fmt.Errorf("failed to get metric data: %v", err)
}
results = ap... | [
"func",
"(",
"c",
"*",
"CloudWatch",
")",
"gatherMetrics",
"(",
"params",
"*",
"cloudwatch",
".",
"GetMetricDataInput",
",",
")",
"(",
"[",
"]",
"*",
"cloudwatch",
".",
"MetricDataResult",
",",
"error",
")",
"{",
"results",
":=",
"[",
"]",
"*",
"cloudwat... | // gatherMetrics gets metric data from Cloudwatch. | [
"gatherMetrics",
"gets",
"metric",
"data",
"from",
"Cloudwatch",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L483-L502 |
128,305 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | ctod | func ctod(cDimensions []*cloudwatch.Dimension) *map[string]string {
dimensions := map[string]string{}
for i := range cDimensions {
dimensions[snakeCase(*cDimensions[i].Name)] = *cDimensions[i].Value
}
return &dimensions
} | go | func ctod(cDimensions []*cloudwatch.Dimension) *map[string]string {
dimensions := map[string]string{}
for i := range cDimensions {
dimensions[snakeCase(*cDimensions[i].Name)] = *cDimensions[i].Value
}
return &dimensions
} | [
"func",
"ctod",
"(",
"cDimensions",
"[",
"]",
"*",
"cloudwatch",
".",
"Dimension",
")",
"*",
"map",
"[",
"string",
"]",
"string",
"{",
"dimensions",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"i",
":=",
"range",
"cDimensions",
... | // ctod converts cloudwatch dimensions to regular dimensions. | [
"ctod",
"converts",
"cloudwatch",
"dimensions",
"to",
"regular",
"dimensions",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L561-L567 |
128,306 | influxdata/telegraf | plugins/inputs/cloudwatch/cloudwatch.go | isValid | func (f *metricCache) isValid() bool {
return f.metrics != nil && time.Since(f.built) < f.ttl
} | go | func (f *metricCache) isValid() bool {
return f.metrics != nil && time.Since(f.built) < f.ttl
} | [
"func",
"(",
"f",
"*",
"metricCache",
")",
"isValid",
"(",
")",
"bool",
"{",
"return",
"f",
".",
"metrics",
"!=",
"nil",
"&&",
"time",
".",
"Since",
"(",
"f",
".",
"built",
")",
"<",
"f",
".",
"ttl",
"\n",
"}"
] | // isValid checks the validity of the metric cache. | [
"isValid",
"checks",
"the",
"validity",
"of",
"the",
"metric",
"cache",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/cloudwatch/cloudwatch.go#L578-L580 |
128,307 | influxdata/telegraf | internal/models/filter.go | Compile | func (f *Filter) Compile() error {
if len(f.NameDrop) == 0 &&
len(f.NamePass) == 0 &&
len(f.FieldDrop) == 0 &&
len(f.FieldPass) == 0 &&
len(f.TagInclude) == 0 &&
len(f.TagExclude) == 0 &&
len(f.TagPass) == 0 &&
len(f.TagDrop) == 0 {
return nil
}
f.isActive = true
var err error
f.nameDrop, err = fi... | go | func (f *Filter) Compile() error {
if len(f.NameDrop) == 0 &&
len(f.NamePass) == 0 &&
len(f.FieldDrop) == 0 &&
len(f.FieldPass) == 0 &&
len(f.TagInclude) == 0 &&
len(f.TagExclude) == 0 &&
len(f.TagPass) == 0 &&
len(f.TagDrop) == 0 {
return nil
}
f.isActive = true
var err error
f.nameDrop, err = fi... | [
"func",
"(",
"f",
"*",
"Filter",
")",
"Compile",
"(",
")",
"error",
"{",
"if",
"len",
"(",
"f",
".",
"NameDrop",
")",
"==",
"0",
"&&",
"len",
"(",
"f",
".",
"NamePass",
")",
"==",
"0",
"&&",
"len",
"(",
"f",
".",
"FieldDrop",
")",
"==",
"0",
... | // Compile all Filter lists into filter.Filter objects. | [
"Compile",
"all",
"Filter",
"lists",
"into",
"filter",
".",
"Filter",
"objects",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/filter.go#L41-L95 |
128,308 | influxdata/telegraf | plugins/inputs/zipkin/codec/jsonV1/jsonV1.go | Decode | func (j *JSON) Decode(octets []byte) ([]codec.Span, error) {
var spans []span
err := json.Unmarshal(octets, &spans)
if err != nil {
return nil, err
}
res := make([]codec.Span, len(spans))
for i := range spans {
if err := spans[i].Validate(); err != nil {
return nil, err
}
res[i] = &spans[i]
}
return... | go | func (j *JSON) Decode(octets []byte) ([]codec.Span, error) {
var spans []span
err := json.Unmarshal(octets, &spans)
if err != nil {
return nil, err
}
res := make([]codec.Span, len(spans))
for i := range spans {
if err := spans[i].Validate(); err != nil {
return nil, err
}
res[i] = &spans[i]
}
return... | [
"func",
"(",
"j",
"*",
"JSON",
")",
"Decode",
"(",
"octets",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"codec",
".",
"Span",
",",
"error",
")",
"{",
"var",
"spans",
"[",
"]",
"span",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"octets",
",",
... | // Decode unmarshals and validates the JSON body | [
"Decode",
"unmarshals",
"and",
"validates",
"the",
"JSON",
"body"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/jsonV1/jsonV1.go#L17-L32 |
128,309 | influxdata/telegraf | plugins/inputs/zipkin/codec/jsonV1/jsonV1.go | IDFromString | func IDFromString(s string) (string, error) {
if len(s) > 16 {
return "", fmt.Errorf("ID cannot be longer than 16 hex characters: %s", s)
}
id, err := strconv.ParseUint(s, 16, 64)
if err != nil {
return "", err
}
return strconv.FormatUint(id, 16), nil
} | go | func IDFromString(s string) (string, error) {
if len(s) > 16 {
return "", fmt.Errorf("ID cannot be longer than 16 hex characters: %s", s)
}
id, err := strconv.ParseUint(s, 16, 64)
if err != nil {
return "", err
}
return strconv.FormatUint(id, 16), nil
} | [
"func",
"IDFromString",
"(",
"s",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"s",
")",
">",
"16",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"s",
")",
"\n",
"}",
"\n",
"id",
",",
... | // IDFromString validates the ID and returns it in hexadecimal format. | [
"IDFromString",
"validates",
"the",
"ID",
"and",
"returns",
"it",
"in",
"hexadecimal",
"format",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/jsonV1/jsonV1.go#L243-L252 |
128,310 | influxdata/telegraf | plugins/inputs/win_perf_counters/pdh.go | PdhAddEnglishCounter | func PdhAddEnglishCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintptr, phCounter *PDH_HCOUNTER) uint32 {
if pdh_AddEnglishCounterW == nil {
return ERROR_INVALID_FUNCTION
}
ptxt, _ := syscall.UTF16PtrFromString(szFullCounterPath)
ret, _, _ := pdh_AddEnglishCounterW.Call(
uintptr(hQuery),
u... | go | func PdhAddEnglishCounter(hQuery PDH_HQUERY, szFullCounterPath string, dwUserData uintptr, phCounter *PDH_HCOUNTER) uint32 {
if pdh_AddEnglishCounterW == nil {
return ERROR_INVALID_FUNCTION
}
ptxt, _ := syscall.UTF16PtrFromString(szFullCounterPath)
ret, _, _ := pdh_AddEnglishCounterW.Call(
uintptr(hQuery),
u... | [
"func",
"PdhAddEnglishCounter",
"(",
"hQuery",
"PDH_HQUERY",
",",
"szFullCounterPath",
"string",
",",
"dwUserData",
"uintptr",
",",
"phCounter",
"*",
"PDH_HCOUNTER",
")",
"uint32",
"{",
"if",
"pdh_AddEnglishCounterW",
"==",
"nil",
"{",
"return",
"ERROR_INVALID_FUNCTIO... | // PdhAddEnglishCounter adds the specified language-neutral counter to the query. See the PdhAddCounter function. This function only exists on
// Windows versions higher than Vista. | [
"PdhAddEnglishCounter",
"adds",
"the",
"specified",
"language",
"-",
"neutral",
"counter",
"to",
"the",
"query",
".",
"See",
"the",
"PdhAddCounter",
"function",
".",
"This",
"function",
"only",
"exists",
"on",
"Windows",
"versions",
"higher",
"than",
"Vista",
".... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/pdh.go#L261-L274 |
128,311 | influxdata/telegraf | plugins/inputs/win_perf_counters/pdh.go | PdhCloseQuery | func PdhCloseQuery(hQuery PDH_HQUERY) uint32 {
ret, _, _ := pdh_CloseQuery.Call(uintptr(hQuery))
return uint32(ret)
} | go | func PdhCloseQuery(hQuery PDH_HQUERY) uint32 {
ret, _, _ := pdh_CloseQuery.Call(uintptr(hQuery))
return uint32(ret)
} | [
"func",
"PdhCloseQuery",
"(",
"hQuery",
"PDH_HQUERY",
")",
"uint32",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"pdh_CloseQuery",
".",
"Call",
"(",
"uintptr",
"(",
"hQuery",
")",
")",
"\n\n",
"return",
"uint32",
"(",
"ret",
")",
"\n",
"}"
] | // PdhCloseQuery closes all counters contained in the specified query, closes all handles related to the query,
// and frees all memory associated with the query. | [
"PdhCloseQuery",
"closes",
"all",
"counters",
"contained",
"in",
"the",
"specified",
"query",
"closes",
"all",
"handles",
"related",
"to",
"the",
"query",
"and",
"frees",
"all",
"memory",
"associated",
"with",
"the",
"query",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/pdh.go#L278-L282 |
128,312 | influxdata/telegraf | plugins/inputs/win_perf_counters/pdh.go | PdhGetFormattedCounterValueDouble | func PdhGetFormattedCounterValueDouble(hCounter PDH_HCOUNTER, lpdwType *uint32, pValue *PDH_FMT_COUNTERVALUE_DOUBLE) uint32 {
ret, _, _ := pdh_GetFormattedCounterValue.Call(
uintptr(hCounter),
uintptr(PDH_FMT_DOUBLE|PDH_FMT_NOCAP100),
uintptr(unsafe.Pointer(lpdwType)),
uintptr(unsafe.Pointer(pValue)))
return... | go | func PdhGetFormattedCounterValueDouble(hCounter PDH_HCOUNTER, lpdwType *uint32, pValue *PDH_FMT_COUNTERVALUE_DOUBLE) uint32 {
ret, _, _ := pdh_GetFormattedCounterValue.Call(
uintptr(hCounter),
uintptr(PDH_FMT_DOUBLE|PDH_FMT_NOCAP100),
uintptr(unsafe.Pointer(lpdwType)),
uintptr(unsafe.Pointer(pValue)))
return... | [
"func",
"PdhGetFormattedCounterValueDouble",
"(",
"hCounter",
"PDH_HCOUNTER",
",",
"lpdwType",
"*",
"uint32",
",",
"pValue",
"*",
"PDH_FMT_COUNTERVALUE_DOUBLE",
")",
"uint32",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"pdh_GetFormattedCounterValue",
".",
"Call",
"(",
... | // PdhGetFormattedCounterValueDouble formats the given hCounter using a 'double'. The result is set into the specialized union struct pValue.
// This function does not directly translate to a Windows counterpart due to union specialization tricks. | [
"PdhGetFormattedCounterValueDouble",
"formats",
"the",
"given",
"hCounter",
"using",
"a",
"double",
".",
"The",
"result",
"is",
"set",
"into",
"the",
"specialized",
"union",
"struct",
"pValue",
".",
"This",
"function",
"does",
"not",
"directly",
"translate",
"to",... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/pdh.go#L344-L352 |
128,313 | influxdata/telegraf | plugins/inputs/win_perf_counters/pdh.go | PdhOpenQuery | func PdhOpenQuery(szDataSource uintptr, dwUserData uintptr, phQuery *PDH_HQUERY) uint32 {
ret, _, _ := pdh_OpenQuery.Call(
szDataSource,
dwUserData,
uintptr(unsafe.Pointer(phQuery)))
return uint32(ret)
} | go | func PdhOpenQuery(szDataSource uintptr, dwUserData uintptr, phQuery *PDH_HQUERY) uint32 {
ret, _, _ := pdh_OpenQuery.Call(
szDataSource,
dwUserData,
uintptr(unsafe.Pointer(phQuery)))
return uint32(ret)
} | [
"func",
"PdhOpenQuery",
"(",
"szDataSource",
"uintptr",
",",
"dwUserData",
"uintptr",
",",
"phQuery",
"*",
"PDH_HQUERY",
")",
"uint32",
"{",
"ret",
",",
"_",
",",
"_",
":=",
"pdh_OpenQuery",
".",
"Call",
"(",
"szDataSource",
",",
"dwUserData",
",",
"uintptr"... | // PdhOpenQuery creates a new query that is used to manage the collection of performance data.
// szDataSource is a null terminated string that specifies the name of the log file from which to
// retrieve the performance data. If 0, performance data is collected from a real-time data source.
// dwUserData is a user-def... | [
"PdhOpenQuery",
"creates",
"a",
"new",
"query",
"that",
"is",
"used",
"to",
"manage",
"the",
"collection",
"of",
"performance",
"data",
".",
"szDataSource",
"is",
"a",
"null",
"terminated",
"string",
"that",
"specifies",
"the",
"name",
"of",
"the",
"log",
"f... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/pdh.go#L409-L416 |
128,314 | influxdata/telegraf | plugins/inputs/win_perf_counters/pdh.go | PdhValidatePath | func PdhValidatePath(path string) uint32 {
ptxt, _ := syscall.UTF16PtrFromString(path)
ret, _, _ := pdh_ValidatePathW.Call(uintptr(unsafe.Pointer(ptxt)))
return uint32(ret)
} | go | func PdhValidatePath(path string) uint32 {
ptxt, _ := syscall.UTF16PtrFromString(path)
ret, _, _ := pdh_ValidatePathW.Call(uintptr(unsafe.Pointer(ptxt)))
return uint32(ret)
} | [
"func",
"PdhValidatePath",
"(",
"path",
"string",
")",
"uint32",
"{",
"ptxt",
",",
"_",
":=",
"syscall",
".",
"UTF16PtrFromString",
"(",
"path",
")",
"\n",
"ret",
",",
"_",
",",
"_",
":=",
"pdh_ValidatePathW",
".",
"Call",
"(",
"uintptr",
"(",
"unsafe",
... | // PdhValidatePath validates a path. Will return ERROR_SUCCESS when ok, or PDH_CSTATUS_BAD_COUNTERNAME when the path is
// erroneous. | [
"PdhValidatePath",
"validates",
"a",
"path",
".",
"Will",
"return",
"ERROR_SUCCESS",
"when",
"ok",
"or",
"PDH_CSTATUS_BAD_COUNTERNAME",
"when",
"the",
"path",
"is",
"erroneous",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_perf_counters/pdh.go#L464-L469 |
128,315 | influxdata/telegraf | plugins/inputs/httpjson/httpjson.go | Gather | func (h *HttpJson) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
if h.client.HTTPClient() == nil {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return err
}
tr := &http.Transport{
ResponseHeaderTimeout: h.ResponseTimeout.Duration,
TLSClientConfig: tlsCfg,
}
cl... | go | func (h *HttpJson) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
if h.client.HTTPClient() == nil {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return err
}
tr := &http.Transport{
ResponseHeaderTimeout: h.ResponseTimeout.Duration,
TLSClientConfig: tlsCfg,
}
cl... | [
"func",
"(",
"h",
"*",
"HttpJson",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n\n",
"if",
"h",
".",
"client",
".",
"HTTPClient",
"(",
")",
"==",
"nil",
"{",
"tlsCfg",
",",
... | // Gathers data for all servers. | [
"Gathers",
"data",
"for",
"all",
"servers",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/httpjson/httpjson.go#L125-L155 |
128,316 | influxdata/telegraf | plugins/parsers/dropwizard/parser.go | Parse | func (p *parser) Parse(buf []byte) ([]telegraf.Metric, error) {
metrics := make([]telegraf.Metric, 0)
metricTime, err := p.parseTime(buf)
if err != nil {
return nil, err
}
dwr, err := p.unmarshalMetrics(buf)
if err != nil {
return nil, err
}
metrics = p.readDWMetrics("counter", dwr["counters"], metrics, ... | go | func (p *parser) Parse(buf []byte) ([]telegraf.Metric, error) {
metrics := make([]telegraf.Metric, 0)
metricTime, err := p.parseTime(buf)
if err != nil {
return nil, err
}
dwr, err := p.unmarshalMetrics(buf)
if err != nil {
return nil, err
}
metrics = p.readDWMetrics("counter", dwr["counters"], metrics, ... | [
"func",
"(",
"p",
"*",
"parser",
")",
"Parse",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"metrics",
":=",
"make",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"0",
")",
"\n\n",
"metri... | // Parse parses the input bytes to an array of metrics | [
"Parse",
"parses",
"the",
"input",
"bytes",
"to",
"an",
"array",
"of",
"metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/dropwizard/parser.go#L69-L114 |
128,317 | influxdata/telegraf | plugins/parsers/dropwizard/parser.go | ParseLine | func (p *parser) ParseLine(line string) (telegraf.Metric, error) {
return nil, fmt.Errorf("ParseLine not supported: %s, for data format: dropwizard", line)
} | go | func (p *parser) ParseLine(line string) (telegraf.Metric, error) {
return nil, fmt.Errorf("ParseLine not supported: %s, for data format: dropwizard", line)
} | [
"func",
"(",
"p",
"*",
"parser",
")",
"ParseLine",
"(",
"line",
"string",
")",
"(",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"line",
")",
"\n",
"}"
] | // ParseLine is not supported by the dropwizard format | [
"ParseLine",
"is",
"not",
"supported",
"by",
"the",
"dropwizard",
"format"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/dropwizard/parser.go#L138-L140 |
128,318 | influxdata/telegraf | plugins/inputs/phpfpm/phpfpm.go | gatherServer | func (g *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
if g.client == nil {
tlsCfg, err := g.ClientConfig.TLSConfig()
if err != nil {
return err
}
tr := &http.Transport{
TLSClientConfig: tlsCfg,
}
g.client = &http.Client{
Transport: tr,
Timeout: g.Timeout.Duration,
}
... | go | func (g *phpfpm) gatherServer(addr string, acc telegraf.Accumulator) error {
if g.client == nil {
tlsCfg, err := g.ClientConfig.TLSConfig()
if err != nil {
return err
}
tr := &http.Transport{
TLSClientConfig: tlsCfg,
}
g.client = &http.Client{
Transport: tr,
Timeout: g.Timeout.Duration,
}
... | [
"func",
"(",
"g",
"*",
"phpfpm",
")",
"gatherServer",
"(",
"addr",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"g",
".",
"client",
"==",
"nil",
"{",
"tlsCfg",
",",
"err",
":=",
"g",
".",
"ClientConfig",
".",
"TLSCon... | // Request status page to get stat raw data and import it | [
"Request",
"status",
"page",
"to",
"get",
"stat",
"raw",
"data",
"and",
"import",
"it"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/phpfpm.go#L111-L175 |
128,319 | influxdata/telegraf | plugins/inputs/phpfpm/phpfpm.go | gatherFcgi | func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc telegraf.Accumulator, addr string) error {
fpmOutput, fpmErr, err := fcgi.Request(map[string]string{
"SCRIPT_NAME": "/" + statusPath,
"SCRIPT_FILENAME": statusPath,
"REQUEST_METHOD": "GET",
"CONTENT_LENGTH": "0",
"SERVER_PROTOCOL": "HTTP/1.... | go | func (g *phpfpm) gatherFcgi(fcgi *conn, statusPath string, acc telegraf.Accumulator, addr string) error {
fpmOutput, fpmErr, err := fcgi.Request(map[string]string{
"SCRIPT_NAME": "/" + statusPath,
"SCRIPT_FILENAME": statusPath,
"REQUEST_METHOD": "GET",
"CONTENT_LENGTH": "0",
"SERVER_PROTOCOL": "HTTP/1.... | [
"func",
"(",
"g",
"*",
"phpfpm",
")",
"gatherFcgi",
"(",
"fcgi",
"*",
"conn",
",",
"statusPath",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
"addr",
"string",
")",
"error",
"{",
"fpmOutput",
",",
"fpmErr",
",",
"err",
":=",
"fcgi",
".",
... | // Gather stat using fcgi protocol | [
"Gather",
"stat",
"using",
"fcgi",
"protocol"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/phpfpm.go#L178-L195 |
128,320 | influxdata/telegraf | plugins/inputs/phpfpm/phpfpm.go | gatherHttp | func (g *phpfpm) gatherHttp(addr string, acc telegraf.Accumulator) error {
u, err := url.Parse(addr)
if err != nil {
return fmt.Errorf("Unable parse server address '%s': %s", addr, err)
}
req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s", u.Scheme,
u.Host, u.Path), nil)
res, err := g.client.Do(req)
... | go | func (g *phpfpm) gatherHttp(addr string, acc telegraf.Accumulator) error {
u, err := url.Parse(addr)
if err != nil {
return fmt.Errorf("Unable parse server address '%s': %s", addr, err)
}
req, err := http.NewRequest("GET", fmt.Sprintf("%s://%s%s", u.Scheme,
u.Host, u.Path), nil)
res, err := g.client.Do(req)
... | [
"func",
"(",
"g",
"*",
"phpfpm",
")",
"gatherHttp",
"(",
"addr",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Gather stat using http protocol | [
"Gather",
"stat",
"using",
"http",
"protocol"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/phpfpm.go#L198-L220 |
128,321 | influxdata/telegraf | plugins/inputs/phpfpm/phpfpm.go | importMetric | func importMetric(r io.Reader, acc telegraf.Accumulator, addr string) (poolStat, error) {
stats := make(poolStat)
var currentPool string
scanner := bufio.NewScanner(r)
for scanner.Scan() {
statLine := scanner.Text()
keyvalue := strings.Split(statLine, ":")
if len(keyvalue) < 2 {
continue
}
fieldName ... | go | func importMetric(r io.Reader, acc telegraf.Accumulator, addr string) (poolStat, error) {
stats := make(poolStat)
var currentPool string
scanner := bufio.NewScanner(r)
for scanner.Scan() {
statLine := scanner.Text()
keyvalue := strings.Split(statLine, ":")
if len(keyvalue) < 2 {
continue
}
fieldName ... | [
"func",
"importMetric",
"(",
"r",
"io",
".",
"Reader",
",",
"acc",
"telegraf",
".",
"Accumulator",
",",
"addr",
"string",
")",
"(",
"poolStat",
",",
"error",
")",
"{",
"stats",
":=",
"make",
"(",
"poolStat",
")",
"\n",
"var",
"currentPool",
"string",
"... | // Import stat data into Telegraf system | [
"Import",
"stat",
"data",
"into",
"Telegraf",
"system"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/phpfpm.go#L223-L276 |
128,322 | influxdata/telegraf | metric/metric.go | FromMetric | func FromMetric(other telegraf.Metric) telegraf.Metric {
m := &metric{
name: other.Name(),
tags: make([]*telegraf.Tag, len(other.TagList())),
fields: make([]*telegraf.Field, len(other.FieldList())),
tm: other.Time(),
tp: other.Type(),
aggregate: other.IsAggregate(),
}
for i, t... | go | func FromMetric(other telegraf.Metric) telegraf.Metric {
m := &metric{
name: other.Name(),
tags: make([]*telegraf.Tag, len(other.TagList())),
fields: make([]*telegraf.Field, len(other.FieldList())),
tm: other.Time(),
tp: other.Type(),
aggregate: other.IsAggregate(),
}
for i, t... | [
"func",
"FromMetric",
"(",
"other",
"telegraf",
".",
"Metric",
")",
"telegraf",
".",
"Metric",
"{",
"m",
":=",
"&",
"metric",
"{",
"name",
":",
"other",
".",
"Name",
"(",
")",
",",
"tags",
":",
"make",
"(",
"[",
"]",
"*",
"telegraf",
".",
"Tag",
... | // FromMetric returns a deep copy of the metric with any tracking information
// removed. | [
"FromMetric",
"returns",
"a",
"deep",
"copy",
"of",
"the",
"metric",
"with",
"any",
"tracking",
"information",
"removed",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/metric/metric.go#L67-L85 |
128,323 | influxdata/telegraf | metric/metric.go | convertField | func convertField(v interface{}) interface{} {
switch v := v.(type) {
case float64:
return v
case int64:
return v
case string:
return v
case bool:
return v
case int:
return int64(v)
case uint:
return uint64(v)
case uint64:
return uint64(v)
case []byte:
return string(v)
case int32:
return int... | go | func convertField(v interface{}) interface{} {
switch v := v.(type) {
case float64:
return v
case int64:
return v
case string:
return v
case bool:
return v
case int:
return int64(v)
case uint:
return uint64(v)
case uint64:
return uint64(v)
case []byte:
return string(v)
case int32:
return int... | [
"func",
"convertField",
"(",
"v",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"switch",
"v",
":=",
"v",
".",
"(",
"type",
")",
"{",
"case",
"float64",
":",
"return",
"v",
"\n",
"case",
"int64",
":",
"return",
"v",
"\n",
"case",
"string"... | // Convert field to a supported type or nil if unconvertible | [
"Convert",
"field",
"to",
"a",
"supported",
"type",
"or",
"nil",
"if",
"unconvertible"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/metric/metric.go#L283-L379 |
128,324 | influxdata/telegraf | internal/templating/template.go | Apply | func (t *Template) Apply(line string, joiner string) (string, map[string]string, string, error) {
fields := strings.Split(line, t.separator)
var (
measurement []string
tags = make(map[string][]string)
field []string
)
// Set any default tags
for k, v := range t.defaultTags {
tags[k] = append(... | go | func (t *Template) Apply(line string, joiner string) (string, map[string]string, string, error) {
fields := strings.Split(line, t.separator)
var (
measurement []string
tags = make(map[string][]string)
field []string
)
// Set any default tags
for k, v := range t.defaultTags {
tags[k] = append(... | [
"func",
"(",
"t",
"*",
"Template",
")",
"Apply",
"(",
"line",
"string",
",",
"joiner",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"string",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"Split",
"(",
"lin... | // apply extracts the template fields from the given line and returns the measurement
// name, tags and field name | [
"apply",
"extracts",
"the",
"template",
"fields",
"from",
"the",
"given",
"line",
"and",
"returns",
"the",
"measurement",
"name",
"tags",
"and",
"field",
"name"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/template.go#L19-L78 |
128,325 | influxdata/telegraf | internal/templating/template.go | NewTemplate | func NewTemplate(separator string, pattern string, defaultTags map[string]string) (*Template, error) {
parts := strings.Split(pattern, separator)
hasMeasurement := false
template := &Template{
separator: separator,
parts: parts,
defaultTags: defaultTags,
}
for _, part := range parts {
if strings.H... | go | func NewTemplate(separator string, pattern string, defaultTags map[string]string) (*Template, error) {
parts := strings.Split(pattern, separator)
hasMeasurement := false
template := &Template{
separator: separator,
parts: parts,
defaultTags: defaultTags,
}
for _, part := range parts {
if strings.H... | [
"func",
"NewTemplate",
"(",
"separator",
"string",
",",
"pattern",
"string",
",",
"defaultTags",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"Template",
",",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"pattern",
",",
"separat... | // NewTemplate returns a new template ensuring it has a measurement
// specified. | [
"NewTemplate",
"returns",
"a",
"new",
"template",
"ensuring",
"it",
"has",
"a",
"measurement",
"specified",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/template.go#L86-L111 |
128,326 | influxdata/telegraf | internal/templating/template.go | Less | func (e templateSpecs) Less(j, k int) bool {
if len(e[j].filter) == 0 && len(e[k].filter) == 0 {
jlength := len(strings.Split(e[j].template, e[j].separator))
klength := len(strings.Split(e[k].template, e[k].separator))
return jlength < klength
}
if len(e[j].filter) == 0 {
return true
}
if len(e[k].filter) ... | go | func (e templateSpecs) Less(j, k int) bool {
if len(e[j].filter) == 0 && len(e[k].filter) == 0 {
jlength := len(strings.Split(e[j].template, e[j].separator))
klength := len(strings.Split(e[k].template, e[k].separator))
return jlength < klength
}
if len(e[j].filter) == 0 {
return true
}
if len(e[k].filter) ... | [
"func",
"(",
"e",
"templateSpecs",
")",
"Less",
"(",
"j",
",",
"k",
"int",
")",
"bool",
"{",
"if",
"len",
"(",
"e",
"[",
"j",
"]",
".",
"filter",
")",
"==",
"0",
"&&",
"len",
"(",
"e",
"[",
"k",
"]",
".",
"filter",
")",
"==",
"0",
"{",
"j... | // Less reports whether the element with
// index j should sort before the element with index k. | [
"Less",
"reports",
"whether",
"the",
"element",
"with",
"index",
"j",
"should",
"sort",
"before",
"the",
"element",
"with",
"index",
"k",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/templating/template.go#L126-L142 |
128,327 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherGlobalVariables | func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(globalVariablesQuery)
if err != nil {
return err
}
defer rows.Close()
var key string
var val sql.RawBytes
// parse DSN and save server tag
servtag := getDSNTag(serv)
tags := ... | go | func (m *Mysql) gatherGlobalVariables(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(globalVariablesQuery)
if err != nil {
return err
}
defer rows.Close()
var key string
var val sql.RawBytes
// parse DSN and save server tag
servtag := getDSNTag(serv)
tags := ... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherGlobalVariables",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// run query",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"... | // gatherGlobalVariables can be used to fetch all global variables from
// MySQL environment. | [
"gatherGlobalVariables",
"can",
"be",
"used",
"to",
"fetch",
"all",
"global",
"variables",
"from",
"MySQL",
"environment",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L533-L572 |
128,328 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherSlaveStatuses | func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(slaveStatusQuery)
if err != nil {
return err
}
defer rows.Close()
servtag := getDSNTag(serv)
tags := map[string]string{"server": servtag}
fields := make(map[string]interface{})
... | go | func (m *Mysql) gatherSlaveStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(slaveStatusQuery)
if err != nil {
return err
}
defer rows.Close()
servtag := getDSNTag(serv)
tags := map[string]string{"server": servtag}
fields := make(map[string]interface{})
... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherSlaveStatuses",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// run query",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"sl... | // gatherSlaveStatuses can be used to get replication analytics
// When the server is slave, then it returns only one row.
// If the multi-source replication is set, then everything works differently
// This code does not work with multi-source replication. | [
"gatherSlaveStatuses",
"can",
"be",
"used",
"to",
"get",
"replication",
"analytics",
"When",
"the",
"server",
"is",
"slave",
"then",
"it",
"returns",
"only",
"one",
"row",
".",
"If",
"the",
"multi",
"-",
"source",
"replication",
"is",
"set",
"then",
"everyth... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L578-L620 |
128,329 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherBinaryLogs | func (m *Mysql) gatherBinaryLogs(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(binaryLogsQuery)
if err != nil {
return err
}
defer rows.Close()
// parse DSN and save host as a tag
servtag := getDSNTag(serv)
tags := map[string]string{"server": servtag}
var (
... | go | func (m *Mysql) gatherBinaryLogs(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(binaryLogsQuery)
if err != nil {
return err
}
defer rows.Close()
// parse DSN and save host as a tag
servtag := getDSNTag(serv)
tags := map[string]string{"server": servtag}
var (
... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherBinaryLogs",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// run query",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"binar... | // gatherBinaryLogs can be used to collect size and count of all binary files
// binlogs metric requires the MySQL server to turn it on in configuration | [
"gatherBinaryLogs",
"can",
"be",
"used",
"to",
"collect",
"size",
"and",
"count",
"of",
"all",
"binary",
"files",
"binlogs",
"metric",
"requires",
"the",
"MySQL",
"server",
"to",
"turn",
"it",
"on",
"in",
"configuration"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L624-L656 |
128,330 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | GatherProcessListStatuses | func (m *Mysql) GatherProcessListStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(infoSchemaProcessListQuery)
if err != nil {
return err
}
defer rows.Close()
var (
command string
state string
count uint32
)
var servtag string
fields := make(map... | go | func (m *Mysql) GatherProcessListStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(infoSchemaProcessListQuery)
if err != nil {
return err
}
defer rows.Close()
var (
command string
state string
count uint32
)
var servtag string
fields := make(map... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"GatherProcessListStatuses",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// run query",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",... | // GatherProcessList can be used to collect metrics on each running command
// and its state with its running count | [
"GatherProcessList",
"can",
"be",
"used",
"to",
"collect",
"metrics",
"on",
"each",
"running",
"command",
"and",
"its",
"state",
"with",
"its",
"running",
"count"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L768-L836 |
128,331 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | GatherUserStatisticsStatuses | func (m *Mysql) GatherUserStatisticsStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(infoSchemaUserStatisticsQuery)
if err != nil {
// disable collecting if table is not found (mysql specific error)
// (suppresses repeat errors)
if strings.Contains(err.Erro... | go | func (m *Mysql) GatherUserStatisticsStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
// run query
rows, err := db.Query(infoSchemaUserStatisticsQuery)
if err != nil {
// disable collecting if table is not found (mysql specific error)
// (suppresses repeat errors)
if strings.Contains(err.Erro... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"GatherUserStatisticsStatuses",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// run query",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"... | // GatherUserStatistics can be used to collect metrics on each running command
// and its state with its running count | [
"GatherUserStatistics",
"can",
"be",
"used",
"to",
"collect",
"metrics",
"on",
"each",
"running",
"command",
"and",
"its",
"state",
"with",
"its",
"running",
"count"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L840-L891 |
128,332 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | columnsToLower | func columnsToLower(s []string, e error) ([]string, error) {
if e != nil {
return nil, e
}
d := make([]string, len(s))
for i := range s {
d[i] = strings.ToLower(s[i])
}
return d, nil
} | go | func columnsToLower(s []string, e error) ([]string, error) {
if e != nil {
return nil, e
}
d := make([]string, len(s))
for i := range s {
d[i] = strings.ToLower(s[i])
}
return d, nil
} | [
"func",
"columnsToLower",
"(",
"s",
"[",
"]",
"string",
",",
"e",
"error",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"e",
"!=",
"nil",
"{",
"return",
"nil",
",",
"e",
"\n",
"}",
"\n",
"d",
":=",
"make",
"(",
"[",
"]",
"strin... | // columnsToLower converts selected column names to lowercase. | [
"columnsToLower",
"converts",
"selected",
"column",
"names",
"to",
"lowercase",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L894-L904 |
128,333 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherInfoSchemaAutoIncStatuses | func (m *Mysql) gatherInfoSchemaAutoIncStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(infoSchemaAutoIncQuery)
if err != nil {
return err
}
defer rows.Close()
var (
schema, table, column string
incValue, maxInt uint64
)
servtag := getDSNTag(serv)
for rows.... | go | func (m *Mysql) gatherInfoSchemaAutoIncStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(infoSchemaAutoIncQuery)
if err != nil {
return err
}
defer rows.Close()
var (
schema, table, column string
incValue, maxInt uint64
)
servtag := getDSNTag(serv)
for rows.... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherInfoSchemaAutoIncStatuses",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"infoSche... | // gatherInfoSchemaAutoIncStatuses can be used to get auto incremented values of the column | [
"gatherInfoSchemaAutoIncStatuses",
"can",
"be",
"used",
"to",
"get",
"auto",
"incremented",
"values",
"of",
"the",
"column"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1156-L1191 |
128,334 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherPerfEventWaits | func (m *Mysql) gatherPerfEventWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(perfEventWaitsQuery)
if err != nil {
return err
}
defer rows.Close()
var (
event string
starCount, timeWait float64
)
servtag := getDSNTag(serv)
tags := map[string]string{
... | go | func (m *Mysql) gatherPerfEventWaits(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(perfEventWaitsQuery)
if err != nil {
return err
}
defer rows.Close()
var (
event string
starCount, timeWait float64
)
servtag := getDSNTag(serv)
tags := map[string]string{
... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherPerfEventWaits",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"perfEventWaitsQuery... | // gatherPerfEventWaits can be used to get total time and number of event waits | [
"gatherPerfEventWaits",
"can",
"be",
"used",
"to",
"get",
"total",
"time",
"and",
"number",
"of",
"event",
"waits"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1363-L1392 |
128,335 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherPerfFileEventsStatuses | func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(perfFileEventsQuery)
if err != nil {
return err
}
defer rows.Close()
var (
eventName string
countRead, countWrite, countMisc float64
sumTi... | go | func (m *Mysql) gatherPerfFileEventsStatuses(db *sql.DB, serv string, acc telegraf.Accumulator) error {
rows, err := db.Query(perfFileEventsQuery)
if err != nil {
return err
}
defer rows.Close()
var (
eventName string
countRead, countWrite, countMisc float64
sumTi... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherPerfFileEventsStatuses",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"rows",
",",
"err",
":=",
"db",
".",
"Query",
"(",
"perfFileEve... | // gatherPerfFileEvents can be used to get stats on file events | [
"gatherPerfFileEvents",
"can",
"be",
"used",
"to",
"get",
"stats",
"on",
"file",
"events"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1395-L1450 |
128,336 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | gatherPerfEventsStatements | func (m *Mysql) gatherPerfEventsStatements(db *sql.DB, serv string, acc telegraf.Accumulator) error {
query := fmt.Sprintf(
perfEventsStatementsQuery,
m.PerfEventsStatementsDigestTextLimit,
m.PerfEventsStatementsTimeLimit,
m.PerfEventsStatementsLimit,
)
rows, err := db.Query(query)
if err != nil {
return... | go | func (m *Mysql) gatherPerfEventsStatements(db *sql.DB, serv string, acc telegraf.Accumulator) error {
query := fmt.Sprintf(
perfEventsStatementsQuery,
m.PerfEventsStatementsDigestTextLimit,
m.PerfEventsStatementsTimeLimit,
m.PerfEventsStatementsLimit,
)
rows, err := db.Query(query)
if err != nil {
return... | [
"func",
"(",
"m",
"*",
"Mysql",
")",
"gatherPerfEventsStatements",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"serv",
"string",
",",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"query",
":=",
"fmt",
".",
"Sprintf",
"(",
"perfEventsStatementsQuery... | // gatherPerfEventsStatements can be used to get attributes of each event | [
"gatherPerfEventsStatements",
"can",
"be",
"used",
"to",
"get",
"attributes",
"of",
"each",
"event"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1453-L1517 |
128,337 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | parseValue | func parseValue(value sql.RawBytes) (interface{}, bool) {
if bytes.EqualFold(value, []byte("YES")) || bytes.Compare(value, []byte("ON")) == 0 {
return 1, true
}
if bytes.EqualFold(value, []byte("NO")) || bytes.Compare(value, []byte("OFF")) == 0 {
return 0, true
}
if val, err := strconv.ParseInt(string(value)... | go | func parseValue(value sql.RawBytes) (interface{}, bool) {
if bytes.EqualFold(value, []byte("YES")) || bytes.Compare(value, []byte("ON")) == 0 {
return 1, true
}
if bytes.EqualFold(value, []byte("NO")) || bytes.Compare(value, []byte("OFF")) == 0 {
return 0, true
}
if val, err := strconv.ParseInt(string(value)... | [
"func",
"parseValue",
"(",
"value",
"sql",
".",
"RawBytes",
")",
"(",
"interface",
"{",
"}",
",",
"bool",
")",
"{",
"if",
"bytes",
".",
"EqualFold",
"(",
"value",
",",
"[",
"]",
"byte",
"(",
"\"",
"\"",
")",
")",
"||",
"bytes",
".",
"Compare",
"(... | // parseValue can be used to convert values such as "ON","OFF","Yes","No" to 0,1 | [
"parseValue",
"can",
"be",
"used",
"to",
"convert",
"values",
"such",
"as",
"ON",
"OFF",
"Yes",
"No",
"to",
"0",
"1"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1644-L1664 |
128,338 | influxdata/telegraf | plugins/inputs/mysql/mysql.go | findThreadState | func findThreadState(rawCommand, rawState string) string {
var (
// replace '_' symbol with space
command = strings.Replace(strings.ToLower(rawCommand), "_", " ", -1)
state = strings.Replace(strings.ToLower(rawState), "_", " ", -1)
)
// if the state is already valid, then return it
if _, ok := generalThread... | go | func findThreadState(rawCommand, rawState string) string {
var (
// replace '_' symbol with space
command = strings.Replace(strings.ToLower(rawCommand), "_", " ", -1)
state = strings.Replace(strings.ToLower(rawState), "_", " ", -1)
)
// if the state is already valid, then return it
if _, ok := generalThread... | [
"func",
"findThreadState",
"(",
"rawCommand",
",",
"rawState",
"string",
")",
"string",
"{",
"var",
"(",
"// replace '_' symbol with space",
"command",
"=",
"strings",
".",
"Replace",
"(",
"strings",
".",
"ToLower",
"(",
"rawCommand",
")",
",",
"\"",
"\"",
","... | // findThreadState can be used to find thread state by command and plain state | [
"findThreadState",
"can",
"be",
"used",
"to",
"find",
"thread",
"state",
"by",
"command",
"and",
"plain",
"state"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mysql/mysql.go#L1667-L1700 |
128,339 | influxdata/telegraf | plugins/inputs/docker/stats_helpers.go | calculateMemUsageUnixNoCache | func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 {
return float64(mem.Usage - mem.Stats["cache"])
} | go | func calculateMemUsageUnixNoCache(mem types.MemoryStats) float64 {
return float64(mem.Usage - mem.Stats["cache"])
} | [
"func",
"calculateMemUsageUnixNoCache",
"(",
"mem",
"types",
".",
"MemoryStats",
")",
"float64",
"{",
"return",
"float64",
"(",
"mem",
".",
"Usage",
"-",
"mem",
".",
"Stats",
"[",
"\"",
"\"",
"]",
")",
"\n",
"}"
] | // calculateMemUsageUnixNoCache calculate memory usage of the container.
// Page cache is intentionally excluded to avoid misinterpretation of the output. | [
"calculateMemUsageUnixNoCache",
"calculate",
"memory",
"usage",
"of",
"the",
"container",
".",
"Page",
"cache",
"is",
"intentionally",
"excluded",
"to",
"avoid",
"misinterpretation",
"of",
"the",
"output",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/docker/stats_helpers.go#L44-L46 |
128,340 | influxdata/telegraf | plugins/inputs/ipvs/ipvs.go | Gather | func (i *IPVS) Gather(acc telegraf.Accumulator) error {
if i.handle == nil {
h, err := ipvs.New("") // TODO: make the namespace configurable
if err != nil {
return errors.New("Unable to open IPVS handle")
}
i.handle = h
}
services, err := i.handle.GetServices()
if err != nil {
i.handle.Close()
i.han... | go | func (i *IPVS) Gather(acc telegraf.Accumulator) error {
if i.handle == nil {
h, err := ipvs.New("") // TODO: make the namespace configurable
if err != nil {
return errors.New("Unable to open IPVS handle")
}
i.handle = h
}
services, err := i.handle.GetServices()
if err != nil {
i.handle.Close()
i.han... | [
"func",
"(",
"i",
"*",
"IPVS",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"i",
".",
"handle",
"==",
"nil",
"{",
"h",
",",
"err",
":=",
"ipvs",
".",
"New",
"(",
"\"",
"\"",
")",
"// TODO: make the namespace con... | // Gather gathers the stats | [
"Gather",
"gathers",
"the",
"stats"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ipvs/ipvs.go#L34-L94 |
128,341 | influxdata/telegraf | plugins/inputs/lustre2/lustre2.go | Gather | func (l *Lustre2) Gather(acc telegraf.Accumulator) error {
l.allFields = make(map[string]map[string]interface{})
if len(l.Ost_procfiles) == 0 {
// read/write bytes are in obdfilter/<ost_name>/stats
err := l.GetLustreProcStats("/proc/fs/lustre/obdfilter/*/stats",
wanted_ost_fields, acc)
if err != nil {
re... | go | func (l *Lustre2) Gather(acc telegraf.Accumulator) error {
l.allFields = make(map[string]map[string]interface{})
if len(l.Ost_procfiles) == 0 {
// read/write bytes are in obdfilter/<ost_name>/stats
err := l.GetLustreProcStats("/proc/fs/lustre/obdfilter/*/stats",
wanted_ost_fields, acc)
if err != nil {
re... | [
"func",
"(",
"l",
"*",
"Lustre2",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"l",
".",
"allFields",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n\n",
"if",... | // Gather reads stats from all lustre targets | [
"Gather",
"reads",
"stats",
"from",
"all",
"lustre",
"targets"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/lustre2/lustre2.go#L425-L500 |
128,342 | influxdata/telegraf | plugins/inputs/tail/tail.go | receiver | func (t *Tail) receiver(parser parsers.Parser, tailer *tail.Tail) {
defer t.wg.Done()
var firstLine = true
var metrics []telegraf.Metric
var m telegraf.Metric
var err error
var line *tail.Line
for line = range tailer.Lines {
if line.Err != nil {
t.acc.AddError(fmt.Errorf("E! Error tailing file %s, Error: %... | go | func (t *Tail) receiver(parser parsers.Parser, tailer *tail.Tail) {
defer t.wg.Done()
var firstLine = true
var metrics []telegraf.Metric
var m telegraf.Metric
var err error
var line *tail.Line
for line = range tailer.Lines {
if line.Err != nil {
t.acc.AddError(fmt.Errorf("E! Error tailing file %s, Error: %... | [
"func",
"(",
"t",
"*",
"Tail",
")",
"receiver",
"(",
"parser",
"parsers",
".",
"Parser",
",",
"tailer",
"*",
"tail",
".",
"Tail",
")",
"{",
"defer",
"t",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"var",
"firstLine",
"=",
"true",
"\n",
"var",
"met... | // this is launched as a goroutine to continuously watch a tailed logfile
// for changes, parse any incoming msgs, and add to the accumulator. | [
"this",
"is",
"launched",
"as",
"a",
"goroutine",
"to",
"continuously",
"watch",
"a",
"tailed",
"logfile",
"for",
"changes",
"parse",
"any",
"incoming",
"msgs",
"and",
"add",
"to",
"the",
"accumulator",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/tail/tail.go#L153-L203 |
128,343 | influxdata/telegraf | plugins/inputs/neptune_apex/neptune_apex.go | Gather | func (n *NeptuneApex) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
for _, server := range n.Servers {
wg.Add(1)
go func(server string) {
defer wg.Done()
acc.AddError(n.gatherServer(acc, server))
}(server)
}
wg.Wait()
return nil
} | go | func (n *NeptuneApex) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
for _, server := range n.Servers {
wg.Add(1)
go func(server string) {
defer wg.Done()
acc.AddError(n.gatherServer(acc, server))
}(server)
}
wg.Wait()
return nil
} | [
"func",
"(",
"n",
"*",
"NeptuneApex",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"_",
",",
"server",
":=",
"range",
"n",
".",
"Servers",
"{",
"wg",
".",
"Add",
"... | // Gather implements telegraf.Input.Gather | [
"Gather",
"implements",
"telegraf",
".",
"Input",
".",
"Gather"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/neptune_apex/neptune_apex.go#L81-L92 |
128,344 | influxdata/telegraf | plugins/inputs/zipkin/codec/thrift/thrift.go | UnmarshalThrift | func UnmarshalThrift(body []byte) ([]*zipkincore.Span, error) {
buffer := thrift.NewTMemoryBuffer()
if _, err := buffer.Write(body); err != nil {
return nil, err
}
transport := thrift.NewTBinaryProtocolTransport(buffer)
_, size, err := transport.ReadListBegin()
if err != nil {
return nil, err
}
spans := m... | go | func UnmarshalThrift(body []byte) ([]*zipkincore.Span, error) {
buffer := thrift.NewTMemoryBuffer()
if _, err := buffer.Write(body); err != nil {
return nil, err
}
transport := thrift.NewTBinaryProtocolTransport(buffer)
_, size, err := transport.ReadListBegin()
if err != nil {
return nil, err
}
spans := m... | [
"func",
"UnmarshalThrift",
"(",
"body",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"*",
"zipkincore",
".",
"Span",
",",
"error",
")",
"{",
"buffer",
":=",
"thrift",
".",
"NewTMemoryBuffer",
"(",
")",
"\n",
"if",
"_",
",",
"err",
":=",
"buffer",
".",
"Wr... | // UnmarshalThrift converts raw bytes in thrift format to a slice of spans | [
"UnmarshalThrift",
"converts",
"raw",
"bytes",
"in",
"thrift",
"format",
"to",
"a",
"slice",
"of",
"spans"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/thrift/thrift.go#L17-L42 |
128,345 | influxdata/telegraf | plugins/inputs/zipkin/codec/thrift/thrift.go | Decode | func (t *Thrift) Decode(octets []byte) ([]codec.Span, error) {
spans, err := UnmarshalThrift(octets)
if err != nil {
return nil, err
}
res := make([]codec.Span, len(spans))
for i, s := range spans {
res[i] = &span{s}
}
return res, nil
} | go | func (t *Thrift) Decode(octets []byte) ([]codec.Span, error) {
spans, err := UnmarshalThrift(octets)
if err != nil {
return nil, err
}
res := make([]codec.Span, len(spans))
for i, s := range spans {
res[i] = &span{s}
}
return res, nil
} | [
"func",
"(",
"t",
"*",
"Thrift",
")",
"Decode",
"(",
"octets",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"codec",
".",
"Span",
",",
"error",
")",
"{",
"spans",
",",
"err",
":=",
"UnmarshalThrift",
"(",
"octets",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Decode unmarshals and validates bytes in thrift format | [
"Decode",
"unmarshals",
"and",
"validates",
"bytes",
"in",
"thrift",
"format"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/zipkin/codec/thrift/thrift.go#L48-L59 |
128,346 | influxdata/telegraf | plugins/processors/converter/converter.go | convertTags | func (p *Converter) convertTags(metric telegraf.Metric) {
if p.tagConversions == nil {
return
}
for key, value := range metric.Tags() {
if p.tagConversions.String != nil && p.tagConversions.String.Match(key) {
metric.RemoveTag(key)
metric.AddField(key, value)
continue
}
if p.tagConversions.Integer... | go | func (p *Converter) convertTags(metric telegraf.Metric) {
if p.tagConversions == nil {
return
}
for key, value := range metric.Tags() {
if p.tagConversions.String != nil && p.tagConversions.String.Match(key) {
metric.RemoveTag(key)
metric.AddField(key, value)
continue
}
if p.tagConversions.Integer... | [
"func",
"(",
"p",
"*",
"Converter",
")",
"convertTags",
"(",
"metric",
"telegraf",
".",
"Metric",
")",
"{",
"if",
"p",
".",
"tagConversions",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"metric",
".",
"Ta... | // convertTags converts tags into fields | [
"convertTags",
"converts",
"tags",
"into",
"fields"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/processors/converter/converter.go#L154-L217 |
128,347 | influxdata/telegraf | plugins/processors/converter/converter.go | convertFields | func (p *Converter) convertFields(metric telegraf.Metric) {
if p.fieldConversions == nil {
return
}
for key, value := range metric.Fields() {
if p.fieldConversions.Tag != nil && p.fieldConversions.Tag.Match(key) {
v, ok := toString(value)
if !ok {
metric.RemoveField(key)
logPrintf("error convertin... | go | func (p *Converter) convertFields(metric telegraf.Metric) {
if p.fieldConversions == nil {
return
}
for key, value := range metric.Fields() {
if p.fieldConversions.Tag != nil && p.fieldConversions.Tag.Match(key) {
v, ok := toString(value)
if !ok {
metric.RemoveField(key)
logPrintf("error convertin... | [
"func",
"(",
"p",
"*",
"Converter",
")",
"convertFields",
"(",
"metric",
"telegraf",
".",
"Metric",
")",
"{",
"if",
"p",
".",
"fieldConversions",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"key",
",",
"value",
":=",
"range",
"metric",
".",
... | // convertFields converts fields into tags or other field types | [
"convertFields",
"converts",
"fields",
"into",
"tags",
"or",
"other",
"field",
"types"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/processors/converter/converter.go#L220-L304 |
128,348 | influxdata/telegraf | plugins/processors/converter/converter.go | Round | func Round(x float64) float64 {
t := math.Trunc(x)
if math.Abs(x-t) >= 0.5 {
return t + math.Copysign(1, x)
}
return t
} | go | func Round(x float64) float64 {
t := math.Trunc(x)
if math.Abs(x-t) >= 0.5 {
return t + math.Copysign(1, x)
}
return t
} | [
"func",
"Round",
"(",
"x",
"float64",
")",
"float64",
"{",
"t",
":=",
"math",
".",
"Trunc",
"(",
"x",
")",
"\n",
"if",
"math",
".",
"Abs",
"(",
"x",
"-",
"t",
")",
">=",
"0.5",
"{",
"return",
"t",
"+",
"math",
".",
"Copysign",
"(",
"1",
",",
... | // math.Round was not added until Go 1.10, can be removed when support for Go
// 1.9 is dropped. | [
"math",
".",
"Round",
"was",
"not",
"added",
"until",
"Go",
"1",
".",
"10",
"can",
"be",
"removed",
"when",
"support",
"for",
"Go",
"1",
".",
"9",
"is",
"dropped",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/processors/converter/converter.go#L440-L446 |
128,349 | influxdata/telegraf | plugins/inputs/vsphere/vsphere.go | Start | func (v *VSphere) Start(acc telegraf.Accumulator) error {
log.Println("D! [inputs.vsphere]: Starting plugin")
ctx, cancel := context.WithCancel(context.Background())
v.cancel = cancel
// Create endpoints, one for each vCenter we're monitoring
v.endpoints = make([]*Endpoint, len(v.Vcenters))
for i, rawURL := rang... | go | func (v *VSphere) Start(acc telegraf.Accumulator) error {
log.Println("D! [inputs.vsphere]: Starting plugin")
ctx, cancel := context.WithCancel(context.Background())
v.cancel = cancel
// Create endpoints, one for each vCenter we're monitoring
v.endpoints = make([]*Endpoint, len(v.Vcenters))
for i, rawURL := rang... | [
"func",
"(",
"v",
"*",
"VSphere",
")",
"Start",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithCancel",
"(",
"context",
".",
"Backgrou... | // Start is called from telegraf core when a plugin is started and allows it to
// perform initialization tasks. | [
"Start",
"is",
"called",
"from",
"telegraf",
"core",
"when",
"a",
"plugin",
"is",
"started",
"and",
"allows",
"it",
"to",
"perform",
"initialization",
"tasks",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/vsphere.go#L232-L251 |
128,350 | influxdata/telegraf | plugins/inputs/vsphere/vsphere.go | Stop | func (v *VSphere) Stop() {
log.Println("D! [inputs.vsphere]: Stopping plugin")
v.cancel()
// Wait for all endpoints to finish. No need to wait for
// Gather() to finish here, since it Stop() will only be called
// after the last Gather() has finished. We do, however, need to
// wait for any discovery to complete... | go | func (v *VSphere) Stop() {
log.Println("D! [inputs.vsphere]: Stopping plugin")
v.cancel()
// Wait for all endpoints to finish. No need to wait for
// Gather() to finish here, since it Stop() will only be called
// after the last Gather() has finished. We do, however, need to
// wait for any discovery to complete... | [
"func",
"(",
"v",
"*",
"VSphere",
")",
"Stop",
"(",
")",
"{",
"log",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"v",
".",
"cancel",
"(",
")",
"\n\n",
"// Wait for all endpoints to finish. No need to wait for",
"// Gather() to finish here, since it Stop() will only ... | // Stop is called from telegraf core when a plugin is stopped and allows it to
// perform shutdown tasks. | [
"Stop",
"is",
"called",
"from",
"telegraf",
"core",
"when",
"a",
"plugin",
"is",
"stopped",
"and",
"allows",
"it",
"to",
"perform",
"shutdown",
"tasks",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/vsphere.go#L255-L272 |
128,351 | influxdata/telegraf | plugins/inputs/vsphere/vsphere.go | Gather | func (v *VSphere) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
for _, ep := range v.endpoints {
wg.Add(1)
go func(endpoint *Endpoint) {
defer wg.Done()
err := endpoint.Collect(context.Background(), acc)
if err == context.Canceled {
// No need to signal errors if we were merely canc... | go | func (v *VSphere) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
for _, ep := range v.endpoints {
wg.Add(1)
go func(endpoint *Endpoint) {
defer wg.Done()
err := endpoint.Collect(context.Background(), acc)
if err == context.Canceled {
// No need to signal errors if we were merely canc... | [
"func",
"(",
"v",
"*",
"VSphere",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"_",
",",
"ep",
":=",
"range",
"v",
".",
"endpoints",
"{",
"wg",
".",
"Add",
"(",
... | // Gather is the main data collection function called by the Telegraf core. It performs all
// the data collection and writes all metrics into the Accumulator passed as an argument. | [
"Gather",
"is",
"the",
"main",
"data",
"collection",
"function",
"called",
"by",
"the",
"Telegraf",
"core",
".",
"It",
"performs",
"all",
"the",
"data",
"collection",
"and",
"writes",
"all",
"metrics",
"into",
"the",
"Accumulator",
"passed",
"as",
"an",
"arg... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/vsphere/vsphere.go#L276-L296 |
128,352 | influxdata/telegraf | plugins/inputs/sensors/sensors.go | snake | func snake(input string) string {
return strings.ToLower(strings.Replace(strings.TrimSpace(input), " ", "_", -1))
} | go | func snake(input string) string {
return strings.ToLower(strings.Replace(strings.TrimSpace(input), " ", "_", -1))
} | [
"func",
"snake",
"(",
"input",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"Replace",
"(",
"strings",
".",
"TrimSpace",
"(",
"input",
")",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",
")",
")",
"\n",
... | // snake converts string to snake case | [
"snake",
"converts",
"string",
"to",
"snake",
"case"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/sensors/sensors.go#L108-L110 |
128,353 | influxdata/telegraf | internal/models/makemetric.go | makemetric | func makemetric(
metric telegraf.Metric,
nameOverride string,
namePrefix string,
nameSuffix string,
tags map[string]string,
globalTags map[string]string,
) telegraf.Metric {
if len(nameOverride) != 0 {
metric.SetName(nameOverride)
}
if len(namePrefix) != 0 {
metric.AddPrefix(namePrefix)
}
if len(nameSuf... | go | func makemetric(
metric telegraf.Metric,
nameOverride string,
namePrefix string,
nameSuffix string,
tags map[string]string,
globalTags map[string]string,
) telegraf.Metric {
if len(nameOverride) != 0 {
metric.SetName(nameOverride)
}
if len(namePrefix) != 0 {
metric.AddPrefix(namePrefix)
}
if len(nameSuf... | [
"func",
"makemetric",
"(",
"metric",
"telegraf",
".",
"Metric",
",",
"nameOverride",
"string",
",",
"namePrefix",
"string",
",",
"nameSuffix",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"globalTags",
"map",
"[",
"string",
"]",
"string",... | // Makemetric applies new metric plugin and agent measurement and tag
// settings. | [
"Makemetric",
"applies",
"new",
"metric",
"plugin",
"and",
"agent",
"measurement",
"and",
"tag",
"settings",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/models/makemetric.go#L9-L42 |
128,354 | influxdata/telegraf | plugins/inputs/win_services/win_services.go | listServices | func listServices(scmgr WinServiceManager, userServices []string) ([]string, error) {
if len(userServices) != 0 {
return userServices, nil
}
names, err := scmgr.ListServices()
if err != nil {
return nil, fmt.Errorf("Could not list services: %s", err)
}
return names, nil
} | go | func listServices(scmgr WinServiceManager, userServices []string) ([]string, error) {
if len(userServices) != 0 {
return userServices, nil
}
names, err := scmgr.ListServices()
if err != nil {
return nil, fmt.Errorf("Could not list services: %s", err)
}
return names, nil
} | [
"func",
"listServices",
"(",
"scmgr",
"WinServiceManager",
",",
"userServices",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"len",
"(",
"userServices",
")",
"!=",
"0",
"{",
"return",
"userServices",
",",
"nil",
"\n",
... | // listServices returns a list of services to gather. | [
"listServices",
"returns",
"a",
"list",
"of",
"services",
"to",
"gather",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_services/win_services.go#L154-L164 |
128,355 | influxdata/telegraf | plugins/inputs/win_services/win_services.go | collectServiceInfo | func collectServiceInfo(scmgr WinServiceManager, serviceName string) (*ServiceInfo, error) {
srv, err := scmgr.OpenService(serviceName)
if err != nil {
return nil, &ServiceErr{
Message: "could not open service",
Service: serviceName,
Err: err,
}
}
defer srv.Close()
srvStatus, err := srv.Query()
... | go | func collectServiceInfo(scmgr WinServiceManager, serviceName string) (*ServiceInfo, error) {
srv, err := scmgr.OpenService(serviceName)
if err != nil {
return nil, &ServiceErr{
Message: "could not open service",
Service: serviceName,
Err: err,
}
}
defer srv.Close()
srvStatus, err := srv.Query()
... | [
"func",
"collectServiceInfo",
"(",
"scmgr",
"WinServiceManager",
",",
"serviceName",
"string",
")",
"(",
"*",
"ServiceInfo",
",",
"error",
")",
"{",
"srv",
",",
"err",
":=",
"scmgr",
".",
"OpenService",
"(",
"serviceName",
")",
"\n",
"if",
"err",
"!=",
"ni... | // collectServiceInfo gathers info about a service. | [
"collectServiceInfo",
"gathers",
"info",
"about",
"a",
"service",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/win_services/win_services.go#L167-L203 |
128,356 | influxdata/telegraf | plugins/outputs/cratedb/cratedb.go | escapeString | func escapeString(s string, quote string) string {
return quote + strings.Replace(s, quote, quote+quote, -1) + quote
} | go | func escapeString(s string, quote string) string {
return quote + strings.Replace(s, quote, quote+quote, -1) + quote
} | [
"func",
"escapeString",
"(",
"s",
"string",
",",
"quote",
"string",
")",
"string",
"{",
"return",
"quote",
"+",
"strings",
".",
"Replace",
"(",
"s",
",",
"quote",
",",
"quote",
"+",
"quote",
",",
"-",
"1",
")",
"+",
"quote",
"\n",
"}"
] | // escapeString wraps s in the given quote string and replaces all occurrences
// of it inside of s with a double quote. | [
"escapeString",
"wraps",
"s",
"in",
"the",
"given",
"quote",
"string",
"and",
"replaces",
"all",
"occurrences",
"of",
"it",
"inside",
"of",
"s",
"with",
"a",
"double",
"quote",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/outputs/cratedb/cratedb.go#L188-L190 |
128,357 | influxdata/telegraf | plugins/inputs/nvidia_smi/nvidia_smi.go | Gather | func (smi *NvidiaSMI) Gather(acc telegraf.Accumulator) error {
if _, err := os.Stat(smi.BinPath); os.IsNotExist(err) {
return fmt.Errorf("nvidia-smi binary not at path %s, cannot gather GPU data", smi.BinPath)
}
data, err := smi.pollSMI()
if err != nil {
return err
}
err = gatherNvidiaSMI(data, acc)
if er... | go | func (smi *NvidiaSMI) Gather(acc telegraf.Accumulator) error {
if _, err := os.Stat(smi.BinPath); os.IsNotExist(err) {
return fmt.Errorf("nvidia-smi binary not at path %s, cannot gather GPU data", smi.BinPath)
}
data, err := smi.pollSMI()
if err != nil {
return err
}
err = gatherNvidiaSMI(data, acc)
if er... | [
"func",
"(",
"smi",
"*",
"NvidiaSMI",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"smi",
".",
"BinPath",
")",
";",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{... | // Gather implements the telegraf interface | [
"Gather",
"implements",
"the",
"telegraf",
"interface"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/nvidia_smi/nvidia_smi.go#L62-L79 |
128,358 | influxdata/telegraf | plugins/inputs/docker/docker.go | parseSize | func parseSize(sizeStr string) (int64, error) {
matches := sizeRegex.FindStringSubmatch(sizeStr)
if len(matches) != 4 {
return -1, fmt.Errorf("invalid size: '%s'", sizeStr)
}
size, err := strconv.ParseFloat(matches[1], 64)
if err != nil {
return -1, err
}
uMap := map[string]int64{"k": KB, "m": MB, "g": GB,... | go | func parseSize(sizeStr string) (int64, error) {
matches := sizeRegex.FindStringSubmatch(sizeStr)
if len(matches) != 4 {
return -1, fmt.Errorf("invalid size: '%s'", sizeStr)
}
size, err := strconv.ParseFloat(matches[1], 64)
if err != nil {
return -1, err
}
uMap := map[string]int64{"k": KB, "m": MB, "g": GB,... | [
"func",
"parseSize",
"(",
"sizeStr",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"matches",
":=",
"sizeRegex",
".",
"FindStringSubmatch",
"(",
"sizeStr",
")",
"\n",
"if",
"len",
"(",
"matches",
")",
"!=",
"4",
"{",
"return",
"-",
"1",
",",
"... | // Parses the human-readable size string into the amount it represents. | [
"Parses",
"the",
"human",
"-",
"readable",
"size",
"string",
"into",
"the",
"amount",
"it",
"represents",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/docker/docker.go#L769-L787 |
128,359 | influxdata/telegraf | plugins/inputs/mock_Plugin.go | Gather | func (m *MockPlugin) Gather(_a0 telegraf.Accumulator) error {
ret := m.Called(_a0)
r0 := ret.Error(0)
return r0
} | go | func (m *MockPlugin) Gather(_a0 telegraf.Accumulator) error {
ret := m.Called(_a0)
r0 := ret.Error(0)
return r0
} | [
"func",
"(",
"m",
"*",
"MockPlugin",
")",
"Gather",
"(",
"_a0",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"Called",
"(",
"_a0",
")",
"\n\n",
"r0",
":=",
"ret",
".",
"Error",
"(",
"0",
")",
"\n\n",
"return",
"r0",
"... | // Gather defines what data the plugin will gather. | [
"Gather",
"defines",
"what",
"data",
"the",
"plugin",
"will",
"gather",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/mock_Plugin.go#L25-L31 |
128,360 | influxdata/telegraf | plugins/inputs/unbound/unbound.go | unboundRunner | func unboundRunner(cmdName string, Timeout internal.Duration, UseSudo bool, Server string, ThreadAsTag bool) (*bytes.Buffer, error) {
cmdArgs := []string{"stats_noreset"}
if Server != "" {
host, port, err := net.SplitHostPort(Server)
if err != nil { // No port was specified
host = Server
port = ""
}
/... | go | func unboundRunner(cmdName string, Timeout internal.Duration, UseSudo bool, Server string, ThreadAsTag bool) (*bytes.Buffer, error) {
cmdArgs := []string{"stats_noreset"}
if Server != "" {
host, port, err := net.SplitHostPort(Server)
if err != nil { // No port was specified
host = Server
port = ""
}
/... | [
"func",
"unboundRunner",
"(",
"cmdName",
"string",
",",
"Timeout",
"internal",
".",
"Duration",
",",
"UseSudo",
"bool",
",",
"Server",
"string",
",",
"ThreadAsTag",
"bool",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"cmdArgs",
":=",
"... | // Shell out to unbound_stat and return the output | [
"Shell",
"out",
"to",
"unbound_stat",
"and",
"return",
"the",
"output"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/unbound/unbound.go#L70-L114 |
128,361 | influxdata/telegraf | plugins/inputs/unbound/unbound.go | Gather | func (s *Unbound) Gather(acc telegraf.Accumulator) error {
// Always exclude histrogram statistics
statExcluded := []string{"histogram.*"}
filterExcluded, err := filter.Compile(statExcluded)
if err != nil {
return err
}
out, err := s.run(s.Binary, s.Timeout, s.UseSudo, s.Server, s.ThreadAsTag)
if err != nil ... | go | func (s *Unbound) Gather(acc telegraf.Accumulator) error {
// Always exclude histrogram statistics
statExcluded := []string{"histogram.*"}
filterExcluded, err := filter.Compile(statExcluded)
if err != nil {
return err
}
out, err := s.run(s.Binary, s.Timeout, s.UseSudo, s.Server, s.ThreadAsTag)
if err != nil ... | [
"func",
"(",
"s",
"*",
"Unbound",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"// Always exclude histrogram statistics",
"statExcluded",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
"}",
"\n",
"filterExcluded",
",",
"err",
":=... | // Gather collects stats from unbound-control and adds them to the Accumulator
//
// All the dots in stat name will replaced by underscores. Histogram statistics will not be collected. | [
"Gather",
"collects",
"stats",
"from",
"unbound",
"-",
"control",
"and",
"adds",
"them",
"to",
"the",
"Accumulator",
"All",
"the",
"dots",
"in",
"stat",
"name",
"will",
"replaced",
"by",
"underscores",
".",
"Histogram",
"statistics",
"will",
"not",
"be",
"co... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/unbound/unbound.go#L119-L199 |
128,362 | influxdata/telegraf | plugins/parsers/logfmt/parser.go | NewParser | func NewParser(metricName string, defaultTags map[string]string) *Parser {
return &Parser{
MetricName: metricName,
DefaultTags: defaultTags,
Now: time.Now,
}
} | go | func NewParser(metricName string, defaultTags map[string]string) *Parser {
return &Parser{
MetricName: metricName,
DefaultTags: defaultTags,
Now: time.Now,
}
} | [
"func",
"NewParser",
"(",
"metricName",
"string",
",",
"defaultTags",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"Parser",
"{",
"return",
"&",
"Parser",
"{",
"MetricName",
":",
"metricName",
",",
"DefaultTags",
":",
"defaultTags",
",",
"Now",
":",
"tim... | // NewParser creates a parser. | [
"NewParser",
"creates",
"a",
"parser",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/logfmt/parser.go#L26-L32 |
128,363 | influxdata/telegraf | plugins/parsers/logfmt/parser.go | Parse | func (p *Parser) Parse(b []byte) ([]telegraf.Metric, error) {
reader := bytes.NewReader(b)
decoder := logfmt.NewDecoder(reader)
metrics := make([]telegraf.Metric, 0)
for {
ok := decoder.ScanRecord()
if !ok {
err := decoder.Err()
if err != nil {
return nil, err
}
break
}
fields := make(map[st... | go | func (p *Parser) Parse(b []byte) ([]telegraf.Metric, error) {
reader := bytes.NewReader(b)
decoder := logfmt.NewDecoder(reader)
metrics := make([]telegraf.Metric, 0)
for {
ok := decoder.ScanRecord()
if !ok {
err := decoder.Err()
if err != nil {
return nil, err
}
break
}
fields := make(map[st... | [
"func",
"(",
"p",
"*",
"Parser",
")",
"Parse",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"reader",
":=",
"bytes",
".",
"NewReader",
"(",
"b",
")",
"\n",
"decoder",
":=",
"logfmt",
".",
"N... | // Parse converts a slice of bytes in logfmt format to metrics. | [
"Parse",
"converts",
"a",
"slice",
"of",
"bytes",
"in",
"logfmt",
"format",
"to",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/logfmt/parser.go#L35-L79 |
128,364 | influxdata/telegraf | plugins/parsers/logfmt/parser.go | ParseLine | func (p *Parser) ParseLine(s string) (telegraf.Metric, error) {
metrics, err := p.Parse([]byte(s))
if err != nil {
return nil, err
}
if len(metrics) < 1 {
return nil, ErrNoMetric
}
return metrics[0], nil
} | go | func (p *Parser) ParseLine(s string) (telegraf.Metric, error) {
metrics, err := p.Parse([]byte(s))
if err != nil {
return nil, err
}
if len(metrics) < 1 {
return nil, ErrNoMetric
}
return metrics[0], nil
} | [
"func",
"(",
"p",
"*",
"Parser",
")",
"ParseLine",
"(",
"s",
"string",
")",
"(",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"metrics",
",",
"err",
":=",
"p",
".",
"Parse",
"(",
"[",
"]",
"byte",
"(",
"s",
")",
")",
"\n",
"if",
"err",
... | // ParseLine converts a single line of text in logfmt format to metrics. | [
"ParseLine",
"converts",
"a",
"single",
"line",
"of",
"text",
"in",
"logfmt",
"format",
"to",
"metrics",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/logfmt/parser.go#L82-L92 |
128,365 | influxdata/telegraf | plugins/inputs/sqlserver/sqlserver.go | Gather | func (s *SQLServer) Gather(acc telegraf.Accumulator) error {
if !isInitialized {
initQueries(s)
}
if len(s.Servers) == 0 {
s.Servers = append(s.Servers, defaultServer)
}
var wg sync.WaitGroup
for _, serv := range s.Servers {
for _, query := range queries {
wg.Add(1)
go func(serv string, query Query... | go | func (s *SQLServer) Gather(acc telegraf.Accumulator) error {
if !isInitialized {
initQueries(s)
}
if len(s.Servers) == 0 {
s.Servers = append(s.Servers, defaultServer)
}
var wg sync.WaitGroup
for _, serv := range s.Servers {
for _, query := range queries {
wg.Add(1)
go func(serv string, query Query... | [
"func",
"(",
"s",
"*",
"SQLServer",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"!",
"isInitialized",
"{",
"initQueries",
"(",
"s",
")",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"s",
".",
"Servers",
")",
"==",
"0... | // Gather collect data from SQL Server | [
"Gather",
"collect",
"data",
"from",
"SQL",
"Server"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/sqlserver/sqlserver.go#L123-L146 |
128,366 | influxdata/telegraf | plugins/inputs/http/http.go | Gather | func (h *HTTP) Gather(acc telegraf.Accumulator) error {
if h.parser == nil {
return errors.New("Parser is not set")
}
if h.client == nil {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return err
}
h.client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsCfg,
Prox... | go | func (h *HTTP) Gather(acc telegraf.Accumulator) error {
if h.parser == nil {
return errors.New("Parser is not set")
}
if h.client == nil {
tlsCfg, err := h.ClientConfig.TLSConfig()
if err != nil {
return err
}
h.client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsCfg,
Prox... | [
"func",
"(",
"h",
"*",
"HTTP",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"h",
".",
"parser",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"h",
".",
"c... | // Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval" | [
"Gather",
"takes",
"in",
"an",
"accumulator",
"and",
"adds",
"the",
"metrics",
"that",
"the",
"Input",
"gathers",
".",
"This",
"is",
"called",
"every",
"interval"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/http/http.go#L94-L127 |
128,367 | influxdata/telegraf | plugins/inputs/varnish/varnish.go | varnishRunner | func varnishRunner(cmdName string, UseSudo bool, InstanceName string, Timeout internal.Duration) (*bytes.Buffer, error) {
cmdArgs := []string{"-1"}
if InstanceName != "" {
cmdArgs = append(cmdArgs, []string{"-n", InstanceName}...)
}
cmd := exec.Command(cmdName, cmdArgs...)
if UseSudo {
cmdArgs = append([]st... | go | func varnishRunner(cmdName string, UseSudo bool, InstanceName string, Timeout internal.Duration) (*bytes.Buffer, error) {
cmdArgs := []string{"-1"}
if InstanceName != "" {
cmdArgs = append(cmdArgs, []string{"-n", InstanceName}...)
}
cmd := exec.Command(cmdName, cmdArgs...)
if UseSudo {
cmdArgs = append([]st... | [
"func",
"varnishRunner",
"(",
"cmdName",
"string",
",",
"UseSudo",
"bool",
",",
"InstanceName",
"string",
",",
"Timeout",
"internal",
".",
"Duration",
")",
"(",
"*",
"bytes",
".",
"Buffer",
",",
"error",
")",
"{",
"cmdArgs",
":=",
"[",
"]",
"string",
"{"... | // Shell out to varnish_stat and return the output | [
"Shell",
"out",
"to",
"varnish_stat",
"and",
"return",
"the",
"output"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/varnish/varnish.go#L69-L93 |
128,368 | influxdata/telegraf | internal/internal.go | UnmarshalTOML | func (d *Duration) UnmarshalTOML(b []byte) error {
var err error
b = bytes.Trim(b, `'`)
// see if we can directly convert it
d.Duration, err = time.ParseDuration(string(b))
if err == nil {
return nil
}
// Parse string duration, ie, "1s"
if uq, err := strconv.Unquote(string(b)); err == nil && len(uq) > 0 {
... | go | func (d *Duration) UnmarshalTOML(b []byte) error {
var err error
b = bytes.Trim(b, `'`)
// see if we can directly convert it
d.Duration, err = time.ParseDuration(string(b))
if err == nil {
return nil
}
// Parse string duration, ie, "1s"
if uq, err := strconv.Unquote(string(b)); err == nil && len(uq) > 0 {
... | [
"func",
"(",
"d",
"*",
"Duration",
")",
"UnmarshalTOML",
"(",
"b",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"b",
"=",
"bytes",
".",
"Trim",
"(",
"b",
",",
"`'`",
")",
"\n\n",
"// see if we can directly convert it",
"d",
".",
... | // UnmarshalTOML parses the duration from the TOML config file | [
"UnmarshalTOML",
"parses",
"the",
"duration",
"from",
"the",
"TOML",
"config",
"file"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L71-L103 |
128,369 | influxdata/telegraf | internal/internal.go | CombinedOutputTimeout | func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error) {
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
if err := c.Start(); err != nil {
return nil, err
}
err := WaitTimeout(c, timeout)
return b.Bytes(), err
} | go | func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error) {
var b bytes.Buffer
c.Stdout = &b
c.Stderr = &b
if err := c.Start(); err != nil {
return nil, err
}
err := WaitTimeout(c, timeout)
return b.Bytes(), err
} | [
"func",
"CombinedOutputTimeout",
"(",
"c",
"*",
"exec",
".",
"Cmd",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"c",
".",
"Stdout",
"=",
"&",
"b",
"\n",
"c... | // CombinedOutputTimeout runs the given command with the given timeout and
// returns the combined output of stdout and stderr.
// If the command times out, it attempts to kill the process. | [
"CombinedOutputTimeout",
"runs",
"the",
"given",
"command",
"with",
"the",
"given",
"timeout",
"and",
"returns",
"the",
"combined",
"output",
"of",
"stdout",
"and",
"stderr",
".",
"If",
"the",
"command",
"times",
"out",
"it",
"attempts",
"to",
"kill",
"the",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L191-L200 |
128,370 | influxdata/telegraf | internal/internal.go | RunTimeout | func RunTimeout(c *exec.Cmd, timeout time.Duration) error {
if err := c.Start(); err != nil {
return err
}
return WaitTimeout(c, timeout)
} | go | func RunTimeout(c *exec.Cmd, timeout time.Duration) error {
if err := c.Start(); err != nil {
return err
}
return WaitTimeout(c, timeout)
} | [
"func",
"RunTimeout",
"(",
"c",
"*",
"exec",
".",
"Cmd",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"Start",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"WaitTi... | // RunTimeout runs the given command with the given timeout.
// If the command times out, it attempts to kill the process. | [
"RunTimeout",
"runs",
"the",
"given",
"command",
"with",
"the",
"given",
"timeout",
".",
"If",
"the",
"command",
"times",
"out",
"it",
"attempts",
"to",
"kill",
"the",
"process",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L204-L209 |
128,371 | influxdata/telegraf | internal/internal.go | WaitTimeout | func WaitTimeout(c *exec.Cmd, timeout time.Duration) error {
timer := time.AfterFunc(timeout, func() {
err := c.Process.Kill()
if err != nil {
log.Printf("E! FATAL error killing process: %s", err)
return
}
})
err := c.Wait()
isTimeout := timer.Stop()
if err != nil {
return err
} else if isTimeout ... | go | func WaitTimeout(c *exec.Cmd, timeout time.Duration) error {
timer := time.AfterFunc(timeout, func() {
err := c.Process.Kill()
if err != nil {
log.Printf("E! FATAL error killing process: %s", err)
return
}
})
err := c.Wait()
isTimeout := timer.Stop()
if err != nil {
return err
} else if isTimeout ... | [
"func",
"WaitTimeout",
"(",
"c",
"*",
"exec",
".",
"Cmd",
",",
"timeout",
"time",
".",
"Duration",
")",
"error",
"{",
"timer",
":=",
"time",
".",
"AfterFunc",
"(",
"timeout",
",",
"func",
"(",
")",
"{",
"err",
":=",
"c",
".",
"Process",
".",
"Kill"... | // WaitTimeout waits for the given command to finish with a timeout.
// It assumes the command has already been started.
// If the command times out, it attempts to kill the process. | [
"WaitTimeout",
"waits",
"for",
"the",
"given",
"command",
"to",
"finish",
"with",
"a",
"timeout",
".",
"It",
"assumes",
"the",
"command",
"has",
"already",
"been",
"started",
".",
"If",
"the",
"command",
"times",
"out",
"it",
"attempts",
"to",
"kill",
"the... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L214-L233 |
128,372 | influxdata/telegraf | internal/internal.go | RandomSleep | func RandomSleep(max time.Duration, shutdown chan struct{}) {
if max == 0 {
return
}
maxSleep := big.NewInt(max.Nanoseconds())
var sleepns int64
if j, err := rand.Int(rand.Reader, maxSleep); err == nil {
sleepns = j.Int64()
}
t := time.NewTimer(time.Nanosecond * time.Duration(sleepns))
select {
case <-t.... | go | func RandomSleep(max time.Duration, shutdown chan struct{}) {
if max == 0 {
return
}
maxSleep := big.NewInt(max.Nanoseconds())
var sleepns int64
if j, err := rand.Int(rand.Reader, maxSleep); err == nil {
sleepns = j.Int64()
}
t := time.NewTimer(time.Nanosecond * time.Duration(sleepns))
select {
case <-t.... | [
"func",
"RandomSleep",
"(",
"max",
"time",
".",
"Duration",
",",
"shutdown",
"chan",
"struct",
"{",
"}",
")",
"{",
"if",
"max",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"maxSleep",
":=",
"big",
".",
"NewInt",
"(",
"max",
".",
"Nanoseconds",
"(",
... | // RandomSleep will sleep for a random amount of time up to max.
// If the shutdown channel is closed, it will return before it has finished
// sleeping. | [
"RandomSleep",
"will",
"sleep",
"for",
"a",
"random",
"amount",
"of",
"time",
"up",
"to",
"max",
".",
"If",
"the",
"shutdown",
"channel",
"is",
"closed",
"it",
"will",
"return",
"before",
"it",
"has",
"finished",
"sleeping",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L238-L257 |
128,373 | influxdata/telegraf | internal/internal.go | RandomDuration | func RandomDuration(max time.Duration) time.Duration {
if max == 0 {
return 0
}
var sleepns int64
maxSleep := big.NewInt(max.Nanoseconds())
if j, err := rand.Int(rand.Reader, maxSleep); err == nil {
sleepns = j.Int64()
}
return time.Duration(sleepns)
} | go | func RandomDuration(max time.Duration) time.Duration {
if max == 0 {
return 0
}
var sleepns int64
maxSleep := big.NewInt(max.Nanoseconds())
if j, err := rand.Int(rand.Reader, maxSleep); err == nil {
sleepns = j.Int64()
}
return time.Duration(sleepns)
} | [
"func",
"RandomDuration",
"(",
"max",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"if",
"max",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"var",
"sleepns",
"int64",
"\n",
"maxSleep",
":=",
"big",
".",
"NewInt",
"(",
"max",
".",... | // RandomDuration returns a random duration between 0 and max. | [
"RandomDuration",
"returns",
"a",
"random",
"duration",
"between",
"0",
"and",
"max",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L260-L272 |
128,374 | influxdata/telegraf | internal/internal.go | SleepContext | func SleepContext(ctx context.Context, duration time.Duration) error {
if duration == 0 {
return nil
}
t := time.NewTimer(duration)
select {
case <-t.C:
return nil
case <-ctx.Done():
t.Stop()
return ctx.Err()
}
} | go | func SleepContext(ctx context.Context, duration time.Duration) error {
if duration == 0 {
return nil
}
t := time.NewTimer(duration)
select {
case <-t.C:
return nil
case <-ctx.Done():
t.Stop()
return ctx.Err()
}
} | [
"func",
"SleepContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"duration",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"duration",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"t",
":=",
"time",
".",
"NewTimer",
"(",
"duration",
")",
... | // SleepContext sleeps until the context is closed or the duration is reached. | [
"SleepContext",
"sleeps",
"until",
"the",
"context",
"is",
"closed",
"or",
"the",
"duration",
"is",
"reached",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L275-L288 |
128,375 | influxdata/telegraf | internal/internal.go | AlignDuration | func AlignDuration(tm time.Time, interval time.Duration) time.Duration {
return AlignTime(tm, interval).Sub(tm)
} | go | func AlignDuration(tm time.Time, interval time.Duration) time.Duration {
return AlignTime(tm, interval).Sub(tm)
} | [
"func",
"AlignDuration",
"(",
"tm",
"time",
".",
"Time",
",",
"interval",
"time",
".",
"Duration",
")",
"time",
".",
"Duration",
"{",
"return",
"AlignTime",
"(",
"tm",
",",
"interval",
")",
".",
"Sub",
"(",
"tm",
")",
"\n",
"}"
] | // AlignDuration returns the duration until next aligned interval.
// If the current time is aligned a 0 duration is returned. | [
"AlignDuration",
"returns",
"the",
"duration",
"until",
"next",
"aligned",
"interval",
".",
"If",
"the",
"current",
"time",
"is",
"aligned",
"a",
"0",
"duration",
"is",
"returned",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L292-L294 |
128,376 | influxdata/telegraf | internal/internal.go | AlignTime | func AlignTime(tm time.Time, interval time.Duration) time.Time {
truncated := tm.Truncate(interval)
if truncated == tm {
return tm
}
return truncated.Add(interval)
} | go | func AlignTime(tm time.Time, interval time.Duration) time.Time {
truncated := tm.Truncate(interval)
if truncated == tm {
return tm
}
return truncated.Add(interval)
} | [
"func",
"AlignTime",
"(",
"tm",
"time",
".",
"Time",
",",
"interval",
"time",
".",
"Duration",
")",
"time",
".",
"Time",
"{",
"truncated",
":=",
"tm",
".",
"Truncate",
"(",
"interval",
")",
"\n",
"if",
"truncated",
"==",
"tm",
"{",
"return",
"tm",
"\... | // AlignTime returns the time of the next aligned interval.
// If the current time is aligned the current time is returned. | [
"AlignTime",
"returns",
"the",
"time",
"of",
"the",
"next",
"aligned",
"interval",
".",
"If",
"the",
"current",
"time",
"is",
"aligned",
"the",
"current",
"time",
"is",
"returned",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L298-L304 |
128,377 | influxdata/telegraf | internal/internal.go | CompressWithGzip | func CompressWithGzip(data io.Reader) (io.Reader, error) {
pipeReader, pipeWriter := io.Pipe()
gzipWriter := gzip.NewWriter(pipeWriter)
var err error
go func() {
_, err = io.Copy(gzipWriter, data)
gzipWriter.Close()
// subsequent reads from the read half of the pipe will
// return no bytes and the error er... | go | func CompressWithGzip(data io.Reader) (io.Reader, error) {
pipeReader, pipeWriter := io.Pipe()
gzipWriter := gzip.NewWriter(pipeWriter)
var err error
go func() {
_, err = io.Copy(gzipWriter, data)
gzipWriter.Close()
// subsequent reads from the read half of the pipe will
// return no bytes and the error er... | [
"func",
"CompressWithGzip",
"(",
"data",
"io",
".",
"Reader",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"pipeReader",
",",
"pipeWriter",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"gzipWriter",
":=",
"gzip",
".",
"NewWriter",
"(",
"pipeWrite... | // CompressWithGzip takes an io.Reader as input and pipes
// it through a gzip.Writer returning an io.Reader containing
// the gzipped data.
// An error is returned if passing data to the gzip.Writer fails | [
"CompressWithGzip",
"takes",
"an",
"io",
".",
"Reader",
"as",
"input",
"and",
"pipes",
"it",
"through",
"a",
"gzip",
".",
"Writer",
"returning",
"an",
"io",
".",
"Reader",
"containing",
"the",
"gzipped",
"data",
".",
"An",
"error",
"is",
"returned",
"if",
... | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L322-L336 |
128,378 | influxdata/telegraf | internal/internal.go | ParseTimestamp | func ParseTimestamp(timestamp interface{}, format string) (time.Time, error) {
return ParseTimestampWithLocation(timestamp, format, "UTC")
} | go | func ParseTimestamp(timestamp interface{}, format string) (time.Time, error) {
return ParseTimestampWithLocation(timestamp, format, "UTC")
} | [
"func",
"ParseTimestamp",
"(",
"timestamp",
"interface",
"{",
"}",
",",
"format",
"string",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"return",
"ParseTimestampWithLocation",
"(",
"timestamp",
",",
"format",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // ParseTimestamp with no location provided parses a timestamp value as UTC | [
"ParseTimestamp",
"with",
"no",
"location",
"provided",
"parses",
"a",
"timestamp",
"value",
"as",
"UTC"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/internal/internal.go#L339-L341 |
128,379 | influxdata/telegraf | plugins/parsers/graphite/parser.go | ParseLine | func (p *GraphiteParser) ParseLine(line string) (telegraf.Metric, error) {
// Break into 3 fields (name, value, timestamp).
fields := strings.Fields(line)
if len(fields) != 2 && len(fields) != 3 {
return nil, fmt.Errorf("received %q which doesn't have required fields", line)
}
// decode the name and tags
measu... | go | func (p *GraphiteParser) ParseLine(line string) (telegraf.Metric, error) {
// Break into 3 fields (name, value, timestamp).
fields := strings.Fields(line)
if len(fields) != 2 && len(fields) != 3 {
return nil, fmt.Errorf("received %q which doesn't have required fields", line)
}
// decode the name and tags
measu... | [
"func",
"(",
"p",
"*",
"GraphiteParser",
")",
"ParseLine",
"(",
"line",
"string",
")",
"(",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"// Break into 3 fields (name, value, timestamp).",
"fields",
":=",
"strings",
".",
"Fields",
"(",
"line",
")",
"\n",... | // Parse performs Graphite parsing of a single line. | [
"Parse",
"performs",
"Graphite",
"parsing",
"of",
"a",
"single",
"line",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/graphite/parser.go#L107-L170 |
128,380 | influxdata/telegraf | plugins/parsers/graphite/parser.go | ApplyTemplate | func (p *GraphiteParser) ApplyTemplate(line string) (string, map[string]string, string, error) {
// Break line into fields (name, value, timestamp), only name is used
fields := strings.Fields(line)
if len(fields) == 0 {
return "", make(map[string]string), "", nil
}
// decode the name and tags
name, tags, field,... | go | func (p *GraphiteParser) ApplyTemplate(line string) (string, map[string]string, string, error) {
// Break line into fields (name, value, timestamp), only name is used
fields := strings.Fields(line)
if len(fields) == 0 {
return "", make(map[string]string), "", nil
}
// decode the name and tags
name, tags, field,... | [
"func",
"(",
"p",
"*",
"GraphiteParser",
")",
"ApplyTemplate",
"(",
"line",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"string",
",",
"error",
")",
"{",
"// Break line into fields (name, value, timestamp), only name is used",
"fie... | // ApplyTemplate extracts the template fields from the given line and
// returns the measurement name and tags. | [
"ApplyTemplate",
"extracts",
"the",
"template",
"fields",
"from",
"the",
"given",
"line",
"and",
"returns",
"the",
"measurement",
"name",
"and",
"tags",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/parsers/graphite/parser.go#L174-L191 |
128,381 | influxdata/telegraf | plugins/inputs/phpfpm/fcgi_client.go | newFcgiClient | func newFcgiClient(h string, args ...interface{}) (*conn, error) {
var con net.Conn
if len(args) != 1 {
return nil, errors.New("fcgi: not enough params")
}
var err error
switch args[0].(type) {
case int:
addr := h + ":" + strconv.FormatInt(int64(args[0].(int)), 10)
con, err = net.Dial("tcp", addr)
case st... | go | func newFcgiClient(h string, args ...interface{}) (*conn, error) {
var con net.Conn
if len(args) != 1 {
return nil, errors.New("fcgi: not enough params")
}
var err error
switch args[0].(type) {
case int:
addr := h + ":" + strconv.FormatInt(int64(args[0].(int)), 10)
con, err = net.Dial("tcp", addr)
case st... | [
"func",
"newFcgiClient",
"(",
"h",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"conn",
",",
"error",
")",
"{",
"var",
"con",
"net",
".",
"Conn",
"\n",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
"{",
"return",
"nil",
",",
... | // Create an fcgi client | [
"Create",
"an",
"fcgi",
"client"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/phpfpm/fcgi_client.go#L12-L34 |
128,382 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | name | func (m *metric) name() string {
buf := bytes.Buffer{}
for i := len(m.pathStack) - 1; i >= 0; i-- {
if buf.Len() > 0 {
buf.WriteString(".")
}
buf.WriteString(m.pathStack[i])
}
return buf.String()
} | go | func (m *metric) name() string {
buf := bytes.Buffer{}
for i := len(m.pathStack) - 1; i >= 0; i-- {
if buf.Len() > 0 {
buf.WriteString(".")
}
buf.WriteString(m.pathStack[i])
}
return buf.String()
} | [
"func",
"(",
"m",
"*",
"metric",
")",
"name",
"(",
")",
"string",
"{",
"buf",
":=",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"for",
"i",
":=",
"len",
"(",
"m",
".",
"pathStack",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
... | // Pops names of pathStack to build the flattened name for a metric | [
"Pops",
"names",
"of",
"pathStack",
"to",
"build",
"the",
"flattened",
"name",
"for",
"a",
"metric"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L230-L239 |
128,383 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | newTaggedMetricMap | func newTaggedMetricMap(data map[string]interface{}) taggedMetricMap {
tmm := make(taggedMetricMap)
for tag, datapoints := range data {
mm := make(metricMap)
for _, m := range flatten(datapoints) {
mm[m.name()] = m.value
}
tmm[tag] = mm
}
return tmm
} | go | func newTaggedMetricMap(data map[string]interface{}) taggedMetricMap {
tmm := make(taggedMetricMap)
for tag, datapoints := range data {
mm := make(metricMap)
for _, m := range flatten(datapoints) {
mm[m.name()] = m.value
}
tmm[tag] = mm
}
return tmm
} | [
"func",
"newTaggedMetricMap",
"(",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"taggedMetricMap",
"{",
"tmm",
":=",
"make",
"(",
"taggedMetricMap",
")",
"\n",
"for",
"tag",
",",
"datapoints",
":=",
"range",
"data",
"{",
"mm",
":=",
"ma... | // Builds a TaggedMetricMap out of a generic string map.
// The top-level key is used as a tag and all sub-keys are flattened into metrics | [
"Builds",
"a",
"TaggedMetricMap",
"out",
"of",
"a",
"generic",
"string",
"map",
".",
"The",
"top",
"-",
"level",
"key",
"is",
"used",
"as",
"a",
"tag",
"and",
"all",
"sub",
"-",
"keys",
"are",
"flattened",
"into",
"metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L259-L269 |
128,384 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | exec | func (c *Ceph) exec(command string) (string, error) {
cmdArgs := []string{"--conf", c.CephConfig, "--name", c.CephUser, "--format", "json"}
cmdArgs = append(cmdArgs, strings.Split(command, " ")...)
cmd := exec.Command(c.CephBinary, cmdArgs...)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != n... | go | func (c *Ceph) exec(command string) (string, error) {
cmdArgs := []string{"--conf", c.CephConfig, "--name", c.CephUser, "--format", "json"}
cmdArgs = append(cmdArgs, strings.Split(command, " ")...)
cmd := exec.Command(c.CephBinary, cmdArgs...)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != n... | [
"func",
"(",
"c",
"*",
"Ceph",
")",
"exec",
"(",
"command",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"cmdArgs",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"c",
".",
"CephConfig",
",",
"\"",
"\"",
",",
"c",
".",
"CephUser",
","... | // exec executes the 'ceph' command with the supplied arguments, returning JSON formatted output | [
"exec",
"executes",
"the",
"ceph",
"command",
"with",
"the",
"supplied",
"arguments",
"returning",
"JSON",
"formatted",
"output"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L297-L318 |
128,385 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeStatus | func decodeStatus(acc telegraf.Accumulator, input string) error {
data := &CephStatus{}
if err := json.Unmarshal([]byte(input), data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
decoders := []func(telegraf.Accumulator, *CephStatus) error{
decodeStatusHealth,
decodeStatusOs... | go | func decodeStatus(acc telegraf.Accumulator, input string) error {
data := &CephStatus{}
if err := json.Unmarshal([]byte(input), data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
decoders := []func(telegraf.Accumulator, *CephStatus) error{
decodeStatusHealth,
decodeStatusOs... | [
"func",
"decodeStatus",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"input",
"string",
")",
"error",
"{",
"data",
":=",
"&",
"CephStatus",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"input",
")",
","... | // decodeStatus decodes the output of 'ceph -s' | [
"decodeStatus",
"decodes",
"the",
"output",
"of",
"ceph",
"-",
"s"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L357-L377 |
128,386 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeStatusHealth | func decodeStatusHealth(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"status": data.Health.Status,
"overall_status": data.Health.OverallStatus,
}
acc.AddFields("ceph_health", fields, map[string]string{})
return nil
} | go | func decodeStatusHealth(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"status": data.Health.Status,
"overall_status": data.Health.OverallStatus,
}
acc.AddFields("ceph_health", fields, map[string]string{})
return nil
} | [
"func",
"decodeStatusHealth",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"data",
"*",
"CephStatus",
")",
"error",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"data",
".",
"Health",
".",
"Status",
"... | // decodeStatusHealth decodes the health portion of the output of 'ceph status' | [
"decodeStatusHealth",
"decodes",
"the",
"health",
"portion",
"of",
"the",
"output",
"of",
"ceph",
"status"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L380-L387 |
128,387 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeStatusOsdmap | func decodeStatusOsdmap(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"epoch": data.OSDMap.OSDMap.Epoch,
"num_osds": data.OSDMap.OSDMap.NumOSDs,
"num_up_osds": data.OSDMap.OSDMap.NumUpOSDs,
"num_in_osds": data.OSDMap.OSDMap.NumInOSDs,
"full... | go | func decodeStatusOsdmap(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"epoch": data.OSDMap.OSDMap.Epoch,
"num_osds": data.OSDMap.OSDMap.NumOSDs,
"num_up_osds": data.OSDMap.OSDMap.NumUpOSDs,
"num_in_osds": data.OSDMap.OSDMap.NumInOSDs,
"full... | [
"func",
"decodeStatusOsdmap",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"data",
"*",
"CephStatus",
")",
"error",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"data",
".",
"OSDMap",
".",
"OSDMap",
"... | // decodeStatusOsdmap decodes the OSD map portion of the output of 'ceph -s' | [
"decodeStatusOsdmap",
"decodes",
"the",
"OSD",
"map",
"portion",
"of",
"the",
"output",
"of",
"ceph",
"-",
"s"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L390-L402 |
128,388 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeStatusPgmap | func decodeStatusPgmap(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"version": data.PGMap.Version,
"num_pgs": data.PGMap.NumPGs,
"data_bytes": data.PGMap.DataBytes,
"bytes_used": data.PGMap.BytesUsed,
"bytes_avail": data.PGMap.BytesA... | go | func decodeStatusPgmap(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"version": data.PGMap.Version,
"num_pgs": data.PGMap.NumPGs,
"data_bytes": data.PGMap.DataBytes,
"bytes_used": data.PGMap.BytesUsed,
"bytes_avail": data.PGMap.BytesA... | [
"func",
"decodeStatusPgmap",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"data",
"*",
"CephStatus",
")",
"error",
"{",
"fields",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
":",
"data",
".",
"PGMap",
".",
"Version",
",... | // decodeStatusPgmap decodes the PG map portion of the output of 'ceph -s' | [
"decodeStatusPgmap",
"decodes",
"the",
"PG",
"map",
"portion",
"of",
"the",
"output",
"of",
"ceph",
"-",
"s"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L405-L421 |
128,389 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeStatusPgmapState | func decodeStatusPgmapState(acc telegraf.Accumulator, data *CephStatus) error {
for _, pgState := range data.PGMap.PGsByState {
tags := map[string]string{
"state": pgState.StateName,
}
fields := map[string]interface{}{
"count": pgState.Count,
}
acc.AddFields("ceph_pgmap_state", fields, tags)
}
return... | go | func decodeStatusPgmapState(acc telegraf.Accumulator, data *CephStatus) error {
for _, pgState := range data.PGMap.PGsByState {
tags := map[string]string{
"state": pgState.StateName,
}
fields := map[string]interface{}{
"count": pgState.Count,
}
acc.AddFields("ceph_pgmap_state", fields, tags)
}
return... | [
"func",
"decodeStatusPgmapState",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"data",
"*",
"CephStatus",
")",
"error",
"{",
"for",
"_",
",",
"pgState",
":=",
"range",
"data",
".",
"PGMap",
".",
"PGsByState",
"{",
"tags",
":=",
"map",
"[",
"string",
... | // decodeStatusPgmapState decodes the PG map state portion of the output of 'ceph -s' | [
"decodeStatusPgmapState",
"decodes",
"the",
"PG",
"map",
"state",
"portion",
"of",
"the",
"output",
"of",
"ceph",
"-",
"s"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L424-L435 |
128,390 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeDf | func decodeDf(acc telegraf.Accumulator, input string) error {
data := &CephDf{}
if err := json.Unmarshal([]byte(input), data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
// ceph.usage: records global utilization and number of objects
fields := map[string]interface{}{
"total... | go | func decodeDf(acc telegraf.Accumulator, input string) error {
data := &CephDf{}
if err := json.Unmarshal([]byte(input), data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
// ceph.usage: records global utilization and number of objects
fields := map[string]interface{}{
"total... | [
"func",
"decodeDf",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"input",
"string",
")",
"error",
"{",
"data",
":=",
"&",
"CephDf",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"input",
")",
",",
"dat... | // decodeDf decodes the output of 'ceph df' | [
"decodeDf",
"decodes",
"the",
"output",
"of",
"ceph",
"df"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L460-L493 |
128,391 | influxdata/telegraf | plugins/inputs/ceph/ceph.go | decodeOsdPoolStats | func decodeOsdPoolStats(acc telegraf.Accumulator, input string) error {
data := CephOSDPoolStats{}
if err := json.Unmarshal([]byte(input), &data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
// ceph.pool.stats: records pre pool IO and recovery throughput
for _, pool := range d... | go | func decodeOsdPoolStats(acc telegraf.Accumulator, input string) error {
data := CephOSDPoolStats{}
if err := json.Unmarshal([]byte(input), &data); err != nil {
return fmt.Errorf("failed to parse json: '%s': %v", input, err)
}
// ceph.pool.stats: records pre pool IO and recovery throughput
for _, pool := range d... | [
"func",
"decodeOsdPoolStats",
"(",
"acc",
"telegraf",
".",
"Accumulator",
",",
"input",
"string",
")",
"error",
"{",
"data",
":=",
"CephOSDPoolStats",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"input",
")",
... | // decodeOsdPoolStats decodes the output of 'ceph osd pool stats' | [
"decodeOsdPoolStats",
"decodes",
"the",
"output",
"of",
"ceph",
"osd",
"pool",
"stats"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ceph/ceph.go#L513-L538 |
128,392 | influxdata/telegraf | plugins/inputs/prometheus/parser.go | Parse | func Parse(buf []byte, header http.Header) ([]telegraf.Metric, error) {
var metrics []telegraf.Metric
var parser expfmt.TextParser
// parse even if the buffer begins with a newline
buf = bytes.TrimPrefix(buf, []byte("\n"))
// Read raw data
buffer := bytes.NewBuffer(buf)
reader := bufio.NewReader(buffer)
mediat... | go | func Parse(buf []byte, header http.Header) ([]telegraf.Metric, error) {
var metrics []telegraf.Metric
var parser expfmt.TextParser
// parse even if the buffer begins with a newline
buf = bytes.TrimPrefix(buf, []byte("\n"))
// Read raw data
buffer := bytes.NewBuffer(buf)
reader := bufio.NewReader(buffer)
mediat... | [
"func",
"Parse",
"(",
"buf",
"[",
"]",
"byte",
",",
"header",
"http",
".",
"Header",
")",
"(",
"[",
"]",
"telegraf",
".",
"Metric",
",",
"error",
")",
"{",
"var",
"metrics",
"[",
"]",
"telegraf",
".",
"Metric",
"\n",
"var",
"parser",
"expfmt",
".",... | // Parse returns a slice of Metrics from a text representation of a
// metrics | [
"Parse",
"returns",
"a",
"slice",
"of",
"Metrics",
"from",
"a",
"text",
"representation",
"of",
"a",
"metrics"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/prometheus/parser.go#L26-L98 |
128,393 | influxdata/telegraf | plugins/inputs/jti_openconfig_telemetry/collection.go | IsAvailable | func (a CollectionByKeys) IsAvailable(tags map[string]string) *DataGroup {
sort.Sort(CollectionByKeys(a))
// Iterate through all the groups and see if we have group with these tags
for _, group := range a {
// Since already sorted, match with only groups with N keys
if group.numKeys < len(tags) {
continue
... | go | func (a CollectionByKeys) IsAvailable(tags map[string]string) *DataGroup {
sort.Sort(CollectionByKeys(a))
// Iterate through all the groups and see if we have group with these tags
for _, group := range a {
// Since already sorted, match with only groups with N keys
if group.numKeys < len(tags) {
continue
... | [
"func",
"(",
"a",
"CollectionByKeys",
")",
"IsAvailable",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"*",
"DataGroup",
"{",
"sort",
".",
"Sort",
"(",
"CollectionByKeys",
"(",
"a",
")",
")",
"\n\n",
"// Iterate through all the groups and see if we hav... | // Checks to see if there is already a group with these tags and returns its index. Returns -1 if unavailable. | [
"Checks",
"to",
"see",
"if",
"there",
"is",
"already",
"a",
"group",
"with",
"these",
"tags",
"and",
"returns",
"its",
"index",
".",
"Returns",
"-",
"1",
"if",
"unavailable",
"."
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jti_openconfig_telemetry/collection.go#L19-L49 |
128,394 | influxdata/telegraf | plugins/inputs/jti_openconfig_telemetry/collection.go | Insert | func (a CollectionByKeys) Insert(tags map[string]string, data map[string]interface{}) CollectionByKeys {
// If there is already a group with this set of tags, insert into it. Otherwise create a new group and insert
if group := a.IsAvailable(tags); group != nil {
for k, v := range data {
group.data[k] = v
}
} ... | go | func (a CollectionByKeys) Insert(tags map[string]string, data map[string]interface{}) CollectionByKeys {
// If there is already a group with this set of tags, insert into it. Otherwise create a new group and insert
if group := a.IsAvailable(tags); group != nil {
for k, v := range data {
group.data[k] = v
}
} ... | [
"func",
"(",
"a",
"CollectionByKeys",
")",
"Insert",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"CollectionByKeys",
"{",
"// If there is already a group with this set of tags, insert into it.... | // Inserts into already existing group or creates a new group | [
"Inserts",
"into",
"already",
"existing",
"group",
"or",
"creates",
"a",
"new",
"group"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/jti_openconfig_telemetry/collection.go#L52-L63 |
128,395 | influxdata/telegraf | plugins/inputs/procstat/procstat.go | updateProcesses | func (p *Procstat) updateProcesses(pids []PID, tags map[string]string, prevInfo map[PID]Process) (map[PID]Process, error) {
procs := make(map[PID]Process, len(prevInfo))
for _, pid := range pids {
info, ok := prevInfo[pid]
if ok {
// Assumption: if a process has no name, it probably does not exist
if name,... | go | func (p *Procstat) updateProcesses(pids []PID, tags map[string]string, prevInfo map[PID]Process) (map[PID]Process, error) {
procs := make(map[PID]Process, len(prevInfo))
for _, pid := range pids {
info, ok := prevInfo[pid]
if ok {
// Assumption: if a process has no name, it probably does not exist
if name,... | [
"func",
"(",
"p",
"*",
"Procstat",
")",
"updateProcesses",
"(",
"pids",
"[",
"]",
"PID",
",",
"tags",
"map",
"[",
"string",
"]",
"string",
",",
"prevInfo",
"map",
"[",
"PID",
"]",
"Process",
")",
"(",
"map",
"[",
"PID",
"]",
"Process",
",",
"error"... | // Update monitored Processes | [
"Update",
"monitored",
"Processes"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/procstat.go#L292-L330 |
128,396 | influxdata/telegraf | plugins/inputs/procstat/procstat.go | getPIDFinder | func (p *Procstat) getPIDFinder() (PIDFinder, error) {
if p.finder == nil {
f, err := p.createPIDFinder()
if err != nil {
return nil, err
}
p.finder = f
}
return p.finder, nil
} | go | func (p *Procstat) getPIDFinder() (PIDFinder, error) {
if p.finder == nil {
f, err := p.createPIDFinder()
if err != nil {
return nil, err
}
p.finder = f
}
return p.finder, nil
} | [
"func",
"(",
"p",
"*",
"Procstat",
")",
"getPIDFinder",
"(",
")",
"(",
"PIDFinder",
",",
"error",
")",
"{",
"if",
"p",
".",
"finder",
"==",
"nil",
"{",
"f",
",",
"err",
":=",
"p",
".",
"createPIDFinder",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Create and return PIDGatherer lazily | [
"Create",
"and",
"return",
"PIDGatherer",
"lazily"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/procstat.go#L333-L342 |
128,397 | influxdata/telegraf | plugins/inputs/procstat/procstat.go | findPids | func (p *Procstat) findPids(acc telegraf.Accumulator) ([]PID, map[string]string, error) {
var pids []PID
tags := make(map[string]string)
var err error
f, err := p.getPIDFinder()
if err != nil {
return nil, nil, err
}
if p.PidFile != "" {
pids, err = f.PidFile(p.PidFile)
tags = map[string]string{"pidfile"... | go | func (p *Procstat) findPids(acc telegraf.Accumulator) ([]PID, map[string]string, error) {
var pids []PID
tags := make(map[string]string)
var err error
f, err := p.getPIDFinder()
if err != nil {
return nil, nil, err
}
if p.PidFile != "" {
pids, err = f.PidFile(p.PidFile)
tags = map[string]string{"pidfile"... | [
"func",
"(",
"p",
"*",
"Procstat",
")",
"findPids",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"(",
"[",
"]",
"PID",
",",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"pids",
"[",
"]",
"PID",
"\n",
"tags",
":=",
"make... | // Get matching PIDs and their initial tags | [
"Get",
"matching",
"PIDs",
"and",
"their",
"initial",
"tags"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/procstat/procstat.go#L345-L381 |
128,398 | influxdata/telegraf | plugins/inputs/ipmi_sensor/ipmi.go | Gather | func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
if len(m.Path) == 0 {
return fmt.Errorf("ipmitool not found: verify that ipmitool is installed and that ipmitool is in your PATH")
}
if len(m.Servers) > 0 {
wg := sync.WaitGroup{}
for _, server := range m.Servers {
wg.Add(1)
go func(a telegraf.Accu... | go | func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
if len(m.Path) == 0 {
return fmt.Errorf("ipmitool not found: verify that ipmitool is installed and that ipmitool is in your PATH")
}
if len(m.Servers) > 0 {
wg := sync.WaitGroup{}
for _, server := range m.Servers {
wg.Add(1)
go func(a telegraf.Accu... | [
"func",
"(",
"m",
"*",
"Ipmi",
")",
"Gather",
"(",
"acc",
"telegraf",
".",
"Accumulator",
")",
"error",
"{",
"if",
"len",
"(",
"m",
".",
"Path",
")",
"==",
"0",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",... | // Gather is the main execution function for the plugin | [
"Gather",
"is",
"the",
"main",
"execution",
"function",
"for",
"the",
"plugin"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ipmi_sensor/ipmi.go#L75-L101 |
128,399 | influxdata/telegraf | plugins/inputs/ipmi_sensor/ipmi.go | extractFieldsFromRegex | func extractFieldsFromRegex(re *regexp.Regexp, input string) map[string]string {
submatches := re.FindStringSubmatch(input)
results := make(map[string]string)
subexpNames := re.SubexpNames()
if len(subexpNames) > len(submatches) {
log.Printf("D! No matches found in '%s'", input)
return results
}
for i, name :... | go | func extractFieldsFromRegex(re *regexp.Regexp, input string) map[string]string {
submatches := re.FindStringSubmatch(input)
results := make(map[string]string)
subexpNames := re.SubexpNames()
if len(subexpNames) > len(submatches) {
log.Printf("D! No matches found in '%s'", input)
return results
}
for i, name :... | [
"func",
"extractFieldsFromRegex",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
",",
"input",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"submatches",
":=",
"re",
".",
"FindStringSubmatch",
"(",
"input",
")",
"\n",
"results",
":=",
"make",
"(",
... | // extractFieldsFromRegex consumes a regex with named capture groups and returns a kvp map of strings with the results | [
"extractFieldsFromRegex",
"consumes",
"a",
"regex",
"with",
"named",
"capture",
"groups",
"and",
"returns",
"a",
"kvp",
"map",
"of",
"strings",
"with",
"the",
"results"
] | 6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1 | https://github.com/influxdata/telegraf/blob/6a73ad56ae733953e7c1108d9f9b5e6fd699c0b1/plugins/inputs/ipmi_sensor/ipmi.go#L229-L243 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.