Mq's calculate last online time script

Download, Add a comment, Back to main page
[Wed 09:55] flickefly (www) (email) ah, this looks handy. I'm going to have to give it a shot when this calm down here at work.
[2004-02-19 08:54 CST] fh (email) Hm, doesnt work here (jabberd 1.4.3). Will look closer tonight.

#!/usr/bin/perl
#
# Script has to be run on the Jabber server.
# Command line parameters are the names of XML spool files to process.
# Output is how long the corresponding users have been offline (in days).
# Suggested use: Determine the number of accounts used in the last
# days for statistical purposes ("calclastonline spool/.../*.xml | wc -l").
#

$now = time();

do {
  $filename = pop(@ARGV);
  $list = '';

  sysopen (LIST, "$filename", O_RDONLY, 0700);
#  open (LIST, "$filename");
  while(<LIST>)
  {
    $list .= $_;
  }
  close LIST;

  $list =~ /jabber:iq:last.*last=\'([0-9]*)\'/;
  $age = $now - $1;

  # only display accounts used in the last 61 days
  if(($age/60/60/24)<61) {
    printf("%07.1f %s\n", $age/60/60/24, $filename);
  }
} while ($#ARGV > 0);