Updated DB to Collect Stats and Config v1.2
Sunday 18th March, 2007Update on the Database to Collect Stats and Config for your Domino Servers. Been testing and found a few problems. Addressed them in this version along with some minor other changes. Main thing is I found that the SH STAT command would return more than 32K of data for a text field on certain servers so I had to change that to a Rich Text Field. I made the same change for SH CONFIG as well just in case that command grows over time.
If you find the tool useful, please leave feedback. If you customize it to do something different, please share that as well so I can either incorporate it or allow others to pull from your knowledge.
One idea you can use the tool for is if you ever need to push out a notes.ini change to your servers, just enter the parameter using "SH CONFIG PARAMETER=X" into one of the custom variable options and the tool will automatically push the parameter to every server by just running the agent.
You can download the database from my here:
www.blogging4dominos.com/FTP/collector.zip
www.blogging4dominos.com/FTP/collector.zip
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)
sCV1 = doc.PCVariable1(0)
sCC1 = doc.PCCommand1(0)
sCV2 = doc.PCVariable2(0)
sCC2 = doc.PCCommand2(0)
sCV3 = doc.PCVariable3(0)
sCC3 = doc.PCCommand3(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")
If sCV1 = "1" Then
ccustom1 = session.SendConsoleCommand( sName,sCC1)
End If
If sCV2 = "1" Then
ccustom2 = session.SendConsoleCommand( sName,sCC2)
End If
If sCV3 = "1" Then
ccustom3 = session.SendConsoleCommand( sName,sCC3)
End If
'Create Doc locally in DB
Dim nsn As New NotesSession
Dim ndb As NotesDatabase
Dim ndo As NotesDocument
Dim nit As NotesItem
Set ndb = nsn.CurrentDatabase
Set ndo = ndb.CreateDocument
With ndo
'Create Fields for Base Entries
.Form="ServerTrack"
.STServerName=sName
.STDateTime=cdatetime
.STConsoleServer=cconsole
Dim nrt As New NotesRichTextItem(ndo, "STConsoleStat")
Call nrt.AppendText(cstat)
Dim nrt1 As New NotesRichTextItem(ndo, "STConsoleConfig")
Call nrt1.AppendText(cconfig)
.STConsoleTask = ctask
If sLog = "2" Then
.STEmailLog = sEmail
Else
.STEmailLog = "No Email Sent"
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
'Append Custom Variables if specified in ServerTrack Doc
If sCV1 = "1" Then
.STCustom1 = ccustom1
.STCustomV1 = sCC1
End If
If sCV2 = "1" Then
.STCustom2 = ccustom2
.STCustomV2 = sCC2
End If
If sCV3 = "1" Then
.STCustom3 = ccustom3
.STCustomV3 = sCC3
End If
'Finish Local Doc, Save and Close
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")
'Include three primary console outputs in outbound email
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 TASK")
Call .AddNewline(1)
Call .AppendText(ctask)
Call .AddNewline(2)
Call .AppendText("Show CONFIG")
Call .AddNewline(1)
Call .AppendText(cconfig)
Call .AddNewline(2)
Call .AppendText("Show STAT")
Call .AddNewline(1)
Call .AppendText(cstat)
'Include three custom console outputs in outbound email
If sCV1 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 1")
Call .AddNewline(1)
Call .AppendText(sCC1)
Call .AddNewline(1)
Call .AppendText(ccustom1)
End If
If sCV2 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 2")
Call .AddNewline(1)
Call .AppendText(sCC2)
Call .AddNewline(1)
Call .AppendText(ccustom2)
End If
If sCV3 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 3")
Call .AddNewline(1)
Call .AppendText(sCC3)
Call .AddNewline(1)
Call .AppendText(ccustom3)
End If
'Send Outbound Email
End With
Call ndo2.Send(False)
End If
'Reset variables to blank
sname = ""
cconsole = ""
cstat = ""
cconfig = ""
ctask = ""
cdatetime = ""
sLog = ""
sEmail = ""
sCV1 = ""
sCC1 = ""
sCV2 = ""
sCC2 = ""
sCV3 = ""
sCC3 = ""
'Get next Active Server Doc
Set doc = viewprofile.getnextdocument(doc)
Loop
End Sub
If you find the tool useful, please leave feedback. If you customize it to do something different, please share that as well so I can either incorporate it or allow others to pull from your knowledge.
One idea you can use the tool for is if you ever need to push out a notes.ini change to your servers, just enter the parameter using "SH CONFIG PARAMETER=X" into one of the custom variable options and the tool will automatically push the parameter to every server by just running the agent.
You can download the database from my here:
www.blogging4dominos.com/FTP/collector.zip
www.blogging4dominos.com/FTP/collector.zip
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)
sCV1 = doc.PCVariable1(0)
sCC1 = doc.PCCommand1(0)
sCV2 = doc.PCVariable2(0)
sCC2 = doc.PCCommand2(0)
sCV3 = doc.PCVariable3(0)
sCC3 = doc.PCCommand3(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")
If sCV1 = "1" Then
ccustom1 = session.SendConsoleCommand( sName,sCC1)
End If
If sCV2 = "1" Then
ccustom2 = session.SendConsoleCommand( sName,sCC2)
End If
If sCV3 = "1" Then
ccustom3 = session.SendConsoleCommand( sName,sCC3)
End If
'Create Doc locally in DB
Dim nsn As New NotesSession
Dim ndb As NotesDatabase
Dim ndo As NotesDocument
Dim nit As NotesItem
Set ndb = nsn.CurrentDatabase
Set ndo = ndb.CreateDocument
With ndo
'Create Fields for Base Entries
.Form="ServerTrack"
.STServerName=sName
.STDateTime=cdatetime
.STConsoleServer=cconsole
Dim nrt As New NotesRichTextItem(ndo, "STConsoleStat")
Call nrt.AppendText(cstat)
Dim nrt1 As New NotesRichTextItem(ndo, "STConsoleConfig")
Call nrt1.AppendText(cconfig)
.STConsoleTask = ctask
If sLog = "2" Then
.STEmailLog = sEmail
Else
.STEmailLog = "No Email Sent"
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
'Append Custom Variables if specified in ServerTrack Doc
If sCV1 = "1" Then
.STCustom1 = ccustom1
.STCustomV1 = sCC1
End If
If sCV2 = "1" Then
.STCustom2 = ccustom2
.STCustomV2 = sCC2
End If
If sCV3 = "1" Then
.STCustom3 = ccustom3
.STCustomV3 = sCC3
End If
'Finish Local Doc, Save and Close
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")
'Include three primary console outputs in outbound email
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 TASK")
Call .AddNewline(1)
Call .AppendText(ctask)
Call .AddNewline(2)
Call .AppendText("Show CONFIG")
Call .AddNewline(1)
Call .AppendText(cconfig)
Call .AddNewline(2)
Call .AppendText("Show STAT")
Call .AddNewline(1)
Call .AppendText(cstat)
'Include three custom console outputs in outbound email
If sCV1 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 1")
Call .AddNewline(1)
Call .AppendText(sCC1)
Call .AddNewline(1)
Call .AppendText(ccustom1)
End If
If sCV2 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 2")
Call .AddNewline(1)
Call .AppendText(sCC2)
Call .AddNewline(1)
Call .AppendText(ccustom2)
End If
If sCV3 = 1 Then
Call .AddNewline(2)
Call .AppendText("Custom Variable 3")
Call .AddNewline(1)
Call .AppendText(sCC3)
Call .AddNewline(1)
Call .AppendText(ccustom3)
End If
'Send Outbound Email
End With
Call ndo2.Send(False)
End If
'Reset variables to blank
sname = ""
cconsole = ""
cstat = ""
cconfig = ""
ctask = ""
cdatetime = ""
sLog = ""
sEmail = ""
sCV1 = ""
sCC1 = ""
sCV2 = ""
sCC2 = ""
sCV3 = ""
sCC3 = ""
'Get next Active Server Doc
Set doc = viewprofile.getnextdocument(doc)
Loop
End Sub
[0]