Skip to content

Commit

Permalink
[jmxfetch] Check that a name is set when the jmx_url option is used
Browse files Browse the repository at this point in the history
  • Loading branch information
olivielpeau committed Oct 23, 2015
1 parent fa5b6a2 commit f9676f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion conf.d/jmx.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ instances:
# port: 7199
# user: username
# password: password
# process_name_regex: .*process_name.* # Instead of specifying a host, and port. The agent can connect using the attach api.

# # If the agent needs to connect to a non-default JMX URL, specify it here instead of a host and a port
# # If you use this you need to specify a 'name' for the instance, below
# jmx_url: "service:jmx:rmi:///jndi/rmi://myhost.host:9999/custompath"

# process_name_regex: .*process_name.* # Instead of specifying a host and port or jmx_url, the agent can connect using the attach api.
# # This requires the JDK to be installed and the path to tools.jar to be set below.
# tools_jar_path: /usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar # To be set when process_name_regex is set

# name: jmx_instance
# # java_bin_path: /path/to/java # Optional, should be set if the agent cannot find your java executable
# # java_options: "-Xmx200m -Xms50m" # Optional, Java JVM options
Expand Down
6 changes: 6 additions & 0 deletions jmxfetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,15 @@ def _is_jmx_check(check_config, check_name, checks_list):

# Support for attach api using a process name regex
proc_regex = inst.get('process_name_regex')
# Support for a custom jmx URL
jmx_url = inst.get('jmx_url')
name = inst.get('name')

if proc_regex is not None:
is_attach_api = True
elif jmx_url is not None:
if name is None:
raise InvalidJMXConfiguration("A name must be specified when using a jmx_url")
else:
if host is None:
raise InvalidJMXConfiguration("A host must be specified")
Expand Down

0 comments on commit f9676f7

Please sign in to comment.