Permalink
Browse files

Merge pull request #69 from waxie/add-cumulative-total-nfscalls-sum-m…

…etric

nfsstats/python_modules/nfsstats.py:
  • Loading branch information...
jbuchbinder committed Jul 3, 2012
2 parents 20acfda + cbf826c commit b4649cb36b8048cdb9ddc7edf33de4b3acd309c0
Showing with 25 additions and 1 deletion.
  1. +8 −0 nfsstats/conf.d/nfsstats.pyconf
  2. +17 −1 nfsstats/python_modules/nfsstats.py
@@ -8,6 +8,10 @@ modules {
collection_group {
collect_every = 60
time_threshold = 120
+ metric {
+ name = "nfs_v3_total"
+ title = "NFS v3 total"
+ }
metric {
name = "nfs_v3_getattr"
title = "NFS v3 getattr"
@@ -92,6 +96,10 @@ collection_group {
name = "nfs_v3_commit"
title = "NFS v3 commit"
}
+ metric {
+ name = "nfsd_v3_total"
+ title = "NFSD v3 total"
+ }
metric {
name = "nfsd_v3_getattr"
title = "NFSD v3 getattr"
@@ -6,6 +6,7 @@
import time
import syslog
import sys
+import string
def test_proc3( p_file ):
@@ -41,6 +42,7 @@ def test_proc3( p_file ):
'units': 'calls/sec',
'format': '%f',
'names': {
+ 'total': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\d+.*\d)\n" },
'getattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\S*)" },
'setattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){3}(\S*)" },
'lookup': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){4}(\S*)" },
@@ -74,6 +76,7 @@ def test_proc3( p_file ):
'units': 'calls/sec',
'format': '%f',
'names': {
+ 'total': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\d+.*\d)\n" },
'getattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){2}(\S*)" },
'setattr': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){3}(\S*)" },
'lookup': { 'description':'dummy description', 're': ".*proc3 (?:\S*\s){4}(\S*)" },
@@ -197,10 +200,23 @@ def get_value(name):
break
contents = file(descriptors[i]['file']).read()
m = re.search(descriptors[i]['re'], contents, flags=re.MULTILINE)
+
+ m_value = m.group(1)
+
+ #RB: multiple (space seperated) values: calculate sum
+ if string.count( m_value, ' ' ) > 0:
+ m_fields = string.split( m_value, ' ' )
+
+ sum_value = 0
+
+ for f in m_fields:
+ sum_value = sum_value + int(f)
+
+ m_value = sum_value
# Return time and value.
ts = time.time()
- return (ts, int(m.group(1)))
+ return (ts, int(m_value))
def debug(level, text):
global verboselevel

0 comments on commit b4649cb

Please sign in to comment.