Skip to content
Browse files

nfsstats/python_modules/nfsstats.py:

 * add nfs_v3_total: sum of all calls

nfsstats/conf.d/nfsstats.pyconf:

 * add nfs_v3_total: sum of all calls
  • Loading branch information...
1 parent 6d693d6 commit 08a47d5fd16147a1155d3b6f9365ee8cbe9cccc3 Ramon Bastiaans committed Jun 29, 2012
Showing with 21 additions and 1 deletion.
  1. +4 −0 nfsstats/conf.d/nfsstats.pyconf
  2. +17 −1 nfsstats/python_modules/nfsstats.py
View
4 nfsstats/conf.d/nfsstats.pyconf
@@ -9,6 +9,10 @@ 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"
}
View
18 nfsstats/python_modules/nfsstats.py
@@ -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 08a47d5

Please sign in to comment.
Something went wrong with that request. Please try again.