The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.
Summary
Is there a way to pass the server side commands in “asadm” from client code programmatically?
Resolution
You can execute the server side asadm commands from the client code using the Info calls. However, the commands issued from the client are by default to a specific node and if you wish to execute the command on all the servers then looping around all the nodes in the cluster can be done.
Example 1: Java
To get the statistics from a specific node in the cluster you could do the following:
Server side:
asinfo -v 'statistics'
Client side
Info.request(infoPolicy, client.getNodes()[0],"statistics")
Example 2: Java
To get the read latency for a certain duration on a node you could do the following
Server side:
asinfo -v 'latency:' -l
Client side:
Info.request(infoPolicy, client.getNodes()[0],"latency:hist={test}-read;slice=10;back=300;duration:120")
Example 3: Python
Server side:
asinfo -v "sets"
Client side:
client.info_node("sets")
Useful links:
Info Class C# API reference:
Info Class: Java API reference: https://www.aerospike.com/apidocs/java/com/aerospike/client/Info.html
Info Class: Python API reference: https://www.aerospike.com/apidocs/python/client.html?highlight=info_node#aerospike.Client.info_node
To get the list of asinfo
commands that can be executed using the above method, please see the following link: Info Command Reference | Aerospike Documentation
Timestamp
October 2019