From:	AITGW::"koffley%NRLVX1.NRL.NAVY.MIL@VM1.NoDak.EDU" 14-NOV-1991 13:44:05.44
To:	Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
CC:	
Subj:	Re: Logging NEWS accesses

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Thu, 14 Nov 91 13:42:35 EST
Received: from vm1.NoDak.edu by aitgw.ge.com (5.65/GE Gateway 1.4)
	id AA11131; Thu, 14 Nov 91 13:42:08 -0500
Message-Id: <9111141842.AA11131@aitgw.ge.com>
Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 2040; Thu, 14 Nov 91 12:40:52 CST
Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.07) with BSMTP id
 1881; Thu, 14 Nov 91 12:40:27 CST
Date:         Thu, 14 Nov 1991 11:48:06 GMT
Reply-To: koffley%NRLVX1.NRL.NAVY.MIL@VM1.NoDak.EDU
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: koffley%NRLVX1.NRL.NAVY.MIL@VM1.NoDak.EDU
Subject:      Re: Logging NEWS accesses
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
 
In article <1991Nov13.105904.1@galaxy.bcsystems.gov.bc.ca>, Ed.Wilts@BSC.Galaxy.
BCsystems.Gov.BC.CA (Ed Wilts) writes:
> I will soon be initiating a pilot project to bring in News to our organization
.
> One of the things I have been asked for is a method of determining usage.  I
> have seen the Arbitron output, and it doesn't seem to be what my director
> wants, so I'll ask if anyone has done anything like this.
>
> What I would like to see is a way to determine who is reading what groups and
> when.  For example, a report that said:
>                                          Read
>       Username  Group                 Items  Start Time           End Time
>       --------  -----                 -----  ----------           --------
>       EWILTS    comp.os.vms              50  13-NOV-1991 09:30:01 10:30:30
>       EWILTS    news.software.anu-news    5  13-NOV-1991 10:30:35 10:33:40
>       EWILTS    rec.humor               175  13-NOV-1991 19:01:20 20:10:55
>
> This is just a rough idea to give us a handle on News utilization.  By countin
g
> the actually read items, we can also see who is reading every article (and
> mostly wasting his time), and who is reading efficiently.  By reading some of
> the groups out of prime time, we can also determine who's wasting cycles.
>
> This obviously may require some hacking of the code, but if somebody has added
> something similar, it would save me some effort.
>
> The other thing I have to determine is whether our pilot is "successful".  Has
> anyone out there attempted to quantify the usefulness of bringing in News?
>
> Any and all info greatly appreciated.
>
> --
>         .../Ed     Preferrred:  Ed.Wilts@BSC.Galaxy.BCSystems.Gov.BC.CA
> Ed Wilts            Alternate:  EdWilts@BCSC02.BITNET    (604) 389-3430
> B.C. Systems Corp., 4000 Seymour Place, Victoria, B.C., Canada, V8X 4S8
 
