Merge branch 'master' into patch-1
This commit is contained in:
commit
1f78983f96
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -48,7 +48,15 @@ based on _prefix_ in addition to globs. This means that a filter like
|
||||||
- disque: `host -> disque_host`
|
- disque: `host -> disque_host`
|
||||||
- rethinkdb: `host -> rethinkdb_host`
|
- rethinkdb: `host -> rethinkdb_host`
|
||||||
|
|
||||||
- **Breaking Change**: The `win_perf_counters` input has been changed to sanitize field names, replacing `/Sec` and `/sec` with `_persec`, as well as spaces with underscores. This is needed because Graphite doesn't like slashes and spaces, and was failing to accept metrics that had them. The `/[sS]ec` -> `_persec` is just to make things clearer and uniform.
|
- **Breaking Change**: The `win_perf_counters` input has been changed to
|
||||||
|
sanitize field names, replacing `/Sec` and `/sec` with `_persec`, as well as
|
||||||
|
spaces with underscores. This is needed because Graphite doesn't like slashes
|
||||||
|
and spaces, and was failing to accept metrics that had them.
|
||||||
|
The `/[sS]ec` -> `_persec` is just to make things clearer and uniform.
|
||||||
|
|
||||||
|
- **Breaking Change**: snmp plugin. The `host` tag of the snmp plugin has been
|
||||||
|
changed to the `snmp_host` tag.
|
||||||
|
|
||||||
- The `disk` input plugin can now be configured with the `HOST_MOUNT_PREFIX` environment variable.
|
- The `disk` input plugin can now be configured with the `HOST_MOUNT_PREFIX` environment variable.
|
||||||
This value is prepended to any mountpaths discovered before retrieving stats.
|
This value is prepended to any mountpaths discovered before retrieving stats.
|
||||||
It is not included on the report path. This is necessary for reporting host disk stats when running from within a container.
|
It is not included on the report path. This is necessary for reporting host disk stats when running from within a container.
|
||||||
|
|
|
@ -638,8 +638,8 @@
|
||||||
#
|
#
|
||||||
# ## If no servers are specified, then default to 127.0.0.1:1936
|
# ## If no servers are specified, then default to 127.0.0.1:1936
|
||||||
# servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"]
|
# servers = ["http://myhaproxy.com:1936", "http://anotherhaproxy.com:1936"]
|
||||||
# ## Or you can also use local socket(not work yet)
|
# ## Or you can also use local socket
|
||||||
# ## servers = ["socket://run/haproxy/admin.sock"]
|
# ## servers = ["socket:/run/haproxy/admin.sock"]
|
||||||
|
|
||||||
|
|
||||||
# # HTTP/HTTPS request given an address a method and a timeout
|
# # HTTP/HTTPS request given an address a method and a timeout
|
||||||
|
|
|
@ -26,9 +26,6 @@ type Snmp struct {
|
||||||
nameToOid map[string]string
|
nameToOid map[string]string
|
||||||
initNode Node
|
initNode Node
|
||||||
subTableMap map[string]Subtable
|
subTableMap map[string]Subtable
|
||||||
|
|
||||||
// TODO change as unexportable
|
|
||||||
//OidInstanceMapping map[string]map[string]string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Host struct {
|
type Host struct {
|
||||||
|
@ -53,6 +50,8 @@ type Host struct {
|
||||||
// array of processed oids
|
// array of processed oids
|
||||||
// to skip oid duplication
|
// to skip oid duplication
|
||||||
processedOids []string
|
processedOids []string
|
||||||
|
|
||||||
|
OidInstanceMapping map[string]map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Table struct {
|
type Table struct {
|
||||||
|
@ -116,9 +115,6 @@ type Node struct {
|
||||||
subnodes map[string]Node
|
subnodes map[string]Node
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move this var to snmp struct
|
|
||||||
var OidInstanceMapping = make(map[string]map[string]string)
|
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
## Use 'oids.txt' file to translate oids to names
|
## Use 'oids.txt' file to translate oids to names
|
||||||
## To generate 'oids.txt' you need to run:
|
## To generate 'oids.txt' you need to run:
|
||||||
|
@ -396,7 +392,7 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error {
|
||||||
// TODO save mapping and computed oids
|
// TODO save mapping and computed oids
|
||||||
// to do it only the first time
|
// to do it only the first time
|
||||||
// only if len(s.OidInstanceMapping) == 0
|
// only if len(s.OidInstanceMapping) == 0
|
||||||
if len(OidInstanceMapping) >= 0 {
|
if len(host.OidInstanceMapping) >= 0 {
|
||||||
if err := host.SNMPMap(acc, s.nameToOid, s.subTableMap); err != nil {
|
if err := host.SNMPMap(acc, s.nameToOid, s.subTableMap); err != nil {
|
||||||
log.Printf("SNMP Mapping error for host '%s': %s", host.Address, err)
|
log.Printf("SNMP Mapping error for host '%s': %s", host.Address, err)
|
||||||
continue
|
continue
|
||||||
|
@ -413,7 +409,14 @@ func (s *Snmp) Gather(acc telegraf.Accumulator) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) SNMPMap(acc telegraf.Accumulator, nameToOid map[string]string, subTableMap map[string]Subtable) error {
|
func (h *Host) SNMPMap(
|
||||||
|
acc telegraf.Accumulator,
|
||||||
|
nameToOid map[string]string,
|
||||||
|
subTableMap map[string]Subtable,
|
||||||
|
) error {
|
||||||
|
if h.OidInstanceMapping == nil {
|
||||||
|
h.OidInstanceMapping = make(map[string]map[string]string)
|
||||||
|
}
|
||||||
// Get snmp client
|
// Get snmp client
|
||||||
snmpClient, err := h.GetSNMPClient()
|
snmpClient, err := h.GetSNMPClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -523,11 +526,11 @@ func (h *Host) SNMPMap(acc telegraf.Accumulator, nameToOid map[string]string, su
|
||||||
|
|
||||||
// Building mapping table
|
// Building mapping table
|
||||||
mapping := map[string]string{strings.Trim(key, "."): string(variable.Value.([]byte))}
|
mapping := map[string]string{strings.Trim(key, "."): string(variable.Value.([]byte))}
|
||||||
_, exists := OidInstanceMapping[table.oid]
|
_, exists := h.OidInstanceMapping[table.oid]
|
||||||
if exists {
|
if exists {
|
||||||
OidInstanceMapping[table.oid][strings.Trim(key, ".")] = string(variable.Value.([]byte))
|
h.OidInstanceMapping[table.oid][strings.Trim(key, ".")] = string(variable.Value.([]byte))
|
||||||
} else {
|
} else {
|
||||||
OidInstanceMapping[table.oid] = mapping
|
h.OidInstanceMapping[table.oid] = mapping
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add table oid in bulk oid list
|
// Add table oid in bulk oid list
|
||||||
|
@ -720,7 +723,12 @@ func (h *Host) GetSNMPClient() (*gosnmp.GoSNMP, error) {
|
||||||
return snmpClient, nil
|
return snmpClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Host) HandleResponse(oids map[string]Data, result *gosnmp.SnmpPacket, acc telegraf.Accumulator, initNode Node) (string, error) {
|
func (h *Host) HandleResponse(
|
||||||
|
oids map[string]Data,
|
||||||
|
result *gosnmp.SnmpPacket,
|
||||||
|
acc telegraf.Accumulator,
|
||||||
|
initNode Node,
|
||||||
|
) (string, error) {
|
||||||
var lastOid string
|
var lastOid string
|
||||||
for _, variable := range result.Variables {
|
for _, variable := range result.Variables {
|
||||||
lastOid = variable.Name
|
lastOid = variable.Name
|
||||||
|
@ -755,7 +763,7 @@ func (h *Host) HandleResponse(oids map[string]Data, result *gosnmp.SnmpPacket, a
|
||||||
strings.Split(string(variable.Name[1:]), "."))
|
strings.Split(string(variable.Name[1:]), "."))
|
||||||
// Set instance tag
|
// Set instance tag
|
||||||
// From mapping table
|
// From mapping table
|
||||||
mapping, inMappingNoSubTable := OidInstanceMapping[oid_key]
|
mapping, inMappingNoSubTable := h.OidInstanceMapping[oid_key]
|
||||||
if inMappingNoSubTable {
|
if inMappingNoSubTable {
|
||||||
// filter if the instance in not in
|
// filter if the instance in not in
|
||||||
// OidInstanceMapping mapping map
|
// OidInstanceMapping mapping map
|
||||||
|
@ -784,7 +792,7 @@ func (h *Host) HandleResponse(oids map[string]Data, result *gosnmp.SnmpPacket, a
|
||||||
// Because the result oid is equal to inputs.snmp.get section
|
// Because the result oid is equal to inputs.snmp.get section
|
||||||
field_name = oid.Name
|
field_name = oid.Name
|
||||||
}
|
}
|
||||||
tags["host"], _, _ = net.SplitHostPort(h.Address)
|
tags["snmp_host"], _, _ = net.SplitHostPort(h.Address)
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
fields[string(field_name)] = variable.Value
|
fields[string(field_name)] = variable.Value
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ func TestSNMPGet1(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ func TestSNMPGet2(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ func TestSNMPGet3(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ func TestSNMPEasyGet4(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ func TestSNMPEasyGet4(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ func TestSNMPEasyGet5(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ func TestSNMPEasyGet5(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ func TestSNMPEasyGet6(t *testing.T) {
|
||||||
},
|
},
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ func TestSNMPBulk1(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ func TestSNMPBulk1(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "2",
|
"instance": "2",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ func TestSNMPBulk1(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "3",
|
"instance": "3",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ func TestSNMPBulk1(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "36",
|
"instance": "36",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ func dTestSNMPBulk2(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ func dTestSNMPBulk2(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "2",
|
"instance": "2",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ func dTestSNMPBulk2(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "3",
|
"instance": "3",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ func dTestSNMPBulk2(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"unit": "octets",
|
"unit": "octets",
|
||||||
"instance": "36",
|
"instance": "36",
|
||||||
"host": testutil.GetLocalHost(),
|
"snmp_host": testutil.GetLocalHost(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue