Thursday, 24 January 2013
ESXi Host Memory Swapping and Balloon not deflating - Solved
I came across an interesting problem where hypervisor's memory was ballooning although there wasn't a memory contention on the host.
Problem:
Host has 32GB of RAM and provisioned RAM is 20GB, there was absolutely no reason for Memory swapping or Ballooning but when I did SSH and esxtop then 'm' for memory, you can see in the screenshot memory swapping is taking place:
This was confirmed from the VIClient Performance tab as well where 1.5GB of hypervisor's memory was in used by Baloon drivers.
I've also added screenshot from VKernel vOPS
After going back to basis and checking esxtop again, I found that although MEMSZ is 2048MB the GRANT memory is 449.11MB this tells me something is wrong with resource allocation.
On checking VM Properties, strangely there is a limit of 512MB on the memory resources which is not visible in Summary and you can also see from the screenshot memory limit bar wasn't moved or adjusted to 512MB.
You can also run following command (change the VMNAME) to identify the memory size and maximum memory size
egrep "memsize|sched.mem.max" /vmfs/volumes/*/*/VMNAME.vmx | awk -F/ '{print $6}' | more
Solution:
After completing the VMotion check the performace monitor and see memory release from the Balloon drivers and difference in VM performance and VM memory chart.
Possible Cause:
Problem:
Host has 32GB of RAM and provisioned RAM is 20GB, there was absolutely no reason for Memory swapping or Ballooning but when I did SSH and esxtop then 'm' for memory, you can see in the screenshot memory swapping is taking place:
This was confirmed from the VIClient Performance tab as well where 1.5GB of hypervisor's memory was in used by Baloon drivers.
I've also added screenshot from VKernel vOPS
After going back to basis and checking esxtop again, I found that although MEMSZ is 2048MB the GRANT memory is 449.11MB this tells me something is wrong with resource allocation.
On checking VM Properties, strangely there is a limit of 512MB on the memory resources which is not visible in Summary and you can also see from the screenshot memory limit bar wasn't moved or adjusted to 512MB.
You can also run following command (change the VMNAME) to identify the memory size and maximum memory size
egrep "memsize|sched.mem.max" /vmfs/volumes/*/*/VMNAME.vmx | awk -F/ '{print $6}' | more
Solution:
If
sched.mem.max is smaller than memsize, the balloon driver can start consuming memory
(especially if the guest operating system application has periodic bursts of
memory usage). However, this setting can cause the balloon driver to retain its
hold on memory. If the guest operating system requires memory that is made
unavailable by the balloon driver, the guest operating system starts using swap
memory instead, which slows it down considerably.
To force the balloon driver to release its hold on
memory and prevent the guest operating system from using swap space, use one of
these options:
After completing the VMotion check the performace monitor and see memory release from the Balloon drivers and difference in VM performance and VM memory chart.
Possible Cause:
Migrating a virtual machine from ESX 2.x to 3.x
or 4.x may cause a carry-over of memory reservation that is smaller than the
virtual machine's allocated memory (likely a customer-specific
setting).
Auto delete files older than x number of days
Following script is ideal where you want to clear the space from backup repository and keep files created in last x number of day, I've been utilizing this to delete all SQL backup files *.bak from backup repository D:\foldername where anything older than 6 days should be deleted.
Create a batch file Script.bat and Add it the Scheduled Tasks to run daily/weekly/monthly
forfiles /p "D:\foldername" /m *.bak /s /d -6 /c "cmd /c del @PATH"
Switches used:
/P pathname
/M searchmask
/S recuse and check all the subdirectories
/D date
Selects files with a last modified date greater than or equal to (+), or less than or equal to (-), the specified date using the "dd/MM/yyyy" format; or selects files with a last modified date greater than or equal to (+) the current date plus "dd" days, or less than or equal to (-) the current date minus "dd" days. A valid "dd" number of days can be any number in the range of 0 - 32768. "+" is taken as default sign if not specified.
/C command Indicates the command to execute for each file.
Command strings should be wrapped in double quotes.
The default command is "cmd /c echo @file".
The following variables can be used in the command string:
@file - returns the name of the file.
@fname - returns the file name without extension.
@ext - returns only the extension of the file.
@path - returns the full path of the file.
@relpath - returns the relative path of the file.
@isdir - returns "TRUE" if a file type is a directory, and "FALSE" for files.
@fsize - returns the size of the file in bytes.
@fdate - returns the last modified date of the file.
@ftime - returns the last modified time of the file.
Internal CMD.exe commands should be preceded with "cmd /c".
Create a batch file Script.bat and Add it the Scheduled Tasks to run daily/weekly/monthly
forfiles /p "D:\foldername" /m *.bak /s /d -6 /c "cmd /c del @PATH"
Switches used:
/P pathname
/M searchmask
/S recuse and check all the subdirectories
/D date
Selects files with a last modified date greater than or equal to (+), or less than or equal to (-), the specified date using the "dd/MM/yyyy" format; or selects files with a last modified date greater than or equal to (+) the current date plus "dd" days, or less than or equal to (-) the current date minus "dd" days. A valid "dd" number of days can be any number in the range of 0 - 32768. "+" is taken as default sign if not specified.
/C command Indicates the command to execute for each file.
Command strings should be wrapped in double quotes.
The default command is "cmd /c echo @file".
The following variables can be used in the command string:
@file - returns the name of the file.
@fname - returns the file name without extension.
@ext - returns only the extension of the file.
@path - returns the full path of the file.
@relpath - returns the relative path of the file.
@isdir - returns "TRUE" if a file type is a directory, and "FALSE" for files.
@fsize - returns the size of the file in bytes.
@fdate - returns the last modified date of the file.
@ftime - returns the last modified time of the file.
Internal CMD.exe commands should be preceded with "cmd /c".
Tuesday, 22 January 2013
Active Directory Health Check Script
netdom query fsmo > C:\temp\HealthCheck_FSMO_roles.txt
Dcdiag.exe /v > c:\temp\HealthCheck_dcdiag.txt
Dcdiag.exe /q > c:\temp\HealthCheck_dcdiag_erroronly.txt
Netdiag.exe /v > c:\temp\HealthCheck_Netdiag.txt
Netsh dhcp show server > c:\temp\HealthCheck_dhcp.txt
Repadmin /showreps > c:\temp\HealthCheck_rep_partners.txt
repadmin /replsum /errorsonly > c:\temp\HealthCheck_rep_erroronly.txt
Dcdiag.exe /v > c:\temp\HealthCheck_dcdiag.txt
Dcdiag.exe /q > c:\temp\HealthCheck_dcdiag_erroronly.txt
Netdiag.exe /v > c:\temp\HealthCheck_Netdiag.txt
Netsh dhcp show server > c:\temp\HealthCheck_dhcp.txt
Repadmin /showreps > c:\temp\HealthCheck_rep_partners.txt
repadmin /replsum /errorsonly > c:\temp\HealthCheck_rep_erroronly.txt
Sunday, 20 January 2013
Consolidate Helper- 0
If you are using VSphere 4.x or higher and Veeam Backup & Replication v6 and getting random 'Consolidate Helper- 0' snapshot(s) in snapshot manager, as shown in the screenshot, it is time to upgrade to Veaam Backup & Replication version 6.5. For whatever reason you cannot upgrade to 6.5 or downgrade to 5 then create an alert in VIClietnt Alarms to notify VMs running on snapshot and delete the snapshot manually as soon as you get an alert.
Having couple or more of these Snapshot will massively deteriorate your VMs performance specially if this is on your File, SQL or Exchange server which require high disk read and write IOs. Also not to forget the disk space they consume which carry great risk of bringing your VM(s) to a complete halt and the time it takes to delete them to bring your VMs up and online.
Saturday, 19 January 2013
Bulk Out of Office Assistant for Exchange Admins
Download link:http://sourceforge.net/projects/bulkoutofoffice/files/BulkOoO-v4.zip/download
Name:Bulk Out Of Office For Exchange 2003 2007 2010 Admins
Description:
Handy tool for Ms Exchange Admins that allow:
- Setup out of office message with just few clicks - No need to 'owa' user's mailbox to setup an Out of Office Message
- Create bulk out of office message using a CSV file
- Application detects Exchange Servers Names and populate Server Name box for you to select.
- Progress bar updates keeps you updated when modifying OoO in bulk
- Works on Windows XP, 7, Server 2003, 2008 (Ms Outlook required, see requirement section below)
Requirements:
- Microsoft Exchange MAPI Client (Ms Outlook)
- Microsoft Download Collaboration Data Objects CDO 1.2.1 or higher
(Not required if you are running BulkOutOfOffice from Exchange Server)
- For Outlook 2003 – Enable CDO from Add and Remove Programs
- For Outlook 2007 – download and install from here
- For Outlook 2010 – CDO is not provided by Microsoft
- Workaround is to uninstall MS Outlook 2010, install CDO and then reinstall MS Outlook 2010
- And of course Windows XP, 7, Sever 2003, 2008
Files:
BulkOoO-v4.exe
gradient-background.jpg
microsoft_office_outlook.ico
microsoft_office_outlook.png
ExchangeCdo.MSI for Outlook 2007
Sample.csv –(missed during compilation, will be updated soon)
Example of Sample.csv
Problems:
Mail Server Name
|
Mailbox Name or Email Address
|
Out Of Office Message
|
Enable/Disable
|
ExchServer1
|
testuser1@domain.com
|
This Mailbox is no longer monitored
resend you email to newaddress1@domain.com
|
TRUE
|
ExchServer2
|
testuser2
|
This Mailbox is no longer monitored
resend you email to newaddress2@domain.com
|
FALSE
|
MailServer
|
xyzuser
|
This Mailbox is no longer monitored
resend you email to newaddress3@domain.com
|
TRUE
|
Bulk Out of Office will freeze if :
- Your PC is member of a workgroup
- Cannot communicate with the AD and Exchange Servers in your organisation
Wednesday, 16 January 2013
Automate FTP file copy - Batch Script
To Automate FTP file copy create two files, Import.bat and Script.txt rename to scr when finished editing (Script.scr)
Import.bat
REM @echo off
cd\
C:\
del importedfile
ftp -s:Script.scr
ping 127.0.0.1 -n 4 -w 1000 REM use ping to delay the copy of ftp file
xcopy C:\importedfile \\destination\share /Y
Script.scr
open ftpsite
ftp_username
ftp_password
lcd "C:\"
cd ftp_folder
get importedfile
bye
Run Import.bat to fetch importedfile to C: from ftpsite
Import.bat
REM @echo off
cd\
C:\
del importedfile
ftp -s:Script.scr
ping 127.0.0.1 -n 4 -w 1000 REM use ping to delay the copy of ftp file
xcopy C:\importedfile \\destination\share /Y
Script.scr
open ftpsite
ftp_username
ftp_password
lcd "C:\"
cd ftp_folder
get importedfile
bye
Run Import.bat to fetch importedfile to C: from ftpsite
SQL Flat File Daily Backup Job and Daily Checks script
Backup of MS SQL 2005/2008 Databases from SQL Maintenace job is way easier and quicker when it comes to restoring compared to BackupExec or similar products.
Also SQL Agent maintains the log of scheduled maintenance task, successes and failures etc.
Following are the steps for creating automated SQL Backup Maintenance job and Batch script to check if your backup has been successful and drop you an email on daily basis
Create SQL Backup Maintenance Job
http://www.freetutorialssubmit.com/create-ms-sql-backup-maintenance-plan/1585
Verify backup path and Backup file format
Create Batch script to monitor the Backup folders
Create a batch file sqlcheck.bat
@echo off
FOR /F "TOKENS=1,2 DELIMS=/ " %%A IN ('DATE /T') DO SET mm=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('DATE /T') DO SET yyyy=%%B
FOR /F "TOKENS=1 DELIMS=/ " %%A IN ('DATE /T') DO SET dd=%%A
set efin=%mm%%dd%%yyyy%
if %dd% LSS 10 set dd=%dd:~-1%
set /A dd=%dd%-1
IF %dd% LSS 10 set dd=0%dd%
if %dd% equ 00 if %mm% equ 01 (
Set dd=31
Set mm=12
)
if %dd% equ 00 if %mm% equ 02 (
Set dd=31
Set mm=01
)
if %dd% equ 00 if %mm% equ 03 (
Set dd=28
Set mm=02
)
if %dd% equ 00 if %mm% equ 04 (
Set dd=31
Set mm=03
)
if %dd% equ 00 if %mm% equ 05 (
Set dd=30
Set mm=04
)
if %dd% equ 00 if %mm% equ 06 (
Set dd=31
Set mm=05
)
if %dd% equ 00 if %mm% equ 07 (
Set dd=30
Set mm=06
)
if %dd% equ 00 if %mm% equ 08 (
Set dd=31
Set mm=07
)
if %dd% equ 00 if %mm% equ 09 (
Set dd=31
Set mm=08
)
if %dd% equ 00 if %mm% equ 10 (
Set dd=30
Set mm=09
)
if %dd% equ 00 if %mm% equ 11 (
Set dd=31
Set mm=10
)
if %dd% equ 00 if %mm% equ 12 (
Set dd=30
Set mm=11
)
set ymd=%yyyy%%mm%%dd%
REM Backup file format Northwind20121217.bak
set y_m_d=%yyyy%_%mm%_%dd%
REM Backup file format Northwind_2012_12_17.bak
:END
REM Examples
dir \\RepositoryServer\d$\backup\*.bak |find "/"
dir \\RepositoryServer\Backup\DatabaseName\*.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%ymd%*1400.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%ymd%*.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%y_m_d%*1400.bak | find "/"
Schedule to run daily and email the report
download BMAIL.exe to email the report
Create second batch file sqlreport.bat to count number of lines to ensure all the databases are backed up and add it to Windows Scheduled Task:
sqlcheck.bat > sqlcheck.txt
REM following will count no of Databases backed up and add on the bottom of the txt file
for /f "tokens=* delims= " %%t in ('dir/b sqlcheck.txt') do (
for /f "tokens=* delims= " %%a in (%%t) do (
set /a N+=1
)
)
@echo ****************************** >> "SQLCheck.txt"
echo Total Backedup files count = !N! >>"SQLCheck.txt"
REM 120 are the number of databases my script was checking daily
Set /A p=120-%N%
echo Flat Files missed = %p% >>"SQLCheck.txt"
bmail -s smtpservername -t emailaddress@domain.com -f sendersaddress@domain.com-h -a "SQLCheck" -m SQLCheck.txt -c
Also SQL Agent maintains the log of scheduled maintenance task, successes and failures etc.
Following are the steps for creating automated SQL Backup Maintenance job and Batch script to check if your backup has been successful and drop you an email on daily basis
Create SQL Backup Maintenance Job
http://www.freetutorialssubmit.com/create-ms-sql-backup-maintenance-plan/1585
Verify backup path and Backup file format
Create Batch script to monitor the Backup folders
Create a batch file sqlcheck.bat
@echo off
FOR /F "TOKENS=1,2 DELIMS=/ " %%A IN ('DATE /T') DO SET mm=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('DATE /T') DO SET yyyy=%%B
FOR /F "TOKENS=1 DELIMS=/ " %%A IN ('DATE /T') DO SET dd=%%A
set efin=%mm%%dd%%yyyy%
if %dd% LSS 10 set dd=%dd:~-1%
set /A dd=%dd%-1
IF %dd% LSS 10 set dd=0%dd%
if %dd% equ 00 if %mm% equ 01 (
Set dd=31
Set mm=12
)
if %dd% equ 00 if %mm% equ 02 (
Set dd=31
Set mm=01
)
if %dd% equ 00 if %mm% equ 03 (
Set dd=28
Set mm=02
)
if %dd% equ 00 if %mm% equ 04 (
Set dd=31
Set mm=03
)
if %dd% equ 00 if %mm% equ 05 (
Set dd=30
Set mm=04
)
if %dd% equ 00 if %mm% equ 06 (
Set dd=31
Set mm=05
)
if %dd% equ 00 if %mm% equ 07 (
Set dd=30
Set mm=06
)
if %dd% equ 00 if %mm% equ 08 (
Set dd=31
Set mm=07
)
if %dd% equ 00 if %mm% equ 09 (
Set dd=31
Set mm=08
)
if %dd% equ 00 if %mm% equ 10 (
Set dd=30
Set mm=09
)
if %dd% equ 00 if %mm% equ 11 (
Set dd=31
Set mm=10
)
if %dd% equ 00 if %mm% equ 12 (
Set dd=30
Set mm=11
)
set ymd=%yyyy%%mm%%dd%
REM Backup file format Northwind20121217.bak
set y_m_d=%yyyy%_%mm%_%dd%
REM Backup file format Northwind_2012_12_17.bak
:END
REM Examples
dir \\RepositoryServer\d$\backup\*.bak |find "/"
dir \\RepositoryServer\Backup\DatabaseName\*.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%ymd%*1400.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%ymd%*.bak | find "/"
dir \\RepositoryServer\Backup\DatabaseName\*%y_m_d%*1400.bak | find "/"
Schedule to run daily and email the report
download BMAIL.exe to email the report
Create second batch file sqlreport.bat to count number of lines to ensure all the databases are backed up and add it to Windows Scheduled Task:
sqlcheck.bat > sqlcheck.txt
REM following will count no of Databases backed up and add on the bottom of the txt file
for /f "tokens=* delims= " %%t in ('dir/b sqlcheck.txt') do (
for /f "tokens=* delims= " %%a in (%%t) do (
set /a N+=1
)
)
@echo ****************************** >> "SQLCheck.txt"
echo Total Backedup files count = !N! >>"SQLCheck.txt"
REM 120 are the number of databases my script was checking daily
Set /A p=120-%N%
echo Flat Files missed = %p% >>"SQLCheck.txt"
bmail -s smtpservername -t emailaddress@domain.com -f sendersaddress@domain.com-h -a "SQLCheck" -m SQLCheck.txt -c
Subscribe to:
Posts (Atom)