Attached is a patch suppiled to me by Bill Glass (THANKS BILL ! ! ) that
does the trick here at NRL. I , like Bill, have written a piece of code to
read/parse the usage summary file which is created and if there is any
interest in it, I'll post it as well. Be advised that this read/parse code
is hacked together and works for me (it's FORTRAN) but is not the prettiest
thing in the world as it is cut and pasted from various pieces of code I
wrote as far back as 1982.
 
..............................  CUT HERE  .....................................
 
From:   MX%"glass@mgi.com" 22-APR-1991 23:55:17.63
To:     KOFFLEY
CC:
Subj:   News Metering
 
Return-Path: <@NRLVX1.NRL.NAVY.MIL:glass@vixvax.mgi.com>
Received: from VIXVAX.MGI.COM by NRLVX1.NRL.NAVY.MIL (MX V2.2-1) with SMTP;
          Mon, 22 Apr 1991 23:55:04 EDT
Received: by vixvax.mgi.com (MX V2.2-2) id 23512; Mon, 22 Apr 1991 22:53:00 CDT
Date: Mon, 22 Apr 1991 22:53:00 CDT
From: "William H. Glass" <glass@vixvax.mgi.com>
Reply-To: glass@mgi.com
To: koffley@nrlvax.nrl.navy.mil
CC: glass@mgi.com
Message-ID: <0094787D.3B52BBE0.23512@vixvax.mgi.com>
Subject: News Metering
 
Joe,
 
>I'm attempting to modify NEWS so that I can monitor each users usage.
 
I don't know if this stuff will be of any help to you, but I've been keeping
some statistics on news usage at my site for some time.  I don't try to
kick people off for too much idle time, but merely log the amount of their
usage.  My logs include the amount of time spent in news, the number of articles
read (by group), and the number of articles posted (by group).
 
Here's what I did.  First define the logical NEWS_USAGE_LOG to the name of
the file that will receive the logging information.
 
$ DEFINE/SYSTEM/EXEC NEWS_USAGE_LOG NEWS_MANAGER:NEWS_USAGE.LOG
 
Second, install the patches attached at the end of this file (I hope that
it survives e-mail - it has a couple of form feeds in it - if you want,
I can VMS_SHARE it and send it again).
 
The logging file looks like the following:
 
Sun Apr 21 09:10:35: User teter - 2 minutes - 2 articles read - 0 posted
        local 1 0
        alt.recovery 1 0
Sun Apr 21 18:36:22: User glass - 9 minutes - 1 articles read - 0 posted
        comp.risks 1 0
Sun Apr 21 22:38:03: User keeney - 6 minutes - 39 articles read - 0 posted
        alt.personals 33 0
        soc.singles 2 0
        alt.romance 1 0
        soc.net-people 1 0
        soc.couples 1 0
        talk.bizarre 1 0
 
Finally, I have a program that will read the logging file and print a summary
of the total usage by each user (I'm not including a copy of this - it's
not fit for public display at the moment).
 
--
 
Bill Glass                              Internet: glass@mgi.com
Management Graphics, Inc.               Phone:    +1 (612) 854-1220
1401 E. 79th Street
Minneapolis, MN  55425
 
________________________________________________________________________________
 
*** news.c;1
--- news.c
**************
*** 78,83
  #endif
 
    *nntp_node = '\0';
 
    if ((lib$get_foreign(&tempdsc,0,&temp_len,0) & 1) && temp_len) {
      temp[temp_len] = '\0';
--- 82,88 -----
  #endif
 
    *nntp_node = '\0';
+   log_to_usage_file(0,0);
 
    if ((lib$get_foreign(&tempdsc,0,&temp_len,0) & 1) && temp_len) {
      temp[temp_len] = '\0';
*** newsfiles.c;1
--- newsfiles.c
**************
*** 811,816
    write_reg_file();
    noscreen();
    print_exit();
  }
 
 
 
 
 
 
 
 
 
 
  /*
--- 813,819 -----
    write_reg_file();
    noscreen();
    print_exit();
+   log_to_usage_file(1,0);
  }
 
 
 
 
 
 
 
 
 
 
  /*
*** newspost.c;1
--- newspost.c
**************
*** 1098,1103
    fclose(fpw);
 
    c$cks(1);
    if (*post_address) {
      sprintf(err_oline,"Post to %s Moderator (%s)",
              ga[g]->grp_name,post_address);
--- 1098,1104 -----
    fclose(fpw);
 
    c$cks(1);
+   log_to_usage_file(-2,g);
    if (*post_address) {
      sprintf(err_oline,"Post to %s Moderator (%s)",
              ga[g]->grp_name,post_address);
**************
*** 1506,1511
    fclose(fpr);
 
    c$cks(1);
    if (*post_address) {
      sprintf(err_oline,"Post to %s Moderator (%s)",
              ga[g]->grp_name,post_address);
--- 1507,1513 -----
    fclose(fpr);
 
    c$cks(1);
+   log_to_usage_file(-2,g);
    if (*post_address) {
      sprintf(err_oline,"Post to %s Moderator (%s)",
              ga[g]->grp_name,post_address);
*** newsread.c;1
--- newsread.c
**************
*** 92,97
    with a primary alpha key and an integer field. The opening and closing of th
e file
    would be performed in NEWSFILES.C
   */
      if (ga[g]->grp_unread > 0) {
        --ga[g]->grp_unread;
        screen_update_gread(g);
--- 92,98 -----
    with a primary alpha key and an integer field. The opening and closing of th
e file
    would be performed in NEWSFILES.C
   */
+     log_to_usage_file(-1,g);
      if (ga[g]->grp_unread > 0) {
        --ga[g]->grp_unread;
        screen_update_gread(g);
*** newsutility.c;1
--- newsutility.c
**************
*** 3018,3023
      close_mail_file();
      noscreen();
      print_exit();
      exit(1);
  }
 
 
 
 
 
 
 
 
 
 
--- 3024,3030 -----
      close_mail_file();
      noscreen();
      print_exit();
+     log_to_usage_file(1,0);
      exit(1);
  }
 
 
 
 
 
 
 
 
 
 
**************
*** 3269,3272
      cur_up_itm(curr_g,lines,1);
      }
    return(0);
  }
