User Counter

Home >>> User Counter


Overview

ParaChat Server v5.7 constantly logs current server usage into log files. It logs the active user names and active room names into these files. The log files can be used to generate usage statistics, or to display the information on your web site.

If you query the logs periodically and feed the data to an external application, which is able to display statistics graphically, you can see the usage trends over time.

Here is a list of items that you can display throughout your site:

  1. All active groups
  2. All active rooms
  3. Number of users in an active room
  4. All active users
  5. Total number of users on the chat server

Server Configuration Default

By default, a ParaChat Server writes current usage data into 3 files under directory "C:\Program Files\ParaChat\ParaChat570\usage". They are:

    total_users.txt
    all_users.txt
    public_rooms.txt

These files are updated by the chat server regularly. By default, they are refreshed every 3 minutes.

Format:

File
Data
Format
total_users.txt
the total number of active users
an integer
all_users.txt
all the user names on this server
one user name per line
public_rooms.txt
all the active public rooms on server
One room per line. Every line starts with a number, followed by an equal sign and then a room name. For example, "xxx=#Room" where "xxx" is the number of users in room "#Room".

Example:

File
File Contents
Meaning
total_users.txt
3
There are 3 active users on server
all_users.txt
Mike
Nicole
cindy
There are 3 active users: Mike, Nicole, and cindy
public_rooms.txt
2=#TestRoom
1=#general
There are 2 users in room #TestRoom and 1 user in room #general

Counter Configuration

Here are the configurations available for you to customize the chat server. In a text editor, open the server config file "C:\Program Files\ParaChat\ParaChat570\config\pchatd.conf". Add your new configurations after the line that says "# Add your new config below".


Config
Value
Purpose
pchatd.usage.Schedule=true
true or false
in case of "false", server usage is not updated at all.
pchatd.usage.RefreshRate
integer
the frequency log files are updated in minutes.
pchatd.usage.file.TotalUsers
a full file path
the full file path to store the number of active users.
pchatd.usage.file.AllUsers
a full file path
the full file path to store the names of all active users.
pchatd.usage.file.PublicRooms
a full file path
the full file path to store the active room names.
pchatd.usage.ShowAllRooms
true or false
Whether to log all the active rooms in a file, including hidden rooms. Default is false.


This is an example using Unix file names. It tells the server to update the log files every 2 minutes. It also changed the default file names of the logs. They are all under "/www/html/chat", but they do not have to be stored in the same directory.

    pchatd.usage.RefreshRate=2
    pchatd.usage.file.TotalUsers=/www/html/chat/total_users.log
    pchatd.usage.file.AllUsers=/www/html/chat/all_users.log
    pchatd.usage.file.PublicRooms=/www/html/chat/public_rooms.log


Display User Count Via Java Applet


Overview

ParaChat Server v5.7 includes Java applet code that displays the number of users in a group, a room or on an entire chat server. After you have completed the set-up process, it is as simple as inserting a few lines of HTML code. For example:

    <applet codebase=http://myhostname.com/pchat/classes archive=counter.zip
    code=ParaCounter.class HEIGHT=18 WIDTH=120>
    <param name="query.Group" value="MyGroup">
    If you see this message you do not have a Java
    enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
    ParaChat Support</a> for more information on how to upgrade your browser!
    </applet>

The code above displays the number of users in group MyGroup.

Set Up CGI on Server Side

Before you can use an applet to display a number, you must complete the set-up on the server side. Below is an example using CGI:

First, you should have installed a ParaChat Server v5.7, and completed the Counter Configuration outlined above. Assume the server is installed under path:

    C:\Program Files\ParaChat\ParaChat570

Assume also your host name is "myhostname.com". You could also use an IP address.

Your chat applet codebase looks like this:

    codebase=http://myhostname.com:7877/pchat/classes

You should also see a text file:

    C:\Program Files\ParaChat\ParaChat570\usage\total_users.txt

This file is updated by the chat server every 3 minutes. It contains only a number.

You should have a web server that supports CGI. If you do not know about CGI, refer to:
http://hoohoo.ncsa.uiuc.edu/cgi/

Your webserver, such as Apache or Windows IIS, should support CGI. In particular, it needs to support CGI programs written in perl as the example below is written in perl.

Provide a name for the CGI program that returns the number of users on your chat server. Let's assume you will install it as "cgi-bin/counter/users.cgi".

Your complete URL looks like:

    http://myhostname.com/cgi-bin/counter/users.cgi

Now follow these steps.
    Step 1.
      Create a directory called "cgi-bin/counter" under your webserver directory.

    Step 2.

      Copy this file, put it under "cgi-bin/counter" and rename it to "users.cgi".

      server.cgi.txt <<<<< click for file

    Step 3.

      Copy this file, put it under "cgi-bin/counter" and rename it to "parseform.lib"

      parseform.lib.txt <<<<< click for file

    Step 4.

      Open "users.cgi" in a text editor and change the input file at the top to:

      "C:\Program Files\ParaChat\ParaChat570\usage\total_users.txt"

    Step 5.

      Test the CGI by loading it in a web browser:

      http://myhostname.com/cgi-bin/counter/users.cgi?server=server

      You should see "0=server" where 0 is the number of users on your chat server.
      If you see an error, check your webserver config and you may need to change "users.cgi" to "users.pl" so that the server recognizes it as a Perl program.

    Step 6.

      Copy the applet code below and paste it into an HTML docuement. Be certain to replace the hostname in the code below with your hostname, where indicated in red.

      <applet codebase=http://myhostname.com:7877/pchat/classes archive=counter.zip
      code=ParaCounter.class HEIGHT=18 WIDTH=60>
      <param name="query.Server" value="server">
      <param name="query.Host" value="http://myhostname.com/">
      <param name="query.CGI" value="cgi-bin/counter/users.cgi">
      If you see this message you do not have a Java
         enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
         ParaChat Support</a> for more information on how to upgrade your browser!
      </applet>

      Note if you combine "query.Host" and "query.CGI" in the applet code, you get the correct URL to the CGI program.

      "http://myhostname.com/" + "cgi-bin/counter/users.cgi" =
      http://myhostname.com/cgi-bin/counter/users.cgi

      Now if you put the applet code in an HTML page of your web site, users will be able to see the number of users currently chatting.

    Step 7.
      If you want to show the number of chatters in a particular room or group, you may modify the Perl program below, and set up a different CGI program on your webserver.

      chat.cgi.txt <<<<< click for file

Examples

You need to change the text in red with your own server configuration. For example,
for myhostname.com, you need to change it to mydomain.com:7877 or 123.456.78.9:7877.

    Example 1: a regular room

    <applet codebase=http://myhostname.com/pchat/classes archive=counter.zip
    code=ParaCounter.class HEIGHT=18 WIDTH=120>
    <param name="query.Room" value="#TestRoom">
    If you see this message you do not have a Java
       enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
       ParaChat Support</a> for more information on how to upgrade your browser!
    </applet>


    Example 2: all rooms in a base room

    <applet codebase=http://myhostname.com/pchat/classes archive=counter.zip
    code=ParaCounter.class HEIGHT=18 WIDTH=40>
    <param name="query.Base" value="#Base">
    If you see this message you do not have a Java
       enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
       ParaChat Support</a> for more information on how to upgrade your browser!
    </applet>


    Example 3
    : all rooms in a group

    <applet codebase=http://myhostname.com/pchat/classes archive=counter.zip
    code=ParaCounter.class HEIGHT=18 WIDTH=120>
    <param name="ui.fg" value="CCCC99">
    <param name="ui.bg" value="0000ff">
    <param name="query.Group" value="MyGroup">
    <param name="ui.FontSize" value="18">
    <param name="ui.FontName" value="Courier">
    <param name="query.Host" value="http://myhostname.com:8080/">
    <param name="query.CGI" value="cgi-bin/counter/chat.cgi">
    If you see this message you do not have a Java
       enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
       ParaChat Support</a> for more information on how to upgrade your browser!
    </applet>


    Example 4: the number of users on a chat server

    <applet codebase=http://myhostname.com/pchat/classes archive=counter.zip
    code=ParaCounter.class HEIGHT=18 WIDTH=120>
    <param name="query.Server" value="server">
    If you see this message you do not have a Java
       enabled browser. Visit <a href="http://www.parachat.com/faq/java.html">
       ParaChat Support</a> for more information on how to upgrade your browser!
    </applet>

