Jboss 和 Wildfly api 的 Python 客户端
项目描述
pyjboss
用 python 编写的 jboss 和 Wildfly API 客户端
该模块可用于获取 jboss/wildfly 及其资源的信息,实现起来很简单,也可以在命令行中使用。
安装
使用 pip 安装 pyjboss
pip install pyjboss
兼容性
- Jboss EAP >= 7
- 野蝇 >= 10
Python 兼容性
- 蟒蛇> = 2.7
- Python >= 3.0
示例使用 python 命令行 (cli)
如何在运行的 jboss 中创建对象并获取有关 jvm 内存的信息standalone mode。
>>> from pyjboss import PyJboss
>>> objboss = PyJboss(controller='ip_host_controller', user='jboss_admin_user' , password='jboss_admin_password')
>>> objboss.utils.get_memory_info()
{'heap-memory-usage': {'init': 67108864, 'used': 61638768, 'committed': 103874560, 'max': 518979584}, 'non-heap-memory-usage': {'init': 7667712, 'used': 118607784, 'committed': 134217728, 'max': 780140544}, 'object-name': 'java.lang:type=Memory', 'object-pending-finalization-count': 0, 'verbose': False}
ExampleDS如何在运行的 jboss 中创建对象并获取有关数据源的信息domain mode,域中有一个主机,称为master该主机的服务器server-one
>>> from pyjboss import PyJboss
>>> objboss = PyJboss(controller='ip_domain_controller', user='jboss_admin_user' , password='jboss_admin_password', host='master', server='server-one')
>>> objboss.datasource.get(datasource_type='datasource', datasource_name='ExampleDS')
{'allocation-retry': None, 'allocation-retry-wait-millis': None, 'allow-multiple-users': False, 'authentication-context': None, 'background-validation': None, 'background-validation-millis': None, 'blocking-timeout-wait-millis': None, 'capacity-decrementer-class': None, 'capacity-decrementer-properties': None, 'capacity-incrementer-class': None, 'capacity-incrementer-properties': None, 'check-valid-connection-sql': None, 'connectable': False, 'connection-listener-class': None, 'connection-listener-property': None, 'connection-url': 'jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE', 'credential-reference': None, 'datasource-class': None, 'driver-class': None, 'driver-name': 'h2', 'elytron-enabled': False, 'enabled': True, 'enlistment-trace': False, 'exception-sorter-class-name': None, 'exception-sorter-properties': None, 'flush-strategy': None, 'idle-timeout-minutes': None, 'initial-pool-size': None, 'jndi-name': 'java:jboss/datasources/ExampleDS', 'jta': True, 'max-pool-size': None, 'mcp': 'org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool', 'min-pool-size': None, 'new-connection-sql': None, 'password': 'sa', 'pool-fair': None, 'pool-prefill': None, 'pool-use-strict-min': None, 'prepared-statements-cache-size': None, 'query-timeout': None, 'reauth-plugin-class-name': None, 'reauth-plugin-properties': None, 'security-domain': None, 'set-tx-query-timeout': False, 'share-prepared-statements': False, 'spy': False, 'stale-connection-checker-class-name': None, 'stale-connection-checker-properties': None, 'statistics-enabled': True, 'track-statements': 'NOWARN', 'tracking': False, 'transaction-isolation': None, 'url-delimiter': None, 'url-selector-strategy-class-name': None, 'use-ccm': True, 'use-fast-fail': False, 'use-java-context': True, 'use-try-lock': None, 'user-name': 'sa', 'valid-connection-checker-class-name': None, 'valid-connection-checker-properties': None, 'validate-on-match': None, 'connection-properties': None, 'statistics': {'jdbc': None, 'pool': None}}
示例使用 bash 终端
如何获取有关调用default的ejb 线程池的信息standalone mode。
$ python -m pyjboss -u jboss_admin_user -p jboss_admin_password -c ip_host_controller ejb --thread-pool-name default
{
"active-count": 0,
"completed-task-count": 0,
"core-threads": null,
"current-thread-count": 0,
"keepalive-time": {
"time": 60,
"unit": "SECONDS"
},
"largest-thread-count": 0,
"max-threads": 10,
"name": "default",
"queue-size": 0,
"rejected-count": 0,
"task-count": 0,
"thread-factory": null
}
如何在 shell 命令行中获得帮助
$ python -m pyjboss -h
usage: jbosspy [-h] [-u USER] [-p PASSWORD] [-c CONTROLLER] [--host HOST]
[--server SERVER] [-v]
{ejb,message,datasource,utils} ...
This package can be used to call the jbossapi by http protocol and return
values
optional arguments:
-h, --help show this help message and exit
-u USER, --user USER Jboss user with administrator permissions.
-p PASSWORD, --password PASSWORD
Jboss user password.
-c CONTROLLER, --controller CONTROLLER
IP or name of Jboss host controller, or domain
controller.
--host HOST A host from domain. This option is only necessary if
your jboss is running in domain mode.
--server SERVER A server from the host. This option is only necessary
if your jboss is running in domain mode.
-v, --verbose
Commands:
{ejb,message,datasource,utils}
ejb Manage ejb resources
message Manage message resources
datasource Manage datasource resources
utils Get information aboute many resources in general
如何获得有关特定命令的帮助,例如:数据源。
$ python -m pyjboss datasource -h
usage: jbosspy datasource [-h] [--datasource DATASOURCE]
[--xa-datasource XA_DATASOURCE]
[--list {datasource,xa-datasource}]
Get information about datasources
optional arguments:
-h, --help show this help message and exit
--datasource DATASOURCE
Show information about an datasource, important: to
obtain more information enable datasource statistic
--xa-datasource XA_DATASOURCE
Return information about an xa-datasource, important:
to obtain more information enable datasource statistic
--list {datasource,xa-datasource}
Obtain a list of datasources
特征
该模块处于开发初期,具有以下功能。
- 数据源:获取有关数据源和 xa 数据源的信息。
- 消息:获取有关队列或主题中的消息以及列表队列或主题的信息。
- Ejb:获取有关线程池 ejb 的信息。
- 实用程序:获取有关 jvm 内存的信息。
- 日志记录:获取有关日志文件的信息并允许从日志中获取行。
- 部署:获取有关已部署包的信息。