JMX::Jmx4Perl::Request - A jmx4perl request
$req = JMX::Jmx4Perl::Request->new(READ,$mbean,$attribute);
A JMX::Jmx4Perl::Request encapsulates a request for various operational types.
The following attributes are available:
Name of the targetted mbean in its canonical format.
Type of request, which should be one of the constants
Get the value of a attribute
Write an attribute
Execute an JMX operation
List all MBeans available
Search for MBeans
Get the agent's version and extra runtime information of the serverside.
Register for a JMX notification (not supported yet)
Remove a JMX notification (not supported yet)
If type is READ or WRITE this specifies the requested attribute
READ
WRITE
For WRITE this specifies the value to set
List of arguments of EXEC operations
EXEC
This optional parameter can be used to specify a nested value in an complex mbean attribute or nested return value from a JMX operation. For example, the MBean java.lang:type=Memory's attribute HeapMemoryUsage is a complex value, which looks in the JSON representation like
java.lang:type=Memory
HeapMemoryUsage
"value":{"init":0,"max":518979584,"committed":41381888,"used":33442568}
So, to fetch the "used" value only, specify used as path within the request. You can access deeper nested values by building up a path with "/" as separator. This looks a bit like a simplified form of XPath.
"used"
used
With these number you can restrict the size of the JSON structure returned. maxDepth gives the maximum nesting level of the JSON object,maxObjects returns the maximum number of objects to be returned in total and maxCollectionSize restrict the number of all arrays and collections (maps, lists) in the answer. Note, that you should use this restrictions if you are doing massive bulk operations. ignoreErrors is useful for read requests with multiple attributes to skip errors while reading attribute values on the errors side (the error text will be set as value).
maxDepth
maxObjects
maxCollectionSize
ignoreErrors
If given, the request is processed by the agent in proxy mode, i.e. it will proxy to another server exposing via a JSR-160 connector. target is a hash which contains information how to reach the target service via the proxy. This hash knows the following keys:
target
JMX service URL as specified in JSR-160 pointing to the target server.
Further context information which is another hash.
$req = new JMX::Jmx4Perl::Request(READ,$mbean,$attribute,$path, { ... options ... } ); $req = new JMX::Jmx4Perl::Request(READ,{ mbean => $mbean,... }); $req = new JMX::Jmx4Perl::Request({type => READ, mbean => $mbean, ... });
The constructor can be used in various way. In the simplest form, you provide the type as first argument and depending on the type one or more additional attributes which specify the request. The second form uses the type as first parameter and a hashref containing named parameter for the request parameters (for the names, see above). Finally you can specify the arguments completely as a hashref, using 'type' for the entry specifying the request type.
For the options maxDepth, maxObjects and maxCollectionSize, you can mix them in into the hashref if using the hashed argument format. For the first format, these options are given as a final hashref.
The option method can be used to suggest a HTTP request method to use. By default, the agent decides automatically which HTTP method to use depending on the number of requests and whether an extended format should be used (which is only possible with an HTTP POST request). The value of this option can be either post or get, dependening on your preference.
method
post
get
If the request should be proxied through this request, a target configuration needs to be given as optional parameter. The target configuration consists of a JMX service url and a optional environment, which is given as a key-value map. For example
url
$req = new JMX::Jmx4Perl::Request(..., { target => { url => "", env => { ..... } } } );
Note, depending on the type, some parameters are mandatory. The mandatory parameters and the order of the arguments for the constructor variant without named parameters are:
Order : $mbean, $attribute, $path Mandatory: $mbean, $attribute
Note that $attribute can be either a single name or a reference to a list of attribute names.
$attribute
Order : $mbean, $attribute, $value, $path Mandatory: $mbean, $attribute, $value
Order : $mbean, $operation, $arg1, $arg2, ... Mandatory: $mbean, $operation
LIST
Order : $path
SEARCH
Order : $pattern Mandatory: $pattern
Set the HTTP request method for this requst excplicitely. If not provided either during construction time (config key 'method') a prefered request method is determined dynamically based on the request contents.
Returns true, if the MBean name used in this request is a MBean pattern (which can be used in SEARCH or for READ) or not
Get a request parameter
This file is part of jmx4perl.
Jmx4perl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
jmx4perl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with jmx4perl. If not, see <http://www.gnu.org/licenses/>.
A commercial license is available as well. Please contact roland@cpan.org for further details.
roland@cpan.org
To install JMX::Jmx4Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JMX::Jmx4Perl
CPAN shell
perl -MCPAN -e shell install JMX::Jmx4Perl
For more information on module installation, please visit the detailed CPAN module installation guide.