Skip to content

Instantly share code, notes, and snippets.

@choffee
Created January 3, 2013 16:39
Show Gist options
  • Select an option

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

Select an option

Save choffee/4444780 to your computer and use it in GitHub Desktop.
A simple patch to the nfsiostat command in debian that will output stats that you can send directly to graphite. # nfsiostat 30 |netcat graphiteserver.example.com 2003
--- /usr/sbin/nfsiostat 2012-04-09 13:21:11.000000000 +0100
+++ nfsiostat 2013-01-03 16:28:11.564087330 +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 = 'servers.%s.nfsiostat.%s.%s' % (hostname, export, rw)
+
+ print '%s.ops %7.3f %s' % (prefix, ops / sample_time, seconds)
+ print '%s.kb %7.3f %s' % (prefix, kilobytes / sample_time, seconds)
+ print '%s.kbperop %7.3f %s' % (prefix, kb_per_op, seconds)
+ print '%s.retrans %7d %s' % (prefix, retrans, seconds)
+ print '%s.rtt %7.3f %s' % (prefix, rtt_per_op, seconds)
+ print '%s.exe %7.3f %s' % (prefix, exe_per_op, seconds)
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 = 'servers.%s.nfsiostat.%s' % (hostname, export)
+ print '%s.ops %7.2f %s' % (prefix, sends / sample_time, seconds)
+ print '%s.backlog %7.2f %s' % (prefix, backlog, seconds)
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