If you are administrate a Web server on a remote machine, then your know how important it can is able to quickly view R Event logs and ' check on things ' Until recently, the only way to did this is to log onto the machine via Terminal Servic ES, VNC or PC Anywhere, log onto the desktop, and bring up Event viewer that way. Or, you could use somebody ' s component.
Fortunately,. The Windows Management Instrumentation (WMI) interface has become so sophisticated--and scriptable--we can All this using the scripting interfaces in an ASP page. Not so, but we can make things a lot easier by creating a form-based query interface this lets you enter search T Erms to get back only what you need to.
The key to the implementation of the Desktop Management Task Force ' s (DMTF) web-based Enterprise (WB EM) Initiative for microsoft®windows platforms This extends Common information Model (CIM) to represent management OB Jects in Windows management environments. The Common information Model, also a DMTF standard, is a extensible data Model for logically organizing object s in a consistent, unified manner in a managed environment. IT provides:
A Rich Query language that enables detailed queries of the information model.
A scriptable API that developers can use to create management applications. The scripting API supports several languages, including Microsoft Visual basic®; Visual Basic for Applications (VBA); Visual Basic, Scripting Edition (VBScript); Microsoft jscript®development software. Besides VBScript and JScript, developers can use any scripting language implementation that supports Microsoft ' s ActiveX® Scripting technologies with the This APIs (for example, a Perl scripting engine). Additionally, can use the Windows scripting Host or Microsoft Internet Explorer to run scripts utilizing this INTERFAC E. Windows scripting Host, like Internet Explorer, serves as a controller engine of ActiveX scripting engines. Windows scripting Host supports scripts written in VBScript and JScript.
What we ' ll do this are use the scripting interface to write a ASP Web page that can be loaded from the IIS machine just Li Ke any web page, and then allows us to view and search the Event Logs:
<%
' Event Log Reader by Peter A Bromberg
' In our we-script block, we simply check to the if the form has been submitted. If So, we are instantiate the Wscript.Network object to
' Get an instance of the ' Computer name, and display it
If Request.Form ("SUBMIT") = "" Then
Set ONet =createobject ("Wscript.Network")
Compname=onet.computername
Response.Write "<basefont face=verdana>"
Response.Write "Viewing:" & Compname & "<BR>"
Set ONet = Nothing
%>
<!--the form wasn ' t submitted, so let's display it for the user...-->
<form ACTION =eventlog.asp method=post>
<table cellpadding=2 cellspacing=2 border=0>
<TR><TD>
<input type=text NAME=CN Value=<%=compname%>></td><td>computer name</td></TR>
<tr><td><select name=lf>
<option value=application>application</option>
<option value=system>system</option>
<option value=security>security</option>
</select></td><td>log file</td></tr>
<tr><td><input type =text name=s></td><td>event source</td></tr>
<tr><td><select name=t>
<option value=>all</option>
<option value=information>information</option>
<option value=warning>warning</option>
<option value=error>error</option>
</select></TD><TD>Type</TD></TR>
<tr><td><input Type=text name=e></td><td>event code</td></tr>
<tr><td><input Type=text name=u></td><td>username</td></tr>
<tr><td><input Type=password name=p></td><td>password</td></tr>
<TR><TD colspan=2 align=center><input type=submit name=submit value=check></td></tr>
</TABLE>
</FORM>
<%
' The form is submitted, so let's do our processing of the ' user ' query.
Else
' Declare and initialize the variables we need ...
Dim wmiservices, Wmiresultset, Wmirecord
Dim StrComputer, strLogFile, Strwqlquery
Dim Dtdate, Dttime
Set ONet =createobject ("Wscript.Network")
Set wmilocator = Createobjec