import paramiko
cmd = 'asadm -U admin -P password -e "enable; asinfo -v get-stats:context=xdr;dc=A"'
def get_aerospike_hs():
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect('ip_address', username='username', key_filename=r'local_file_location/keyfile.pem')
command = f'sudo su -c "{cmd}"' # Use f-string for command
_, stdout, stderr = ssh.exec_command(command)
errors = stderr.read().decode('utf-8')
if errors:
print(f"Error: {errors}")
status = stdout.read().decode('utf-8')
return status
except Exception as e:
print(f"Exception occurred: {e}")
finally:
ssh.close()
if __name__ == '__main__':
aerospike_status = get_aerospike_hs()
if aerospike_status:
print(aerospike_status)
else:
print("No Status Returned")
Please check and review the above code so that it can return the health check status of Aerospike Cluster
The above code was executed to get the output: No Status Returned