Block Ads using dnsmasq

DNSMasq is a very light-weight DNS server that is perfectly suited to run on low power home appliances like NAS devices or routers running custom firmware.
The script below pulls ad blocking host files from 3 different providers and combines them to use as a DNSMasq resolver file.

Here is the script – it can be used verbatim on a Synology NAS running the DNSMasq package from

Edit the DNSMasq file to add an entry ‘addn-hosts’ to point to the hosts file that was just created – for example:

cd ~/AdBlock

echo "# Generated on: $(date +"%D %T")" > adblock

echo "Downloading file from"
wget -O yoyo
echo "Processing file"
cat yoyo | grep zone | tr -d '"' | awk '{ print "\t"$2 }' >> adblock

echo "Downloading file from"
wget -O mvps
echo "Processing file"
cat mvps | grep | grep -v "#" | awk '{ print "\t"$2 }' >> adblock

echo "Downloading file from HPHosts"
wget -O hphosts
echo "Processing HPHosts file"
cat hphosts | grep "" | awk '{ print "\t"$2 }' >> adblock

echo "Writing changes to zone file"
tr '[A-Z]' '[a-z]' < adblock | sort -f | uniq > adblock.uniq

echo "Reloading DNS Server"
/var/packages/dnsmasq/scripts/start-stop-status stop
/var/packages/dnsmasq/scripts/start-stop-status start
/var/packages/dnsmasq/scripts/start-stop-status status

Get complete ESX Host inventory from VCenter

This is a handy little script that gives you a complete list of all hosts and some pertinent information about them including Config Issues reported by VCenter.
The script saves all this information to a CSV file and emails the contents of that file in a formatted table to the email address you specify.
Let me know if there are other parameters that you think should be in here but aren’t and I will put them in here. Continue reading

Find space consumed by a Thin Provisioned vmdk

Here’s some fun commands to get some stats on Thin provisioned disks.

To find out the actual space consumed on disk (in GB):

stat <filename-flat>.vmdk | grep Size: | awk '{print (($4*512)/(1024*1024*1024))}'

To find out the total space provisioned (in GB):

stat <filename-flat>.vmdk | grep Size: | awk '{print ($2/(1024*1024*1024))}'

Percent not used:

stat <filename-flat>.vmdk | grep Size: | awk '{print ((($2/(1024*1024*1024))-($4*512)/(1024*1024*1024))/($2/(1024*1024*1024)))*100}'