Manage Learn to apply best practices and optimize your operations.

Fix a corrupt BUSITIME.NSF automatically

How to fix a corrupt BUSITIME.NSF automatically.

Option Public %REM

Sometimes the busytime.nsf gets corrupt and you don't realize it before it's too late. It especially happens with R5 servers. This agent kills the corrupt database. A new busytime.nsf will be created when the scheduler task restarts. The code uses a few Notes API calls to send console commands to the server.

Run as a scheduled agent
%END REM

'===============================================================
' DECLARATION SECTION
'===============================================================
Declare Function NSFRemoteConsole Lib "NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As_ 

String, Byval cmd As String, ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject" (Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject" (Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval Handle)

Const QUIT_SCHEDULER = "tell sched q"
Const LOAD_SCHEDULER = "load sched"
Const UNLOAD_CACHE = "dbcache flush"

'Replace the location of the busytime.nsf
Const KILL_BUSYTIME_NSF = "c:notesnotesdatbusytime.nsf"

'Replace the value with your server?s name
Const SERVER = "YOUR_SERVER"

Class remoteConsole
	Private IsError As Variant
	Private rc As Integer
	Private hBuffer As Long
	Private Server As String
	Private Command As String
	Private Result As String
	
	Sub New(inpServer As String)
		Dim server As New NotesSession
		If inpServer = "" Then
			Me.IsError = True
		Else
			Me.server=inpServer
			Me.IsError = False
		End If
	End Sub
	
	Function Execute(inpCommand As String) As String
		If Me.Server = "" Then
			Exit Function
		End If
		If inpCommand = "" Then
			Me.execute="You must specify a command"
			Me.iserror = True
			Exit Function
		Else
			Me.command = inpCommand
		End If
		
		Me.rc = NSFRemoteConsole(Me.server, Me.command, hBuffer)
		If Me.rc <> 0 Then
			Me.iserror = True
			Me.result= "ERROR"	
		Else
			Me.result = OSLockObject(hBuffer)
			Call OSUnlockObject(hBuffer)
			Call OSMemFree(hBuffer)
			Me.Iserror = False
		End If
		Me.execute = Me.result
	End Function
End Class

'===============================================================
' SUB INITIALIZE
'===============================================================
Sub Initialize
	On Error Resume Next
	Dim exec As String
	Dim dummy As Variant
	Dim remConsole As New RemoteConsole ( SERVER )
	dummy =  remConsole.Execute ( QUIT_SCHEDULER )
	dummy =  remConsole.Execute ( UNLOAD_CACHE )		
	Sleep ( 10 )
	Kill KILL_BUSYTIME_NSF
	dummy =  remConsole.Execute ( LOAD_SCHEDULER )
End Sub
 

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close