Manage Learn to apply best practices and optimize your operations.

A Quicker Way To Get Formatted Server Information

Need to get server information for documentational purposes? Think opening server documents in R5 is SLOW? So did I...
This agent collects information from all the server documents in the Domino Directory and presents this (nicely formatted) in a document. It can be run as a scheduled agent or via the menu. The agent works with a form called "Document" containing the fields "From", "Subject", "Categories" and "Body" (rtf).
(Declarations) section
Dim thisdb As NotesDatabase
Dim nab As NotesDatabase
Dim serverview As NotesView
Dim serverdoc As NotesDocument
Dim mapdocs As NotesDocumentCollection
Dim mapdoc As NotesDocument
Dim newdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim servername As NotesName
Dim richStyle As NotesRichTextStyle
Dim rtpStyle As NotesRichTextParagraphStyle

Dim tmpsrvname As String
Dim tmptime As String
Dim pos As Long
Dim interval As Long

Sub Initialize
'Most declarations are in (Declarations) section
Dim session As New NotesSession
'Get a handle to this database
Set thisdb = session.CurrentDatabase
'simple error check
If thisdb.Server = "" Then
Msgbox "This agent must be run in a server replica of the database.", 0 + 48, "Error - stopping execution"
Exit Sub
End If
'simple version check
version$ = session.NotesVersion
boxTitle$ = "You are running " & version$
message$ = |This tool can only be used with R5 releases of the Notes client.
Check your version in the title bar of this message.

Do you want to continue?|
continue% = Messagebox ( message$ , 4 + 32 + 0 + 0, boxTitle$)
If continue% = 7 Then Exit Sub
'Get handles to a few other objects
Set nab = New NotesDatabase( thisdb.Server, "names.nsf" )
Set serverview = nab.GetView("Servers")
Set serverdoc = serverview.GetFirstDocument

'Loop through all the server documents found
Do While Not serverdoc Is Nothing

'For each server document, create a document in this database
'with information on the server
Set newdoc = New NotesDocument(thisdb)
'First the necessary fields for the doc in this database
newdoc.Form = "Document"
newdoc.From = session.Commonusername
newdoc.readers = ""
newdoc.Status = 1
newdoc.CurrentUser = session.Commonusername
tmptime = Str(Now)
Set servername = New NotesName(serverdoc.ServerName(0))
tmpsrvname = servername.Abbreviated
newdoc.Subject = tmpsrvname & " -> Info collected " & tmptime
newdoc.Categories = "Current Server Configurations"
'Create richtextstyle and richtextparagraphstyle (R5 only)
Set richStyle = session.CreateRichTextStyle
Set rtpStyle = session.CreateRichTextParagraphStyle
'Now collect some useful information
Set rtitem = New NotesRichTextItem(newdoc, "Body")
'WriteTextline and WriteHeader are subs
Call WriteTextline("Information collected on " & tmptime, 2)
'Servername, title, buildnumber, location and comment
Call WriteHeader("Server Name")
Call WriteTextline(tmpsrvname, 1)
Call WriteTextline(serverdoc.ServerTitle(0), 1)
Call WriteTextline(serverdoc.ServerBuildNumber(0), 2)
Call WriteHeader("Location")
Call WriteTextline(serverdoc.Location(0), 1)
Call WriteTextline(serverdoc.Comment(0), 2)
'Some information on the HTTP settings
Call WriteHeader("HTTP information")
If serverdoc.HTTP_DatabaseBrowsing(0) = "1" Then
tmpbrowse = "Yes"
Else
tmpbrowse = "No"
End If
Call WriteTextline("Database browsing: " & tmpbrowse, 1)
Call WriteTextline("HTTP port:" & Str(serverdoc.HTTP_Port(0)), 1)
Call WriteTextline("Home URL: " & serverdoc.HTTP_HomeURL(0),2)
Call WriteHeader("Host Name")
Call WriteTextline(serverdoc.SMTPFullHostDomain(0), 2)
'Notes Network information (gathered in its own procedure)
Call WriteHeader("Network Information")
Call WriteNetworkInfo()
'Web log file information
Call WriteHeader("Web Log Files")
Call WriteTextline("Log file directory: " & serverdoc.HTTP_LogDirectory(0), 1)
Call WriteTextline("Access log: " & serverdoc.HTTP_AccessLog(0), 1)
Call WriteTextline("Agent log: " & serverdoc.HTTP_AgentLog(0), 1)
Call WriteTextline("Referer log: " & serverdoc.HTTP_RefererLog(0), 1)
Call WriteTextline("Error log: " & serverdoc.HTTP_ErrorLog(0), 1)
Call WriteTextline("CGI-Error log: " & serverdoc.HTTP_CGIErrorLog(0), 2)
'Transaction logging information
Call WriteHeader("Transaction Logging")
If serverdoc.TRANSLOG_Status(0) = "1" Then
tmptranslogstatus = "Enabled"
'translogfile = serverdoc.TRANSLOG_Path(0)
Else
tmptranslogstatus = "Disabled"
'translogfile = ""
End If
Call WriteTextline("" & tmptranslogstatus, 1)
Call WriteTextline("Log path: " & serverdoc.TRANSLOG_Path(0), 2)
'Redirection URL information gathered from response documents to server document
Call WriteHeader("Redirection URL's")
Set mapdocs = serverdoc.Responses
If mapdocs.Count > 0 Then
Set mapdoc = mapdocs.GetFirstDocument
Do While Not mapdoc Is Nothing
If mapdoc.Form(0) = "Mapping" And mapdoc.RM_MapType(0) = "Redirect" Then
textline$ = mapdoc.RM_MapFrom(0) & " ---> " & mapdoc.RM_MapTo(0)
Call WriteTextline(textline$, 1)
End If
Set mapdoc = mapdocs.GetNextDocument(mapdoc)
Loop
End If
Call WriteTextline("", 2)

