{"id":19762603,"url":"https://github.com/zuazo/node-jmx","last_synced_at":"2025-04-30T14:31:01.135Z","repository":{"id":8339864,"uuid":"9896985","full_name":"zuazo/node-jmx","owner":"zuazo","description":"Node.js library to connect to Java applications through JMX.","archived":false,"fork":false,"pushed_at":"2020-03-20T03:44:46.000Z","size":258,"stargazers_count":34,"open_issues_count":10,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T14:23:20.199Z","etag":null,"topics":["java","jmx","jvm","node"],"latest_commit_sha":null,"homepage":"http://zuazo.github.io/node-jmx/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zuazo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-06T21:10:14.000Z","updated_at":"2023-03-02T01:31:56.000Z","dependencies_parsed_at":"2022-08-07T03:00:11.881Z","dependency_job_id":null,"html_url":"https://github.com/zuazo/node-jmx","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fnode-jmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fnode-jmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fnode-jmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuazo%2Fnode-jmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuazo","download_url":"https://codeload.github.com/zuazo/node-jmx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251406335,"owners_count":21584429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jmx","jvm","node"],"created_at":"2024-11-12T04:05:21.011Z","updated_at":"2025-04-30T14:31:00.824Z","avatar_url":"https://github.com/zuazo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-jmx\n\n[![NPM version](https://badge.fury.io/js/jmx.svg)](http://badge.fury.io/js/jmx)\n[![Code Climate](https://img.shields.io/codeclimate/maintainability-percentage/zuazo/node-jmx.svg)](https://codeclimate.com/github/zuazo/node-jmx)\n[![Build Status](http://img.shields.io/travis/zuazo/node-jmx.svg)](https://travis-ci.org/zuazo/node-jmx)\n[![Coverage Status](http://img.shields.io/coveralls/zuazo/node-jmx.svg)](https://coveralls.io/github/zuazo/node-jmx?branch=master)\n\nNode.js bridge library to communicate with Java applications through JMX.\n\n## Requirements\n\n* Tested with node `\u003e= 0.10`.\n* Java version `6` or higher.\n* `node-java`: See [its installation instructions](https://github.com/joeferner/node-java/blob/v0.9.0/README.md#installation)\n\n## Installation\n\n    $ npm install jmx\n\n## Usage examples\n\n```js\nvar jmx = require(\"jmx\");\n\nclient = jmx.createClient({\n  host: \"localhost\", // optional\n  port: 3000\n});\n\nclient.connect();\nclient.on(\"connect\", function() {\n\n  client.getAttribute(\"java.lang:type=Memory\", \"HeapMemoryUsage\", function(data) {\n    var used = data.getSync('used');\n    console.log(\"HeapMemoryUsage used: \" + used.longValue);\n    // console.log(data.toString());\n  });\n\n  client.setAttribute(\"java.lang:type=Memory\", \"Verbose\", true, function() {\n    console.log(\"Memory verbose on\"); // callback is optional\n  });\n\n  client.invoke(\"java.lang:type=Memory\", \"gc\", [], function(data) {\n    console.log(\"gc() done\");\n  });\n\n});\n```\n\n```js\nclient = jmx.createClient({\n  service: \"service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi\"\n});\n```\nYou can check the [node-java documentation](https://github.com/nearinfinity/node-java/blob/master/README.md#quick-examples) to learn how to work with java objects in node.js.\n\n## Documentation\n\n### jmx.createClient(options)\n\nReturns a `Client` object.\n\n#### options\n\n`options` is a hash table with the following values:\n\n* `service` - The full service URL string, with *host*, *port*, *protocol* and *urlPath* included. For example `\"service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi\"`.\n* `host` - Hostname to connect to (defaults to `\"localhost\"`).\n* `port` - JMX port number to connect to.\n* `protocol` - Protocol to use (defaults to `\"rmi\"`).\n* `urlPath` - JMX URL Path (defaults to `\"/jndi/{protocol}://{host}:{port}/jmx{protocol}\"`).\n* `username` - JMX authentication username.\n* `password` - JMX authentication password.\n\n### Client.connect()\n\nConnects to the JMX server. Emits `connect` event when done.\n\n### Client.disconnect()\n\nDisconnects from the JMX server. Emits `disconnect` event when done.\n\n### Client.getAttribute(mbean, attribute, callback)\n\nReturns an attribute from a MBean.\n\n* `mbean` - MBean query address as string. For example \"java.lang:type=Memory\".\n* `attribute` - Attribute name as string.\n* `callback(attrValue)`\n\n### Client.getAttributes(mbean, attributes, callback)\n\nReturns an attribute list from a MBean.\n\n* `mbean` - MBean query address as string. For example \"java.lang:type=Memory\".\n* `attributes` - Attribute names as an array of strings.\n* `callback(attrValue)`\n\n### Client.getDefaultDomain(callback)\n\nReturns the default domain as string.\n\n* `callback(domainName)`\n\n### Client.getDomains(callback)\n\nReturns an array of domain names.\n\n* `callback(domainsArray)`\n\n### Client.getMBeanCount(callback)\n\nReturns total the number of MBeans.\n\n* `callback(mbeanCount)`\n\n### Client.invoke(mbean, methodName, params, [signature,] [callback])\n\nInvokes a MBean operation.\n\n* `mbean` - The MBean query address as string. For example `\"java.lang:type=Memory\"`.\n* `methodName` - The method name as string.\n* `params` - The parameters to pass to the operation as array. For example `[ 1, 5, \"param3\" ]`.\n* `signature` (optional) - An array with the signature of the *params*. Sometimes may be necessary to use this if class names are not correctly detected (gives a *NoSuchMethodException*). For example `[ \"int\", \"java.lang.Integer\", \"java.lang.String\" ]`.\n* `callback(returnedValue)`\n\n### Client.listMBeans(callback)\n\nLists server MBeans. Callback returns an array of strings containing MBean names.\n\n### Client.on(event, callback)\n\nAdds a listener for the especified event.\n\n#### events\n\n* `connect`\n* `disconnect`\n* `error` - Passes the error as first parameter to the callback function.\n\n### Client.setAttribute(mbean, attribute, value, [className,] [callback])\n\nChanges an attribute value of the MBean.\n\n* `mbean` - The MBean query address as string. For example `\"java.lang:type=Memory\"`.\n* `attribute` - The attribute name as string.\n* `value` - The attribute value.\n* `className` (optional) - The attribute java className. Sometimes may be necessary to use this if value type is not correctly detected (gives a *InvalidAttributeValueException*). For example `\"java.lang.Long\"`.\n* `callback()` (optional)\n\n## Error handling\n\nErrors are **not printed** to the console by default. You can catch them with something like the following:\n\n```js\nclient.on(\"error\", function(err) {\n  // ...\n});\n```\n\n## Debugging\n\nYou can enable debugging and error printing to console using `NODE_DEBUG` environment variable:\n\n    $ NODE_DEBUG=\"jmx\" node [...]\n\n## Testing\n\nSee [TESTING.md](https://github.com/zuazo/node-jmx/blob/master/TESTING.md).\n\n## Contributing\n\nPlease do not hesitate to [open an issue](https://github.com/zuazo/node-jmx/issues/new) with any questions or problems.\n\nSee [CONTRIBUTING.md](https://github.com/zuazo/node-jmx/blob/master/CONTRIBUTING.md).\n\n## TODO\n\nSee [TODO.md](https://github.com/zuazo/node-jmx/blob/master/TODO.md).\n\n## History\n\nSee [CHANGELOG.md](https://github.com/zuazo/node-jmx/blob/master/CHANGELOG.md).\n\n\n## License and Author\n\n|                      |                                          |\n|:---------------------|:-----------------------------------------|\n| **Author:**          | [Xabier de Zuazo](https://github.com/zuazo) (\u003cxabier@zuazo.org\u003e)\n| **Contributor:**     | [Eric](https://github.com/ericbroda)\n| **Contributor:**     | [DarkSorrow](https://github.com/DarkSorrow)\n| **Copyright:**       | Copyright (c) 2015, Xabier de Zuazo\n| **Copyright:**       | Copyright (c) 2013-2015 Onddo Labs, SL.\n| **License:**         | Apache License, Version 2.0\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n        http://www.apache.org/licenses/LICENSE-2.0\n    \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuazo%2Fnode-jmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuazo%2Fnode-jmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuazo%2Fnode-jmx/lists"}