VMware Thin Provisioning

If you ever use VMware with thin provisioning you are probably always wondering how much disk each server is actually using. This command gives you an idea on what your disk utilization is by server.

find -iname '*.vmdk' -exec du -h '{}' +

So, if you have SSH enabled on your VMware host,

cd /vmfs/volumes
find -iname '*.vmdk' -exec du -h '{}' +

Take the output, put it in Excel, etc.

SQL Foo

I always need to find out whats eating disk on a MS-SQL box. Here are some queries that I use to discover what database is taking the most space;

EXEC sp_databases

This is a stored procedure that gives you DB name and size. Here is another query that you need to run on the actual DB to see the tables and their size;

SELECT 
    t.NAME AS TableName,
    p.rows AS RowCounts,
    SUM(a.total_pages) * 8 AS TotalSpaceKB, 
    SUM(a.used_pages) * 8 AS UsedSpaceKB, 
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM 
    sys.tables t
INNER JOIN      
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN 
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE 
    t.NAME NOT LIKE 'dt%' 
    AND t.is_ms_shipped = 0
    AND i.OBJECT_ID > 255 
GROUP BY 
    t.Name, p.Rows
ORDER BY 
    t.Name

From: http://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database

This will give you table name, and size. Hunt down the large tables and empty some records. Don’t forget to shrink the DB after you do, so that you can reclaim that space.

Cris.