'Save the new document and get the next serverdoc
Call newdoc.Save(True,True)
Call newdoc.ComputeWithForm(True,True)
Set serverdoc = serverview.GetNextDocument(serverdoc)
Loop

End Sub

Sub WriteHeader(tmptext As String)
'Headers are written in underlined bold style
richStyle.FontSize = 10
richStyle.Bold = True
richStyle.Underline = True
Call rtitem.AppendStyle(richStyle)
Call rtitem.Appendtext(tmptext)
Call rtitem.Addnewline(1)
End Sub

Sub WriteTextline(tmptext As String, postlines As Integer)
'postlines is the number of new lines to add after the text
richStyle.FontSize = 8
richStyle.Bold = False
richStyle.Underline = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.Appendtext(tmptext)
Call rtitem.Addnewline(postlines)
End Sub

Sub WriteNetworkInfo
'This sub utilizes tabs from NotesRichTextParagraphStyle
'to create a table-like output
pos = RULER_ONE_INCH
interval = 2000 'RULER_ONE_INCH
Call rtpStyle.SetTabs(5, pos, interval, TAB_LEFT)
Call rtitem.AppendParagraphStyle(rtpStyle)
richStyle.FontSize = 9
richStyle.Bold = True
richStyle.Underline = False
Call rtitem.AppendStyle(richStyle)
Call rtitem.AppendText("Port Name")
Call rtitem.AddTab(1)
Call rtitem.AppendText("Protocol")
Call rtitem.AddTab(1)
Call rtitem.AppendText("Notes Network")
Call rtitem.AddTab(1)
Call rtitem.AppendText("Net Address")
Call rtitem.AddNewLine(1)

richStyle.FontSize = 9
richStyle.Bold = False
richStyle.Underline = False
Call rtitem.AppendStyle(richStyle)
For i = 0 To 7
fieldname = "Enabled_" & Ltrim(Rtrim(Str(i)))
If serverdoc.GetItemValue(fieldname)(0) = "1" Then
fieldname = "Port_" & Ltrim(Rtrim(Str(i)))
Call rtitem.AppendText(serverdoc.GetItemValue(fieldname)(0))
Call rtitem.AddTab(1)
fieldname = "Protocol_" & Ltrim(Rtrim(Str(i)))
Call rtitem.AppendText(serverdoc.GetItemValue(fieldname)(0))
Call rtitem.AddTab(1)
fieldname = "NetName_" & Ltrim(Rtrim(Str(i)))
Call rtitem.AppendText(serverdoc.GetItemValue(fieldname)(0))
Call rtitem.AddTab(1)
fieldname = "NetAddr_" & Ltrim(Rtrim(Str(i)))
Call rtitem.AppendText(serverdoc.GetItemValue(fieldname)(0))
Call rtitem.AddNewLine(1)
End If
Next
Call rtpStyle.ClearAllTabs()
Call rtitem.AppendParagraphStyle(rtpStyle)
Set rtpStyle = Nothing
Call rtitem.AddNewLine(1)
End Sub

Dig Deeper on Lotus Domino Directory

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