From d280b968d7e0319514071706f46226b9b2e47e61 Mon Sep 17 00:00:00 2001 From: Simon Fraser Date: Mon, 10 Aug 2015 21:08:21 +0100 Subject: [PATCH] Ensure tests pass now that we're passing fstype around go fmt checks Rework the example configuration snippets --- README.md | 20 ++++++++++++++------ plugins/system/ps/disk/disk_test.go | 3 ++- plugins/system/system_test.go | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e0d802a8d..217313e02 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ This is tested on metrics that have passed the tagpass test. global interval, but if one particular plugin should be run less or more often, you can configure that here. -### Plugin Configuration Example +### Plugin Configuration Examples ``` # Read metrics about disk usage by mount point @@ -102,13 +102,21 @@ interval = "1m" # Run at a 1 minute interval instead of the default # These tag conditions are OR, not AND. # If the (filesystem is ext4 or xfs) or (the path is /opt or /home) then the metric passes fstype = [ "ext4", "xfs" ] -path = [ "/", /opt", "/home" ] +path = [ "/opt", "/home" ] -# Any metrics that succeed at 'tagpass' are then checked to see if they should be dropped +[postgresql] + +[postgresql.tagdrop] +# Don't report stats about the database name 'testdatabase' +db = [ "testdatabase" ] + +``` + +``` +[disk] +# Don't report stats about the following filesystem types [disk.tagdrop] -# Drop the root mountpoint from the metrics -path = [ "/" ] - +fstype = [ "nfs", "tmpfs", "ecryptfs" ] ``` ## Plugins diff --git a/plugins/system/ps/disk/disk_test.go b/plugins/system/ps/disk/disk_test.go index 6a91bae8c..becc6ad85 100644 --- a/plugins/system/ps/disk/disk_test.go +++ b/plugins/system/ps/disk/disk_test.go @@ -59,6 +59,7 @@ func TestDisk_io_counters(t *testing.T) { func TestDiskUsageStat_String(t *testing.T) { v := DiskUsageStat{ Path: "/", + Fstype: "ext4", Total: 1000, Free: 2000, Used: 3000, @@ -68,7 +69,7 @@ func TestDiskUsageStat_String(t *testing.T) { InodesFree: 6000, InodesUsedPercent: 49.1, } - e := `{"path":"/","total":1000,"free":2000,"used":3000,"used_percent":50.1,"inodes_total":4000,"inodes_used":5000,"inodes_free":6000,"inodes_used_percent":49.1}` + e := `{"path":"/","fstype":"ext4","total":1000,"free":2000,"used":3000,"used_percent":50.1,"inodes_total":4000,"inodes_used":5000,"inodes_free":6000,"inodes_used_percent":49.1}` if e != fmt.Sprintf("%v", v) { t.Errorf("DiskUsageStat string is invalid: %v", v) } diff --git a/plugins/system/system_test.go b/plugins/system/system_test.go index 7a3d13570..d7b63c988 100644 --- a/plugins/system/system_test.go +++ b/plugins/system/system_test.go @@ -48,6 +48,7 @@ func TestSystemStats_GenerateStats(t *testing.T) { du := &disk.DiskUsageStat{ Path: "/", + Fstype: "ext4", Total: 128, Free: 23, InodesTotal: 1234, @@ -195,7 +196,8 @@ func TestSystemStats_GenerateStats(t *testing.T) { require.NoError(t, err) tags := map[string]string{ - "path": "/", + "path": "/", + "fstype": "ext4", } assert.True(t, acc.CheckTaggedValue("total", uint64(128), tags))