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

vsphere: Add limits for host collection. Improve doc #1226

Merged
merged 4 commits into from
Dec 2, 2014
Merged
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
18 changes: 16 additions & 2 deletions checks.d/vsphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def get_external_host_tags(self):
return external_host_tags

@atomic_method
def _cache_morlist_raw_atomic(self, i_key, obj_type, obj, tags):
def _cache_morlist_raw_atomic(self, i_key, obj_type, obj, tags, regexes=None):
""" Compute tags for a single node in the vCenter rootFolder
and queue other such jobs for children nodes.
Usual hierarchy:
Expand Down Expand Up @@ -533,6 +533,11 @@ def _cache_morlist_raw_atomic(self, i_key, obj_type, obj, tags):
)

elif obj_type == 'host':
if regexes and regexes.get('host_include') is not None:
match = re.search(regexes['host_include'], obj.name)
if not match:
Copy link

Choose a reason for hiding this comment

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

Same comment as below here.

self.log.debug(u"Filtered out VM {0} because of host_include_only_regex".format(obj.name))
return
watched_mor = dict(mor_type='host', mor=obj, hostname=obj.name, tags=tags_copy+['vsphere_type:host'])
self.morlist_raw[i_key].append(watched_mor)

Expand All @@ -547,6 +552,11 @@ def _cache_morlist_raw_atomic(self, i_key, obj_type, obj, tags):
)

elif obj_type == 'vm':
if regexes and regexes.get('vm_include') is not None:
match = re.search(regexes['vm_include'], obj.name)
if not match:
Copy link

Choose a reason for hiding this comment

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

Can you log something in debug in that case ?
Could be helpful.

self.log.debug(u"Filtered out VM {0} because of vm_include_only_regex".format(obj.name))
return
watched_mor = dict(mor_type='vm', mor=obj, hostname=obj.name, tags=tags_copy+['vsphere_type:vm'])
self.morlist_raw[i_key].append(watched_mor)

Expand All @@ -571,9 +581,13 @@ def _cache_morlist_raw(self, instance):
root_folder = server_instance.content.rootFolder

instance_tag = "vcenter_server:%s" % instance.get('name')
regexes = {
'host_include': instance.get('host_include_only_regex'),
'vm_include': instance.get('vm_include_only_regex')
}
self.pool.apply_async(
self._cache_morlist_raw_atomic,
args=(i_key, 'rootFolder', root_folder, [instance_tag])
args=(i_key, 'rootFolder', root_folder, [instance_tag], regexes)
)
self.cache_times[i_key][MORLIST][LAST] = time.time()

Expand Down
32 changes: 30 additions & 2 deletions conf.d/vsphere.yaml.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
# Section used for global vsphere check config
init_config:


# Define your list of instances here
# each item is a vCenter instance you want to connect to and
# fetch metrics from
instances:
# name is a unique key representing your vCenter instance
# name must be a unique key representing your vCenter instance
# mandatory
# - name: main-vcenter
# the host used to resolve the vCenter IP
# mandatory
# host: vcenter.domain.com
# Read-only credentials to connect to vCenter
# mandatory
# see https://app.datadoghq.com/account/settings#integrations/vsphere
# username: [email protected]
# password: mypassword
# all_metrics: false # will generate a lot of metrics
# Use a regex like this if you want only the check
# to fetch metrics for these ESXi hosts and the VMs
# running on it
# optional
# host_include_only_regex: ".*\.prod.datadoghq.com"
# Use a regex to include only the VMs that are
# matching this pattern.
# optional
# vm_include_only_regex: ".*\.sql\.datadoghq\.com"
# When set to true, this will collect EVERY metric
# from vCenter, which means a LOT of metrics you probably
# do not care about. We have selected a set of metrics
# that are interesting to monitor for you if false
# optional
# all_metrics: false # /!\ will generate a lot of metrics
# Event config is a dictionary
# For now the only switch you can flip is collect_vcenter_alarms
# which will send as events the alarms set in vCenter
# event_config:
# collect_vcenter_alarms: false # defaults to false