IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SQL server - monitor replication queue
RA
post Oct 30 2007, 04:52 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: SQLReplication.lua
-- Author: Kevin Prestage
-- Required INM version: 3.3
-- Version: 1.0
-- Date: 2007-09-21
-- Description: This script will monitor the replication queue on
-- the specified server and track the number of transactions
-- pending replication and the number of minutes behind
-- the replication queue is.
--
--
-- Arguments:
-- 1) Server Name
-----------------------------------------------------------------

servername = GetArgument(0);

db = TLuaDB();
con = servername .. "@distribution";
print(con);
sql = "select count(*), min(entry_time), max(entry_time), datediff(minute, min(entry_time), max(entry_time)), datediff(minute, min(entry_time), getdate()) from msrepl_transactions";
x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER);
result = "";
records = 0;
minutes = 0;

if (x == true) then
    x = db:Execute(sql);
    if (db:ResultAvilable() == true) then
        db:NextRow();
        records = db:GetCol(1);
        minutes = db:GetCol(5);
        
        result = records .. " transactions are pending replication.  The oldest transaction pending replication is " .. minutes .. " minutes old";

        StoreStatisticalData(0,records,0,"Records")
        StoreStatisticalData(1,minutes,0,"Minutes")

    end
    


else
    result = db:GetErrorDescription();
end

SetExitStatus(result, x);


--------------------
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 31st July 2010 - 05:56 PM