Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding an option to turn off derivatives of values for bind collector #563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/collectors/BindCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ publish | resolver, server, zonemgmt, sockets, memory, | Available stats:<br>
| list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mode change???
100644 → 100755

publish_view_bind | False | | bool
publish_view_meta | False | | bool
derivative | True | Report derived stats or raw (always incrementing) | bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be auto-generated from get_default_config, not manually edited

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not familiar with this - Can you give me a pointer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 ways you can fix it:

  • use build_doc.py
  • alphabetize and add the same exact text to the get_default_config function in the code


#### Example Output

Expand Down
10 changes: 7 additions & 3 deletions src/collectors/bind/bind.py
100644 → 100755
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 @@ -35,6 +36,7 @@ def get_default_config_help(self):
" - memory (Global memory usage)\n",
'publish_view_bind': "",
'publish_view_meta': "",
'derivative': "",
})
return config_help

Expand Down Expand Up @@ -63,13 +65,15 @@ def get_default_config(self):
# By default we don't publish these special views
'publish_view_bind': False,
'publish_view_meta': False,
'derivative': True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this to get_default_config as well

})
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