Viewing The Event Logs Remotely Via an ASP Page with WMI

If you administrate a web server on a remote machine, then you know how important it can be to be able to quickly view your event logs and "check on things" Until recently, the only way to do this was to log onto the machine via Terminal Services, 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 -- that we can now do all this using these scripting interfaces in an ASP page. Not only that, but we can make things a lot easier by creating a form - based query interface that lets you enter search terms to get back only what you need to see.

The key to all this is an implementation of the Desktop Management Task Force's (DMTF) Web-Based Enterprise Management (WBEM) initiative for Microsoft Windows platforms that extends the Common Information Model (CIM) to represent management objects in Windows management environments. The Common Information Model, also a DMTF standard, is an extensible data model for logically organizing management objects 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 this API (for example, a Perl scripting engine). Additionally, you can use the Windows Scripting Host or Microsoft Internet Explorer to run scripts utilizing this interface. 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 here is use the scripting interface to write an ASP web page that can be loaded from the IIS machine just like any web page, and that allows us to view and search the Event Logs:

<%
' Event Log Reader by Peter A Bromberg
' In our first script block, we simply check to see if the form has been submitted. If so, we 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 was submitted, so let's do our processing of the user's 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

时间: 2024-12-22 14:30:46

Viewing The Event Logs Remotely Via an ASP Page with WMI的相关文章

Viewing The Event Logs Remotely Via an ASP Page wi

If you administrate a web server on a remote machine, then you know how important it can be to be able to quickly view your event logs and "check on things" Until recently, the only way to do this was to log onto the machine via Terminal Service

ASP.NET通过WMI创建站点添加虚拟目录和主机头

前言 本文介绍了ASP.NET如何通过WMI创建站点.添加虚拟目录和添加主机头.并且已在Windows Server 2003及IIS6的环境下测试通过.       这玩意儿花了老子3天时间才搞定,用了几个小时写代码,而且当中还花了不少时间解决Win32: Access denied error的问题.当然我要指出的是,无论NETWORK SERVER帐户还是IUSR_<servername>帐户都不要设置过大的权限.对于WMI和IIS metabase的安全机理,我还是一无所知的.我只不过

ASP.NET缓存:方法和最佳实践

asp.net|缓存 [简 介] 在 ASP.NET 提供的许多特性中,缓存支持无疑是我最欣赏的特性,我这样说当然是有充分理由的.相比 ASP.NET 的所有其他特性,缓存对应用程序的性能具有最大的潜在影响,利用缓存和其他机制,ASP.NET 开发人员可以接受使用开销很大的控件(例如,DataGrid)构建站点时的额外开销,而不必担心性能会受到太大的影响.为了在应用程序中最大程度地利用缓存,您应该考虑在所有程序级别上都实现缓存的方法. 实现 要实现页面输出缓存,只要将一条 OutputCache

设计并实现用于ASP.NET一个通用的数据存取层应用程序

asp.net|程序|设计|数据 Designing and implementing a versatile data access tier for an ASP.NET applicationBy Paul Abarham In this article, we will drill down deeper in to the design of a n-tier architecture and our focus will be on the data access tier (DAT

asp.net 各种页面缓存详解

asp教程.net 各种页面缓存详解 实现     要实现页面输出缓存,只要将一条 OutputCache 指令添加到页面即可.     <%@ OutputCache Duration="60" VaryByParam="*" %>     如同其他页面指令一样,该指令应该出现在 ASPX 页面的顶部,即在任何输出之前.它支持五个属性(或参数),其中两个是必需的.     Duration     必需属性.页面应该被缓存的时间,以秒为单位.必须是正整

ASP.NET缓存的方法和最佳实践_实用技巧

尽早缓存:经常缓存 您应该在应用程序的每一层都实现缓存.向数据层.业务逻辑层.UI 或输出层添加缓存支持.内存现在非常便宜 - 因此,通过以智能的方式在整个应用程序中实现缓存,可以获得很大的性能提高. 缓存可以掩盖许多过失 缓存是一种无需大量时间和分析就可以获得"足够良好的"性能的方法.这里再次强调,内存现在非常便宜,因此,如果您能通过将输出缓存 30 秒,而不是花上一整天甚至一周的时间尝试优化代码或数据库就可以获得所需的性能,您肯定会选择缓存解决方案(假设可以接受 30 秒的旧数据)

asp+XMLHTTP组件做采集常用函数收集

asp+|xml|采集|函数 asp+XMLHTTP组件做采集常用函数其中的html代码处理函数很管用,写得相当漂亮 <%'=================================================='函数名:GetHttpPage'作 用:获取网页源码'参 数:HttpUrl ------网页地址'==================================================Function GetHttpPage(HttpUrl)If IsNul

解析ASP的Application和Session对象

application|session|对象 在已经发表的系列文章中我们已经讨论了两个ASP对象:Application对象和Session对象,因此能够访问Application对象和Session对象提供的集合.方法.属性和事件.本节将从程序设计的角度对这两个对象进行研究. · 当载入ASP DLL并响应对一个ASP网页的第一个请求时,创建Application对象.该对象提供一个存储场所,用来存储对于所有访问者打开的所有网页都可用的变量和对象. · 当访问者首次从站点请求一个ASP页面时,

免费ASP空间集锦~~

100Masp+access,72小时开通服务简介:phidji提供100M的免费主页空间,无限流量,二级域名,文件大小不可超过1.5M(数据库没限制),支持FTP.logs(http://myidentifier.phidji.com/logs).在线编辑.ASP(ASPMail,SmartUpload,FileSystemObject,global.asa等多种组件).ASP.NET.Access2000.Excel等多种数据库,而且未来还有可能支持jsp.php.有弹出式广告! 演示:ht