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