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"
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
package nfsclient
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"fmt"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
)
|
||||
|
||||
type NFSCLIENT struct {
|
||||
Fullstat bool
|
||||
Fullstat bool
|
||||
}
|
||||
|
||||
var sampleConfig = `
|
||||
|
@ -23,317 +23,319 @@ var sampleConfig = `
|
|||
`
|
||||
|
||||
func (n *NFSCLIENT) SampleConfig() string {
|
||||
return sampleConfig
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (n *NFSCLIENT) Description() string {
|
||||
return "Read per-mount NFS metrics from /proc/self/mountstats"
|
||||
return "Read per-mount NFS metrics from /proc/self/mountstats"
|
||||
}
|
||||
|
||||
var eventsFields = []string{
|
||||
"inoderevalidates",
|
||||
"dentryrevalidates",
|
||||
"datainvalidates",
|
||||
"attrinvalidates",
|
||||
"vfsopen",
|
||||
"vfslookup",
|
||||
"vfspermission",
|
||||
"vfsupdatepage",
|
||||
"vfsreadpage",
|
||||
"vfsreadpages",
|
||||
"vfswritepage",
|
||||
"vfswritepages",
|
||||
"vfsreaddir",
|
||||
"vfssetattr",
|
||||
"vfsflush",
|
||||
"vfsfsync",
|
||||
"vfslock",
|
||||
"vfsrelease",
|
||||
"congestionwait",
|
||||
"setattrtrunc",
|
||||
"extendwrite",
|
||||
"sillyrenames",
|
||||
"shortreads",
|
||||
"shortwrites",
|
||||
"delay",
|
||||
"pnfsreads",
|
||||
"pnfswrites",
|
||||
"inoderevalidates",
|
||||
"dentryrevalidates",
|
||||
"datainvalidates",
|
||||
"attrinvalidates",
|
||||
"vfsopen",
|
||||
"vfslookup",
|
||||
"vfspermission",
|
||||
"vfsupdatepage",
|
||||
"vfsreadpage",
|
||||
"vfsreadpages",
|
||||
"vfswritepage",
|
||||
"vfswritepages",
|
||||
"vfsreaddir",
|
||||
"vfssetattr",
|
||||
"vfsflush",
|
||||
"vfsfsync",
|
||||
"vfslock",
|
||||
"vfsrelease",
|
||||
"congestionwait",
|
||||
"setattrtrunc",
|
||||
"extendwrite",
|
||||
"sillyrenames",
|
||||
"shortreads",
|
||||
"shortwrites",
|
||||
"delay",
|
||||
"pnfsreads",
|
||||
"pnfswrites",
|
||||
}
|
||||
|
||||
var bytesFields = []string{
|
||||
"normalreadbytes",
|
||||
"normalwritebytes",
|
||||
"directreadbytes",
|
||||
"directwritebytes",
|
||||
"serverreadbytes",
|
||||
"serverwritebytes",
|
||||
"readpages",
|
||||
"writepages",
|
||||
"normalreadbytes",
|
||||
"normalwritebytes",
|
||||
"directreadbytes",
|
||||
"directwritebytes",
|
||||
"serverreadbytes",
|
||||
"serverwritebytes",
|
||||
"readpages",
|
||||
"writepages",
|
||||
}
|
||||
|
||||
var xprtudpFields = []string{
|
||||
// "port",
|
||||
"bind_count",
|
||||
"rpcsends",
|
||||
"rpcreceives",
|
||||
"badxids",
|
||||
"inflightsends",
|
||||
"backlogutil",
|
||||
// "port",
|
||||
"bind_count",
|
||||
"rpcsends",
|
||||
"rpcreceives",
|
||||
"badxids",
|
||||
"inflightsends",
|
||||
"backlogutil",
|
||||
}
|
||||
|
||||
var xprttcpFields = []string{
|
||||
// "port",
|
||||
"bind_count",
|
||||
"connect_count",
|
||||
"connect_time",
|
||||
"idle_time",
|
||||
"rpcsends",
|
||||
"rpcreceives",
|
||||
"badxids",
|
||||
"inflightsends",
|
||||
"backlogutil",
|
||||
// "port",
|
||||
"bind_count",
|
||||
"connect_count",
|
||||
"connect_time",
|
||||
"idle_time",
|
||||
"rpcsends",
|
||||
"rpcreceives",
|
||||
"badxids",
|
||||
"inflightsends",
|
||||
"backlogutil",
|
||||
}
|
||||
|
||||
var nfs3Fields = []string{
|
||||
"NULL",
|
||||
"GETATTR",
|
||||
"SETATTR",
|
||||
"LOOKUP",
|
||||
"ACCESS",
|
||||
"READLINK",
|
||||
"READ",
|
||||
"WRITE",
|
||||
"CREATE",
|
||||
"MKDIR",
|
||||
"SYMLINK",
|
||||
"MKNOD",
|
||||
"REMOVE",
|
||||
"RMDIR",
|
||||
"RENAME",
|
||||
"LINK",
|
||||
"READDIR",
|
||||
"READDIRPLUS",
|
||||
"FSSTAT",
|
||||
"FSINFO",
|
||||
"PATHCONF",
|
||||
"COMMIT",
|
||||
"NULL",
|
||||
"GETATTR",
|
||||
"SETATTR",
|
||||
"LOOKUP",
|
||||
"ACCESS",
|
||||
"READLINK",
|
||||
"READ",
|
||||
"WRITE",
|
||||
"CREATE",
|
||||
"MKDIR",
|
||||
"SYMLINK",
|
||||
"MKNOD",
|
||||
"REMOVE",
|
||||
"RMDIR",
|
||||
"RENAME",
|
||||
"LINK",
|
||||
"READDIR",
|
||||
"READDIRPLUS",
|
||||
"FSSTAT",
|
||||
"FSINFO",
|
||||
"PATHCONF",
|
||||
"COMMIT",
|
||||
}
|
||||
|
||||
var nfs4Fields = []string{
|
||||
"NULL",
|
||||
"READ",
|
||||
"WRITE",
|
||||
"COMMIT",
|
||||
"OPEN",
|
||||
"OPEN_CONFIRM",
|
||||
"OPEN_NOATTR",
|
||||
"OPEN_DOWNGRADE",
|
||||
"CLOSE",
|
||||
"SETATTR",
|
||||
"FSINFO",
|
||||
"RENEW",
|
||||
"SETCLIENTID",
|
||||
"SETCLIENTID_CONFIRM",
|
||||
"LOCK",
|
||||
"LOCKT",
|
||||
"LOCKU",
|
||||
"ACCESS",
|
||||
"GETATTR",
|
||||
"LOOKUP",
|
||||
"LOOKUP_ROOT",
|
||||
"REMOVE",
|
||||
"RENAME",
|
||||
"LINK",
|
||||
"SYMLINK",
|
||||
"CREATE",
|
||||
"PATHCONF",
|
||||
"STATFS",
|
||||
"READLINK",
|
||||
"READDIR",
|
||||
"SERVER_CAPS",
|
||||
"DELEGRETURN",
|
||||
"GETACL",
|
||||
"SETACL",
|
||||
"FS_LOCATIONS",
|
||||
"RELEASE_LOCKOWNER",
|
||||
"SECINFO",
|
||||
"FSID_PRESENT",
|
||||
"EXCHANGE_ID",
|
||||
"CREATE_SESSION",
|
||||
"DESTROY_SESSION",
|
||||
"SEQUENCE",
|
||||
"GET_LEASE_TIME",
|
||||
"RECLAIM_COMPLETE",
|
||||
"LAYOUTGET",
|
||||
"GETDEVICEINFO",
|
||||
"LAYOUTCOMMIT",
|
||||
"LAYOUTRETURN",
|
||||
"SECINFO_NO_NAME",
|
||||
"TEST_STATEID",
|
||||
"FREE_STATEID",
|
||||
"GETDEVICELIST",
|
||||
"BIND_CONN_TO_SESSION",
|
||||
"DESTROY_CLIENTID",
|
||||
"SEEK",
|
||||
"ALLOCATE",
|
||||
"DEALLOCATE",
|
||||
"LAYOUTSTATS",
|
||||
"CLONE",
|
||||
"NULL",
|
||||
"READ",
|
||||
"WRITE",
|
||||
"COMMIT",
|
||||
"OPEN",
|
||||
"OPEN_CONFIRM",
|
||||
"OPEN_NOATTR",
|
||||
"OPEN_DOWNGRADE",
|
||||
"CLOSE",
|
||||
"SETATTR",
|
||||
"FSINFO",
|
||||
"RENEW",
|
||||
"SETCLIENTID",
|
||||
"SETCLIENTID_CONFIRM",
|
||||
"LOCK",
|
||||
"LOCKT",
|
||||
"LOCKU",
|
||||
"ACCESS",
|
||||
"GETATTR",
|
||||
"LOOKUP",
|
||||
"LOOKUP_ROOT",
|
||||
"REMOVE",
|
||||
"RENAME",
|
||||
"LINK",
|
||||
"SYMLINK",
|
||||
"CREATE",
|
||||
"PATHCONF",
|
||||
"STATFS",
|
||||
"READLINK",
|
||||
"READDIR",
|
||||
"SERVER_CAPS",
|
||||
"DELEGRETURN",
|
||||
"GETACL",
|
||||
"SETACL",
|
||||
"FS_LOCATIONS",
|
||||
"RELEASE_LOCKOWNER",
|
||||
"SECINFO",
|
||||
"FSID_PRESENT",
|
||||
"EXCHANGE_ID",
|
||||
"CREATE_SESSION",
|
||||
"DESTROY_SESSION",
|
||||
"SEQUENCE",
|
||||
"GET_LEASE_TIME",
|
||||
"RECLAIM_COMPLETE",
|
||||
"LAYOUTGET",
|
||||
"GETDEVICEINFO",
|
||||
"LAYOUTCOMMIT",
|
||||
"LAYOUTRETURN",
|
||||
"SECINFO_NO_NAME",
|
||||
"TEST_STATEID",
|
||||
"FREE_STATEID",
|
||||
"GETDEVICELIST",
|
||||
"BIND_CONN_TO_SESSION",
|
||||
"DESTROY_CLIENTID",
|
||||
"SEEK",
|
||||
"ALLOCATE",
|
||||
"DEALLOCATE",
|
||||
"LAYOUTSTATS",
|
||||
"CLONE",
|
||||
}
|
||||
|
||||
var nfsopFields = []string {
|
||||
"ops",
|
||||
"trans",
|
||||
"timeouts",
|
||||
"bytes_sent",
|
||||
"bytes_recv",
|
||||
"queue_time",
|
||||
"response_time",
|
||||
"total_time",
|
||||
var nfsopFields = []string{
|
||||
"ops",
|
||||
"trans",
|
||||
"timeouts",
|
||||
"bytes_sent",
|
||||
"bytes_recv",
|
||||
"queue_time",
|
||||
"response_time",
|
||||
"total_time",
|
||||
}
|
||||
|
||||
func convert(line []string) []float64 {
|
||||
var nline []float64
|
||||
for _, l := range line[1:] {
|
||||
f, _ := strconv.ParseFloat(l, 64)
|
||||
nline = append(nline, f)
|
||||
}
|
||||
return nline
|
||||
var nline []float64
|
||||
for _, l := range line[1:] {
|
||||
f, _ := strconv.ParseFloat(l, 64)
|
||||
nline = append(nline, f)
|
||||
}
|
||||
return nline
|
||||
}
|
||||
|
||||
func In(list []string, val string) bool {
|
||||
for _, v := range list {
|
||||
if v == val {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
for _, v := range list {
|
||||
if v == val {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (n *NFSCLIENT) parseStat(mountpoint string, export string, version string, line []string, acc telegraf.Accumulator) error {
|
||||
tags := map[string]string{"mountpoint": mountpoint, "serverexport": export}
|
||||
nline := convert(line)
|
||||
first := strings.Replace(line[0], ":", "", 1)
|
||||
tags := map[string]string{"mountpoint": mountpoint, "serverexport": export}
|
||||
nline := convert(line)
|
||||
first := strings.Replace(line[0], ":", "", 1)
|
||||
|
||||
var fields = make(map[string]interface{})
|
||||
var fields = make(map[string]interface{})
|
||||
|
||||
if version == "3" || version == "4" {
|
||||
if In(nfs3Fields, first) {
|
||||
if first == "READ" {
|
||||
fields["read_ops"] = nline[0]
|
||||
fields["read_retrans"] = (nline[1] - nline[0])
|
||||
fields["read_bytes"] = (nline[3] + nline[4])
|
||||
fields["read_rtt"] = nline[6]
|
||||
fields["read_exe"] = nline[7]
|
||||
acc.AddFields("nfsstat_read", fields, tags)
|
||||
} else if first == "WRITE" {
|
||||
fields["write_ops"] = nline[0]
|
||||
fields["write_retrans"] = (nline[1] - nline[0])
|
||||
fields["write_bytes"] = (nline[3] + nline[4])
|
||||
fields["write_rtt"] = nline[6]
|
||||
fields["write_exe"] = nline[7]
|
||||
acc.AddFields("nfsstat_write", fields, tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
if version == "3" || version == "4" {
|
||||
if In(nfs3Fields, first) {
|
||||
if first == "READ" {
|
||||
fields["read_ops"] = nline[0]
|
||||
fields["read_retrans"] = (nline[1] - nline[0])
|
||||
fields["read_bytes"] = (nline[3] + nline[4])
|
||||
fields["read_rtt"] = nline[6]
|
||||
fields["read_exe"] = nline[7]
|
||||
acc.AddFields("nfsstat_read", fields, tags)
|
||||
} else if first == "WRITE" {
|
||||
fields["write_ops"] = nline[0]
|
||||
fields["write_retrans"] = (nline[1] - nline[0])
|
||||
fields["write_bytes"] = (nline[3] + nline[4])
|
||||
fields["write_rtt"] = nline[6]
|
||||
fields["write_exe"] = nline[7]
|
||||
acc.AddFields("nfsstat_write", fields, tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NFSCLIENT) parseData(mountpoint string, export string, version string, line []string, acc telegraf.Accumulator) error {
|
||||
tags := map[string]string{"mountpoint": mountpoint, "serverexport": export}
|
||||
nline := convert(line)
|
||||
first := strings.Replace(line[0], ":", "", 1)
|
||||
tags := map[string]string{"mountpoint": mountpoint, "serverexport": export}
|
||||
nline := convert(line)
|
||||
first := strings.Replace(line[0], ":", "", 1)
|
||||
|
||||
var fields = make(map[string]interface{})
|
||||
var fields = make(map[string]interface{})
|
||||
|
||||
if first == "events" {
|
||||
for i,t := range eventsFields {
|
||||
fields[t] = nline[i]
|
||||
}
|
||||
acc.AddFields("nfs_events", fields, tags)
|
||||
} else if first == "bytes" {
|
||||
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 {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprttcp", fields, tags)
|
||||
}
|
||||
case "udp": {
|
||||
for i,t := range xprtudpFields {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprtudp", fields, tags)
|
||||
}
|
||||
}
|
||||
} else if version == "3" {
|
||||
if In(nfs3Fields, first) {
|
||||
for i , t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
acc.AddFields("nfs_ops", fields, tags)
|
||||
}
|
||||
} else if version == "4" {
|
||||
if In(nfs4Fields, first) {
|
||||
for i , t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
acc.AddFields("nfs_ops", fields, tags)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
if first == "events" {
|
||||
for i, t := range eventsFields {
|
||||
fields[t] = nline[i]
|
||||
}
|
||||
acc.AddFields("nfs_events", fields, tags)
|
||||
} else if first == "bytes" {
|
||||
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 {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprttcp", fields, tags)
|
||||
}
|
||||
case "udp":
|
||||
{
|
||||
for i, t := range xprtudpFields {
|
||||
fields[t] = nline[i+2]
|
||||
}
|
||||
acc.AddFields("nfs_xprtudp", fields, tags)
|
||||
}
|
||||
}
|
||||
} else if version == "3" {
|
||||
if In(nfs3Fields, first) {
|
||||
for i, t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
acc.AddFields("nfs_ops", fields, tags)
|
||||
}
|
||||
} else if version == "4" {
|
||||
if In(nfs4Fields, first) {
|
||||
for i, t := range nline {
|
||||
item := fmt.Sprintf("%s_%s", first, nfsopFields[i])
|
||||
fields[item] = t
|
||||
}
|
||||
acc.AddFields("nfs_ops", fields, tags)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NFSCLIENT) processText(scanner *bufio.Scanner, acc telegraf.Accumulator) error {
|
||||
var device string
|
||||
var version string
|
||||
var export string
|
||||
for scanner.Scan() {
|
||||
line := strings.Fields(scanner.Text())
|
||||
if In(line, "fstype") && In(line, "nfs") || In(line, "nfs4") {
|
||||
device = line[4]
|
||||
export = line[1]
|
||||
} else if In(line, "(nfs)") || In(line, "(nfs4)") {
|
||||
version = strings.Split(line[5], "/")[1]
|
||||
}
|
||||
if (len(line) > 0) {
|
||||
n.parseStat(device, export, version, line, acc)
|
||||
if n.Fullstat == true {
|
||||
n.parseData(device, export, version, line, acc)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
var device string
|
||||
var version string
|
||||
var export string
|
||||
for scanner.Scan() {
|
||||
line := strings.Fields(scanner.Text())
|
||||
if In(line, "fstype") && In(line, "nfs") || In(line, "nfs4") {
|
||||
device = line[4]
|
||||
export = line[1]
|
||||
} else if In(line, "(nfs)") || In(line, "(nfs4)") {
|
||||
version = strings.Split(line[5], "/")[1]
|
||||
}
|
||||
if len(line) > 0 {
|
||||
n.parseStat(device, export, version, line, acc)
|
||||
if n.Fullstat == true {
|
||||
n.parseData(device, export, version, line, acc)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *NFSCLIENT) Gather(acc telegraf.Accumulator) error {
|
||||
var outerr error
|
||||
var outerr error
|
||||
|
||||
file, err := os.Open("/proc/self/mountstats")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
file, err := os.Open("/proc/self/mountstats")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
n.processText(scanner, acc)
|
||||
scanner := bufio.NewScanner(file)
|
||||
n.processText(scanner, acc)
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return outerr
|
||||
return outerr
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("nfsclient", func() telegraf.Input {
|
||||
return &NFSCLIENT{}
|
||||
})
|
||||
inputs.Add("nfsclient", func() telegraf.Input {
|
||||
return &NFSCLIENT{}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package nfsclient
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"bufio"
|
||||
"strings"
|
||||
"bufio"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const mountstatstext = `device rootfs mounted on / with fstype rootfs
|
||||
|
@ -131,137 +130,137 @@ device 2.2.2.2:/nfsdata/ mounted on /mnt with fstype nfs4 statvers=1.1
|
|||
`
|
||||
|
||||
func TestNFSCLIENTParsev3(t *testing.T) {
|
||||
var acc testutil.Accumulator
|
||||
var acc testutil.Accumulator
|
||||
|
||||
nfsclient := NFSCLIENT{}
|
||||
data := strings.Fields(" READLINK: 500 501 502 503 504 505 506 507")
|
||||
nfsclient.parseData("1.2.3.4:/storage/NFSCLIENT /storage/NFS", "3", data, &acc)
|
||||
nfsclient := NFSCLIENT{}
|
||||
data := strings.Fields(" READLINK: 500 501 502 503 504 505 506 507")
|
||||
nfsclient.parseData("1.2.3.4:/storage/NFSCLIENT /storage/NFS", "3", data, &acc)
|
||||
|
||||
fields_ops := map[string]interface{}{
|
||||
"READLINK_ops": float64(500),
|
||||
"READLINK_trans": float64(501),
|
||||
"READLINK_timeouts": float64(502),
|
||||
"READLINK_bytes_sent": float64(503),
|
||||
"READLINK_bytes_recv": float64(504),
|
||||
"READLINK_queue_time": float64(505),
|
||||
"READLINK_response_time": float64(506),
|
||||
"READLINK_total_time": float64(507),
|
||||
}
|
||||
acc.AssertContainsFields(t, "nfs_ops", fields_ops)
|
||||
fields_ops := map[string]interface{}{
|
||||
"READLINK_ops": float64(500),
|
||||
"READLINK_trans": float64(501),
|
||||
"READLINK_timeouts": float64(502),
|
||||
"READLINK_bytes_sent": float64(503),
|
||||
"READLINK_bytes_recv": float64(504),
|
||||
"READLINK_queue_time": float64(505),
|
||||
"READLINK_response_time": float64(506),
|
||||
"READLINK_total_time": float64(507),
|
||||
}
|
||||
acc.AssertContainsFields(t, "nfs_ops", fields_ops)
|
||||
}
|
||||
|
||||
func TestNFSCLIENTParsev4(t *testing.T) {
|
||||
var acc testutil.Accumulator
|
||||
var acc testutil.Accumulator
|
||||
|
||||
nfsclient := NFSCLIENT{}
|
||||
data := strings.Fields(" DESTROY_SESSION: 500 501 502 503 504 505 506 507")
|
||||
nfs.parseData("2.2.2.2:/nfsdata/ /mnt", "4", data, &acc)
|
||||
nfsclient := NFSCLIENT{}
|
||||
data := strings.Fields(" DESTROY_SESSION: 500 501 502 503 504 505 506 507")
|
||||
nfs.parseData("2.2.2.2:/nfsdata/ /mnt", "4", data, &acc)
|
||||
|
||||
fields_ops := map[string]interface{}{
|
||||
"DESTROY_SESSION_ops": float64(500),
|
||||
"DESTROY_SESSION_trans": float64(501),
|
||||
"DESTROY_SESSION_timeouts": float64(502),
|
||||
"DESTROY_SESSION_bytes_sent": float64(503),
|
||||
"DESTROY_SESSION_bytes_recv": float64(504),
|
||||
"DESTROY_SESSION_queue_time": float64(505),
|
||||
"DESTROY_SESSION_response_time": float64(506),
|
||||
"DESTROY_SESSION_total_time": float64(507),
|
||||
}
|
||||
acc.AssertContainsFields(t, "nfs_ops", fields_ops)
|
||||
fields_ops := map[string]interface{}{
|
||||
"DESTROY_SESSION_ops": float64(500),
|
||||
"DESTROY_SESSION_trans": float64(501),
|
||||
"DESTROY_SESSION_timeouts": float64(502),
|
||||
"DESTROY_SESSION_bytes_sent": float64(503),
|
||||
"DESTROY_SESSION_bytes_recv": float64(504),
|
||||
"DESTROY_SESSION_queue_time": float64(505),
|
||||
"DESTROY_SESSION_response_time": float64(506),
|
||||
"DESTROY_SESSION_total_time": float64(507),
|
||||
}
|
||||
acc.AssertContainsFields(t, "nfs_ops", fields_ops)
|
||||
}
|
||||
|
||||
func TestNFSCLIENTProcessStat(t *testing.T) {
|
||||
var acc testutil.Accumulator
|
||||
var acc testutil.Accumulator
|
||||
|
||||
nfsclient := NFSCLIENT{}
|
||||
nfsclient.Iostat = true
|
||||
scanner := bufio.NewScanner(strings.NewReader(mountstatstext))
|
||||
nfsclient := NFSCLIENT{}
|
||||
nfsclient.Iostat = true
|
||||
scanner := bufio.NewScanner(strings.NewReader(mountstatstext))
|
||||
|
||||
nfsclient.processText(scanner, &acc)
|
||||
nfsclient.processText(scanner, &acc)
|
||||
|
||||
fields_readstat := map[string]interface{}{
|
||||
"read_ops": float64(600),
|
||||
"read_retrans": float64(1),
|
||||
"read_bytes": float64(1207),
|
||||
"read_rtt": float64(606),
|
||||
"read_exe": float64(607),
|
||||
}
|
||||
fields_writestat := map[string]interface{}{
|
||||
"write_ops": float64(700),
|
||||
"write_retrans": float64(1),
|
||||
"write_bytes": float64(1407),
|
||||
"write_rtt": float64(706),
|
||||
"write_exe": float64(707),
|
||||
}
|
||||
tags := map[string]string {
|
||||
"mountpoint": "1.2.3.4:/storage/NFSCLIENT /storage/NFS",
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "nfsstat_read", fields_readstat, tags)
|
||||
acc.AssertContainsTaggedFields(t, "nfsstat_write", fields_writestat, tags)
|
||||
fields_readstat := map[string]interface{}{
|
||||
"read_ops": float64(600),
|
||||
"read_retrans": float64(1),
|
||||
"read_bytes": float64(1207),
|
||||
"read_rtt": float64(606),
|
||||
"read_exe": float64(607),
|
||||
}
|
||||
fields_writestat := map[string]interface{}{
|
||||
"write_ops": float64(700),
|
||||
"write_retrans": float64(1),
|
||||
"write_bytes": float64(1407),
|
||||
"write_rtt": float64(706),
|
||||
"write_exe": float64(707),
|
||||
}
|
||||
tags := map[string]string{
|
||||
"mountpoint": "1.2.3.4:/storage/NFSCLIENT /storage/NFS",
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "nfsstat_read", fields_readstat, tags)
|
||||
acc.AssertContainsTaggedFields(t, "nfsstat_write", fields_writestat, tags)
|
||||
}
|
||||
|
||||
func TestNFSCLIENTProcessFull(t *testing.T) {
|
||||
var acc testutil.Accumulator
|
||||
var acc testutil.Accumulator
|
||||
|
||||
nfsclient := NFSCLIENT{}
|
||||
nfsclient.Fullstat = true
|
||||
scanner := bufio.NewScanner(strings.NewReader(mountstatstext))
|
||||
nfsclient := NFSCLIENT{}
|
||||
nfsclient.Fullstat = true
|
||||
scanner := bufio.NewScanner(strings.NewReader(mountstatstext))
|
||||
|
||||
nfsclient.processText(scanner, &acc)
|
||||
nfsclient.processText(scanner, &acc)
|
||||
|
||||
fields_events := map[string]interface{}{
|
||||
"inoderevalidates": float64(301736),
|
||||
"dentryrevalidates": float64(22838),
|
||||
"datainvalidates": float64(410979),
|
||||
"attrinvalidates": float64(26188427),
|
||||
"vfsopen": float64(27525),
|
||||
"vfslookup": float64(9140),
|
||||
"vfspermission": float64(114420),
|
||||
"vfsupdatepage": float64(30785253),
|
||||
"vfsreadpage": float64(5308856),
|
||||
"vfsreadpages": float64(5364858),
|
||||
"vfswritepage": float64(30784819),
|
||||
"vfswritepages": float64(79832668),
|
||||
"vfsreaddir": float64(170),
|
||||
"vfssetattr": float64(64),
|
||||
"vfsflush": float64(18194),
|
||||
"vfsfsync": float64(29294718),
|
||||
"vfslock": float64(0),
|
||||
"vfsrelease": float64(18279),
|
||||
"congestionwait": float64(0),
|
||||
"setattrtrunc": float64(2),
|
||||
"extendwrite": float64(785551),
|
||||
"sillyrenames": float64(0),
|
||||
"shortreads": float64(0),
|
||||
"shortwrites": float64(0),
|
||||
"delay": float64(0),
|
||||
"pnfsreads": float64(0),
|
||||
"pnfswrites": float64(0),
|
||||
}
|
||||
fields_bytes := map[string]interface{}{
|
||||
"normalreadbytes": float64(204440464584),
|
||||
"normalwritebytes": float64(110857586443),
|
||||
"directreadbytes": float64(783170354688),
|
||||
"directwritebytes": float64(296174954496),
|
||||
"serverreadbytes": float64(1134399088816),
|
||||
"serverwritebytes": float64(407107155723),
|
||||
"readpages": float64(85749323),
|
||||
"writepages": float64(30784819),
|
||||
}
|
||||
fields_xprttcp := map[string]interface{}{
|
||||
// "port": float64(733),
|
||||
"bind_count": float64(1),
|
||||
"connect_count": float64(1),
|
||||
"connect_time": float64(0),
|
||||
"idle_time": float64(0),
|
||||
"rpcsends": float64(96172963),
|
||||
"rpcreceives": float64(96172963),
|
||||
"badxids": float64(0),
|
||||
"inflightsends": float64(620878754),
|
||||
"backlogutil": float64(0),
|
||||
}
|
||||
fields_events := map[string]interface{}{
|
||||
"inoderevalidates": float64(301736),
|
||||
"dentryrevalidates": float64(22838),
|
||||
"datainvalidates": float64(410979),
|
||||
"attrinvalidates": float64(26188427),
|
||||
"vfsopen": float64(27525),
|
||||
"vfslookup": float64(9140),
|
||||
"vfspermission": float64(114420),
|
||||
"vfsupdatepage": float64(30785253),
|
||||
"vfsreadpage": float64(5308856),
|
||||
"vfsreadpages": float64(5364858),
|
||||
"vfswritepage": float64(30784819),
|
||||
"vfswritepages": float64(79832668),
|
||||
"vfsreaddir": float64(170),
|
||||
"vfssetattr": float64(64),
|
||||
"vfsflush": float64(18194),
|
||||
"vfsfsync": float64(29294718),
|
||||
"vfslock": float64(0),
|
||||
"vfsrelease": float64(18279),
|
||||
"congestionwait": float64(0),
|
||||
"setattrtrunc": float64(2),
|
||||
"extendwrite": float64(785551),
|
||||
"sillyrenames": float64(0),
|
||||
"shortreads": float64(0),
|
||||
"shortwrites": float64(0),
|
||||
"delay": float64(0),
|
||||
"pnfsreads": float64(0),
|
||||
"pnfswrites": float64(0),
|
||||
}
|
||||
fields_bytes := map[string]interface{}{
|
||||
"normalreadbytes": float64(204440464584),
|
||||
"normalwritebytes": float64(110857586443),
|
||||
"directreadbytes": float64(783170354688),
|
||||
"directwritebytes": float64(296174954496),
|
||||
"serverreadbytes": float64(1134399088816),
|
||||
"serverwritebytes": float64(407107155723),
|
||||
"readpages": float64(85749323),
|
||||
"writepages": float64(30784819),
|
||||
}
|
||||
fields_xprttcp := map[string]interface{}{
|
||||
// "port": float64(733),
|
||||
"bind_count": float64(1),
|
||||
"connect_count": float64(1),
|
||||
"connect_time": float64(0),
|
||||
"idle_time": float64(0),
|
||||
"rpcsends": float64(96172963),
|
||||
"rpcreceives": float64(96172963),
|
||||
"badxids": float64(0),
|
||||
"inflightsends": float64(620878754),
|
||||
"backlogutil": float64(0),
|
||||
}
|
||||
|
||||
acc.AssertContainsFields(t, "nfs_events", fields_events)
|
||||
acc.AssertContainsFields(t, "nfs_bytes", fields_bytes)
|
||||
acc.AssertContainsFields(t, "nfs_xprttcp", fields_xprttcp)
|
||||
acc.AssertContainsFields(t, "nfs_events", fields_events)
|
||||
acc.AssertContainsFields(t, "nfs_bytes", fields_bytes)
|
||||
acc.AssertContainsFields(t, "nfs_xprttcp", fields_xprttcp)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue