Get DAOS ObjectCount and Size with LotusScript
2012-04-23 21:48
357 查看
September 27, 2010 – 10:49 am
At AdminCamp last week, I talked about how to get the count of all files in the DAOS repository and it’s overall size using some batch programming in Windows and LINUX.As an alternative I proposed to use the console command “show dir -xml” to return an xml representation of the properties of all applications in the Domino data directory.
I found some code by Julian Robichaux that does the parsing of the XML structure. I’ve stripped out the relevant code snippets and put together a script lib to get the DAOS Object count and the overall size of all DAOS Objects.
The code writes a summary of these values to a database. You can use this data to create nice looking charts and graphs.
Here is the code:
%REM Library DAOS.Objects Created Sep 27, 2010 by Ulrich Krause/singultus Description: Comments for Library %END REM Option Public Option Declare Class DbInfoHolder Public PropertyList List As String Private xh As XmlHelper Private tNode As NotesDOMNode Public Sub New () Set xh = New XmlHelper() End Sub Public Sub GetDbInfo (node As NotesDOMNode) Erase PropertyList On Error Resume Next PropertyList("Title") = xh.getNodeText(xh.findFirstChildNode(node, "title")) Set tNode = xh.findFirstChildNode(node, "daos") PropertyList("DAOSEnabled") = xh.getAttributeText(tNode, "enabled") PropertyList("DAOSObjects") = xh.getAttributeText(tNode, "objects") PropertyList("DAOSBytes") = xh.getAttributeText(tNode, "bytes") End Sub End Class Class XmlHelper Function getNodeText (node As NotesDOMNode) As String '** get the text of the given node Dim child As NotesDOMNode Dim childText As String If (node Is Nothing) Then Exit Function Elseif (node.IsNull) Then Exit Function End If Set child = node.FirstChild Do Until (child.IsNull) If (child.NodeType = DOMNODETYPE_TEXT_NODE) Then childText = childText + child.NodeValue Elseif (child.NodeType = DOMNODETYPE_CDATASECTION_NODE) Then childText = childText + child.NodeValue End If Set child = child.NextSibling Loop getNodeText = childText End Function Function getAttributeText (node As NotesDOMNode, attrName As String) As String '** get the text of a given attribute Dim attrList As NotesDOMNamedNodeMap Dim attr As NotesDOMNode Dim attrValue As String Dim i As Integer If (node Is Nothing) Then Exit Function Elseif (node.IsNull) Then Exit Function End If Set attrList = node.Attributes For i = 1 To attrList.NumberOfEntries Set attr = attrList.GetItem(i) If (attr.NodeName = attrName) Then attrValue = attr.NodeValue End If Next getAttributeText = attrValue End Function Function findFirstChildNode (node As NotesDOMNode, childName As String) As NotesDOMNode '** get the first child node with the given name Set findFirstChildNode = findChildNode(node, childName, 1) End Function Function findChildNode (node As NotesDOMNode, childName As String, count As Integer) As NotesDOMNode '** get the child node with the given name at the given position Dim child As NotesDOMNode Dim i As Integer If (node Is Nothing) Then Exit Function Elseif (node.IsNull) Then Exit Function End If Set child = node.FirstChild Do Until (child.IsNull) If (child.NodeName = childName) Then i = i + 1 If (i >= count) Then Exit Do End If End If Set child = child.NextSibling Loop Set findChildNode = child End Function End Class %REM NOTE: You MUST have rights to run remote console commands on the server you want to get a list of files from. Parts of the code by Julian Robichaux http://www.nsftools.com,14 Aug 2008 %END REM Class DAOSObjects Public Sub New () End Sub Public Sub ObjectCount Dim s As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set db = s.CurrentDatabase Dim session As New NotesSession Dim commandString As String Dim server As String Dim returnString As String Dim dbInfo As New DbInfoHolder server = session.UserName commandString = "!show dir -xml" returnString = s.SendConsoleCommand(server,commandstring) '** if we got some output, try to process it as XML Dim xHelper As New XmlHelper() Dim inputStream As NotesStream Dim outputStream As NotesStream Dim domParser As NotesDOMParser Dim docNode As NotesDOMDocumentNode Dim fileNode As NotesDOMNode Dim dbNode As NotesDOMNode '** load it up into a DOM parser Set inputStream = session.CreateStream Call inputStream.WriteText(returnString) inputStream.Position = 0 Set outputStream = session.CreateStream Set domParser=session.CreateDOMParser(inputStream, outputStream) domParser.Process '** all of the tasks should be contained within a single '** node, as separate entries. Set docNode = domParser.Document '** find the node Set fileNode = xHelper.findFirstChildNode(docNode, "files") '** if we didn't find anything, exit If (fileNode.IsNull) Then Exit Sub End If Dim sumObj As Currency Dim sumSize As Currency sumObj = 0 sumSize = 0 Set dbNode = fileNode.FirstChild Do Until (dbNode.IsNull) If (dbNode.NodeType = DOMNODETYPE_ELEMENT_NODE) And _ (dbNode.NodeName = "filedata") Then Call dbInfo.GetDbInfo(dbNode) If dbInfo.PropertyList("DAOSEnabled")= "readwrite" Then sumObj = sumObj + Ccur(dbInfo.PropertyList("DAOSObjects")) sumSize = sumSize + Ccur(dbInfo.PropertyList("DAOSBytes")) End If End If Set dbNode = dbNode.NextSibling Loop Set doc = db.CreateDocument doc.form = "DAOS.Objects" doc.servername = server doc.sumObjects = Cstr(sumObj) doc.sumSize = Cstr(sumSize) Call doc.save (False, False ) End Sub End Class
相关文章推荐
- SharePoint2013 Powershell script to get site Title, Site Owner, Site user count and usage
- Get AD Object and disable move delete AD account script 查询删除AD账户计算机
- AFNetworking 关于JSON text did not start with array or object and option to allow fragments not set
- Fun with dynamicobject dynamic and the settings table
- [Angular] Get started with data binding and SPA
- [Vue] Get up and running with vue-router
- vtkTimestamp,vtkSetGet,vtkLWObject and vtkObject
- How to get your very own RStudio Server and Shiny Server with DigitalOcean
- linux get current thread count and system threads limit
- Squeezenet alexnet-level accuracy with 50x fewer parameters and less 0.5MB model size
- How to use script to get all oracle EBS Form name and corresponding fmb file name
- AFNetworking 报错 JSON text did not start with array or object and option to allow fragments not set
- Object-Oriented Analysis and Design with Applications
- [under the hood]Reduce EXE and DLL Size with LIBCTINY.LIB
- Generic Object Detection With Dense Neural Patterns and Regionlets
- [转]How to get return values and output values from a stored procedure with EF Core?
- *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from o
- Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option
- How to Install Apache Tomcat 8 (on Windows, Mac OS X, Ubuntu) and Get Started with Java Servlet Prog
- When install ”matplotlib” with ”pip”, if you get the following error, it means the “freetype” and “png” libraries needed by matplotlib are not installed: