Nutanix : Php, API, AHV Reporter !
Background
Because I had to share this with you a long time ago, I decided to do it now. There is a Nutanix employee (Magnus Andersson, VCDX56, from Sweden) who created a wonderful reporting script for AHV-based Nutanix clusters. This script is written in bash and I think, this is a good opportunity for me to share my Nutanix php Framework. So, I decided, with his consent, to port his script into php. This is a good way to introduce my php framework ;)
Let's do this
So, what is this AHV Reporter all about ? This is based on Magnus initiative who generate a csv file with all the details about your VMs, IP, disk usage, vCPU whatever. This could be useful to (re)size a cluster or plan migration. The original script can be found here and here.
Once the layout is done, you have something similar to this :
So first, you need to have a look at my GitHub repository about this Nutanix php Framework. Then, there is a credential file and the script itself.
<?php
$clusterConnect=array(
"username" => "user",
"password" => "password",
"ip" => "ip_address"
);
?>
$clusterConnect=array(
"username" => "user",
"password" => "password",
"ip" => "ip_address"
);
?>
$ ./nxAHVReporter.php
Nutanix Prism Element ip_address will be used to collect information.
=================================================================
Creating reporting input for VM xxxx now (1/63) .....
=================================================================
VM Description : No VM Description Information Available
VM Uuid : fb965551-a9de-493a-9512-7186cd088bc0
Power State : off
vCPU : 2
vCore : 2
Memory : 2 GB
Host : VM Not Powered On
Network : 018b6662-deba-41f9-99f0-32dda634d86d
[...]
Nutanix Prism Element ip_address will be used to collect information.
=================================================================
Creating reporting input for VM xxxx now (1/63) .....
=================================================================
VM Description : No VM Description Information Available
VM Uuid : fb965551-a9de-493a-9512-7186cd088bc0
Power State : off
vCPU : 2
vCore : 2
Memory : 2 GB
Host : VM Not Powered On
Network : 018b6662-deba-41f9-99f0-32dda634d86d
[...]
// Enable debug mode -> chatty screen output
$debug=true;
$debug=true;
Do not hesitate to report any bug or unexpected behaviors that could help improving the tool.
Big thanks to my fellow Nutanix NTC Christian Pedersen who assisted me during the development phase.
Hope this help !
Hi, it's getting errors
ReplyDeletePHP Notice: Trying to get property 'entities' of non-object in nxFramework.php on line 437
PHP Warning: count(): Parameter must be an array or an object that implements Countable in nxFramework.php on line 453
Using php -v
PHP 7.4.11 (cli) (built: Sep 29 2020 10:17:06) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
What do you think?
Thanks
What version of AOS are you running, have you double checked the credentials ? I just tried on a 5.15 LTS without any issues.
DeleteJust I' running: Version pc.2020.9, NCC Version: ncc-3.10.0.6, Software type prism version 5.18
DeleteIt is not supposed to connect to Prism Central.... (sorry only see this reply now)
Delete