![]() ![]() |
Oct 30 2007, 04:50 PM
Post
#1
|
|
|
INM wizard ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Root Admin Posts: 2,282 Joined: 24-August 04 From: Intellipool AB, Härnösand, Sweden Member No.: 3 |
CODE -----------------------------------------------------------------
-- Name: SQLDatabaseSize.lua -- Author: Kevin Prestage -- Required INM version: 3.3 -- Version: 1.0 -- Date: 2007-09-21 -- Description: This script will monitor the size of a -- database. -- -- Arguments: -- 1) Server Name -- 2) name of database ----------------------------------------------------------------- --grab the parameters servername = GetArgument(0); dbname = GetArgument(1); --create a TLuaDB object and connect to the database. db = TLuaDB(); con = servername .. "@" .. dbname; x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER); --set the sql statement to run against the db sql = "exec sp_spaceused"; --create variables to store results. result = ""; reserved = 0; size = 0; unallocated = 0; --if the db connection succeeded we can now execute our sql statement. if (x == true) then x = db:Execute(sql); --read the results of the statement. if (db:ResultAvilable() == true) then db:NextRow(); --retrieve the size and and unallocated space. size = db:GetCol(2); unallocated = db:GetCol(3); size = string.gsub(size, " MB", ""); unallocated = string.gsub(unallocated , " MB", ""); result = size .. " MB, " .. unallocated .. " MB Unallocated."; StoreStatisticalData(0,size,0,"MB"); StoreStatisticalData(1,unallocated,0,"MB"); end else result = db:GetErrorDescription(); end SetExitStatus(result, x); -------------------- |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 31st July 2010 - 05:58 PM |