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

JMXTrans can execute simple JMX operations #803

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jnovak-netsystemcz
Copy link

JMXTrans can execute JMX operation, if it is without parameters. Return
value is returned as string with .toString().

Example of configuration:

"queries" : [ {
  ...
  "operation" : [ "listSessions" ],
  ...

It can be combined with "attr" on same object. When no "attr" is used,
just operation is executed. When "attr" and "operation" is used, all
listed attrs and operations are queried.

Note: Before this change, when there was no "attr" in query all
attributes were queried. With the patch, behaving is slightly changed.
When no "operation" and no "attr" is used, all attributes are queried.
When "operation" is used, but no "attr" is used, just operations are
queried.

@AppVeyorBot
Copy link

Our environment runs a lot of Java applications in Linux HA cluster. So
application can run on any of cluster nodes. We are not able to maintain
JMXTrans config files to match applications running on the node and
JMXTrans configuration is same on every HA node. So many of applications
are not reachable for JMX and JMXTrans logs are full of exceptions.

Currently, when Exception happens during Query, full stack trace is
written to the log. This patch allows to specify attribute
jmxErrorHandling to a query with three ways how to handle Query
exception: dump, warn and ignore. Dump is current behaving.
Warn just prints warning about imposibility to collect the data (1 line).
Ignore just ignores any message.

Example:

{
  "servers" : [ {
    ...
    "queries" : [ {
      ...
      "jmxErrorHandling" : "warn",
      ...
    } ]
  } ]
}
ConfigurationParser creates variables based on host:
hostname, reversed_hostname, escaped_hostname, escaped_reversed_hostname,
canonical_hostname, reversed_canonical_hostname, escaped_canonical_hostname,
escaped_reversed_canonical_hostname, hostaddress, escaped_hostaddress

They are similar to jmxtrans-agent (see
https://github.com/jmxtrans/jmxtrans-agent/wiki/Expression-Language).

ConfigurationParser creates variables based on file name:
filename - filename without path and extension
filename1..N - parts of filename splitted by '_'

All variables can be used in any item of configuration. E.g.:

...
"host" : "${filename3}",
"port" : "${filename2}",
"alias" : "${hostname}",
...

for host myhost and filename test_1234_srv1.json creates:

...
"host" : "srv1",
"port" : "1234",
"alias" : "myhost",
...
JMXTrans can execute JMX operation, if it is without parameters. Return
value is returned as string with .toString().

Example of configuration:

"queries" : [ {
  ...
  "operation" : [ "listSessions" ],
  ...

It can be combined with "attr" on same object. When no "attr" is used,
just operation is executed. When "attr" and "operation" is used, all
listed attrs and operations are queried.

Note: Before this change, when there was no "attr" in query all
attributes were queried. With the patch, behaving is slightly changed.
When no "operation" and no "attr" is used, all attributes are queried.
When "operation" is used, but no "attr" is used, just operations are
queried.

Note 2: Patch must be applied after "Query can specify how JMX
Exceptions are handled." PR#805 and "Extended list of variables
usable in configuration files with ${...}" PR#804.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants