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"
);

?>

Once you have moved the three files (nxFramework.php, nxAHVReporter.php, nxCredentials.php) in the same folder and adjusted the nxCredentials.php file to match your environment, you can run the script :

$ ./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
[...]

You can decide to have the script in debug mode and return a lot of outputs on the screen ... or not :

// Enable debug mode -> chatty screen output 
$debug=true;

Once the script is completed you will find a .CSV file generated in the current directory. This is your report. Of course, the report needs to be layout as you wish. Excel will help you to get it nice with text-to-column functions and all the relevant filtering capabilities. I let you decide how you want your report to be !

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 !

Comments

  1. Hi, it's getting errors

    PHP 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

    ReplyDelete
    Replies
    1. What version of AOS are you running, have you double checked the credentials ? I just tried on a 5.15 LTS without any issues.

      Delete
    2. Just I' running: Version pc.2020.9, NCC Version: ncc-3.10.0.6, Software type prism version 5.18

      Delete
    3. It is not supposed to connect to Prism Central.... (sorry only see this reply now)

      Delete

Post a Comment

Thank you for your message, it has been sent to the moderator for review...

What's hot ?

ShredOS : HDD degaussing with style

Wallbox : Get The Most Of It (with API)