[windows2000] RSM Work Queue Monitor

  • From: "Sullivan, Glenn" <GSullivan@xxxxxxxxxxxxxx>
  • To: <windows2000@xxxxxxxxxxxxx>
  • Date: Mon, 15 Sep 2008 14:53:56 -0400

I wrote up a quick script, and figured, if I needed it, someone else
might.

We use, of all things, NTBackup to do our backups here.  Normally it all
works great, but once a week, when I do the "Full" backup, it runs onto
more than one tape... I kept forgetting to put the second tape into the
tape drive since NTBackup was running in an RDP session to the Exchange
Server.

So I wrote a quick script to monitor the "Work Queue" for events, and
send them to an email address... I use the email address that sends text
messages to my phone, but you could really use any address.

Unfortunately, there is not a whole lot of info available from the
command line on Work Queue entries, but this is the best I could do...
At least I'm notified when there is a new entry, which is almost always
right after I insert a tape (inventory/mount) or when a tape is ejected
(dismount).

Here goes:

<-------------Start----------------->
@echo off
SetLocal
set @BlatLoc=c:\tools\blat\blat.exe
set @MailServer=MailServer
set @MailRecipient=PHONENUMBER@xxxxxxxxx
set @SleepLoc=c:\Tools\Sleep.exe
set @SleepSeconds=60
set @EmailUsername=username
set @EmailPassword=password

rem On intial run, delete any old log.  All requests are "New".  
rem Remove this line to keep a history in the log file.
if exist GUIDLog.txt del /q GUIDLog.txt

:MainProcess
Rem Delete any existing set of "new" entries
if exist NewGUID.txt del /q NewGUID.txt

rem For each entry in the Work Queue, run the "Process" subroutine
for /f "tokens=* skip=3" %%i in ('rsm view /tlibrequest /guiddisplay')
do call :Process "%%i"

rem Check to see if there is anything to mail
if not exist NewGUID.txt goto :AfterMail

rem Mail the end results to the end user.
rem Everything until the :aftermail tag is one line
%@BlatLoc% NewGUID.txt -q -u %@EmailUsername% -pw %@EmailPassword% -to
%@MailRecipient% -subject "LibRequest %ComputerName%" -mime -server
%@MailServer% -f TapeDrive@xxxxxxxxxxxxxx

:AfterMail
rem Sleep, and then restart
%@SleepLoc% %@SleepSeconds%
goto :MainProcess

:Process
rem Remove the quotes
set @Item=%1
Set @Item=%@Item:"=%

rem Skip the last line
if "%@Item%"=="The command completed successfully." Goto :EOF

rem If there is no log, it definitely is new
if not exist GUIDLog.txt goto :NewGUID

rem Look at the log of requests to see if this one is already there...
if not, it is new.
FIND /I "%@Item%" GUIDLog.txt >>Nul
IF ERRORLEVEL 1 GOTO :NewGUID

rem Must not be new... skip it
Goto :EOF

:NewGUID
Echo New GUID %@Item%
Echo %@Item% >>GUIDLog.txt
set @Item=%@Item:~0,-32%
echo %@Item% >>NewGUID.txt
Goto :EOF

:EOF
<----------------end------------>

HTH,

Glenn Sullivan, MCSE+I MCDBA
David Clark Company Inc. 
**********************
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

//www.freelists.org/list/windows2000

Other related posts:

  • » [windows2000] RSM Work Queue Monitor