create csv/excel IPv6 subnet

Reference: http://colinrrobinson.com/technology/programming/php/ipv6-subnet-calculator/

 

  1. download source
  2. modify calculator_tools.php, add following function
    function print_csv( $network )
    {
            if (substr_count($network->position, '.') == 1){
            	echo $network->position.',56,';
    	}else{
            	echo $network->position.',64,';
    	}
    
            if ( count($network->subnets) )
                    echo '';
    
            echo hex_to_human($network->ip) . '/' . $network->prefix . "\n";
    
            foreach( $network->subnets as $subnet )
                    $network_array['subnets'][] = print_csv($subnet); 
    }

     

  3. add create_csv.php
    <?php
    require_once 'calculator_tools.php';
    require_once 'Network.php';
    
    $address = '2001:b000:0015::';
    $prefix  = '48';
    $levels  = array('256','256');
    
    $ip = human_to_hex( $address );
    $network = new Network($ip, $prefix, $levels);
    print_csv($network);
    
    ?>

     

Install VMware vSphere CLI on CentOS 6.4

Reference:

How to install VMware ESXi CLI on CentOS 6.0?

VMware vSphere 5.1 Documentation Center – vSphere 5.1 Command Line Documentation – Install vCLI

 

Install EPEL repo first

download VMware-vSphere-CLI-5.1.0-1060453.x86_64.gz from VMware website

 

yum -y install uuid-perl perl-XML-LibXML uuid-perl  libuuid-devel glibc.i686
tar zxvf VMware-vSphere-CLI-5.1.0-1060453.x86_64.gz
cd vmware-vsphere-cli-distrib
./vmware-install.pl

 

 

[temp]powercli

Connect-VIServer -Server 172.30.65.202 -User youraccount -Password 'your password'
$allvms = @()
$allhosts = @()
$hosts = Get-VMHost
$vms = Get-Vm

foreach($vmHost in $hosts){
  $hoststat = "" | Select HostName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
  $hoststat.HostName = $vmHost.name

  $statcpu = Get-Stat -Entity ($vmHost)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat cpu.usage.average
  $statmem = Get-Stat -Entity ($vmHost)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat mem.usage.average

  $cpu = $statcpu | Measure-Object -Property value -Average -Maximum -Minimum
  $mem = $statmem | Measure-Object -Property value -Average -Maximum -Minimum

  $hoststat.CPUMax = $cpu.Maximum
  $hoststat.CPUAvg = $cpu.Average
  $hoststat.CPUMin = $cpu.Minimum
  $hoststat.MemMax = $mem.Maximum
  $hoststat.MemAvg = $mem.Average
  $hoststat.MemMin = $mem.Minimum
  $allhosts += $hoststat
}
$allhosts | Select HostName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv "c:\Hosts.csv" -noTypeInformation

foreach($vm in $vms){
  $vmstat = "" | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin
  $vmstat.VmName = $vm.name

  $statcpu = Get-Stat -Entity ($vm)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat cpu.usage.average
  $statmem = Get-Stat -Entity ($vm)-start (get-date).AddDays(-30) -Finish (Get-Date)-MaxSamples 10000 -stat mem.usage.average

  $cpu = $statcpu | Measure-Object -Property value -Average -Maximum -Minimum
  $mem = $statmem | Measure-Object -Property value -Average -Maximum -Minimum

  $vmstat.CPUMax = $cpu.Maximum
  $vmstat.CPUAvg = $cpu.Average
  $vmstat.CPUMin = $cpu.Minimum
  $vmstat.MemMax = $mem.Maximum
  $vmstat.MemAvg = $mem.Average
  $vmstat.MemMin = $mem.Minimum
  $allvms += $vmstat
}
$allvms | Select VmName, MemMax, MemAvg, MemMin, CPUMax, CPUAvg, CPUMin | Export-Csv "c:\VMs.csv" -noTypeInformation

 

reference:  https://communities.vmware.com/thread/258250

todo: add disk i/o usage