不管你是网站系统管理员,还是WEB开发人员,了解你的WEB应用及其支撑软件的运行状况,都是至关重要的事情,不然,你就等着业务部门的投诉吧。由于Apache + Resin 是流行的WEB配置,我们就来看看怎样监控 Apache, Resin 及 Resin 的运行环境 JVM的运行状况。
一. Apache 运行状态监控
              Apache 自带了两个用于自身监控的模块,它们是mod_status 和 mod_info,后者比 
      前者显示更为详细的状态信息。通常情况下,启用mod_status就可以了。启用  
      mod_status很简单,在Apache配置文件httpd.conf文件里,加入或取消注释下面的内容并
      重启Apache就 可以了。
            <Location /server-status>
                     SetHandler server-status
                     Order Deny,Allow
                     Allow from 172.16.16.253    <--- 只允许172.16.16.253 访问Apache 状态页面
            </Location>

使用ResinStatusServlet查看resin状态

resin2没有resin3才有的jmx ,也没有像tomcat那样提供一个可以查看系统状态的应用,最近察看文档的时候,发现原来resin从2.0.5开始就提供了一个ResinStatusServlet,由于只是一个servlet,所以它可以嵌入到你的web应用中.  多少也算有些用处(resin3下依然可以继续使用)
   默认情况下,这个servlet是没有启用的,如果要启用,可以编辑resin.conf, 例子如下
< web-app  id ='/admin'>
  
>true</< SPAN>allow-admin>
  
<servlet-mapping url-pattern='/resin-status'
                   
servlet-name='com.caucho.http.servlet.ResinStatusServlet'>
    
='read'/>
  
>

  
 
  
<security-constraint>
    
<ip-constraint>127.0.0.1/32</< SPAN>ip-constraint>

    
<web-resource-collection>
      
<url-pattern>/*</< SPAN>url-pattern>
    
</< SPAN>web-resource-collection>
  
</< SPAN>security-constraint>
</< SPAN>web-app>

这样通过url [url]http://yourhost/yourapp/resin-status[/url] 就可以访问,这个ResinStatusServlet同时还会注册一个com.caucho.http.admin.ApplicationAdmin的对象到你的servlet context中, 名字是"caucho.admin"。
 
三. JVM 运行状态监控
 
        这里说的是JVM作为Resin的运行环境时对JVM的监控。
    配置步骤如下:
    1. cd $JAVA_HOME/jre/lib/management
    2. cp jmxremote.password.template jmxremote.password
    3. chmod 600 jmxremote.password
    4. vi jmxremote.password
       ...
       monitorRole <password>
       controlRole <password>
    5. vi $RESIN_HOME/bin/httpd.sh
       ...
        args="-Dcom.sun.management.jmxremote.port=9999  \
                            -Dcom.sun.management.jmxremote.ssl=false"
     6. 重启Resin。
     7. 在另外一台机器上(安装了JDK),启动jconsole,在弹出的对话框里面     输入相关信息,点击“连接”,就可以看到上图中底下的监控台。