Database to Collect Stats and Config from your Domino Servers

Thursday 22nd February, 2007
Over the past few weeks I have slowly been working on a database that would provide Domino Admins with the ability to collect the stats and configurations about their Domino Servers and then report back on that information in simple views.  What I have created is an agent that you can run manually or on a schedule that will connect to the Domino servers you specify and issue the following commands to the console and return the results:
SH SERVER
SH TA
SH CONFIG *
SH STAT

Once the results are returned, I save each of the four results in a seperate field on a document for simple viewing when you open the document.  The second step is I parse through each entry in the SH CONFIG and SH STAT and save each entry into a seperate field so you can build views to report on specific areas of your Domino Server.  To help manage the data I append a "config_" or "stat_" to the name of the parameter and use that as the field name and then store it's value in the field.  A third option is to email a copy of the document showing the four outputs to any internet email address.

You will need to create a "Server Profile" for each server you want it to collect against.  You can create a server profile for each server and then just enable or disable the ones your want it to run against.  When you create the Server Profile, if you set it to "Log and Email", it will take the email address you specify in the server profile and send a copy of the four outputs via email to the email address you specify.

Once your server profile document is complete, run the "Pull Stats v09" agent from the Actions pull down menu.

You can download the database from my here:
www.blogging4dominos.com/FTP/collector.zip
www.blogging4dominos.com/FTP/collector.zip

This is a work in progress and over time I plan on adding additional views and other functionality.  If you like it or have any suggestions please post them as comments to this blog entry.  If you make any modifications to the code yourself please share them with the rest of the blog community.


Here is a copy of the primary LotusScript agent if you would like to just look over it.
Sub Initialize
       Dim session As New NotesSession
       Dim db As notesdatabase
       Dim doc As notesdocument        
       Set db = session.currentdatabase
       Dim sInfo As NotesItem
       
'  This view contains all server profile docs.  
       Set viewprofile= db.GetView("Active Servers")
       viewprofile.AutoUpdate = False                                                
' Get first Active Server Document        
       Set doc = viewprofile.getfirstdocument()
       
'Pull information from Active Server Doc                        
       Do While Not(doc Is Nothing)
               cdatetime = Date & " " & Time                                
               sName = doc.PName(0)
               sLog = doc.PLog(0)        
               sEmail = doc.PEmailN(0)
               
'Pulls info from Server Console                
               cconsole = session.SendConsoleCommand( sName,"sh server")
               cconsole1 = Split(cconsole,Chr$(10),-1,5)
               cstat = session.SendConsoleCommand( sName,"sh stat")
               cstat1 = Split(cstat,Chr$(10),-1,5)
               cconfig = session.SendConsoleCommand( sName,"sh config *")
               cconfig1 = Split(cconfig,Chr$(10),-1,5)
               ctask = session.SendConsoleCommand( sName,"sh task")                
               
