'resxtop' can be used on a remote linux machine to get the same output of 'esxtop' in esxi terminal session. but cannot be used in your shell script due to not be able to pass a password credential as a command line argument. It is quite useful in some use case such as batch mode data collection or launching as a cron job if can be used in a shell script.
Using 'resxtop' utility accessing VMware vSphere ESXi environment.
In usual usage 'resxtop' assumes that reading a password of an access credential from a terminal device (tty) so can't pass the password as command line argument.
Use the following environment variables to pass the access credentials to 'resxtop' utility.
Ex)
#!/bin/bash
export VI_SERVER=XXX.YYY.ZZZ.AAA
export VI_USERNAME=root
export VI_PASSWORD=12345678abcdefg
resxtop -b -n 100 > output.txt
General introduction of 'resxtop' is described in Using the resxtop Utility.