Browse Source

Add an option to specify the graphite metric prefix

Mathieu 10 years ago
parent
commit
e6a1c3a18d
1 changed files with 3 additions and 2 deletions
  1. 3 2
      contrib/vpn_acct.py

+ 3 - 2
contrib/vpn_acct.py

@@ -34,8 +34,8 @@ def read_vpn_acct_file(filename):
         # format: username ip qos uptxbytes downrxbytes
         if len(d) == 5:
             metrics.extend([
-                ( 'vpn1.%s.upxtbytes'   % d[0], (tstamp, int(d[3])) ),
-                ( 'vpn1.%s.downrxbytes' % d[0], (tstamp, int(d[4])) ),
+                ( '%s.%s.upxtbytes'   % d[0], (options.prefix, tstamp, int(d[3])) ),
+                ( '%s.%s.downrxbytes' % d[0], (options.prefix, tstamp, int(d[4])) ),
             ])
     return tstamp, metrics
 
@@ -103,6 +103,7 @@ if __name__ == '__main__':
         formatter_class=argparse.ArgumentDefaultsHelpFormatter)
 
     parser.add_argument('directory', help='directory to watch')
+    parser.add_argument('prefix', help='prefix for Graphite metrics')
     parser.add_argument('-t', '--timestamp', dest='tstamp', type=int, default=0, help='Timestamp to recover data from')
     parser.add_argument('-s', '--server', dest='server', default='localhost', help='Carbon daemon address')
     parser.add_argument('-p', '--port', dest='port', type=int, default=2004, help='Carbon daemon port')