Applet Parameters

Feature
Configuration Parameter
Defaults / Values / Examples
applet foreground
ui.fg
hex color code, ffffff for white, 000000 for black
applet background
ui.bg
hex color code
font name
ui.FontName
Font name, for example: Dialog, TimesRoman, Courier, Helvetica
font size
ui.FontSize
font size, an integer, for example: 12, 14, 18
get the number of users on this chat server
query.Server
"server" (do not change this text string - always "server")
chat group name
query.Group
a text string. group name to query
chat base room name
query.Base
a text string. base room name to query
chat room name
query.Room
a text string. a regular room name to query. example: #TestRoom
URL base
query.Host
HTTP server to connect to. example: http://hostname.com/
URL path
query.CGI
CGI program path, example: cgi-bin/counter/parachat.cgi
This combined with query.Host should form a valid URL to use.


Display User Count Via SSI


Overview

Because the number of users on a ParaChat Sserver is stored in a file already, it is a matter of putting this number dynamically into a web page for users to view.

There are many techniques to generate dynamic pages, depending your webserver. Here we demonstrate SSI (server side include) with Apache server on a Unix server.

Suppose the webpage where you want to display the user count is:

    http://your_host.com/chat/index.html

and this page is physically stored on your computer as:

    /var/www/html/chat/index.html

Also suppose your chat server is installed on the same computer under:

    /home/chat/ParaChat570/

Step 1.

Step 2.

    Edit this file /var/www/html/chat/index.html and put this line to where you want to display the count.

    <!--#include virtual="total.html"-->

Step 3.

    Create a script to populate the include file above. For example, a script file is created as
     /home/chat/update.sh

    This file contains very simple Unix shell scripts.

    #!/bin/sh # the number of chatters
    inputfile="/home/chat/ParaChat570/usage/total_users.txt"
    finalhtml="/var/www/html/chat/total.html"
    cat $inputfile > $finalhtml

Step 4.

    Schedule a job so that /var/www/html/chat/total.html is updated periodically.
    On Unix systems, run this command

    crontab -e

    and add a line like this to update every minute.

    * * * * * /home/chat/update.sh

    Now load your web page, and you should see a user count.
    http://your_host.com/chat/index.html

Display User Count per Room via SSI

Displaying user count per room is similar to displaying the total number. ParaChat Server produces another file for this purpose. For example, you can see the number of users in ParaChat community rooms:
http://members.parachat.com/start_frame.php

Suppose your chat server is installed under

/home/chat/ParaChat570/

You should see this file: /home/chat/ParaChat570/usage/public_rooms.txt

This file stores the number of users for each room per line in the format of <count>=<#RoomName>.

For example:

14=#Europe
2=#Regulars
21=#Asia
31=#Teen_Zone
18=#Romance

You need to extract the information from this file and put it into your web pages dynamically.

Note that public_rooms.txt contains public rooms only. Rooms of a group are not public. User created hidden rooms are not public either.

To log all the active rooms, follow these steps.

1. Open server config file in a text editor, in this case, the file is,
ParaChat570/config/pchatd.conf

2. Add this line to the config file. If you are not sure where to put this line, append it to the end of the file.
pchatd.usage.ShowAllRooms=true

3. Restart your ParaChat Server.

Now you should see a file /home/chat/ParaChat570/usage/all_rooms.txt