This has only been tested on Backup Exec 11D. Here is the script....enjoy.....
CODE
-----------------------------------------------------------------
-- Name: BEJobStatus.lua
-- Author: Kevin Prestage
-- Required INM version: 3.3
-- Version: 1.0
-- Date: 2007-11-22
-- Description: Checks the status of the last occurance of the
-- specified Backup exec job. Will go into alarm when the
-- status is anything other than 19 (Success) or 3
-- (Complete but with Exceptions). It will also
-- store statistics including duration in minutes, size of backup
-- set in MB, Backup rate in MB/Minute and the total number of
-- files backed up.
--
-- Arguments:
-- 1) Server Name
-- 2) Name of the backup job.
-----------------------------------------------------------------
servername = GetArgument(0);
jobname = GetArgument(1);
db = TLuaDB();
con = servername .. "@BEDB";
print(con);
sql = "select top 1 isjobactive, finaljobstatus,actualstarttime, endtime, elapsedtimeseconds,totaldatasizebytes, totalratembmin, totalnumberoffiles, totalnumberofdirectories ";
sql = sql .. "from vwJobHistorySummary ";
sql = sql .. "where JobName = '" .. jobname .. "' and isjobactive = 0 ";
sql = sql .. "order by actualStartTime desc";
x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER);
result = "";
minutes = 0;
size = 0;
rate = 0;
files = 0;
if (x == true) then
x = db:Execute(sql);
if (db:ResultAvilable() == true) then
db:NextRow();
status = db:GetCol(2);
if (status == "19") then
result = "SUCCESS";
end
if (status == "3") then
result = "COMPLETE W/Exceptions";
end
if (result == "") then
result = "The last execution of this job was not successful.";
x = false;
else
minutes = db:GetCol(5) / 60;
size = db:GetCol(6) / 1048576;
rate = db:GetCol(7);
files = db:GetCol(8);
result = result.. " " .. minutes.. " Minutes, " .. size .. " MB, " .. rate .. " MB/Min, " .. files .. " Files Backed Up.";
--print (result);
StoreStatisticalData(0,minutes,0,"Minutes")
StoreStatisticalData(1,size,0,"MB")
StoreStatisticalData(2,rate,0,"MB/Min")
StoreStatisticalData(3,files,0,"Files")
end
end
else
result = db:GetErrorDescription();
end
SetExitStatus(result, x);
-- Name: BEJobStatus.lua
-- Author: Kevin Prestage
-- Required INM version: 3.3
-- Version: 1.0
-- Date: 2007-11-22
-- Description: Checks the status of the last occurance of the
-- specified Backup exec job. Will go into alarm when the
-- status is anything other than 19 (Success) or 3
-- (Complete but with Exceptions). It will also
-- store statistics including duration in minutes, size of backup
-- set in MB, Backup rate in MB/Minute and the total number of
-- files backed up.
--
-- Arguments:
-- 1) Server Name
-- 2) Name of the backup job.
-----------------------------------------------------------------
servername = GetArgument(0);
jobname = GetArgument(1);
db = TLuaDB();
con = servername .. "@BEDB";
print(con);
sql = "select top 1 isjobactive, finaljobstatus,actualstarttime, endtime, elapsedtimeseconds,totaldatasizebytes, totalratembmin, totalnumberoffiles, totalnumberofdirectories ";
sql = sql .. "from vwJobHistorySummary ";
sql = sql .. "where JobName = '" .. jobname .. "' and isjobactive = 0 ";
sql = sql .. "order by actualStartTime desc";
x = db:Connect(con,TLuaDB.CLIENT_SQLSERVER);
result = "";
minutes = 0;
size = 0;
rate = 0;
files = 0;
if (x == true) then
x = db:Execute(sql);
if (db:ResultAvilable() == true) then
db:NextRow();
status = db:GetCol(2);
if (status == "19") then
result = "SUCCESS";
end
if (status == "3") then
result = "COMPLETE W/Exceptions";
end
if (result == "") then
result = "The last execution of this job was not successful.";
x = false;
else
minutes = db:GetCol(5) / 60;
size = db:GetCol(6) / 1048576;
rate = db:GetCol(7);
files = db:GetCol(8);
result = result.. " " .. minutes.. " Minutes, " .. size .. " MB, " .. rate .. " MB/Min, " .. files .. " Files Backed Up.";
--print (result);
StoreStatisticalData(0,minutes,0,"Minutes")
StoreStatisticalData(1,size,0,"MB")
StoreStatisticalData(2,rate,0,"MB/Min")
StoreStatisticalData(3,files,0,"Files")
end
end
else
result = db:GetErrorDescription();
end
SetExitStatus(result, x);
