VMware – esxtop – troubleshooting VM CPU performance

To display VM only press V (VM only view):

then to expand specific VM press e (expand) then enter the GID number:

As this VM has 3 CPU I can see CPU usage on all of them, RDY, USED and CSTP times.

%RDY is a Key Performance Indicator!  This one defines how much time your virtual machine wanted to execute CPU cycles but could not get access to the physical CPU. It tells you how much time did you spend in a “queue”. I normally expect this value to be better than 5%. In this case we can see that this VM is struggling a bit or it is very busy.

%USED tells you how much time did the virtual machine spend executing CPU cycles on the physical CPU.

%CSTP tells you how much time a virtual machine is waiting for a virtual machine with multiple vCPU to catch up. If this number is higher than 3% you should consider lowering the amount of vCPU in your virtual machine.

Linux – Network Manager – change static IP via nmcli

1 . Display available network adapters

[root@HOST]# nmcli conn show
Wired connection 2 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ethernet ens192

2. Change the IP address, gateway and DNS:

[root@HOST]# nmcli connection modify 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.address
[root@HOST]# nmcli conn modify 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.gateway
[root@HOST]# nmcli conn mod 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.method manual
[root@HOST]# nmcli conn mod 7d08ebcc-94a7-337f-9b74-edecb7cbfd37 ipv4.dns
[root@HOST]# nmcli conn up 7d08ebcc-94a7-337f-9b74-edecb7cbfd37
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)

Linux – Adding and extending LVM disk

Current config:

#df -h
Filesystem            Size  Used Avail Use% Mounted on
                       50G   47G  554M  99% /
tmpfs                 1.9G   76K  1.9G   1% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
                      5.5G   12M  5.2G   1% /home

I have added 10 GB and want to extend the root drive

1. Rescan to find the new space (this will be different for different systems – first find out what SCSI devices you have) – in my case:

[root@HOST ~]# echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
[root@HOST ~]# echo 1 > /sys/class/scsi_device/3\:0\:0\:0/device/rescan

2. Use cfdisk to create new partition from the newly added space – type 8e

3. Run partprobe to detect the new partition (in my case it was /dev/sda3)

# partprobe -s
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).  As a result, it may not reflect all of your changes until after reboot.

#fdisk -l

Disk /dev/sda: 75.2 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00024dad

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        7833    62401536   8e  Linux LVM
/dev/sda3            7833        9138    10485760   8e  Linux LVM

# vgextend vg_HOST /dev/sda3
  Device /dev/sda3 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sda3' to volume group 'vg_HOST'.

4. because Partprobe failed I am unable to use vgextend and I don’t want to reboot that system – solution is to use partx command

# partx -l /dev/sda
# 1:      2048-  1026047 (  1024000 sectors,    524 MB)
# 2:   1026048-125829119 (124803072 sectors,  63899 MB)
# 3: 125829120-146800639 ( 20971520 sectors,  10737 MB)
# 4:         0-       -1 (        0 sectors,      0 MB)

# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2

5. Extend volume group

# vgextend vg_HOST /dev/sda3
  Physical volume "/dev/sda3" successfully created
  Volume group "vg_HOST" successfully extended

# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       50G   47G  555M  99% /
tmpfs                 1.9G   80K  1.9G   1% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
                      5.5G   12M  5.2G   1% /home

6. Extend Logical volume

NOTE: to avoid errors – always use size that is bit smaller then the size we want – so instead 10G I use 9950M – googole it if you want to know why

# lvextend -L+9950M /dev/mapper/vg_HOST-lv_root
  Rounding size to boundary between physical extents: 9.72 GiB.
  Size of logical volume vg_HOST/lv_root changed from 50.00 GiB (12800 extents) to 59.72 GiB (15288 extents).
  Logical volume lv_root successfully resized.

# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       50G   47G  555M  99% /
tmpfs                 1.9G   80K  1.9G   1% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
                      5.5G   12M  5.2G   1% /home

7. Resize the disk

# resize2fs /dev/mapper/vg_HOST-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_HOST-lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 4
Performing an on-line resize of /dev/mapper/vg_HOST-lv_root to 15654912 (4k) blocks.
The filesystem on /dev/mapper/vg_HOST-lv_root is now 15654912 blocks long.

[root@HOST ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
                       59G   47G  9.7G  83% /
tmpfs                 1.9G   80K  1.9G   1% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
                      5.5G   12M  5.2G   1% /home

PowerShell – event ID email monitor

Short little script that will email you all EventIDs (in this case 7040 and 1501) for the last 24 hours

#List Event IDs that you want mainitored
$EventId = 7040,1501

#Sepcify time frame, and log file
$StartTime = (Get-Date).AddDays(-1)
$events = Get-WinEvent -FilterHashtable @{Logname="System"; ID = $EventId; StartTime=$StartTime}

#Specify To, From, Subject and email server
$EmailFrom = "eventID@alerts.com"
$EmailTo = "user@domain.com"
$Subject ="Alert From $MachineName"
$emailServer = A.B.C.D

$result = @()
foreach ($A in $events) {

$Message = $A.Message
$EventID = $A.Id
$MachineName = $A.MachineName
$Source = $A.ProviderName

	$result += New-Object psobject -Property @{
			EventID = $EventId
            Source = $Source
            MachineName = $MachineName
            Message = $Message
Send-MailMessage -From $EmailFrom -To $EmailTo -subject $Subject -Body ($result | fl | out-string ) -smtpServer $emailServer -port 25