Skip to content

Commit

Permalink
Adding an option to turn of derivatives of values. This
Browse files Browse the repository at this point in the history
means you can use graphite derivative or perSecond functions
to get more accurate values over time
  • Loading branch information
Terry Hardie committed Dec 15, 2016
1 parent f946865 commit e445af8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/collectors/BindCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data_format | xml_v2 | Bind stats version:<br>
- xml_v3 (New xml version)<br>
- json_v1 (JSON replacement for XML)<br>
| str
derivative | True | Report derived stats or raw (always incrementing | bool

#### Example Output

Expand Down
10 changes: 7 additions & 3 deletions src/collectors/bind/bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import diamond.collector
import sys
import urllib2
from diamond.collector import str_to_bool

if sys.version_info >= (2, 5):
import xml.etree.cElementTree as ElementTree
Expand All @@ -39,6 +40,7 @@ def get_default_config_help(self):
" - xml_v2 (Original bind stats version from 9.5)\n" +
" - xml_v3 (New xml version)\n" +
" - json_v1 (JSON replacement for XML)\n",
'derivative': "",
})
return config_help

Expand Down Expand Up @@ -68,13 +70,15 @@ def get_default_config(self):
'publish_view_bind': False,
'publish_view_meta': False,
'data_format': 'xml_v2',
'derivative': True,
})
return config

def clean_counter(self, name, value):
value = self.derivative(name, value)
if value < 0:
value = 0
if str_to_bool(self.config['derivative']):
value = self.derivative(name, value)
if value < 0:
value = 0
self.publish(name, value)

def collect(self):
Expand Down

0 comments on commit e445af8

Please sign in to comment.