Creating Resource Detail ASP Pages
The following code sample shows how to create resource details in an ASP page.
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'-------------------------------------------------------------------
' Memory Resource Details Pagelet
'------------------------------------------------------------------
%>
<!-- #include virtual="/admin/inc_framework.asp" -->
<%
Dim page
Call SA_CreatePage("Memory Status Details", "", PT_PAGELET, page)
Call SA_ShowPage(page)
Public Function OnInitPage(ByRef Page, ByRef Reserved)
OnInitPage = TRUE
End Function
Public Function OnServePageletPage(ByRef Page, ByRef Reserved)
OnServePageletPage = TRUE
Call ServeCommonElements()
Call ServeMemoryDetails()
End Function
Private Function ServeMemoryDetails()
on error resume next
Dim objLocator
Dim objNameSpace
Dim oProvider
Dim L_COMMITTED
Dim L_COMMIT_USED
Dim L_COMMIT_LIMIT
L_COMMIT_USED = "Committed Total:"
L_COMMIT_LIMIT = "Committed Limit:"
Set objLocator = Server.CreateObject("WbemScripting.SWbemLocator")
If ( Err.Number <> 0 ) Then
' Handle error here
Exit Function
End If
Set objNameSpace = objLocator.ConnectServer(".","root\CIMV2")
If ( Err.Number <> 0 ) Then
' Handle error here
Exit Function
End If
Set oProvider = objNameSpace.Get("Win32_PerfRawData_PerfOS_Memory")
Set oProvider = oProvider.Instances_
If ( Err.Number <> 0 ) Then
' Handle error here
Exit Function
End If
Dim oSystem
WriteLine("<table border='0' cellspacing='0' cellpadding='0' >")
For each oSystem in oProvider
WriteLine("<tr>")
WriteLine("<td class='TasksBody' nowrap>"+L_COMMIT_USED+"</td>")
WriteLine("<td class='TasksBody' nowrap>"+CStr(Round( (oSystem.CommittedBytes / 1024), 1))+"</td>")
WriteLine("<td class='TasksBody' nowrap>"+" (Kb) </td>")
WriteLine("</tr>")
WriteLine("<tr>")
WriteLine("<td class='TasksBody' nowrap>"+L_COMMIT_LIMIT+"</td>")
WriteLine("<td class='TasksBody' nowrap>"+CStr(Round( (oSystem.CommitLimit / 1024), 1))+"</td>")
WriteLine("<td class='TasksBody' nowrap>"+" (Kb) </td>")
WriteLine("</tr>")
Next
WriteLine("</table>")
End Function
Private Function ServeCommonElements()
%>
<script language='JavaScript'>
function Init()
{
}
</script>
<%
End Function
Private Function WriteLine(ByRef sLine)
Response.Write(sLine + vbCrLf)
End Function
%>