Friday, September 12, 2008

awstats web site statistics for glassfish

awstats is a open source web server log analyzer. Glassfish is an open source java-based web-server. Click here to check out the statistics on my two glassfish domain servers: domain1 domain2. Of course you will restrict access when you deploy this.

To get the awstats package to work with glassfish:
  1. Download and untar awstats (to /usr/local/awstats)
  2. Follow the instructions for installing awstats and run the configuration utility.
    Remember to create the /etc/awstats/ and /var/lib/awstats/ directories and set write permission.
    Edit the config file (/etc/awstats/yourconfigfilename) and change the LogFile property to:
    LogFile="sed -e 's/"\([0-9\.]*\)"/\1 - -/g' -e 's/"\([^"]*-0800\)"/[\1]/g' /usr/local/java/web/glassfish/domains/domain1/logs/access/server_access_log.%YYYY-0-%MM-0-%DD-0.txt |"
    where "/usr/local/java/web/glassfish" is the location of your glassfish server. Also remember to change the time zone offset (mine is -0800) to your timezome offset.
    Change the DirIcons property to:
    DirIcons="icon"
    You will probably want to change your SiteDomain and HostAliases properties to match your domain name.
    I got this info from Glen Smith's blog, Thanks!
  3. Open your glassfish admin page (http://www.yourserver.com:4848), go to configuration -> http service and click the Access Logging enabled box.
    Click on the Access Log Tab and enter:
    %client.name% %datetime% %request% %status% %response.length% %header.referer% %header.user-agent%
    in the Format text box.
    This makes your log format similar to the apache log format
  4. Go you your awstats/wwwroot directory and create a sub-directory WEB-INF
    Create a web.xml file in this directory that contains:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
    <servlet-name>cgi</servlet-name>
    <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>0</param-value>
    </init-param>
    <init-param>
    <param-name>cgiPathPrefix</param-name>
    <param-value>cgi-bin</param-value>
    </init-param>
    <load-on-startup>5</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>cgi</servlet-name>
    <url-pattern>/awstats.pl</url-pattern>
    </servlet-mapping>
    </web-app>
    Afterwards, cd to the wwwroot/cgi-bin directory type chmod a-w *.pl just to be careful.
  5. Now, install this as a web server in the glassfish admin screen (http://www.yourserver.com:4848)
    Applications -> Web Applications -> Deploy
    And deploy the web server directory: /usr/local/awstats/wwwroot. Make sure your context root is awstats.


  6. Try to invoke the servlet as it's described in the awstats documentation:
    http://www.yourdomain.com/awstats/awstats.pl?config=yourconfigfilename
    You should see the awstat config data. Cool!

10 comments:

r2 said...

In the 5th step, I couldn't deploy and I got this error:

Deploying application in domain failed; Error loading deployment descriptors for module [wwwroot]
Line 7 Column 16 -- Deployment descriptor file WEB-INF/web.xml in archive [wwwroot]. cvc-complex-
type.2.4.a: Invalid content was found starting with element 'servlet-class'. One of
'{"http://java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name,
"http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":servlet-name}' is expected.
Error loading deploy...

Do you know why it happened?

Thanks,

kovalan Jayamurugan said...

Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities. Best JAVA Training in Chennai | JAVA Course in Chennai

Badrul Jaman said...

Wonderful post..Excellent post, Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities.
iOS Training in Chennai | Informatica Training in Chennai

Mohamed Omer said...

Great and impressive article!!


Seo Training in Chennai

Ranjitha M said...

Thanks for your informative sharing....
online marketing courses in chennai

D Entertainment said...

dongtam
mu moi ra hom nay
tim phong tro
http://nhatroso.com/
nhạc sàn
tổng đài tư vấn luật
văn phòng luật hà nội
tổng đài tư vấn luật
thành lập công ty trọn gói
http://we-cooking.com/
chém gió
trung tâm tiếng anh

- Xoẹt xoẹt xọe.

Đột nhiên trên tường thành có mấy đạo thân ảnh nhảy ra sau lưng của Nhạc Thành, chính là những trưởng lão có tu vi Đấu Tôn.

Nhạc Thành nhìn đám người này, tổng cộng có bảy mươi người tất cả, trong đó có những trưởng lão của Hồ Điệp cốc, Vạn Kim Môn, Cuồng Sư môn mà Nhạc Thành biết.

Vừa nghe thấy U Minh tông và Luyện Dược sư công hội sẽ công kích thành, tất cả mọi người đều lộ vẻ lo lắng, đặc biệt là khi biết có cường giả Đấu Thánh.

Tuy nhiên Nhạc Thành cũng không lo lắng, chỉ là một Thanh Ma mà thôi, lần trước Vũ Văn Nam để hắn chạy mất, không ngờ lần này hắn lại xuất hiện ở đây.

- Đến đây đi.

Nhạc Thành nhìn về phía xa xa mà nói, khóe miệng nở ra một nụ cười quỷ dị.

- Đến đây đi, mau đến đây.

Một lát sau nhìn thấy phương gia nghìn dặm chằng chịt thân ảnh, Nhạc Thành cất tiếng nói.

Trên tường thành, chúng đệ tử cũng khẩn trương, nhóm đệ tử

Rohit P said...

great job, very useful information
will try using them
seo can make any article to reach people very effectively
seo is so simple that every one will love to get training on seo seo training in bangalore

Steve Smith said...

Great and Useful Article.

Online Java Training

Online Java Training from India

Online Java Training

Online Java Training From India

Java Training Institutes in Chennai

Java Training in Chennai

Indhu Mathy said...

Awesome blog for java technolgy its very useful for java trainers.
Regards,
iOS Training in Chennai | Multimedia Training in Chennai | QTP Training in Chennai | Informatica Training in Chennai | CCNA Training in Chennai | Java Training in Chennai | Oracle Training in Chennai | Android Training in Chennai

Savitha said...

Really awesome blog. Your blog is really useful for me.
Thanks for sharing this informative blog. Keep update your blog.
Oracle Training In Chennai