parent
56aa89e5c8
commit
ae6a5d2255
|
@ -76,6 +76,7 @@ be deprecated eventually.
|
||||||
- [#2215](https://github.com/influxdata/telegraf/issues/2215): Iptables input: document better that rules without a comment are ignored.
|
- [#2215](https://github.com/influxdata/telegraf/issues/2215): Iptables input: document better that rules without a comment are ignored.
|
||||||
- [#2483](https://github.com/influxdata/telegraf/pull/2483): Fix win_perf_counters capping values at 100.
|
- [#2483](https://github.com/influxdata/telegraf/pull/2483): Fix win_perf_counters capping values at 100.
|
||||||
- [#2498](https://github.com/influxdata/telegraf/pull/2498): Exporting Ipmi.Path to be set by config.
|
- [#2498](https://github.com/influxdata/telegraf/pull/2498): Exporting Ipmi.Path to be set by config.
|
||||||
|
- [#2500](https://github.com/influxdata/telegraf/pull/2500): Remove warning if parse empty content
|
||||||
|
|
||||||
## v1.2.1 [2017-02-01]
|
## v1.2.1 [2017-02-01]
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@ func Parse(buf []byte) ([]telegraf.Metric, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
|
func ParseWithDefaultTime(buf []byte, t time.Time) ([]telegraf.Metric, error) {
|
||||||
|
if len(buf) == 0 {
|
||||||
|
return []telegraf.Metric{}, nil
|
||||||
|
}
|
||||||
if len(buf) <= 6 {
|
if len(buf) <= 6 {
|
||||||
return []telegraf.Metric{}, makeError("buffer too short", buf, 0)
|
return []telegraf.Metric{}, makeError("buffer too short", buf, 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ const malformedJson = `
|
||||||
`
|
`
|
||||||
|
|
||||||
const lineProtocol = "cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1\n"
|
const lineProtocol = "cpu,host=foo,datacenter=us-east usage_idle=99,usage_busy=1\n"
|
||||||
|
const lineProtocolEmpty = ""
|
||||||
|
const lineProtocolShort = "ab"
|
||||||
|
|
||||||
const lineProtocolMulti = `
|
const lineProtocolMulti = `
|
||||||
cpu,cpu=cpu0,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
cpu,cpu=cpu0,host=foo,datacenter=us-east usage_idle=99,usage_busy=1
|
||||||
|
@ -167,6 +169,33 @@ func TestLineProtocolParse(t *testing.T) {
|
||||||
acc.AssertContainsTaggedFields(t, "cpu", fields, tags)
|
acc.AssertContainsTaggedFields(t, "cpu", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLineProtocolEmptyParse(t *testing.T) {
|
||||||
|
parser, _ := parsers.NewInfluxParser()
|
||||||
|
e := &Exec{
|
||||||
|
runner: newRunnerMock([]byte(lineProtocolEmpty), nil),
|
||||||
|
Commands: []string{"line-protocol"},
|
||||||
|
parser: parser,
|
||||||
|
}
|
||||||
|
|
||||||
|
var acc testutil.Accumulator
|
||||||
|
err := e.Gather(&acc)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLineProtocolShortParse(t *testing.T) {
|
||||||
|
parser, _ := parsers.NewInfluxParser()
|
||||||
|
e := &Exec{
|
||||||
|
runner: newRunnerMock([]byte(lineProtocolShort), nil),
|
||||||
|
Commands: []string{"line-protocol"},
|
||||||
|
parser: parser,
|
||||||
|
}
|
||||||
|
|
||||||
|
var acc testutil.Accumulator
|
||||||
|
err := e.Gather(&acc)
|
||||||
|
require.Error(t, err)
|
||||||
|
assert.Contains(t, err.Error(), "buffer too short", "A buffer too short error was expected")
|
||||||
|
}
|
||||||
|
|
||||||
func TestLineProtocolParseMultiple(t *testing.T) {
|
func TestLineProtocolParseMultiple(t *testing.T) {
|
||||||
parser, _ := parsers.NewInfluxParser()
|
parser, _ := parsers.NewInfluxParser()
|
||||||
e := &Exec{
|
e := &Exec{
|
||||||
|
|
Loading…
Reference in New Issue