--- 3276,3395 -----
      cur_up_itm(curr_g,lines,1);
      }
    return(0);
+ }
+ #include lnmdef
+ #include psldef
+
+ do_abort()
+ {
+     sysprv();
+     sys$close(&itmfab);
+     sys$close(&grpfab);
+     nosysprv();
+     close_hist_file();
+     close_nntp_file();
+     close_mail_file();
+     noscreen();
+     log_to_usage_file(1,0);
+     exit(1);
+ }
+
+ static char *dat()
+ {
+   static char datum[32];
+   struct tm *stm;
+   int cur_time;
+   char *p;
+
+   time(&cur_time);
+   p = ctime(&cur_time);
+   strncpy(datum, p, 19);
+   return(datum);
+ }
+
+ log_to_usage_file(flag,group)
+   int flag;                           /*  0 - initialize data areas */
+                                       /*  1 - dump data to logging file */
+                                       /* -1 - read article from group */
+                                       /* -2 - post article to group */
+   int group;                          /* group number for read/post */
+ {                                       /* logging declarations */
+   FILE *fpl;
+   int end_time, g, i;
+   static int start_time, max_index, read_count, post_count;
+   static int *group_nums, *read_groups, *post_groups;
+
+   char exec_mode = PSL$C_EXEC, translate_value[256];
+   unsigned int trnlist[4];
+   unsigned short len = 0;
+
+   if (flag == 0) {
+     time(&start_time);
+     max_index = 0;
+     read_count = 0;
+     post_count = 0;
+     group_nums = malloc(100 * sizeof(int));
+     read_groups = malloc(100 * sizeof(int));
+     post_groups = malloc(100 * sizeof(int));
+     return;
+     }
+
+   if (group) group = ga[group]->grp_num;
+   if (flag < 0) {
+     for (g = 0; g < max_index; g++)
+       if (group_nums[g] == group) break;
+     if (g == max_index) {
+       if (max_index == 100) g = -1;
+       else {
+         max_index++;
+         group_nums[g] = group;
+         read_groups[g] = 0;
+         post_groups[g] = 0;
+         }
+       }
+     }
+
+   if (flag == -1) {
+     read_count++;
+     if (g >= 0) read_groups[g]++;
+     return;
+     }
+
+   if (flag == -2) {
+     post_count++;
+     if (g >= 0) post_groups[g]++;
+     return;
+     }
+
+   if (!no_priv()) return;
+
+                    /*    Set up item list for exec mode logical names */
+   trnlist[0] = (LNM$_STRING << 16) + LNM$C_NAMLENGTH;
+   trnlist[1] = translate_value;
+   trnlist[2] = &len;
+   trnlist[3] = 0;
+
+   if (!(sys$trnlnm(0,c$dsc(LOG_TABLE),c$dsc("NEWS_USAGE_LOG"),&exec_mode,&trnl
ist) & 1))
+       return;
+
+   translate_value[len] = '\0';
+   sysprv();
+   if (!(fpl = fopen(translate_value,"a"))) {
+     sleep(1);
+     fpl = fopen(translate_value,"a");
+     }
+   if (fpl) {
+     time(&end_time);
+     end_time -= start_time;
+     if (end_time < 0) end_time = 0;
+     fprintf(fpl,"%s: User %s - %d minutes - %d articles read - %d posted\n",
+       dat(), usr_username, (end_time + 30) / 60, read_count, post_count);
+     for (i = 0; i < max_index; i++) {
+       g = ga_locate(group_nums[i]);
+       if (!g) continue;
+       fprintf(fpl,"\t%s %d %d\n",ga[g]->grp_name,read_groups[i],post_groups[i]
);
+       }
+     fclose(fpl);
+     }
+   nosysprv();
  }
 
.................................  CUT HERE  ..................................
 
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
< Joe Koffley                        KOFFLEY@NRLVAX.NRL.NAVY.MIL             >
< Naval Research Laboratory          KOFFLEY@CCF.NRL.NAVY.MIL                >
< Space Systems Division             AT&T  :  202-767-0894                   >
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