'Create Doc locally in DB
               Dim nsn As New NotesSession
               Dim ndb As NotesDatabase
               Dim ndo As NotesDocument
               Dim nit As NotesItem
               Dim nrt As NotesRichTextItem
               Set ndb = nsn.CurrentDatabase
               Set ndo = ndb.CreateDocument
               With ndo
               'Create Fields for Base Entries                        
                       .Form="ServerTrack"
                       .STServerName=sName
                       .STDateTime=cdatetime
                       .STConsoleServer=cconsole
                       .STConsoleStat=cstat
                       .STConsoleConfig=cconfig
                       .STConsoleTask = ctask
                       If sLog = "2" Then
                               .STEmailLog = sEmail
                       End If
               'Create Individual Fields for all SH STAT Entries                        
                       Forall myx In cstat1
                               howlong = Len(myx)
                               mycount = 1
                               myc = ""
                               Do Until myc = "=" Or howlong = 0 Or mycount = 200
                                       myc = Right(Left(myx,mycount),1)
                                       If myc = "=" Then
                                               myposition = mycount
                                       End If
                                       mycount = mycount +1
                               Loop
                               If howlong > 0 And mycount <> 200 Then
                                       myleft = Left(myx,myposition-2)
                                       myleft = Replace(myleft," ","")
                                       myleft = "stat_" & Replace(myleft,".","")                                        
                                       myright = Left(Right(myx,howlong-myposition-1),howlong-myposition-2)
                                       Set nit = .ReplaceItemValue(myleft,myright)
                                       
                                       'Captures Metrics for Email Out
                                       If myleft = "stat_ServerName" Then
                                               subject1 = myright
                                       End If
                                       If myleft = "stat_ServerVersionNotes" Then
                                               subject2 = myright
                                       End If
                                       If myleft = "stat_ServerVersionNotesBuildNumber" Then
                                               subject3 = "Build " & myright
                                       End If
                                       If myleft = "stat_ServerVersionOS" Then
                                               subject4 = myright
                                       End If
                                       If myleft = "stat_ServerElapsedTime" Then
                                               subject5 = myright
                                       End If
                                       'End Capturing of Metrics for Email Out
                                       
                               End If
                       End Forall
               'Create Individual Fields for all SH CONFIG Entries
                       Forall myx In cconfig1
                               howlong = Len(myx)
                               mycount = 1
                               myc = ""
                               Do Until myc = "=" Or howlong = 0 Or mycount = 200
                                       myc = Right(Left(myx,mycount),1)
                                       If myc = "=" Then
                                               myposition = mycount
                                       End If
                                       mycount = mycount +1
                               Loop
                               If howlong > 0 And mycount <> 200 Then
                                       myleft = "config_" & Left(myx,myposition-1)
                                       myright = Left(Right(myx,howlong-myposition),howlong-myposition-1)
                                       Set nit = .ReplaceItemValue(myleft,myright)
                               End If
                       End Forall
               End With
               Call ndo.Save(True,True)
               
'Create doc to email if sLog = 2
               If sLog = "2" Then
                       Dim nsn2 As New NotesSession
                       Dim ndb2 As NotesDatabase
                       Dim ndo2 As NotesDocument
                       Dim nit2 As NotesItem
                       Dim nrt2 As NotesRichTextItem
                       Dim sendto As String
                       Dim copyto As String
                       Dim blindcopyto As String
                       Dim subject As String
                       sendto=sEmail
                       copyto=""
                       blindcopyto=""
                       Set ndb2 = nsn2.CurrentDatabase
                       Set ndo2 = ndb2.CreateDocument
                       With ndo2
                               .Form="Memo"
                               Set nit2 = .ReplaceItemValue("SendTo", Split(sendto,","))
                               Set nit2 = .ReplaceItemValue("CopyTo",  Split(copyto,","))
                               Set nit2 = .ReplaceItemValue("BlindCopyTo",  Split(blindcopyto,","))
                               'Include Stat Metrics in Subject of Outbound Email
                               subject = "Tracking Server Stats for " & subject1 & " - " & subject2 & " - " & subject3 & " - " & subject4 & " - " & subject5
                               Set nit2 = .ReplaceItemValue("Subject", subject)
                       End With
                       Set nrt2 = ndo2.CreateRichTextItem("Body")
                       With nrt2        
                               Call .AppendText(sName)
                               Call .AddNewline(1)
                               Call .AppendText(cdatetime)
                               Call .AddNewline(2)
                               Call .AppendText("Show Server")
                               Call .AddNewline(1)
                               Call .AppendText(cconsole)
                               Call .AddNewline(2)
                               Call .AppendText("Show CONFIG")
                               Call .AddNewline(1)
                               Call .AppendText(cconfig)                                        
                               Call .AddNewline(2)                                
                               Call .AppendText("Show TASK")
                               Call .AddNewline(1)
                               Call .AppendText(ctask)
                               Call .AddNewline(2)                                                                                
                               Call .AppendText("Show STAT")
                               Call .AddNewline(1)
                               Call .AppendText(cstat)                                        
                       End With
                       Call ndo2.Send(False)
               End If
               
'Reset variables to blank                
               sname = ""
               cconsole = ""
               cstat = ""
               cconfig = ""
               ctask = ""
               cdatetime = ""
               sLog = ""
               sEmail = ""
               
'Get next Active Server Doc                
               Set doc = viewprofile.getnextdocument(doc)
       Loop
End Sub

[3]