Fix formatting.
This commit is contained in:
parent
4fc43dd55e
commit
a9f039e6a4
|
@ -40,8 +40,8 @@ import (
|
|||
_ "github.com/influxdata/telegraf/plugins/inputs/mysql"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nats_consumer"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/net_response"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nginx"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nfsclient"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nginx"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nsq"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nsq_consumer"
|
||||
_ "github.com/influxdata/telegraf/plugins/inputs/nstat"
|
||||
|
|
|
@ -2,11 +2,11 @@ package nfsclient
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"fmt"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
|
@ -72,7 +72,7 @@ var bytesFields = []string{
|
|||
}
|
||||
|
||||
var xprtudpFields = []string{
|
||||
// "port",
|
||||
// "port",
|
||||
"bind_count",
|
||||
"rpcsends",
|
||||
"rpcreceives",
|
||||
|
@ -82,7 +82,7 @@ var xprtudpFields = []string{
|
|||
}
|
||||
|
||||
var xprttcpFields = []string{
|
||||
// "port",
|
||||
// "port",
|
||||
"bind_count",
|
||||
"connect_count",
|
||||
"connect_time",
|
||||
|
@ -181,7 +181,7 @@ var nfs4Fields = []string{
|
|||
"CLONE",
|
||||
}
|
||||
|
||||
var nfsopFields = []string {
|
||||
var nfsopFields = []string{
|
||||
"ops",
|
||||
"trans",
|
||||
"timeouts",
|
||||
|
@ -247,25 +247,27 @@ func (n *NFSCLIENT) parseData(mountpoint string, export string, version string,
|
|||
var fields = make(map[string]interface{})
|
||||
|
||||
if first == "events" {
|
||||
for i,t := range eventsFields {
|
||||
for i, t := range eventsFields {
|
||||
fields[t] = nline[i]
|
||||
}
|
||||
acc.AddFields("nfs_events", fields, tags)
|
||||
} else if first == "bytes" {
|
||||
for i,t := range bytesFields {
|
||||
for i, t := range bytesFields {
|
||||
fields[t] = nline[i]
|
||||
}
|
||||
acc.AddFields("nfs_bytes", fields, tags)
|
||||
} else if first == "xprt" {
|
||||
switch line[1] {
|
||||
case "tcp": {
|
||||
for i,t := range xprttcpFields {
|
||||
case "tcp":
|
||||
{
|
||||
for i, t := range xprttcpFields {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprttcp", fields, tags)
|
||||
}
|
||||
case "udp": {
|
||||
for i,t := range xprtudpFields {
|
||||
case "udp":
|
||||
{
|
||||
for i, t := range xprtudpFields {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprtudp", fields, tags)
|
||||
|
@ -273,7 +275,7 @@ func (n *NFSCLIENT) parseData(mountpoint string, export string, version string,
|
|||
}
|
||||
} else if version == "3" {
|
||||
if In(nfs3Fields, first) {
|
||||
for i , t := range nline {
|
||||
for i, t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
|
@ -281,7 +283,7 @@ func (n *NFSCLIENT) parseData(mountpoint string, export string, version string,
|
|||
}
|
||||
} else if version == "4" {
|
||||
if In(nfs4Fields, first) {
|
||||
for i , t := range nline {
|
||||
for i, t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
|
@ -303,7 +305,7 @@ func (n *NFSCLIENT) processText(scanner *bufio.Scanner, acc telegraf.Accumulator
|
|||
} else if In(line, "(nfs)") || In(line, "(nfs4)") {
|
||||
version = strings.Split(line[5], "/")[1]
|
||||
}
|
||||
if (len(line) > 0) {
|
||||
if len(line) > 0 {
|
||||
n.parseStat(device, export, version, line, acc)
|
||||
if n.Fullstat == true {
|
||||
n.parseData(device, export, version, line, acc)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package nfsclient
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"bufio"
|
||||
"strings"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const mountstatstext = `device rootfs mounted on / with fstype rootfs
|
||||
|
@ -193,7 +192,7 @@ func TestNFSCLIENTProcessStat(t *testing.T) {
|
|||
"write_rtt": float64(706),
|
||||
"write_exe": float64(707),
|
||||
}
|
||||
tags := map[string]string {
|
||||
tags := map[string]string{
|
||||
"mountpoint": "1.2.3.4:/storage/NFSCLIENT /storage/NFS",
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "nfsstat_read", fields_readstat, tags)
|
||||
|
@ -249,7 +248,7 @@ func TestNFSCLIENTProcessFull(t *testing.T) {
|
|||
"writepages": float64(30784819),
|
||||
}
|
||||
fields_xprttcp := map[string]interface{}{
|
||||
// "port": float64(733),
|
||||
// "port": float64(733),
|
||||
"bind_count": float64(1),
|
||||
"connect_count": float64(1),
|
||||
"connect_time": float64(0),
|
||||
|
|
Loading…
Reference in New Issue