使用Powercli千萬要注意系統proxy設定

參考來源:
http://www.yellow-bricks.com/2011/02/24/connection-problems-with-powercli-due-to-proxy-settings/

 

問題:

硬體Firewall/switch ACL/Windows firewall相關設定都查過

telnet vcenter-ip 443也有通

但使用powercli就是怎樣也連不上

後來google才發現是powercli那台設備有設定proxy,而proxy設備因為firewall policy沒開連不到vCenter

 

解決方式:

關閉proxy或是設定vcenter IP不使用proxy

Facebook Comments Box

powercli 取vm-name,vmhost-name,vm-ip-addr

參考來源:
https://communities.vmware.com/thread/457269
http://www.spug.co.uk/?p=259
https://communities.vmware.com/message/2251442

 

get-vm|select name,vmhost,@{N="IP Address";E={@($_.guest.IPAddress)}} |export-csv  -Path c:\VMsAndHostsInfo.csv
Facebook Comments Box

vim for windows 初始化設定

常用設定備忘

set guifont=Consolas:h12
syntax on
colorscheme torte
winsize 160 40
set backspace=2         "在 insert 也可用 backspace
set history=100         "保留 100 個使用過的指令
set number              "顯示行號

 

Facebook Comments Box

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

     

Facebook Comments Box

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

 

 

Facebook Comments Box

[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

Facebook Comments Box

讓VMware ESXi 5.0 正確辨識SSD及啟用host cache

參考資料:

http://www.yellow-bricks.com/2011/08/18/swap-to-host-cache-aka-swap-to-ssd/

http://www.virtuallyghetto.com/2011/07/how-to-trick-esxi-5-in-seeing-ssd.html

http://www.informationweek.com/the-vmware-write-cache-challenge-solved/240147594

 

環境:

Dell R610 300G sas x4 (RAID5), 200G sata ssd x 2 (RAID1)

裝了2顆SSD但是在vCenter上無法正常辨識為SSD,因此無法啟用host cache,必須利用下面的選項將SSD datastore標記為SSD

 

指令備忘

esxcli storage nmp satp rule add --satp VMW_SATP_LOCAL --device naa.6782bcb01ef0cf001a00e4a3722e6b00 --option=enable_ssd

esxcli storage nmp satp rule list | grep enable_ssd

esxcli storage core claiming reclaim -d naa.6782bcb01ef0cf001a00e4a3722e6b00

esxcli storage core device list --device=naa.6782bcb01ef0cf001a00e4a3722e6b00

vim-cmd hostsvc/storage/refresh

 

 

todo:

host cache是write or read cache?(待確認)

Swapping to Host Cache看起來是VM swap file的write cache

Facebook Comments Box

從IP清單轉fortinet firewall語法

<?php

function gen_fw_config_mulit($IP){
  #10.28.101.135-155
  $tmp = preg_split('/\./', $IP);
  $ip_head = "{$tmp[0]}.{$tmp[1]}.{$tmp[2]}";
  $tmp2 = preg_split('/-/', $tmp[3]);
  $ip_start = $tmp2[0];
  $ip_end = $tmp2[1];

  #output config
  echo "edit \"$ip_head.[$ip_start-$ip_end]\"\n";
  echo "    set associated-interface \"P1\"\n";
  echo "    set type iprange\n";
  echo "    set end-ip $ip_head.$ip_end\n";
  echo "    set start-ip $ip_head.$ip_start\n";
  echo "next\n";
}

function gen_fw_config_single($IP){
  #10.28.101.135
  #output config
  echo "edit \"$IP/32\"\n";
  echo "    set associated-interface \"P1\"\n";
  echo "    set subnet $IP 255.255.255.255\n";
  echo "next\n";
}

?>

 

<?php

$ip_file = 'iplist.txt';

require_once 'config.inc.php';
$lines = file($ip_file);
foreach($lines as $line){
  $line = trim($line);
  if (stripos($line, '-') !== false){ //multi IP
    #echo "#$line\n";
    gen_fw_config_mulit($line);
  }else { //single IP
    gen_fw_config_single($line);
  }//if
}//foreach
?>

 

Facebook Comments Box

VMware ESXi 5.0 Enable SNMP

install Vsphere CLI first

 

#check setting
vicfg-snmp.pl --server 172.30.65.240 --username root --password xxxxxxxx --show

#set snmp community
vicfg-snmp.pl --server 172.30.65.240 --username root --password xxxxxxxx --communities public

#enable snmp service
vicfg-snmp.pl --server 172.30.65.240 --username root --password xxxxxxxx --enable

 

Facebook Comments Box