Skip to content

Instantly share code, notes, and snippets.

@choffee
Last active December 11, 2015 04:58
Show Gist options
  • Select an option

  • Save choffee/4548791 to your computer and use it in GitHub Desktop.

Select an option

Save choffee/4548791 to your computer and use it in GitHub Desktop.
Another patch to nfsiostat. This time so that it can be run from collectd. Add the following to your collectd.conf to make it happen. LoadPlugin Exec <Plugin exec> Exec "nobody" "/usr/local/bin/nfsiostat.collectd" "20" "/nfs/mountpoint" </Plugin>
--- /usr/sbin/nfsiostat 2012-04-09 13:21:11.000000000 +0100
+++ nfsiostat.collectd 2013-01-16 16:23:24.020173069 +0000
@@ -22,6 +22,8 @@
"""
import sys, os, time
+import socket
+from datetime import datetime
from optparse import OptionParser, OptionGroup
Iostats_version = '0.2'
@@ -350,16 +352,19 @@
rtt_per_op = 0.0
exe_per_op = 0.0
- op += ':'
- print '%s' % op.lower().ljust(15),
- print ' ops/s\t\t kB/s\t\t kB/op\t\tretrans\t\tavg RTT (ms)\tavg exe (ms)'
-
- print '\t\t%7.3f' % (ops / sample_time),
- print '\t%7.3f' % (kilobytes / sample_time),
- print '\t%7.3f' % kb_per_op,
- print ' %7d (%3.1f%%)' % (retrans, retrans_percent),
- print '\t%7.3f' % rtt_per_op,
- print '\t%7.3f' % exe_per_op
+
+ rw = op.lower().ljust(15).strip()
+ seconds = datetime.now().strftime("%s")
+ hostname = socket.getfqdn().replace(".","_")
+ export = self.__nfs_data['mountpoint'].replace("/","_")
+ prefix = 'PUTVAL %s/nfsio-%s' % (hostname, export)
+
+ print '%s/gauge-operations-%s %s:%.3f' % (prefix, rw, seconds, ops / sample_time)
+ print '%s/bytes-%s %s:%.3f' % (prefix, rw, seconds, kilobytes / sample_time * 1024)
+ print '%s/bytes-per_op-%s %s:%.3f' % (prefix, rw, seconds, kb_per_op * 1024)
+ print '%s/gauge-retrans-%s %s:%d' % (prefix, rw, seconds, retrans)
+ print '%s/gauge-rtt_per_op-%s %s:%.3f' % (prefix, rw, seconds, rtt_per_op)
+ print '%s/gauge-exe_per_op-%s %s:%.3f' % (prefix, rw, seconds, exe_per_op)
def ops(self, sample_time):
sends = float(self.__rpc_data['rpcsends'])
@@ -384,14 +389,13 @@
else:
backlog = 0.0
- print
- print '%s mounted on %s:' % \
- (self.__nfs_data['export'], self.__nfs_data['mountpoint'])
- print
- print ' op/s\t\trpc bklog'
- print '%7.2f' % (sends / sample_time),
- print '\t%7.2f' % backlog
+ seconds = datetime.now().strftime("%s")
+ hostname = socket.getfqdn().replace(".","_")
+ export = self.__nfs_data['mountpoint'].replace("/","_")
+ prefix = 'PUTVAL %s/nfsio-%s' % (hostname, export)
+ print '%s/gauge-sends_per_second %s:%.2f' % (prefix, seconds, sends / sample_time)
+ print '%s/gauge-backlog %s:%.2f' % (prefix, seconds, backlog)
if which == 0:
self.__print_rpc_op_stats('READ', sample_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment